<html>
<head>
<base href="https://bugs.freedesktop.org/">
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - bluetooth audio out of sync when connection temporarily drops"
href="https://bugs.freedesktop.org/show_bug.cgi?id=58746#c14">Comment # 14</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - bluetooth audio out of sync when connection temporarily drops"
href="https://bugs.freedesktop.org/show_bug.cgi?id=58746">bug 58746</a>
from <span class="vcard"><a class="email" href="mailto:paco3346@gmail.com" title="paco3346@gmail.com">paco3346@gmail.com</a>
</span></b>
<pre>(In reply to Dmitry Kalyanov from <a href="show_bug.cgi?id=58746#c8">comment #8</a>)
<span class="quote">> Created <span class=""><a href="attachment.cgi?id=125291" name="attach_125291" title="Proof-of-concept patch">attachment 125291</a> <a href="attachment.cgi?id=125291&action=edit" title="Proof-of-concept patch">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=58746&attachment=125291'>[review]</a> [review]
> Proof-of-concept patch
>
> I've solved this issue for myself - I've been using pulseaudio with my
> changes for several months now with no major problems.
>
> I've noticed that every time signal degrades audio gets more out of sync -
> up to about 10-15 seconds (if I remember correctly).
>
> I've debugged bluez5 pulseaudio module and suspect that the problem lies in
> buffering for bluetooth socket. Here's my analysis:
>
> 1) Pulseaudio detects BT signal drop when write() on bluetooth socket
> returns EAGAIN (i.e., when the buffer is full).
> 2) Bluetooth socket buffer is quite big (by default)
> 3) When pulseaudio stops sending audio packets to BT socket the buffer still
> contains a lot of packets
> 4) pulseaudio considers those packets as successfully sent - but they aren't
> 5) BT connection seems to never be able to "catch up" with the amount of
> buffered packets and audio becomes out-of-sync.
>
> So here's my patch. The main change is to decrease the buffer size as much
> as possible. I've experimented and found out that settings buffer size to
> 2x-5x of packet size works best for me. This ensures that audio lag won't
> accumulate after BT signal degradation while preventing audio skipping due
> to buffer underruns. Audio still may skip (sometimes several times in a row)
> - but without the lag after BT signal restores.
>
> Unfortunately with this patch bluetooth microphone (headset profile) won't
> work - since I don't use one and couldn't test it. I hope that someone would
> be able to pick it up and make into a form that would be possible to merge
> in master branch.
>
> The changes are contained in attached path on github:
> <a href="https://github.com/dmitryvk/pulseaudio/commit/">https://github.com/dmitryvk/pulseaudio/commit/</a>
> 12b13c75d3a9b377e0f7de7c86116e3af41ce5ee. Patch was developed against
> Pulseaudio-8.0 but it works with Pulseaudio-9.0.</span >
Genius! I understand the problems with this patch but for now it's music to my
ears (pun intended). Using on Arch with Pulseaudio 9.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>