Skip to content

Commit 5b0e838

Browse files
committed
wasapi: Deal with device buffer sizes changing.
Otherwise, it would fill the previous size's worth of data into the current size's buffer. Fixes #11122.
1 parent 96e7306 commit 5b0e838

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/audio/wasapi/SDL_wasapi.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
111111
}
112112
}
113113

114+
/* if the device sample size changed, make sure we're asking for enough data. */
115+
if (this->callbackspec.samples != this->spec.samples) {
116+
this->callbackspec.samples = this->spec.samples;
117+
SDL_CalculateAudioSpec(&this->callbackspec);
118+
}
119+
114120
/* make sure our scratch buffer can cover the new device spec. */
115121
if (this->spec.size > this->work_buffer_len) {
116122
Uint8 *ptr = (Uint8 *)SDL_realloc(this->work_buffer, this->spec.size);

0 commit comments

Comments
 (0)