[alsa-devel] Query on PCM lib: wait_for_avail() API

Takashi Iwai tiwai at suse.de
Tue Aug 21 10:04:18 CEST 2012


At Mon, 20 Aug 2012 17:34:26 +0000,
Sarawadi, Ravishankar wrote:
> 
> Greetings,
> 
> I recently started working with ALSA architecture.
> I am very excited to be part of ALSA group and this is my first query as ALSA developer.
> 
> This is in regards to function wait_for_avail() defined in pcm_lib.c
> If audio path is broken the wait_time inside this function is 10 seconds.
> wait_time = msecs_to_jiffies(wait_time * 1000);
> 
> I have a use case where I need to force exit out of this wait when audio hardware path is broken.
> Waiting for 10 seconds is too long and causing synchronization issues.
> 
> My Use-case:
> 
> 1       PCM Audio playback is going on. PCM write is a blocking call. Waiting on DSP WRITE-DONE event.
> 
> 2       Audio hardware path failure
> 
> 3       PCM driver notified of hardware path failure.
> 
> 4       Meanwhile DSP ring buffer gets full as buffers are not getting consumed.
> 
> 5       Next WRITE is blocked on wait_for_avail() buffer call.
> 
> 6       PCM close from driver as part process to handle audio path failure is blocked on Step 5
> 
> 
> I am trying to figure out a way to exit out of this wait forcefully by some external trigger.
> Another option is to reduce this wait time to less than 5 seconds.
> 
> Could someone please recommend the best way to handle this use case?

The driver can wake up the sleeper at any time.
For example, call snd_pcm_stop() with SNDRV_PCM_STATE_XRUN.


Takashi


More information about the Alsa-devel mailing list