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;
|
sample_pos = 0;
|
||||||
stb_vorbis_seek_start(vorbis);
|
stb_vorbis_seek_start(vorbis);
|
||||||
|
|
||||||
if (!IsHalted())
|
|
||||||
{
|
|
||||||
if (SDL_memcmp(&musicVoiceFormat, &format, sizeof(format)) != 0)
|
|
||||||
{
|
|
||||||
Halt();
|
Halt();
|
||||||
musicVoiceFormat = format;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsHalted())
|
|
||||||
{
|
|
||||||
SDL_zero(callbacks);
|
SDL_zero(callbacks);
|
||||||
callbacks.OnBufferStart = &MusicTrack::refillReserve;
|
callbacks.OnBufferStart = &MusicTrack::refillReserve;
|
||||||
callbacks.OnBufferEnd = &MusicTrack::swapBuffers;
|
callbacks.OnBufferEnd = &MusicTrack::swapBuffers;
|
||||||
FAudio_CreateSourceVoice(faudioctx, &musicVoice, &format, 0, 2.0f, &callbacks, NULL, NULL);
|
FAudio_CreateSourceVoice(faudioctx, &musicVoice, &format, 0, 2.0f, &callbacks, NULL, NULL);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Pause();
|
|
||||||
FAudioSourceVoice_FlushSourceBuffers(musicVoice);
|
|
||||||
}
|
|
||||||
|
|
||||||
FAudioBuffer faudio_buffer;
|
FAudioBuffer faudio_buffer;
|
||||||
SDL_zero(faudio_buffer);
|
SDL_zero(faudio_buffer);
|
||||||
|
@ -546,7 +531,6 @@ end:
|
||||||
|
|
||||||
static bool paused;
|
static bool paused;
|
||||||
static FAudioSourceVoice* musicVoice;
|
static FAudioSourceVoice* musicVoice;
|
||||||
static FAudioWaveFormatEx musicVoiceFormat;
|
|
||||||
|
|
||||||
static void refillReserve(FAudioVoiceCallback* callback, void* ctx)
|
static void refillReserve(FAudioVoiceCallback* callback, void* ctx)
|
||||||
{
|
{
|
||||||
|
@ -725,7 +709,6 @@ end:
|
||||||
};
|
};
|
||||||
bool MusicTrack::paused = false;
|
bool MusicTrack::paused = false;
|
||||||
FAudioSourceVoice* MusicTrack::musicVoice = NULL;
|
FAudioSourceVoice* MusicTrack::musicVoice = NULL;
|
||||||
FAudioWaveFormatEx MusicTrack::musicVoiceFormat;
|
|
||||||
|
|
||||||
musicclass::musicclass(void)
|
musicclass::musicclass(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue