Ok, so I took another look at the sample rates. Although every example I’ve seen has set the rate to 48000 for Opus I increased it slightly to 48100:
SDL_zero(w_wav_spec);
w_wav_spec.freq = 48100;
This appears to have resolved the underrun for the most part although it does occasionally fully empty the buffer causing a slight pause in audio it’s a lot better than filling the whole thing up then having to clear to maintain a reasonable latency. I believe the official demo app implements a double buffer which sounds like it may help mitigate this somewhat although the additional latency may be an issue.
Anyway, thanks for the help!
Regards,
Tim.________________________________
From: sdl-bounces@lists.libsdl.org> on behalf of david olofson <david at olofson.net (SDL)
Sent: 20 October 2016 08:12:21
To: SDL Development List
Subject: Re: [SDL] SDL_QueueAudio underrun
On Thu, Oct 20, 2016 at 9:34 AM, Timothy Macintyre <@Timothy_Macintyre> wrote:
But I still then end up with gaps as this is a live stream I have to discard
several of the opus packets whilst the buffer goes down. It doesn’t make
sense that the buffer is filling up that much, it should be playing just as
fast as I fill it up.
Ah…! But then the sample rate of the stream isn’t matching the audio
interface. Even if you set them up to exactly the same value, you
can’t rely on them matching exactly, because even the finest crystal
oscillators aren’t infinitely accurate. The only common situation I
can think of where you do NOT have this problem is in studios, between
local audio interfaces synchronized via wordclock or similar.
However, one can usually get away with just inserting or dropping a
single sample frame every once in a while, so I’m kind of wondering if
you even have the right nominal sample rates… For example, 44 kHz vs
the standard 44.1 kHz would be a problem, and would probably require
proper resampling to avoid constant audible artifacts.
–
//David Olofson - Consultant, Developer, Artist, Open Source Advocate
.— Games, examples, libraries, scripting, sound, music, graphics —.
| http://consulting.olofson.net http://olofsonarcade.com |
’---------------------------------------------------------------------’
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org