[Portaudio] Do I need to care about overflow/underflow when using the read/write API?

Alan Horstmann gineera at aspect135.co.uk
Sun Mar 20 14:24:19 EDT 2016


Hi,

Thought I would add a couple of comments as a double-reply, mainly from the 
Alsa point-of-view...

On Sunday 20 March 2016 03:46, Spencer Russell wrote:
<snip>
> So I guess the question probably comes down to:
> When PortAudio experiences an underflow, does it feed zeros to the
> underlying Host API, or does the Host API “know” about the underflow? Based
> on my experience lurking on this list I’m guessing the answer is “it
> depends on the host API”.

It works the other way round - the underflow occurs in the host API audio 
system when Portaudio/your-app doesn't deliver samples in time, and is 
indicated *to* Portaudio by the host API.  Bear in mind Portaudio is 
essentially a consistent wrapper around host audio interfaces.

> If the underflow is passed to the Host API, in practice are there APIs in
> the wild that react poorly, or is it OK?

Certainly on Linux-Alsa when an underrun occurs the audio system stops.  When 
Portaudio is notified it will attempt to restart the stream, but this can 
take a significant amount of time, in some cases that have been reported.

On Sunday 20 March 2016 04:36, Phil Burk wrote:
> You should avoid underflows and overflows. Those are errors and should
> never be allowed to happen. If you don't have any signal then just write
> silence (zeros) to keep the stream from underflowing. Or, if you don't plan
> on doing any audio for a few minutes then you could just shut down the
> stream and restart it when you are ready.

Agree completely - don't let underflows and overflows happen; feed zero data 
somehow otherwise it will perform very poorly.

Regards

Alan


More information about the Portaudio mailing list