From ad5ba68e8fcc50a99a1f1919ac55661671f189c5 Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Wed, 30 Oct 2024 20:12:32 +0000 Subject: [PATCH] Comments --- source/src/node/io/input/miniaudio.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/src/node/io/input/miniaudio.cpp b/source/src/node/io/input/miniaudio.cpp index cfdc22be..e1f3f0f0 100644 --- a/source/src/node/io/input/miniaudio.cpp +++ b/source/src/node/io/input/miniaudio.cpp @@ -128,6 +128,12 @@ void AudioIn::init() for (int channel = 0; channel < device.capture.internalChannels; channel++) { SampleRingQueue *queue = new SampleRingQueue(device.capture.internalPeriodSizeInFrames * 8); + /*-------------------------------------------------------------------------------- + * Initialise the queue with single block of silence, ensuring that the write + * head is always ahead of the read head by a block. This adds a single block + * of latency between input and output, but buffers against jitter in the + * case that two reads occur between one write (as experienced on Linux/alsa). + *-------------------------------------------------------------------------------*/ std::vector silence(device.capture.internalPeriodSizeInFrames, 0); queue->extend(silence); input_queue.push_back(queue);