From ad1a11164c872aecd72803fb9a319c4e5fcbcfaf Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 26 Jan 2024 13:58:38 -0500 Subject: [PATCH] wasapi: Clamp device->spec.samples to the hardware buffer size. Reference Issue #8924. --- src/audio/wasapi/SDL_wasapi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c index 0b4fcc5ac5..cb69d4dd54 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -486,6 +486,11 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) this->spec.samples = (Uint16)SDL_ceilf(period_frames); } + /* regardless of what we calculated for the period size, clamp it to the expected hardware buffer size. */ + if (this->spec.samples > bufsize) { + this->spec.samples = bufsize; + } + /* Update the fragment size as size in bytes */ SDL_CalculateAudioSpec(&this->spec);