Skip to content

A2DP Sink Optimizations

Phil Schatzmann edited this page Oct 21, 2023 · 23 revisions

Different Arduino/IDF versions are using up a different amount of RAM. The more recent the version the more RAM is needed. With the latest change Espressif is also recommending to use a separate ringbuffer and task to manage the output. This option is using additional RAM. You can try to fine tune the memory requirements by calling the following methods before the start():

BluetoothA2DPSink

The BluetoothA2DPSink provides the default implementation of a Bluetooth Speaker. You can try to adjust the following parameters

  • set_event_stack_size() - default value is 3K
  • set_event_queue_size() - default 20
  • set_task_priority() - default: configMAX_PRIORITIES - 10

BluetoothA2DPSinkQueued

You can use this extended provided by the BluetoothA2DPSinkQueued class. This way you will need about 33K more RAM. This can potentially correct some lost audio depending of the combination of number of volume changes, the selected log level and the source Operating System (e.g. IOS seems to be potentially a source of trouble here).

  • set_event_stack_size() - default value is 3K
  • set_event_queue_size() - default 20
  • set_task_priority()
  • set_i2s_stack_size() - default value is 2K
  • set_i2s_ringbuffer_size() - default value is 32 * 1024
  • set_i2s_ringbuffer_prefetch_percent() - default 70
  • set_i2s_task_priority() - default configMAX_PRIORITIES - 3
  • set_i2s_write_size_upto() - default 240 * 6
  • set_i2s_ticks() - default 20
Clone this wiki locally