-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
BT A2DP sink doesn't handle AVRC commands during playback (IDFGH-4920) #6712
Comments
Thanks for the detailed report, we will look into. |
Hi @boblane1, Good news is, that volume events are handled during playback. Rarely these errors come up (this seems to be the first error displayed)
After that, more often there's this:
And after a while the audio stream cuts off and a seemingly never-ending stream of dropped Packers are printed.
I've applied the patch using git am ./patch
cd examples/bluetooth/bluedroid/classic_bt/a2dp_sink
idf.py -p /dev/tty.usbserial-0001 clean build flash monitor |
Hi @playduck,
These logs indicate that the
This means that the congestion has occurred in Bluetooth L2CAP layer which caused by your quickly sending. In fact, for the reason of limited resources, the Bluetooth stack on the ESP32 handle AVRC and A2DP data in the same task which known as By the way, if the audio packet dropping still exists. You can try to increase the Thanks! |
Thanks for the helpful feedback @boblane1 Increasing I couldn't find anything labeled Slowing down events isn't really an option. Is there some solution to mitigate congestion, like ignoring AVRC commands if they're too frequent to be dealt with? |
I've just noticed I modified the unpatched version. Only after sending a, quite frankly, ridiculous amount of volume events in quick succession do i get
It'd be nice if there was some way to handle these errors and ignore too many events, however I believe I can happily live with this solution. Thank you very much! |
We will do some optimization in the future. Thanks for your advice! |
Awesome! |
@playduck Thanks for sharing the updates, reopen now, will close until the fix is available on GitHub, thanks. |
@playduck does this patch work with current IDF v4.4.1? i have the issue that iphone sends many volume commands very fast, and that causes audio packet drops, i just wonder if the A2DP sink is still broken in this aspect @boblane1 , i am having audio packet drops on the A2DP.sink example, when the iphone makes rapid volume changes |
@mitchjs I'm afraid I can't help you with that as my project isn't using IDF v4.4.1 |
@playduck what version of IDF did you program under? i set the size of s_bt_app_task_queue to 20, didnt seem to change anything |
I am receiving the same I am using the latest esp-adf version (2.6) together with the shipped esp-idf release (4.4 - commit 3c8bc22) |
@pad52 did you check the task priority? |
Hi @pad52,
|
Thank you for your fast reply. |
Environment
Problem Description
I'm using the ESP as a Bluetooth A2DP Sink, like in the official example.
Playback works fine.
However, once a device is connected and playing audio back through the ESP no AVRC Commands, like absolute volume, from the Host/Source are neither executed nor logged (to the monitor).
Only after the Audio Stream has been paused or suspended will all cued AVRC Commands be handled.
Expected Behavior
AVRC Commands should be handled during playback and printed to the monitor as soon as the arrive.
Actual Behavior
AVRC Commands are not executed during playback.
But after the Audio Stream has been suspended.
Steps to reproduce
Code to reproduce this issue
Just the aforementioned Example.
Debug Logs
Thing I've tried
I've used two different Source Devices (an Iphone and a Macbook).
Both of which have delivered the same results.
When commenting out line
./main/bt_app_core.c:128
The AVRC events work as expected.
By measuring this line's execution time by saving calls to
esp_timer_get_time()
before and after the line and printing the difference I've received a nominal time of around 23ms.
With a packet size of 4096 Stereo Samples, we get 4096 / 2 = 2048 Samples per channel per function call.
At fs = 44100Hz this is equal to 2048 * (1/44100Hz) = 46.44ms per Channel.
Thus the function call takes only half the amount of time as our audio samples represent.
I don't think
i2s_write
is too slow to handle the ammount of data nor should it block any AVRC events from being handled.When changing the
portMAX_DELAY
of thei2s_write
to something likepdMS_TO_TICKS(10)
the AVRC events work again in real time, however the audio is now choppy, since not all samples are pushed out.The text was updated successfully, but these errors were encountered: