[pulseaudio-tickets] [Bug 58746] bluetooth audio out of sync when connection temporarily drops

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sun Jul 24 15:46:33 UTC 2016


https://bugs.freedesktop.org/show_bug.cgi?id=58746

Dmitry Kalyanov <Kalyanov.Dmitry at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Kalyanov.Dmitry at gmail.com

--- Comment #8 from Dmitry Kalyanov <Kalyanov.Dmitry at gmail.com> ---
Created attachment 125291
  --> https://bugs.freedesktop.org/attachment.cgi?id=125291&action=edit
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:
https://github.com/dmitryvk/pulseaudio/commit/12b13c75d3a9b377e0f7de7c86116e3af41ce5ee.
Patch was developed against Pulseaudio-8.0 but it works with Pulseaudio-9.0.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-bugs/attachments/20160724/5ac6ae74/attachment.html>


More information about the pulseaudio-bugs mailing list