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:
parent
9a87d23719
commit
671c90f7dc
1 changed files with 11 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue