bluetooth: Refactor dependency to org.bluez.Audio

The state of this interface is needed for one single reason: we need to
wait until all profiles have been connected (or more precisely, until
are connection attempts are finished). This can be made more explicit in
the code by just checking the CONNECTING state (and not loading
module-bluetooth-device during that state), but otherwise treating all
transport types equally.

Ideally, audio_state should be completely removed but it's left there to
avoid an issue with module-card-restore, as documented in the source
code's comments.
This commit is contained in:
Mikel Astiz 2012-12-14 15:14:36 +01:00 committed by Tanu Kaskinen
parent 203c6f8ed4
commit 468c67bb62

View file

@ -1063,13 +1063,15 @@ pa_bluetooth_device* pa_bluetooth_discovery_get_by_path(pa_bluetooth_discovery *
} }
bool pa_bluetooth_device_any_audio_connected(const pa_bluetooth_device *d) { bool pa_bluetooth_device_any_audio_connected(const pa_bluetooth_device *d) {
unsigned i;
pa_assert(d); pa_assert(d);
if (d->dead || !device_is_audio_ready(d)) if (d->dead || !device_is_audio_ready(d))
return false; return false;
/* Deliberately ignore audio_sink_state and headset_state since they are /* Make sure audio_state is *not* in CONNECTING state before we fire the hook
* reflected in audio_state. This is actually very important in order to * to report the new device state. This is actually very important in order to
* make module-card-restore work well with headsets: if the headset * make module-card-restore work well with headsets: if the headset
* supports both HSP and A2DP, one of those profiles is connected first and * supports both HSP and A2DP, one of those profiles is connected first and
* then the other, and lastly the Audio interface becomes connected. * then the other, and lastly the Audio interface becomes connected.
@ -1081,10 +1083,14 @@ bool pa_bluetooth_device_any_audio_connected(const pa_bluetooth_device *d) {
* connected. Waiting until the Audio interface gets connected means that * connected. Waiting until the Audio interface gets connected means that
* both headset profiles will be connected when the device module is * both headset profiles will be connected when the device module is
* loaded. */ * loaded. */
return if (d->audio_state == PA_BT_AUDIO_STATE_CONNECTING)
d->audio_state >= PA_BT_AUDIO_STATE_CONNECTED || return false;
d->profile_state[PROFILE_A2DP_SOURCE] >= PA_BT_AUDIO_STATE_CONNECTED ||
d->profile_state[PROFILE_HFGW] >= PA_BT_AUDIO_STATE_CONNECTED; for (i = 0; i < PA_BLUETOOTH_PROFILE_COUNT; i++)
if (d->profile_state[i] >= PA_BT_AUDIO_STATE_CONNECTED)
return true;
return false;
} }
int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, bool optional, size_t *imtu, size_t *omtu) { int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, bool optional, size_t *imtu, size_t *omtu) {