Skip to content

Commit

Permalink
wasapi: Deal with device buffer sizes changing.
Browse files Browse the repository at this point in the history
Otherwise, it would fill the previous size's worth of data into the current
size's buffer.

Fixes libsdl-org#11122.
  • Loading branch information
icculus committed Oct 28, 2024
1 parent 96e7306 commit 5b0e838
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/audio/wasapi/SDL_wasapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
}
}

/* if the device sample size changed, make sure we're asking for enough data. */
if (this->callbackspec.samples != this->spec.samples) {
this->callbackspec.samples = this->spec.samples;
SDL_CalculateAudioSpec(&this->callbackspec);
}

/* make sure our scratch buffer can cover the new device spec. */
if (this->spec.size > this->work_buffer_len) {
Uint8 *ptr = (Uint8 *)SDL_realloc(this->work_buffer, this->spec.size);
Expand Down

0 comments on commit 5b0e838

Please sign in to comment.