SDL_QueueAudio underrun |
SDL_QueueAudio underrun |
David Olofson
Guest
|
On Thu, Oct 20, 2016 at 12:42 AM, Timothy Macintyre
wrote: [...]
As I understand it, this will discard anything that hasn't already been sent to the underlying audio API, which is probably what's causing glitches. When there's enough in the queue, you're not supposed to do anything at all. :-) -- //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 http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
SDL_QueueAudio underrun |
Timothy Macintyre
Guest
|
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.
From: David Olofson Sent: Thursday, 20 October, 00:53 Subject: Re: [SDL] SDL_QueueAudio underrun To: SDL Development List On Thu, Oct 20, 2016 at 12:42 AM, Timothy Macintyre wrote: [...] > else { > SDL_ClearQueuedAudio(dev); > } As I understand it, this will discard anything that hasn't already been sent to the underlying audio API, which is probably what's causing glitches. When there's enough in the queue, you're not supposed to do anything at all. :-) -- //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 http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
SDL_QueueAudio underrun |
David Olofson
Guest
|
On Thu, Oct 20, 2016 at 9:34 AM, Timothy Macintyre
wrote:
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 http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
SDL_QueueAudio underrun |
Timothy Macintyre
Guest
|
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 on behalf of David Olofson 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 wrote:
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 http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|