[alsa-devel] Alsa-lib Dmix issue
Hello All,
I am trying to play a song using dmix plugin using AlsaLib(1.0.29) , My kernel (Linux 3.8)hangs at poll() on snd timer interface.When I debugged further, I understood that poll hangs because of DMA interrupt (snd_pcm_period_elapsed)not been received.
Asound. conf as pcm.softvol { type softvol slave { pcm "hw:0,0" } control { name "Master" card 0 } } pcm.volmix { type dmix ipc_key 1024 ipc_key_add_uid yes ipc_perm 0660 slave { pcm "hw:0,0" rate 44100 } } used aplay -D 'plug:volmix' 123.wav. Where as the normal playback aplay 123.wav plays the song as expected.
Comparing the two cases, I observed that Dmix is not incrementing the control.appl_ptr(always zero) in SNDRV_PCM_IOCTL_SYNC_PTR ioctl , but the later one(with out dmix) increments this and kernel is notified with the data written with the value in application pointer. Trying to understand further, though I am not an expert here, snd_pcm_dmix_sync_area is invoked, the data is written to destination , dmix->slave_appl_ptr is incremented, but some how the link to dmix->spcm->private_data->sync_ptr->c.control.appl_ptr is not incremented with the written frames.
As I understand, SNDRV_PCM_IOCTL_SYNC_PTR should notify kernel with the application pointer else kernel cant understand how much is written when we do data mmap. I am trying to understand why it is not incremented, but strongly believe that it cannot be a bug in alsa-lib Dmix, but I am lacking some thing, but wondering what I am missing here.My kernel access type is MMAP_INTERLEAVED.
Exactly same issue mentioned on RaspberryPi below but no solution provided https://www.raspberrypi.org/forums/viewtopic.php?t=64936&p=481557. https://www.raspberrypi.org/forums/viewtopic.php?t=64936&p=481557 https://www.raspberrypi.org/forums/viewtopic.php?t=64936&p=481557
Please help me to understand more here, any pointers is appreciated.
Regards, Anoop
Anoop Rajan wrote:
I am trying to play a song using dmix plugin using AlsaLib(1.0.29) , My kernel (Linux 3.8)hangs at poll() on snd timer interface.When I debugged further, I understood that poll hangs because of DMA interrupt (snd_pcm_period_elapsed)not been received.
This sounds like a bug in the driver.
Regards, Clemens
Thanks Clemens for the response.
Can you please help me understand where can be the issue in driver? Aplay -M works fine, only Dmix doesnt work. As I explained, I can see that kernel is not getting DMA interrupts because DMA has not initiated yet,as kernel doesn't have any data in its ring buffer, application pointer is zero. With these observations I assume the issue is in Dmix, it is not incrementing the appl pointer. Correct me If I am wrong.
If I hack the dmix code(pcm_dmix.c) by incrementing the application pointer(dmix->spcm->private_data->sync_ptr->c.control.appl_ptr) after mixing by number of frames written explicitly , it works. But I strongly believe this is not the fix and I am yet to figure out the actual issue.
Regards, Anoop
On Thu, Jan 26, 2017 at 1:22 PM, Clemens Ladisch clemens@ladisch.de wrote:
Anoop Rajan wrote:
I am trying to play a song using dmix plugin using AlsaLib(1.0.29) , My kernel (Linux 3.8)hangs at poll() on snd timer interface.When I debugged further, I understood that poll hangs because of DMA interrupt (snd_pcm_period_elapsed)not been received.
This sounds like a bug in the driver.
Regards, Clemens
Anoop Rajan wrote:
I assume the issue is in Dmix, it is not incrementing the appl pointer.
When there are multiple clients, there are multiple appl pointers. So the dmix plugin does not bother to tell the hardware about any of them.
Are you using a driver that lokos at appl_ptr?
Regards, Clemens
Hello Clemens,
When there are multiple clients, there are multiple appl pointers. So the dmix plugin does not bother to tell the hardware about any of them.
Thanks,Understood.
Are you using a driver that lokos at appl_ptr?
We are working on Marvell chipset,88DE3006. Looks like our driver looks at appl_pointer though I am not sure how to confirm it. I see the appl_pointer coming through SNDRV_PCM_IOCTL_SYNC_PTR is always incremented in case of aplay -M and it works, if we don't increment appl_ptr it doesn't works,
So for dmix to work, I should have the driver that doesn't looks at appl_ptr, right? f appl_pointer should never be incremented, how will the kernel know the data is written? The MMAP to status/control is not implemented in our case. I would start looking to change my driver not to look at appl_ptr, would you please help me with some pointers to understand how/where in drivers should I typically change to adapt these changes?
Regards, Anoop
On Thu, Jan 26, 2017 at 5:33 PM, Clemens Ladisch clemens@ladisch.de wrote:
Anoop Rajan wrote:
I assume the issue is in Dmix, it is not incrementing the appl pointer.
When there are multiple clients, there are multiple appl pointers. So the dmix plugin does not bother to tell the hardware about any of them.
Are you using a driver that lokos at appl_ptr?
Regards, Clemens
participants (2)
-
Anoop Rajan
-
Clemens Ladisch