[alsa-devel] snd_pcm_avail_update returns 0

Singaravelan Nallasellan singaravelann at gmail.com
Thu Jan 14 16:17:23 CET 2010

Thanks for the response.

I am using mmap for the playback. What is the return value of
snd_pcm_avail_update when the ring buffer is empty? How does ALSA
identify the  empty buffer?

We incremented the hardware pointer continuously to large value more
than the hw buffer size. ALSA core did not round of the hw_ptr
properly. The firmware in the audio engine is now rounding of hw ptr
in the audio engine itself. It will always report the hw ptr between 0
and hw buffer size.

Moreover our driver uses the batch mode and updates the hardware
pointer for every period. Is it the right way to do?


On Thu, Jan 14, 2010 at 8:35 PM, Jaroslav Kysela <perex at perex.cz> wrote:
> On Thu, 14 Jan 2010, Singaravelan Nallasellan wrote:
>> Hi,
>> Our audio driver uses the indirect PCM data transfer mechanism to
>> transfer the buffer pointers and the size of the buffer to the Audio
>> engine which DMAs the PCM data to the sound card.
>> The driver uses the .ack callback to receive the buffer pointer and
>> the size. It also sends it to the audio engine.
>> We are facing a problem when we play long wav file using our driver.
>> The application has written the PCM data and the ring buffer is full.
>> snd_pcm_avail_update returns 0 sporadically. But the .ack callback was
>> not called. The playback is stuck. It is not progressing.
>> I have tried with pulseaudio (0.9.15) and with my own player. Both
>> gives the same result.
>> I would appreciate if somebody could provide some pointer to identify
>> the cause of this issue. Let me know if anybody needs more info.
> No idea. You may put some debug printk lines to snd_pcm_lib_write1() routine
> if all correspoding write sequences ends with ->ack callback call.
>                                        Jaroslav
> -----
> Jaroslav Kysela <perex at perex.cz>
> Linux Kernel Sound Maintainer
> ALSA Project, Red Hat, Inc.

More information about the Alsa-devel mailing list