From 75b64cabf5a14ebd48442f0f09a979397de33d7d Mon Sep 17 00:00:00 2001 From: David Reid Date: Fri, 11 Feb 2022 18:35:08 +1000 Subject: [PATCH] DirectSound: Increase the size of the default buffer size. Public issue https://github.com/mackron/miniaudio/issues/429 --- miniaudio.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index f91bb834..684720d6 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -23173,8 +23173,11 @@ static ma_result ma_config_to_WAVEFORMATEXTENSIBLE(ma_format format, ma_uint32 c static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__dsound(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile) { - /* DirectSound has a minimum period size of 20ms. */ - ma_uint32 minPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(20, nativeSampleRate); + /* + DirectSound has a minimum period size of 20ms. In practice, this doesn't seem to be enough for + reliable glitch-free processing so going to use 30ms instead. + */ + ma_uint32 minPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(30, nativeSampleRate); ma_uint32 periodSizeInFrames; periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, nativeSampleRate, performanceProfile);