<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - BlueZ5 module fails to clean out card after headset disconnects"
href="https://bugs.freedesktop.org/show_bug.cgi?id=94958">94958</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>BlueZ5 module fails to clean out card after headset disconnects
</td>
</tr>
<tr>
<th>Product</th>
<td>PulseAudio
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux (All)
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>modules
</td>
</tr>
<tr>
<th>Assignee</th>
<td>pulseaudio-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>juha.kuikka@gmail.com
</td>
</tr>
<tr>
<th>QA Contact</th>
<td>pulseaudio-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>CC</th>
<td>lennart@poettering.net
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=122981" name="attach_122981" title="Patch to fix the issue">attachment 122981</a> <a href="attachment.cgi?id=122981&action=edit" title="Patch to fix the issue">[details]</a></span>
Patch to fix the issue
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.
See attached patch for a fix.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
<li>You are the QA Contact for the bug.</li>
</ul>
</body>
</html>