mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Fix remaining audio speedup/slowdown bug
Fixes #1057. Based on Ethan's hunch, I simply removed the format comparison that decides whether to halt and restart, or reuse the voice. Voices are now always restarted when playing a new track. This also simplifies the code somewhat: `MusicTrack::musicVoiceFormat` was now no longer used, and an `if (!IsHalted())` was no longer necessary because `Halt()` already does that. So those are now removed as well.
This commit is contained in:
parent
456a81df67
commit
133adba10e
1 changed files with 5 additions and 22 deletions
|
@ -435,27 +435,12 @@ end:
|
|||
sample_pos = 0;
|
||||
stb_vorbis_seek_start(vorbis);
|
||||
|
||||
if (!IsHalted())
|
||||
{
|
||||
if (SDL_memcmp(&musicVoiceFormat, &format, sizeof(format)) != 0)
|
||||
{
|
||||
Halt();
|
||||
musicVoiceFormat = format;
|
||||
}
|
||||
}
|
||||
Halt();
|
||||
|
||||
if (IsHalted())
|
||||
{
|
||||
SDL_zero(callbacks);
|
||||
callbacks.OnBufferStart = &MusicTrack::refillReserve;
|
||||
callbacks.OnBufferEnd = &MusicTrack::swapBuffers;
|
||||
FAudio_CreateSourceVoice(faudioctx, &musicVoice, &format, 0, 2.0f, &callbacks, NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
Pause();
|
||||
FAudioSourceVoice_FlushSourceBuffers(musicVoice);
|
||||
}
|
||||
SDL_zero(callbacks);
|
||||
callbacks.OnBufferStart = &MusicTrack::refillReserve;
|
||||
callbacks.OnBufferEnd = &MusicTrack::swapBuffers;
|
||||
FAudio_CreateSourceVoice(faudioctx, &musicVoice, &format, 0, 2.0f, &callbacks, NULL, NULL);
|
||||
|
||||
FAudioBuffer faudio_buffer;
|
||||
SDL_zero(faudio_buffer);
|
||||
|
@ -546,7 +531,6 @@ end:
|
|||
|
||||
static bool paused;
|
||||
static FAudioSourceVoice* musicVoice;
|
||||
static FAudioWaveFormatEx musicVoiceFormat;
|
||||
|
||||
static void refillReserve(FAudioVoiceCallback* callback, void* ctx)
|
||||
{
|
||||
|
@ -725,7 +709,6 @@ end:
|
|||
};
|
||||
bool MusicTrack::paused = false;
|
||||
FAudioSourceVoice* MusicTrack::musicVoice = NULL;
|
||||
FAudioWaveFormatEx MusicTrack::musicVoiceFormat;
|
||||
|
||||
musicclass::musicclass(void)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue