From 7bb4e806ea792cd3f97daebd2c043165740ff995 Mon Sep 17 00:00:00 2001 From: Brick <6098371+0x1F9F1@users.noreply.github.com> Date: Sun, 20 Aug 2023 12:17:46 +0100 Subject: [PATCH] Clear resample_offset in SDL_ClearAudioStream, not SetAudioStreamFormat Not entirely sure if ClearAudioStream is the right place, but SetAudioStreamFormat was the wrong place --- src/audio/SDL_audiocvt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index 5d8370200..a3c7dada3 100644 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -554,7 +554,6 @@ static int SetAudioStreamFormat(SDL_AudioStream *stream, const SDL_AudioSpec *sr stream->history_buffer_allocation = history_buffer_allocation; } - stream->resample_offset = 0; stream->resampler_padding_frames = resampler_padding_frames; stream->history_buffer_frames = history_buffer_frames; stream->max_sample_frame_size = max_sample_frame_size; @@ -1141,6 +1140,7 @@ int SDL_ClearAudioStream(SDL_AudioStream *stream) if (stream->history_buffer != NULL) { SDL_memset(stream->history_buffer, SDL_GetSilenceValueForFormat(stream->src_spec.format), stream->history_buffer_frames * stream->src_spec.channels * sizeof (float)); } + stream->resample_offset = 0; stream->future_buffer_filled_frames = 0; stream->flushed = SDL_FALSE; SDL_UnlockMutex(stream->lock);