From e0c7af29666fe24c8c2be4668ea32d71456b8f8c Mon Sep 17 00:00:00 2001 From: David Reid Date: Mon, 4 Mar 2019 20:28:59 +1000 Subject: [PATCH] DirectSound: Force a minimum latency of 20 milliseconds. --- mini_al.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mini_al.h b/mini_al.h index c798c910..c9edd645 100644 --- a/mini_al.h +++ b/mini_al.h @@ -9122,6 +9122,10 @@ mal_result mal_device_init__dsound(mal_context* pContext, const mal_device_confi } } + /* DirectSound breaks down with tiny buffer sizes (bad glitching and silent output). I am therefore restricting the size of the buffer to a minimum of 20 milliseconds. */ + if ((bufferSizeInMilliseconds/pConfig->periods) < 20) { + bufferSizeInMilliseconds = pConfig->periods * 20; + } // Unfortunately DirectSound uses different APIs and data structures for playback and catpure devices. We need to initialize // the capture device first because we'll want to match it's buffer size and period count on the playback side if we're using