From d6bc3195350f6f2bff0053e6ffca2ce857d9b454 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 18 Mar 2023 16:40:24 -0700 Subject: [PATCH] Add sample rate mismatch check to sound effects Sound effects already get recreated if the number of channels mismatches, but the same could be true if the sample rate mismatches too, which was the case with music tracks as described in #886. So, just to be sure - and to be consistent with music tracks - sound effects now check that the sample rate matches, too, and if not, will be recreated. --- desktop_version/src/Music.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index f4231ca7..1267f360 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -145,7 +145,8 @@ end: { FAudioVoiceDetails details; FAudioVoice_GetVoiceDetails(voices[i], &details); - if (details.InputChannels != format.nChannels) + if (details.InputSampleRate != format.nSamplesPerSec || + details.InputChannels != format.nChannels) { VVV_freefunc(FAudioVoice_DestroyVoice, voices[i]); FAudio_CreateSourceVoice(faudioctx, &voices[i], &format, 0, 2.0f, NULL, NULL, NULL);