feat: A2DP bluetooth audio working

This commit is contained in:
2026-06-10 16:00:42 +02:00
parent 4eb4ba4073
commit e0c8787727
18 changed files with 1312 additions and 4340 deletions
+16 -6
View File
@@ -38,8 +38,10 @@ namespace Drivers::USB::Bluetooth::A2dp {
// Process an AVDTP signaling packet
void ProcessAvdtp(const uint8_t* data, uint16_t len);
// Process an SDP response packet (on the SDP L2CAP channel)
void ProcessSdp(const uint8_t* data, uint16_t len);
// Process an SDP packet (on any SDP L2CAP channel). Dispatches by PDU:
// requests (the headset querying OUR services) are answered by the minimal
// SDP server; responses on our outgoing client channel complete DoSdpQuery.
void ProcessSdp(uint16_t localCid, const uint8_t* data, uint16_t len);
// Configure a stream for the given PCM parameters
bool ConfigureStream(uint32_t sampleRate, uint8_t channels, uint8_t bitsPerSample);
@@ -47,13 +49,21 @@ namespace Drivers::USB::Bluetooth::A2dp {
// Start streaming
bool StartStream();
// Stop streaming
bool StopStream();
// Stop streaming. flushQueued drops any PCM still queued in the media
// ring: pass true when closing the stream (track change / app exit),
// false for a pause so resume continues gaplessly.
bool StopStream(bool flushQueued = true);
// Write PCM audio data to the Bluetooth audio stream
// Returns number of bytes consumed
// Write PCM audio data to the Bluetooth audio stream. Copies into the
// media ring and returns immediately (never blocks); returns the number
// of bytes accepted (0 = ring full, retry later).
int WriteAudio(const uint8_t* pcmData, uint32_t pcmLen);
// Encode + send queued PCM, paced to the audio clock and gated on ACL TX
// readiness. Called from the idle-loop event pump and from WriteAudio;
// self-serializing, cheap no-op when not streaming.
void PumpMedia();
// Get current state
State GetState();