Re: [pulseaudio-discuss] [PATCH 5/5] bluetooth: Refuse to use the HSP profile if there is some other HSP device active.
On Thu, 2011-03-31 at 15:30 +0300, Tanu Kaskinen wrote: On Thu, 2011-03-31 at 15:11 +0300, Tanu Kaskinen wrote: If no volunteers pop up, I guess I'll have to get a bluetooth dongle for my desktop so that I can test this myself. Never mind, I found a dongle already - I'll test it tomorrow. Ok, tests are now done. I couldn't get any audio in the HSP mode (A2DP worked fine). The sink seemed to be running and there were no errors, the problem seemed to be just that the sink was not getting any wakeups from the hardware. Before any BT hardware was connected, module-bluetooth-discover printed some errors at startup, but apart from this no-audio-with-hsp problem the errors didn't seem to cause any trouble. The behavior was identical with the current git master and with my patches applied. Even though I got no audio, looking at pulseaudio logs it seemed like sink_set_volume_cb was working alright, which was the only thing I wanted to test anyway. So, I suggest now that patches 1-4 get merged, along with the bluetooth: Fix HSP volume handling patch. -- Tanu ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] [PATCH 5/5] bluetooth: Refuse to use the HSP profile if there is some other HSP device active.
'Twas brillig, and Tanu Kaskinen at 01/04/11 13:10 did gyre and gimble: So, I suggest now that patches 1-4 get merged, along with the bluetooth: Fix HSP volume handling patch. OK, I can't see anything obvious to object to (partly because I'm pretty green with bluetooth stuff and partly because there cannot possibly be any bugs... :p) Merged in my tree now. Thanks :) Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mageia Contributor [http://www.mageia.org/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] [PATCH 5/5] bluetooth: Refuse to use the HSP profile if there is some other HSP device active.
On Thu, 2011-03-31 at 15:11 +0300, Tanu Kaskinen wrote: If no volunteers pop up, I guess I'll have to get a bluetooth dongle for my desktop so that I can test this myself. Never mind, I found a dongle already - I'll test it tomorrow. -- Tanu ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] [PATCH 5/5] bluetooth: Refuse to use the HSP profile if there is some other HSP device active.
On Mon, 2011-03-28 at 18:17 +0300, Luiz Augusto von Dentz wrote: There is a similar policy in BlueZ already for this and it is configurable via /etc/bluetooth/audio.conf, so I don't think hardcoding this on PA would do any better. Ah, excellent, I didn't know that. So the HSP profile locking part is unnecessary. It seems that I also put some fixes for the userdata handling of the volume callbacks in the same patch - I'll make a new patch for that part. -- Tanu ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] [PATCH 5/5] bluetooth: Refuse to use the HSP profile if there is some other HSP device active.
On Tue, 2011-03-29 at 23:16 +0300, Colin Guthrie wrote: 'Twas brillig, and Luiz Augusto von Dentz at 28/03/11 16:17 did gyre and gimble: There is a similar policy in BlueZ already for this and it is configurable via /etc/bluetooth/audio.conf, so I don't think hardcoding this on PA would do any better. Tanu, what's the best route forward? Patches 1-4 still OK/valid or? Yep, they're good (although it seems that the volume callbacks' userdata handling needed some tuning still in the fifth patch, but I propose you take the four patches and I send a new patch that fixes what there is to fix). -- Tanu ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
Re: [pulseaudio-discuss] [PATCH 5/5] bluetooth: Refuse to use the HSP profile if there is some other HSP device active.
'Twas brillig, and Luiz Augusto von Dentz at 28/03/11 16:17 did gyre and gimble: There is a similar policy in BlueZ already for this and it is configurable via /etc/bluetooth/audio.conf, so I don't think hardcoding this on PA would do any better. Tanu, what's the best route forward? Patches 1-4 still OK/valid or? Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mageia Contributor [http://www.mageia.org/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] ___ pulseaudio-discuss mailing list pulseaudio-discuss@mail.0pointer.de https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss
[pulseaudio-discuss] [PATCH 5/5] bluetooth: Refuse to use the HSP profile if there is some other HSP device active.
From: Tanu Kaskinen ext-tanu.kaski...@nokia.com --- src/modules/bluetooth/module-bluetooth-device.c | 126 +-- 1 files changed, 93 insertions(+), 33 deletions(-) diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 540d48c..1154651 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -185,6 +185,8 @@ struct userdata { #define MAX_PLAYBACK_CATCH_UP_USEC (100*PA_USEC_PER_MSEC) +#define CURRENT_HSP_DEVICE_KEY current-hsp-device /* Key to core-shared. */ + #define USE_SCO_OVER_PCM(u) (u-profile == PROFILE_HSP (u-hsp.sco_sink u-hsp.sco_source)) static int init_bt(struct userdata *u); @@ -1961,6 +1963,8 @@ static pa_hook_result_t source_state_changed_cb(pa_core *c, pa_source *s, struct /* Run from main thread */ static int add_sink(struct userdata *u) { +char *k; + if (USE_SCO_OVER_PCM(u)) { pa_proplist *p; @@ -2014,6 +2018,10 @@ static int add_sink(struct userdata *u) { if (u-profile == PROFILE_HSP) { u-sink-set_volume = sink_set_volume_cb; u-sink-n_volume_steps = 16; + +k = pa_sprintf_malloc(bluetooth-device@%p, (void*) u-sink); +pa_shared_set(u-core, k, u); +pa_xfree(k); } return 0; @@ -2021,6 +2029,8 @@ static int add_sink(struct userdata *u) { /* Run from main thread */ static int add_source(struct userdata *u) { +char *k; + if (USE_SCO_OVER_PCM(u)) { u-source = u-hsp.sco_source; pa_proplist_sets(u-source-proplist, bluetooth.protocol, hsp); @@ -2079,6 +2089,10 @@ static int add_source(struct userdata *u) { if (u-profile == PROFILE_HSP) { u-source-set_volume = source_set_volume_cb; u-source-n_volume_steps = 16; + +k = pa_sprintf_malloc(bluetooth-device@%p, (void*) u-source); +pa_shared_set(u-core, k, u); +pa_xfree(k); } return 0; @@ -2325,6 +2339,8 @@ static int init_profile(struct userdata *u) { /* Run from main thread */ static void stop_thread(struct userdata *u) { +char *k; + pa_assert(u); if (u-thread) { @@ -2349,11 +2365,23 @@ static void stop_thread(struct userdata *u) { } if (u-sink) { +if (u-profile == PROFILE_HSP) { +k = pa_sprintf_malloc(bluetooth-device@%p, (void*) u-sink); +pa_shared_remove(u-core, k); +pa_xfree(k); +} + pa_sink_unref(u-sink); u-sink = NULL; } if (u-source) { +if (u-profile == PROFILE_HSP) { +k = pa_sprintf_malloc(bluetooth-device@%p, (void*) u-source); +pa_shared_remove(u-core, k); +pa_xfree(k); +} + pa_source_unref(u-source); u-source = NULL; } @@ -2383,8 +2411,20 @@ static int start_thread(struct userdata *u) { if (USE_SCO_OVER_PCM(u)) { if (sco_over_pcm_state_update(u) 0) { -u-sink = NULL; -u-source = NULL; +char *k; + +if (u-sink) { +k = pa_sprintf_malloc(bluetooth-device@%p, (void*) u-sink); +pa_shared_remove(u-core, k); +pa_xfree(k); +u-sink = NULL; +} +if (u-source) { +k = pa_sprintf_malloc(bluetooth-device@%p, (void*) u-source); +pa_shared_remove(u-core, k); +pa_xfree(k); +u-source = NULL; +} return -1; } @@ -2421,9 +2461,25 @@ static int start_thread(struct userdata *u) { return 0; } +static void save_sco_volume_callbacks(struct userdata *u) { +pa_assert(u); +pa_assert(USE_SCO_OVER_PCM(u)); + +u-hsp.sco_sink_set_volume = u-hsp.sco_sink-set_volume; +u-hsp.sco_source_set_volume = u-hsp.sco_source-set_volume; +} + +static void restore_sco_volume_callbacks(struct userdata *u) { +pa_assert(u); +pa_assert(USE_SCO_OVER_PCM(u)); + +u-hsp.sco_sink-set_volume = u-hsp.sco_sink_set_volume; +u-hsp.sco_source-set_volume = u-hsp.sco_source_set_volume; +} + /* Run from main thread */ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) { -struct userdata *u; +struct userdata *u, *other_hsp_device; enum profile *d; pa_queue *inputs = NULL, *outputs = NULL; const pa_bluetooth_device *device; @@ -2439,6 +2495,9 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) { return -PA_ERR_IO; } +if (u-profile == PROFILE_HSP) +pa_shared_remove(u-core, CURRENT_HSP_DEVICE_KEY); + /* The state signal is sent by bluez, so it is racy to check strictly for CONNECTED, we should also accept STREAMING state as being good enough. However, if the profile is used @@ -2448,6 +2507,10 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) { pa_log_warn(HSP is not
Re: [pulseaudio-discuss] [PATCH 5/5] bluetooth: Refuse to use the HSP profile if there is some other HSP device active.
Hi Tanu, On Mon, Mar 28, 2011 at 3:35 PM, Tanu Kaskinen tanu.kaski...@digia.com wrote: From: Tanu Kaskinen ext-tanu.kaski...@nokia.com --- src/modules/bluetooth/module-bluetooth-device.c | 126 +-- 1 files changed, 93 insertions(+), 33 deletions(-) diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 540d48c..1154651 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -185,6 +185,8 @@ struct userdata { #define MAX_PLAYBACK_CATCH_UP_USEC (100*PA_USEC_PER_MSEC) +#define CURRENT_HSP_DEVICE_KEY current-hsp-device /* Key to core-shared. */ + #define USE_SCO_OVER_PCM(u) (u-profile == PROFILE_HSP (u-hsp.sco_sink u-hsp.sco_source)) static int init_bt(struct userdata *u); @@ -1961,6 +1963,8 @@ static pa_hook_result_t source_state_changed_cb(pa_core *c, pa_source *s, struct /* Run from main thread */ static int add_sink(struct userdata *u) { + char *k; + if (USE_SCO_OVER_PCM(u)) { pa_proplist *p; @@ -2014,6 +2018,10 @@ static int add_sink(struct userdata *u) { if (u-profile == PROFILE_HSP) { u-sink-set_volume = sink_set_volume_cb; u-sink-n_volume_steps = 16; + + k = pa_sprintf_malloc(bluetooth-device@%p, (void*) u-sink); + pa_shared_set(u-core, k, u); + pa_xfree(k); } return 0; @@ -2021,6 +2029,8 @@ static int add_sink(struct userdata *u) { /* Run from main thread */ static int add_source(struct userdata *u) { + char *k; + if (USE_SCO_OVER_PCM(u)) { u-source = u-hsp.sco_source; pa_proplist_sets(u-source-proplist, bluetooth.protocol, hsp); @@ -2079,6 +2089,10 @@ static int add_source(struct userdata *u) { if (u-profile == PROFILE_HSP) { u-source-set_volume = source_set_volume_cb; u-source-n_volume_steps = 16; + + k = pa_sprintf_malloc(bluetooth-device@%p, (void*) u-source); + pa_shared_set(u-core, k, u); + pa_xfree(k); } return 0; @@ -2325,6 +2339,8 @@ static int init_profile(struct userdata *u) { /* Run from main thread */ static void stop_thread(struct userdata *u) { + char *k; + pa_assert(u); if (u-thread) { @@ -2349,11 +2365,23 @@ static void stop_thread(struct userdata *u) { } if (u-sink) { + if (u-profile == PROFILE_HSP) { + k = pa_sprintf_malloc(bluetooth-device@%p, (void*) u-sink); + pa_shared_remove(u-core, k); + pa_xfree(k); + } + pa_sink_unref(u-sink); u-sink = NULL; } if (u-source) { + if (u-profile == PROFILE_HSP) { + k = pa_sprintf_malloc(bluetooth-device@%p, (void*) u-source); + pa_shared_remove(u-core, k); + pa_xfree(k); + } + pa_source_unref(u-source); u-source = NULL; } @@ -2383,8 +2411,20 @@ static int start_thread(struct userdata *u) { if (USE_SCO_OVER_PCM(u)) { if (sco_over_pcm_state_update(u) 0) { - u-sink = NULL; - u-source = NULL; + char *k; + + if (u-sink) { + k = pa_sprintf_malloc(bluetooth-device@%p, (void*) u-sink); + pa_shared_remove(u-core, k); + pa_xfree(k); + u-sink = NULL; + } + if (u-source) { + k = pa_sprintf_malloc(bluetooth-device@%p, (void*) u-source); + pa_shared_remove(u-core, k); + pa_xfree(k); + u-source = NULL; + } return -1; } @@ -2421,9 +2461,25 @@ static int start_thread(struct userdata *u) { return 0; } +static void save_sco_volume_callbacks(struct userdata *u) { + pa_assert(u); + pa_assert(USE_SCO_OVER_PCM(u)); + + u-hsp.sco_sink_set_volume = u-hsp.sco_sink-set_volume; + u-hsp.sco_source_set_volume = u-hsp.sco_source-set_volume; +} + +static void restore_sco_volume_callbacks(struct userdata *u) { + pa_assert(u); + pa_assert(USE_SCO_OVER_PCM(u)); + + u-hsp.sco_sink-set_volume = u-hsp.sco_sink_set_volume; + u-hsp.sco_source-set_volume = u-hsp.sco_source_set_volume; +} + /* Run from main thread */ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) { - struct userdata *u; + struct userdata *u, *other_hsp_device; enum profile *d; pa_queue *inputs = NULL, *outputs = NULL; const pa_bluetooth_device *device; @@ -2439,6 +2495,9 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) { return -PA_ERR_IO; } + if (u-profile == PROFILE_HSP) + pa_shared_remove(u-core, CURRENT_HSP_DEVICE_KEY); + /* The state signal is sent by bluez, so it is racy to check strictly for CONNECTED, we should also accept STREAMING state as