From: Marc-André Lureau Date: Sat, 4 Apr 2009 14:56:36 +0000 (+0300) Subject: bluetoth-device: be less strict on CONNECTED state to switch profile X-Git-Tag: submit/2.0-panda/20130828.192557~1887 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=099b3284ec7e78da25baa70d42a2ecdc1092b935;p=profile%2Fivi%2Fpulseaudio-panda.git bluetoth-device: be less strict on CONNECTED state to switch profile --- diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 90f6486..ecb5e83 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -1877,11 +1877,16 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) { return -1; } - if (device->headset_state != PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_HSP) { + /* 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 + concurrently (which is unlikely), ipc will fail later on, and + module will be unloaded. */ + if (device->headset_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_HSP) { pa_log_warn("HSP is not connected, refused to switch profile"); return -1; } - else if (device->audio_sink_state != PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_A2DP) { + else if (device->audio_sink_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_A2DP) { pa_log_warn("A2DP is not connected, refused to switch profile"); return -1; }