pulseaudio/src/modules/bluetooth
Juha Kuikka 6a786c9375 bluetooth: fix race condition in BlueZ5 device disconnection
SW: Pulseaudio 8.0 / BlueZ 5.39

Symptoms:
While disconnecting/reconnecting a paired bluetooth headset (LG HBS750)
audio fails roughly on every other connection.

On a failed connection "pactl list cards" shows the bluetooth device's
card but "Active Profile: off". Issuing "pacmd set-card-profile X
a2dp_sink" makes audio work immediately.

I realized that when this happened, the previous disconnection did not
remove the card, instead it was only configured for "Active Profile:
off" but otherwise left in place.

Upon looking at PA debug logs I saw that the transport for the a2dp_sink
was first set into disconnected state and then into idle state. In
"device_connection_changed_cb()" this causes the
"pa_bluetooth_device_any_transport_connected()" return true and the
module-bluez5-device is not unloaded.

Further investigation shows that this is caused by a race of
module-bluez5-device.c:thread_func() and
MediaPoint1::ClearConfiguration().

When the FD in thread_func() is closed (POLLHUP) an
BLUETOOTH_MESSAGE_STREAM_FD_HUP message is sent into the main thread.
The handler of this message unconditionally sets the transport into IDLE
state. This is a problem if it has already been set into DISCONNECTED
state.
2016-11-28 13:17:44 +02:00
..
a2dp-codecs.h update FSF addresses to FSF web page 2015-01-14 22:20:40 +02:00
backend-native.c bluetooth: Fix negative array index write 2016-08-17 17:32:10 +02:00
backend-ofono.c update FSF addresses to FSF web page 2015-01-14 22:20:40 +02:00
bluez4-util.c bluetooth: Reorganize code to avoid Coverity NULL dereference warning 2016-08-17 17:32:03 +02:00
bluez4-util.h bluetooth: unify BlueZ 4 and BlueZ 5 profile constant names 2016-08-10 21:37:33 +03:00
bluez5-util.c bluetooth: refactor BlueZ 4 transport state setting 2016-08-10 21:37:33 +03:00
bluez5-util.h bluetooth: unify BlueZ 4 and BlueZ 5 UUID handling 2016-08-10 21:37:33 +03:00
module-bluetooth-discover.c update FSF addresses to FSF web page 2015-01-14 22:20:40 +02:00
module-bluetooth-policy.c bluetooth: Add support for automatic switch between hsp and a2dp profiles also for bluez5 2016-09-23 17:37:06 +05:30
module-bluez4-device.c Remove newline at end of log messages 2016-08-16 07:03:25 +02:00
module-bluez4-discover.c bluetooth: Fix dead code 2016-08-16 10:31:44 +02:00
module-bluez5-device.c bluetooth: fix race condition in BlueZ5 device disconnection 2016-11-28 13:17:44 +02:00
module-bluez5-discover.c bluetooth: Prevent aborts caused by invalid module arguments 2016-01-15 16:20:53 +05:30
rtp.h update FSF addresses to FSF web page 2015-01-14 22:20:40 +02:00