[alsa-devel] [RFC] ALSA: Reduce delay for a blocking pcm_drain.

Clemens Ladisch clemens at ladisch.de
Mon Sep 30 10:45:52 CEST 2013

Dylan Reid wrote:
> This patch addresses two issues related to calling snd_pcm_drain.
> If no_period_wakeup is set, then snd_pcm_drain would wait
> MAX_SCHEDULE_TIMEOUT jiffies, without a wakeup pending this will leave
> the calling task blocked indefinitely.

no_period_wakeup is used by applications that do _not_ want to use any
of ALSA's blocking functions (and thus want to avoid the interrupt
overhead) and use their own timers instead.  This also applies to

Is there any actual application that tries to use snd_pcm_drain together
with no_period_wakeup?

> Also if the stream is running with period wakeups but with a long
> period, the delay could be seconds.  If only a small part of the
> buffer is being used, this is unnecessary.

Wakeup at period boundaries is part of the ALSA API.  (This is all what
periods are for.)

> Instead wait for the remaining samples to play out, plus one
> millisecond.

The device's clock and the Linux system clock might have larger
differences.  The only reliable synchronization source is the period


More information about the Alsa-devel mailing list