a2dp: Use streaming mode when MPS is enabled
Luiz Augusto von Dentz
maintainerPATCH 1/1 a2dp: Use streaming mode when MPS is enabled
From: Luiz Augusto von Dentz <[email protected]>
If MPS is enabled use L2CAP streaming mode for AVDTP channels.
--- profiles/audio/a2dp.c | 8 ++++++++ profiles/audio/avdtp.c | 9 +++++++++ src/hcid.h | 7 +++++++ src/main.c | 16 ++++++---------- 4 files changed, 30 insertions(+), 10 deletions(-)
profiles/audio/a2dp.c +8 -0
@@ -43,6 +43,7 @@#include "gdbus/gdbus.h" +#include "src/hcid.h" #include "src/plugin.h" #include "src/adapter.h" #include "src/device.h"
@@ -2331,14 +2332,21 @@ drop:static bool a2dp_server_listen (struct a2dp_server *server) {GError *err =NULL ; +BtIOMode mode;if (server->io)return true; +if (main_opts.mps ==MPS_OFF ) + mode =BT_IO_MODE_BASIC ; +else + mode =BT_IO_MODE_STREAMING ; + server->io =bt_io_listen (NULL , confirm_cb, server,NULL , &err,BT_IO_OPT_SOURCE_BDADDR ,btd_adapter_get_address (server->adapter),BT_IO_OPT_PSM ,AVDTP_PSM , +BT_IO_OPT_MODE , mode,BT_IO_OPT_SEC_LEVEL ,BT_IO_SEC_MEDIUM ,BT_IO_OPT_MASTER , true,BT_IO_OPT_INVALID );
profiles/audio/avdtp.c +9 -0
@@ -42,6 +42,7 @@#include "lib/uuid.h" #include "btio/btio.h" +#include "src/hcid.h" #include "src/log.h" #include "src/shared/util.h" #include "src/shared/queue.h"
@@ -2406,9 +2407,15 @@ static GIOChannel *l2cap_connect(struct avdtp *session)GError *err =NULL ;GIOChannel *io;const bdaddr_t *src; +BtIOMode mode; src =btd_adapter_get_address (device_get_adapter (session->device)); +if (main_opts.mps ==MPS_OFF ) + mode =BT_IO_MODE_BASIC ; +else + mode =BT_IO_MODE_STREAMING ; +if (session->phy) io = bt_io_connect(avdtp_connect_cb, session, NULL, &err,
@@ -2416,6 +2423,7 @@ static GIOChannel *l2cap_connect(struct avdtp *session)BT_IO_OPT_DEST_BDADDR ,device_get_address (session->device),BT_IO_OPT_PSM ,AVDTP_PSM , +BT_IO_OPT_MODE , mode,BT_IO_OPT_SEC_LEVEL ,BT_IO_SEC_MEDIUM ,/* Set Input MTU to 0 to auto-tune */ BT_IO_OPT_IMTU, 0,
@@ -2427,6 +2435,7 @@ static GIOChannel *l2cap_connect(struct avdtp *session)BT_IO_OPT_DEST_BDADDR ,device_get_address (session->device),BT_IO_OPT_PSM ,AVDTP_PSM , +BT_IO_OPT_MODE , mode,BT_IO_OPT_SEC_LEVEL ,BT_IO_SEC_MEDIUM , BT_IO_OPT_INVALID);if (!io) {
src/hcid.h +7 -0
@@ -41,6 +41,12 @@ enum jw_repairing_t { JW_REPAIRING_ALWAYS, }; +enum mps_mode_t { +MPS_OFF , +MPS_SINGLE , +MPS_MULTIPLE , +}; +struct main_opts {char *name;uint32_t class;
@@ -102,6 +108,7 @@ struct main_opts {bt_gatt_cache_t gatt_cache;uint16_t gatt_mtu;uint8_t gatt_channels; +enum mps_mode_t mps;uint8_t key_size;
src/main.c +6 -10
@@ -74,12 +74,6 @@ struct main_opts main_opts;static GKeyFile *main_conf;static char *main_conf_file_path; -static enum { -MPS_OFF , -MPS_SINGLE , -MPS_MULTIPLE , -} mps =MPS_OFF ; -static const char *supported_options[] = {"Name" ,"Class" ,
@@ -583,9 +577,11 @@ static void parse_config(GKeyFile *config)DBG ("MultiProfile=%s" , str);if (!strcmp (str,"single" )) - mps =MPS_SINGLE ; + main_opts.mps =MPS_SINGLE ;else if (!strcmp (str,"multiple" )) - mps =MPS_MULTIPLE ; + main_opts.mps =MPS_MULTIPLE ; +else + main_opts.mps =MPS_OFF ;g_free (str); }
@@ -910,8 +906,8 @@ int main(int argc, char *argv[]) main_opts.did_version); } -if (mps !=MPS_OFF ) -register_mps (mps ==MPS_MULTIPLE ); +if (main_opts.mps !=MPS_OFF ) +register_mps (main_opts.mps ==MPS_MULTIPLE );/* Loading plugins has to be done after D-Bus has been setup since * the plugins might wanna expose some paths on the bus. However the
Signature · 1 line
2.25.3
Luiz Augusto von Dentz
maintainerHi,
Quoted 157 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
If MPS is enabled use L2CAP streaming mode for AVDTP channels.
--- profiles/audio/a2dp.c | 8 ++++++++ profiles/audio/avdtp.c | 9 +++++++++ src/hcid.h | 7 +++++++ src/main.c | 16 ++++++---------- 4 files changed, 30 insertions(+), 10 deletions(-)profiles/audio/a2dp.c +8
-0@@ -43,6 +43,7 @@#include "gdbus/gdbus.h" +#include "src/hcid.h" #include "src/plugin.h" #include "src/adapter.h" #include "src/device.h" @@ -2331,14 +2332,21 @@ drop:static bool a2dp_server_listen (struct a2dp_server *server) {GError *err =NULL ; +BtIOMode mode;if (server->io)return true; +if (main_opts.mps ==MPS_OFF ) + mode =BT_IO_MODE_BASIC ; +else + mode =BT_IO_MODE_STREAMING ; + server->io =bt_io_listen (NULL , confirm_cb, server,NULL , &err,BT_IO_OPT_SOURCE_BDADDR ,btd_adapter_get_address (server->adapter),BT_IO_OPT_PSM ,AVDTP_PSM , +BT_IO_OPT_MODE , mode,BT_IO_OPT_SEC_LEVEL ,BT_IO_SEC_MEDIUM ,BT_IO_OPT_MASTER , true,BT_IO_OPT_INVALID );profiles/audio/avdtp.c +9
-0@@ -42,6 +42,7 @@#include "lib/uuid.h" #include "btio/btio.h" +#include "src/hcid.h" #include "src/log.h" #include "src/shared/util.h" #include "src/shared/queue.h" @@ -2406,9 +2407,15 @@ static GIOChannel *l2cap_connect(struct avdtp *session)GError *err =NULL ;GIOChannel *io;const bdaddr_t *src; +BtIOMode mode; src =btd_adapter_get_address (device_get_adapter (session->device)); +if (main_opts.mps ==MPS_OFF ) + mode =BT_IO_MODE_BASIC ; +else + mode =BT_IO_MODE_STREAMING ; +if (session->phy) io = bt_io_connect(avdtp_connect_cb, session, NULL, &err,@@ -2416,6 +2423,7 @@ static GIOChannel *l2cap_connect(struct avdtp *session)BT_IO_OPT_DEST_BDADDR ,device_get_address (session->device),BT_IO_OPT_PSM ,AVDTP_PSM , +BT_IO_OPT_MODE , mode,BT_IO_OPT_SEC_LEVEL ,BT_IO_SEC_MEDIUM ,/* Set Input MTU to 0 to auto-tune */ BT_IO_OPT_IMTU, 0,@@ -2427,6 +2435,7 @@ static GIOChannel *l2cap_connect(struct avdtp *session)BT_IO_OPT_DEST_BDADDR ,device_get_address (session->device),BT_IO_OPT_PSM ,AVDTP_PSM , +BT_IO_OPT_MODE , mode,BT_IO_OPT_SEC_LEVEL ,BT_IO_SEC_MEDIUM , BT_IO_OPT_INVALID);if (!io) {src/hcid.h +7
-0@@ -41,6 +41,12 @@ enum jw_repairing_t { JW_REPAIRING_ALWAYS, }; +enum mps_mode_t { +MPS_OFF , +MPS_SINGLE , +MPS_MULTIPLE , +}; +struct main_opts {char *name;uint32_t class;@@ -102,6 +108,7 @@ struct main_opts {bt_gatt_cache_t gatt_cache;uint16_t gatt_mtu;uint8_t gatt_channels; +enum mps_mode_t mps;uint8_t key_size;src/main.c +6
-11@@ -74,12 +74,6 @@ struct main_opts main_opts;static GKeyFile *main_conf;static char *main_conf_file_path; -static enum { -MPS_OFF , -MPS_SINGLE , -MPS_MULTIPLE , -} mps =MPS_OFF ; -static const char *supported_options[] = {"Name" ,"Class" ,@@ -583,9 +577,11 @@ static void parse_config(GKeyFile *config)DBG ("MultiProfile=%s" , str);if (!strcmp (str,"single" )) - mps =MPS_SINGLE ; + main_opts.mps =MPS_SINGLE ;else if (!strcmp (str,"multiple" )) - mps =MPS_MULTIPLE ; + main_opts.mps =MPS_MULTIPLE ; +else + main_opts.mps =MPS_OFF ;g_free (str); }@@ -910,8 +906,8 @@ int main(int argc, char *argv[]) main_opts.did_version); } -if (mps !=MPS_OFF ) -register_mps (mps ==MPS_MULTIPLE ); +if (main_opts.mps !=MPS_OFF ) +register_mps (main_opts.mps ==MPS_MULTIPLE );/* Loading plugins has to be done after D-Bus has been setup since * the plugins might wanna expose some paths on the bus. However the --
Quoted 2 lines
2.25.3
Pushed.
Signature · 1 line
Luiz Augusto von Dentz