From 25aeb1c5a536219d07bf1e7a75fcacccd0f35249 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 7 Mar 2024 23:19:59 +0000 Subject: [PATCH] Change: Use same audio buffer size (and config parameter) for all sound drivers. (#12227) Windows drivers used a default buffer size of 8192 instead of 1024, which results in a considerable 186ms latency. --- src/sound/win32_s.cpp | 2 +- src/sound/xaudio2_s.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sound/win32_s.cpp b/src/sound/win32_s.cpp index f50346e88c..6cd72b3a2e 100644 --- a/src/sound/win32_s.cpp +++ b/src/sound/win32_s.cpp @@ -70,7 +70,7 @@ const char *SoundDriver_Win32::Start(const StringList &parm) wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign; /* Limit buffer size to prevent overflows. */ - _bufsize = GetDriverParamInt(parm, "bufsize", 8192); + _bufsize = GetDriverParamInt(parm, "samples", 1024); _bufsize = std::min(_bufsize, UINT16_MAX); try { diff --git a/src/sound/xaudio2_s.cpp b/src/sound/xaudio2_s.cpp index b4d08c4900..365cf46367 100644 --- a/src/sound/xaudio2_s.cpp +++ b/src/sound/xaudio2_s.cpp @@ -205,7 +205,7 @@ const char *SoundDriver_XAudio2::Start(const StringList &parm) wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign; // Limit buffer size to prevent overflows - int bufsize = GetDriverParamInt(parm, "bufsize", 8192); + int bufsize = GetDriverParamInt(parm, "samples", 1024); bufsize = std::min(bufsize, UINT16_MAX); _voice_context = new StreamingVoiceContext(bufsize * 4);