bluetooth: set better priorities for profiles

Submitted by Tanu Kaskinen on Oct. 15, 2017, 10:29 a.m.

Details

Message ID 20171015102942.5589-1-tanuk@iki.fi
State Accepted
Series "bluetooth: set better priorities for profiles"
Commit 85daab2725c8964d5e3d07089c4056435022d12e
Headers show

Commit Message

Tanu Kaskinen Oct. 15, 2017, 10:29 a.m.
Since HSP had higher priority than A2DP, the default profile when
connecting a new headset was HSP. To me it makes more sense to default
to high-quality output. We already have some automatic policies to
switch to HSP when it's needed.

I also made the A2DP source and HSP/HFP gateway profiles have lower
priority than the A2DP sink and HSP headset profiles. The A2DP source
and HSP/HFP gateway profiles should only be activated if the remote
device initiates audio streaming, so it makes sense to have lower
priority for those profiles.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=103058
---
 src/modules/bluetooth/module-bluez5-device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
index 8a9063932..fb9914727 100644
--- a/src/modules/bluetooth/module-bluez5-device.c
+++ b/src/modules/bluetooth/module-bluez5-device.c
@@ -1861,7 +1861,7 @@  static pa_card_profile *create_card_profile(struct userdata *u, pa_bluetooth_pro
     switch (profile) {
     case PA_BLUETOOTH_PROFILE_A2DP_SINK:
         cp = pa_card_profile_new(name, _("High Fidelity Playback (A2DP Sink)"), sizeof(pa_bluetooth_profile_t));
-        cp->priority = 10;
+        cp->priority = 40;
         cp->n_sinks = 1;
         cp->n_sources = 0;
         cp->max_sink_channels = 2;
@@ -1873,7 +1873,7 @@  static pa_card_profile *create_card_profile(struct userdata *u, pa_bluetooth_pro
 
     case PA_BLUETOOTH_PROFILE_A2DP_SOURCE:
         cp = pa_card_profile_new(name, _("High Fidelity Capture (A2DP Source)"), sizeof(pa_bluetooth_profile_t));
-        cp->priority = 10;
+        cp->priority = 20;
         cp->n_sinks = 0;
         cp->n_sources = 1;
         cp->max_sink_channels = 0;
@@ -1885,7 +1885,7 @@  static pa_card_profile *create_card_profile(struct userdata *u, pa_bluetooth_pro
 
     case PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT:
         cp = pa_card_profile_new(name, _("Headset Head Unit (HSP/HFP)"), sizeof(pa_bluetooth_profile_t));
-        cp->priority = 20;
+        cp->priority = 30;
         cp->n_sinks = 1;
         cp->n_sources = 1;
         cp->max_sink_channels = 1;
@@ -1898,7 +1898,7 @@  static pa_card_profile *create_card_profile(struct userdata *u, pa_bluetooth_pro
 
     case PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY:
         cp = pa_card_profile_new(name, _("Headset Audio Gateway (HSP/HFP)"), sizeof(pa_bluetooth_profile_t));
-        cp->priority = 20;
+        cp->priority = 10;
         cp->n_sinks = 1;
         cp->n_sources = 1;
         cp->max_sink_channels = 1;

Comments

Georg Chini Oct. 15, 2017, 6:05 p.m.
On 15.10.2017 12:29, Tanu Kaskinen wrote:
> Since HSP had higher priority than A2DP, the default profile when
> connecting a new headset was HSP. To me it makes more sense to default
> to high-quality output. We already have some automatic policies to
> switch to HSP when it's needed.
>
> I also made the A2DP source and HSP/HFP gateway profiles have lower
> priority than the A2DP sink and HSP headset profiles. The A2DP source
> and HSP/HFP gateway profiles should only be activated if the remote
> device initiates audio streaming, so it makes sense to have lower
> priority for those profiles.
>
> BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=103058
> ---
>   src/modules/bluetooth/module-bluez5-device.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
> index 8a9063932..fb9914727 100644
> --- a/src/modules/bluetooth/module-bluez5-device.c
> +++ b/src/modules/bluetooth/module-bluez5-device.c
> @@ -1861,7 +1861,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, pa_bluetooth_pro
>       switch (profile) {
>       case PA_BLUETOOTH_PROFILE_A2DP_SINK:
>           cp = pa_card_profile_new(name, _("High Fidelity Playback (A2DP Sink)"), sizeof(pa_bluetooth_profile_t));
> -        cp->priority = 10;
> +        cp->priority = 40;
>           cp->n_sinks = 1;
>           cp->n_sources = 0;
>           cp->max_sink_channels = 2;
> @@ -1873,7 +1873,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, pa_bluetooth_pro
>   
>       case PA_BLUETOOTH_PROFILE_A2DP_SOURCE:
>           cp = pa_card_profile_new(name, _("High Fidelity Capture (A2DP Source)"), sizeof(pa_bluetooth_profile_t));
> -        cp->priority = 10;
> +        cp->priority = 20;
>           cp->n_sinks = 0;
>           cp->n_sources = 1;
>           cp->max_sink_channels = 0;
> @@ -1885,7 +1885,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, pa_bluetooth_pro
>   
>       case PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT:
>           cp = pa_card_profile_new(name, _("Headset Head Unit (HSP/HFP)"), sizeof(pa_bluetooth_profile_t));
> -        cp->priority = 20;
> +        cp->priority = 30;
>           cp->n_sinks = 1;
>           cp->n_sources = 1;
>           cp->max_sink_channels = 1;
> @@ -1898,7 +1898,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, pa_bluetooth_pro
>   
>       case PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY:
>           cp = pa_card_profile_new(name, _("Headset Audio Gateway (HSP/HFP)"), sizeof(pa_bluetooth_profile_t));
> -        cp->priority = 20;
> +        cp->priority = 10;
>           cp->n_sinks = 1;
>           cp->n_sources = 1;
>           cp->max_sink_channels = 1;

Looks good to me.