Timothy Macintyre
2016-10-19 22:42:47 UTC
Hi,
I'm attempting to decode an opus audio stream and play it back using SDL2 but I'm having issues with a constantly growing audio delay.
It seems like the audio isn't getting moved to the audio device quick enough or is playing back for slightly too long causing a gradual increase in delay over time.
I've tried to limit the audio queue size as seen in the code below but this ends up causing small jitters in the audio. Any help on this would be greatly appreciated
if (SDL_GetQueuedAudioSize(dev) < 38400)
{
int output_samples = opus_decode(dec, (unsigned char*)entry->data, entry->length, decodedBuffer, FRAME_SIZE, 0);
if (output_samples > 0)
{
if (SDL_QueueAudio(dev, decodedBuffer, output_samples * CHANNEL_COUNT * sizeof(opus_int16)) < 0)
LOG_ERROR("error queuing audio: %s", SDL_GetError());
}
}
else {
SDL_ClearQueuedAudio(dev);
}
Regards,
Tim.
I'm attempting to decode an opus audio stream and play it back using SDL2 but I'm having issues with a constantly growing audio delay.
It seems like the audio isn't getting moved to the audio device quick enough or is playing back for slightly too long causing a gradual increase in delay over time.
I've tried to limit the audio queue size as seen in the code below but this ends up causing small jitters in the audio. Any help on this would be greatly appreciated
if (SDL_GetQueuedAudioSize(dev) < 38400)
{
int output_samples = opus_decode(dec, (unsigned char*)entry->data, entry->length, decodedBuffer, FRAME_SIZE, 0);
if (output_samples > 0)
{
if (SDL_QueueAudio(dev, decodedBuffer, output_samples * CHANNEL_COUNT * sizeof(opus_int16)) < 0)
LOG_ERROR("error queuing audio: %s", SDL_GetError());
}
}
else {
SDL_ClearQueuedAudio(dev);
}
Regards,
Tim.