|
TB2026-YDS Firmware
|
Bluetooth A2DP audio sink: bridge the push pipeline to the pull A2DP source. More...
#include "sink_bluetooth.h"#include "bluetooth.h"#include "decoder.h"#include "freertos/FreeRTOS.h"#include "freertos/stream_buffer.h"#include "freertos/task.h"#include "freertos/timers.h"#include "freertos/semphr.h"#include "esp_attr.h"#include <string.h>#include <stdint.h>Macros | |
| #define | SINK_BT_RB_BYTES (21 * 1024) |
| #define | SINK_BT_WRITE_TO_MS 100 /* give up on a full ring after this (stalled link) */ |
| #define | SINK_BT_FRAME_BYTES 4 /* one 16-bit stereo frame in the ring */ |
| #define | SINK_BT_SUSPEND_DELAY_MS 3000 /* stop->SUSPEND grace: rides out skips and short pauses */ |
Functions | |
| const audio_sink_t * | sink_bluetooth_get (void) |
| Get the Bluetooth A2DP sink (PCM -> ring buffer -> A2DP source -> speaker). | |
Bluetooth A2DP audio sink: bridge the push pipeline to the pull A2DP source.
The pipeline pushes PCM via write(); the A2DP source pulls PCM from its own task. A stream buffer decouples the two: write() paces the pipeline by accepting only what fits (the Bluetooth link is the real-time clock). The stack encodes SBC and paces transmission.
The media session outlives one start/stop pair: stop() only arms a deferred SUSPEND and start() cancels it, so a track change (stop+start back-to-back) keeps the stream running. The SUSPEND/CHECK_SRC_RDY/START media commands are asynchronous and unserialised in the stack; issuing a pair of them per skip both added ~1 s of latency and could interleave so the session ended up suspended while the player believed it was playing (silent tracks).
| #define SINK_BT_FRAME_BYTES 4 /* one 16-bit stereo frame in the ring */ |
| #define SINK_BT_RB_BYTES (21 * 1024) |
| #define SINK_BT_SUSPEND_DELAY_MS 3000 /* stop->SUSPEND grace: rides out skips and short pauses */ |
| #define SINK_BT_WRITE_TO_MS 100 /* give up on a full ring after this (stalled link) */ |
| const audio_sink_t * sink_bluetooth_get | ( | void | ) |
Get the Bluetooth A2DP sink (PCM -> ring buffer -> A2DP source -> speaker).