sdl: sync tail pointer in SDL_Audio backend

SDL uses the Audio_out session in streaming fashion. For this reason
the audio might be played with delay of at most the queue size. To
mitigate the effect we synchronize the tail pointer to the current play
pointer when the PlayAudio() function is called by SDL for the first
time.

Fixes #1612.
This commit is contained in:
Josef Söntgen 2015-05-08 16:35:38 +02:00 committed by Christian Helmuth
parent 89255c3979
commit e6995ecad7
1 changed files with 12 additions and 0 deletions

View File

@ -186,6 +186,18 @@ static void GENODEAUD_WaitAudio(_THIS)
static void GENODEAUD_PlayAudio(_THIS)
{
/*
* Synchronize the play pointer when this function is first called
*/
static bool initial_reset = true;
if (initial_reset) {
for (int channel = 0; channel < AUDIO_CHANNELS; channel++) {
Audio_out::Connection *connection = _this->hidden->audio[channel];
connection->stream()->reset();
}
initial_reset = false;
}
Audio_out::Packet *p[AUDIO_CHANNELS];
for (int channel = 0; channel < AUDIO_CHANNELS; channel++)