fix: fix Bluetooth audio delay

This commit is contained in:
daniel committed 2026-10-24 20:38:35 +02:00
1 parent 0a20385e12
commit dab7d5427b
2 files changed
+10 -2

No files matched your search

+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once
#define MONTAUK_BUILD_NUMBER 23
#define MONTAUK_BUILD_NUMBER 25
+9 -1
View File
@@ -119,7 +119,15 @@ namespace Drivers::USB::Bluetooth::A2dp {
// PCM ring between WriteAudio (producer, syscall context) and PumpMedia
// (consumer, idle-loop/syscall context). Absolute byte counters wrapping
// mod 2^32: fill = head - tail, buffer index = counter & (SIZE - 1).
constexpr uint32_t PCM_RING_SIZE = 128 * 1024; // ~0.68 s at 48 kHz stereo
//
// The ring's size IS output latency: the mixer pumps whenever it has
// room, so in steady state the ring sits full (silence included, while a
// stream is paused) and every pause, seek and volume change is heard only
// after it drains. It was 128 KiB (~0.68 s), which with LEAD_MS and the
// sink's own buffer put the headphones ~1 s behind the app. Stall
// tolerance comes from LEAD_MS at the sink plus the mixer's per-stream
// rings upstream, so this only needs to bridge the gap between pumps.
constexpr uint32_t PCM_RING_SIZE = 16 * 1024; // ~85 ms at 48 kHz stereo
constexpr uint64_t LEAD_MS = 150; // sink jitter-buffer target
static uint8_t g_pcmRing[PCM_RING_SIZE];
static std::atomic<uint32_t> g_ringHead{0}; // producer: WriteAudio