1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Fix music playing wrong if played after track of different format

As described in #886, if a track was played when an existing track was
already playing, and the sample rates of the two tracks differ, then the
second track would play wrong and distorted.

This is because the second track would play with the sample rate of the
first. To fix this, halt the track if the sample rate is mismatched,
which destroys the voice. This results in the voice being recreated
later in the Play() function. The track is also halted if the number of
channels or bit depth is mismatched.

Fixes #886.
This commit is contained in:
Misa 2023-03-18 15:33:30 -07:00
parent 9a87d23719
commit 671c90f7dc

View file

@ -314,6 +314,17 @@ end:
sample_pos = 0;
stb_vorbis_seek_start(vorbis);
if (!IsHalted())
{
FAudioVoiceDetails details;
FAudioVoice_GetVoiceDetails(musicVoice, &details);
if (details.InputSampleRate != format.nSamplesPerSec ||
details.InputChannels != format.nChannels)
{
Halt();
}
}
if (IsHalted())
{
SDL_zero(callbacks);