[alsa-devel] underruns and POLLERR when copying audio frames

Clemens Ladisch clemens at ladisch.de
Wed Jul 21 09:07:24 CEST 2010


Stefan Schoenleitner wrote:
> Clemens Ladisch wrote:
> > How do you synchronize the clocks of both devices?
> 
> I don't.  [...]
> I guess if clock drift gets too high, I will get xruns as well ?

Yes.

> > Why would mmap be more ideal?
> 
> I though that it would be possible to use mmapping to "connect" sound
> devices together in a way that read/write operations in between are no
> longer necessary.

Indeed.

> But as mmapping just seems to work for files, I no longer think it is
> possible.

Some optimization is possible even when only one device supports mmap:
When you want to copy from the hardware device to the plugin, you could
call the plugin's snd_pcm_writei with an address in the sound card's
buffer as the source.

> > To avoid overruns in the capture device, use a bigger buffer, which will
> > _not_ increase latency.
> 
> Can you explain to me why a bigger capture buffer will not introduce
> latency ?
> IMHO if there is a large capture buffer, then the sound-card will need
> to capture until the buffer is filled.
> Once this is the case, the application can start to read from the
> capture device.

The application can read from the capture buffer at any time.  When
using a blocking snd_pcm_read* call, it gets woken up at the end of each
period, if avail_min is not larger than the period size.

> It seems that at least one of my devices only supports a small avail_min
> setting.

avail_min can be as large as the buffer size.


Regards,
Clemens


More information about the Alsa-devel mailing list