SDL: Fix DoubleBufferSDLMixerManager doubling audio latency

If it turns out that everything that had previously been fixed by
this manager is broken by this change, everything that had been
fixed probably could have been fixed by just increasing the audio
buffer size in SdlMixerManager. :\
This commit is contained in:
Colin Snover 2017-09-05 20:56:19 -05:00
parent 4a75fbab1b
commit fa52df018e
2 changed files with 9 additions and 0 deletions

View File

@ -62,6 +62,13 @@ void DoubleBufferSDLMixerManager::startAudio() {
SdlMixerManager::startAudio();
}
SDL_AudioSpec DoubleBufferSDLMixerManager::getAudioSpec(uint32 rate) {
SDL_AudioSpec desired = SdlMixerManager::getAudioSpec(rate);
// Don't double audio latency when double buffering
desired.samples /= 2;
return desired;
}
void DoubleBufferSDLMixerManager::mixerProducerThread() {
byte nextSoundBuffer;

View File

@ -44,6 +44,8 @@ protected:
uint _soundBufSize;
byte *_soundBuffers[2];
virtual SDL_AudioSpec getAudioSpec(uint32 rate) override;
/**
* Handles and swap the sound buffers
*/