diff mbox series

[BlueZ] a2dp: Use streaming mode when MPS is enabled

Message ID 20200608202628.875833-1-luiz.dentz@gmail.com (mailing list archive)
State New, archived
Headers show
Series [BlueZ] a2dp: Use streaming mode when MPS is enabled | expand

Commit Message

Luiz Augusto von Dentz June 8, 2020, 8:26 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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(-)

Comments

Luiz Augusto von Dentz June 10, 2020, 8:24 p.m. UTC | #1
Hi,

On Mon, Jun 8, 2020 at 1:26 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> 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(-)
>
> diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
> index 0a66589b0..f00e5c923 100644
> --- a/profiles/audio/a2dp.c
> +++ b/profiles/audio/a2dp.c
> @@ -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);
> diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
> index 45727f01e..e5193f79b 100644
> --- a/profiles/audio/avdtp.c
> +++ b/profiles/audio/avdtp.c
> @@ -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) {
> diff --git a/src/hcid.h b/src/hcid.h
> index 56e2b4f31..1b2714b1d 100644
> --- a/src/hcid.h
> +++ b/src/hcid.h
> @@ -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;
>
> diff --git a/src/main.c b/src/main.c
> index 50e37e57a..e51f614b3 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -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
> --
> 2.25.3
>

Pushed.
diff mbox series

Patch

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 0a66589b0..f00e5c923 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -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);
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 45727f01e..e5193f79b 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -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) {
diff --git a/src/hcid.h b/src/hcid.h
index 56e2b4f31..1b2714b1d 100644
--- a/src/hcid.h
+++ b/src/hcid.h
@@ -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;
 
diff --git a/src/main.c b/src/main.c
index 50e37e57a..e51f614b3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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