-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
increasing delay as a sink #156
Comments
I have the same issue, restarting bluealsa-aplay periodically is a somewhat viable workaround. But of course you hear the sound stutter everytime, you restart it. Is there any way to flush bluealsa-aplay's buffer? |
So I'm using my Raspberry Pi 3 Model B as an A2DP sink over Bluetooth. More specifically, I want to use my Samsung phone's dual-audio over Bluetooth feature, which allows it to pair to two Bluetooth speakers at the same time. I've been trying to get my UE Megaboom speaker to play in-sync with the non-Bluetooth speaker connected to my RPi's audio jack. I also stumbled onto those bluealsa-aplay flags you mentioned: I looked more into those flags, and found this on the aplay man page:
So it seems bluealsa-aplay only allows us to adjust aplay's However, I noticed something interesting about the output of the command: Output:
Specifically, this line: For period time, aplay's man page says:
So I decided to set And if anyone else who reads this is interested, I've tested different Output:
Notice the buffer time and period time are still slightly off (maybe it has to do with rounding to the nearest byte?--I have no idea). I would think this, in turn, means that aplay's All this to say, setting a |
I am now also using I suggest to keep this issue open until the actual cause of the problem gets more clear. |
alsa period time and buffer time settings are not supposed to affect the playback speed, so (in theory) should not change the relative delay between two streams. I think the most likely underlying cause is this: The common factor in the above reports is that they all appear to be using the RPi's on-board DAC, which is of notoriously poor quality. Try with a USB or i2c HAT DAC and see if that cures the problem. |
In my setup, I used the RPi 2 Model B with an external USB sound card that is part of the speaker system. So in this case it should be a quality DAC. Still, I experienced this increasing delay before I found this work-around. |
A recent change in alsa-lib may have improved synchronization when using the rate plugin to convert sample rates. See #451 (comment) for references. If anyone is experiencing this issue, it may be worth compiling alsa-lib to see if that helps. |
Unfortunately that change has not made any difference to the rounding error. However, since this issue was raised (nearly 3 years ago) there have many improvements to BlueALSA. In particular commit bacbf5d has removed the cause of the period time anomaly seen here. Rounding error still exists in the rate plugin, but can be avoided by choosing period time that is a multiple of 10ms when converting between 48000 and 44100 sample rates. The default period time of bluealsa-aplay is therefore now OK for this particular conversion. There is still an issue of clock drift between the bluetooth clock and soundcard clock, but that should be considerably smaller than the amount originally reported here. To compensate for the clock drift, PR #459 if eventually committed, should suffice. |
The latest update to the There still remains the issue of much smaller time drift which results from different clocks in the Bluetooth adapter and the soundcard. PR #459 proposes one way to address that, so please follow progress on that PR if you need to further improve synchronization. |
Hello,
I using AAC sink, with blueasla-aplay on Raspberry Pi Zero W. I tried to play with settings in /src/transport.c
https://github.com/Arkq/bluez-alsa/blob/dbfa1dc3fe339276955cb9163848d3d4ee49996b/src/transport.c#L867-L870
and flags of bluealsa-aplay
--pcm-buffer-time=20000 --pcm-period-time=10000
I achieved low delay and sound become almost synch in videos, but the longer I watch the longer the delay. Аlmost 0.5 sec of delay every 2-3 min of watching.
I don't clearly understand how it happends because I didn't notice any gaps and sound seems to play at normal speed.
So am I doing it right with parameters and how to stop increasing of the sound delay?
Thanks for this tool, using it makes my day happier.
The text was updated successfully, but these errors were encountered: