snd_pcm_avail_update returns 0
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.
Thanks
Sing
Quoted 15 lines · Singaravelan Nallasellan
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_updatereturns 0 sporadically. But the .ack callback was not called. The playback is stuck. It is not progressing.
Quoted 5 lines
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 <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
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?
Sing
Quoted 26 lines · Jaroslav Kysela
Quoted 15 lines · Singaravelan Nallasellan
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_updatereturns 0 sporadically. But the .ack callback was not called. The playback is stuck. It is not progressing.Quoted 5 lines
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.
Quoted 8 lines
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 4 lines · Singaravelan Nallasellan
Thanks for the response.
I am using mmap for the playback. What is the return value of
snd_pcm_avail_updatewhen the ring buffer is empty?
ring buffer size
Quoted 1 line
How does ALSA identify the empty buffer?
hw_ptr == appl_ptr
Quoted 5 lines
We incremented the hardware pointer continuously to large value more than the hw buffer size. ALSA core did not round of the
hw_ptrproperly. 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.
hw_ptr and appl_ptr are from range 0..boundary to detect xruns. The driver should not write to these values and should track own pointers.
Quoted 2 lines
Moreover our driver uses the batch mode and updates the hardware pointer for every period. Is it the right way to do?
I'm not sure about what pointers you're talking. If it's hw_ptr and appl_ptr, then driver shouldn't write to these pointers. The snd_pcm_period_elapsed() function should be called to synchronize hw_ptr when playback of period is finished.
Maybe you can put your code to a public place so we can check it.
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
Thanks again.
Sorry, I missed to ask you another question.
How does the ring buffer full detected in the core?
Quoted 3 lines
hw_ptrandappl_ptrare from range 0..boundary to detect xruns. The driver should not write to these values and should track own pointers.
The driver does not update the pointers. It has its own pointers wherever required.
Quoted 5 lines
Quoted 3 lines
Moreover our driver uses the batch mode and updates the hardware pointer for every period. Is it the right way to do?
Quoted 8 lines
Quoted 2 lines
Moreover our driver uses the batch mode and updates the hardware pointer for every period. Is it the right way to do?
I'm not sure about what pointers you're talking. If it's
hw_ptrandappl_ptr, then driver shouldn't write to these pointers. Thesnd_pcm_period_elapsed()function should be called to synchronizehw_ptrwhen playback of period is finished.
The driver does not update the appl_ptr and hw_ptr. .pointer function just returns the pos returned by the snd_pcm_indirect_playback_pointer function. This function is called with the pointer returned from the audio engine.
Quoted 2 lines
Maybe you can put your code to a public place so we can check it.
Sure, can I send the complete code to this ml?
Quoted 9 lines
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 5 lines · Singaravelan Nallasellan
Thanks again.
Sorry, I missed to ask you another question.
How does the ring buffer full detected in the core?
For playback: appl_ptr - hw_ptr == ring buffer size.
Quoted 3 lines
Quoted 2 lines
Maybe you can put your code to a public place so we can check it.
Sure, can I send the complete code to this ml?
No, please. Use http://pastebin.com or something like that and send only URL to this list. Thanks.
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.