Search
SailfishOS Open Build Service
>
Projects
>
home:kimmoli
:
testing
>
pulseaudio
> _service:tar_git:1009-bluez4-device-Default-to-using-A2DP-profile-initiall.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File _service:tar_git:1009-bluez4-device-Default-to-using-A2DP-profile-initiall.patch of Package pulseaudio
From b58fef2f1ab4a336fc33d74d17cb432752ead534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20H=C3=A4m=C3=A4l=C3=A4inen?= <juho.hamalainen@tieto.com> Date: Thu, 10 Apr 2014 10:34:06 +0300 Subject: [PATCH 1009/1015] bluez4-device: Default to using A2DP profile initially. By default have A2DP profiles with higher priority than HFP profiles, since usually when A2DP+HFP-capable device is connected, it's meant for A2DP streaming. This behavior can be dynamically overridden by setting property bluetooth.prefer.hsp as true to SCO sink. When this property is found in SCO sink upon bluez4-device startup, HFP profiles have higher priority than A2DP to select HFP initially. --- src/modules/bluetooth/module-bluez4-device.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/modules/bluetooth/module-bluez4-device.c b/src/modules/bluetooth/module-bluez4-device.c index 12453e1..efd0589 100644 --- a/src/modules/bluetooth/module-bluez4-device.c +++ b/src/modules/bluetooth/module-bluez4-device.c @@ -208,6 +208,8 @@ enum { #define USE_SCO_OVER_PCM(u) (u->profile == PA_BLUEZ4_PROFILE_HSP && (u->hsp.sco_sink && u->hsp.sco_source)) +#define BLUETOOTH_PREFER_HSP "bluetooth.prefer.hsp" + static int init_profile(struct userdata *u); /* from IO thread */ @@ -2228,6 +2230,22 @@ static void create_card_ports(struct userdata *u, pa_hashmap *ports) { pa_device_port_new_data_done(&port_data); } +static int check_prefer_hsp(struct userdata *u) { + const char *tmp; + int prefer_hsp = 0; + + pa_assert(u); + + if (u->hsp.sco_sink) { + if ((tmp = pa_proplist_gets(u->hsp.sco_sink->proplist, BLUETOOTH_PREFER_HSP))) { + if (pa_streq(tmp, "true")) + prefer_hsp = 20; + } + } + + return prefer_hsp; +} + /* Run from main thread */ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid, pa_hashmap *ports) { pa_device_port *input_port, *output_port; @@ -2241,7 +2259,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid if (pa_streq(uuid, A2DP_SINK_UUID)) { p = pa_card_profile_new("a2dp", _("High Fidelity Playback (A2DP)"), sizeof(pa_bluez4_profile_t)); - p->priority = 10; + p->priority = 20; p->n_sinks = 1; p->n_sources = 0; p->max_sink_channels = 2; @@ -2252,7 +2270,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid *d = PA_BLUEZ4_PROFILE_A2DP; } else if (pa_streq(uuid, A2DP_SOURCE_UUID)) { p = pa_card_profile_new("a2dp_source", _("High Fidelity Capture (A2DP)"), sizeof(pa_bluez4_profile_t)); - p->priority = 10; + p->priority = 20; p->n_sinks = 0; p->n_sources = 1; p->max_sink_channels = 0; @@ -2263,7 +2281,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid *d = PA_BLUEZ4_PROFILE_A2DP_SOURCE; } else if (pa_streq(uuid, HSP_HS_UUID) || pa_streq(uuid, HFP_HS_UUID)) { p = pa_card_profile_new("hsp", _("Telephony Duplex (HSP/HFP)"), sizeof(pa_bluez4_profile_t)); - p->priority = 20; + p->priority = 10 + check_prefer_hsp(u); p->n_sinks = 1; p->n_sources = 1; p->max_sink_channels = 1; @@ -2275,7 +2293,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid *d = PA_BLUEZ4_PROFILE_HSP; } else if (pa_streq(uuid, HFP_AG_UUID)) { p = pa_card_profile_new("hfgw", _("Handsfree Gateway"), sizeof(pa_bluez4_profile_t)); - p->priority = 20; + p->priority = 10 + check_prefer_hsp(u); p->n_sinks = 1; p->n_sources = 1; p->max_sink_channels = 1; @@ -2385,6 +2403,8 @@ static int add_card(struct userdata *u) { d = PA_CARD_PROFILE_DATA(u->card->active_profile); + pa_log_debug("Select initial profile (%s)", *d == PA_BLUEZ4_PROFILE_OFF ? "off" : pa_bluez4_profile_to_string(*d)); + if (*d != PA_BLUEZ4_PROFILE_OFF && (!device->transports[*d] || device->transports[*d]->state == PA_BLUEZ4_TRANSPORT_STATE_DISCONNECTED)) { pa_log_warn("Default profile not connected, selecting off profile"); -- 1.9.1