Page 1 of 1

Alsa-dmix not working

Posted: Tue Dec 31, 2013 9:35 pm
by RantyDave
As per subject I'm trying to get dmix running on alsa on a rev 2 model B - Arch (obviously) and sync'd to latest.

Long story short: this

Code: Select all

aplay sample.wav
works fine but this:

Code: Select all

aplay -D "plug:dmix" sample.wav
does nothing. It starts up just fine then sticks at
Playing WAVE 'sample.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
It would be fine but I'm writing an app that uses more than eight voices and don't want to get into home-cooked software mixing if there's one in there that works already. I don't currently have an /etc/asound.conf or a .asound.conf.

Any ideas? Anyone seen this before?

Thanks,
Dave

Re: Alsa-dmix not working

Posted: Wed Jan 01, 2014 3:43 am
by sdjf
If you start aplay with strace, you can see what system calls are getting made and see what is missing. strace is in the repository.

It may well be that it is stuck not finding an .asoundrc file, any harm in creating one?

Re: Alsa-dmix not working

Posted: Wed Jan 01, 2014 10:28 pm
by RantyDave
Thanks. And "huh" the "interesting" one not the "duhh" one.

It gets stuck polling a file descriptor. Edited highlights:

Code: Select all

open("/dev/snd/timer", O_RDONLY|O_NONBLOCK|O_CLOEXEC) = 3
fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
ioctl(3, SNDRV_TIMER_IOCTL_PVERSION, 0xbedd62c8) = 0
ioctl(3, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, 0xbedd62cc) = 0
ioctl(3, SNDRV_TIMER_IOCTL_SELECT or TIOCSPGRP, 0xbedd62d0) = 0
ioctl(3, SNDRV_TIMER_IOCTL_PVERSION, 0xbedd6668) = 0
ioctl(3, SNDRV_TIMER_IOCTL_PARAMS or TIOCSTI, 0xbedd6518) = 0
ioctl(3, SNDRV_TIMER_IOCTL_START, 0x54a0) = 0
poll([{fd=3, events=POLLIN|POLLERR|POLLNVAL}], 1, -1) = 1 ([{fd=3, revents=POLLIN}])
read(3, "\6\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0\0\0\233\0\0\0\3408\302\20\0\0\0\0", 64) = 32
read(3, 0xbedd6858, 64)                 = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN|POLLERR|POLLNVAL}], 1, -1)
Kernel module snd_timer is loaded

So it's polling on the sound timer, gets a *first* alert but not a second. Playing without dmix never references /dev/snd/timer so it works. /dev/snd/timer is root:audio and 660 - chmod'ing to 777 doesn't help. alsactl init doesn't help. Googling around finds nothing really relevant.

But we can see that after the first read(3) (presumably fetching a timestamp) the next read returns EAGAIN which apparently means "nothing there, this would have blocked" and that would be why it polls waiting for data that presumably never comes.

So it seems very likely that the problem is with /dev/snd/timer not running for some reason. I am officially now out of my depth :(

Re: Alsa-dmix not working

Posted: Wed Jan 01, 2014 11:16 pm
by sdjf
In my mind, the question is what /dev/snd/timer is and does, then. We need an expert!

Googling, I see comments that maybe X does not inherit the permissions of the user using X? How is this getting run? Are both apps command line or both GUIs that you are comparing?

Re: Alsa-dmix not working

Posted: Thu Jan 02, 2014 4:27 am
by RantyDave
Both command line. I was running as root and /dev/snd/timer is chmod 660 and belongs to root:audio so it's not a permissions problem.

I've put the question on the alsa-users mailing list with a link over to this. Let's see if we get anything...

Re: Alsa-dmix not working

Posted: Fri Jan 03, 2014 2:43 pm
by koalo
Are you sure it hangs and not only the output is silence?
Does it come back after some time (when the audio data should be finished)?

Re: Alsa-dmix not working

Posted: Sun Jan 05, 2014 10:33 pm
by RantyDave
Yup, sure. It never returns. It's also definitely blocked waiting for the timer to tell it to "go".

I'm just going to have a go running Raspbian :)

Re: Alsa-dmix not working

Posted: Mon Jan 06, 2014 8:58 am
by koalo
Then you might want to test the I2S driver in the current 3.10 or 3.12 kernel. Sure, you would not hear anything without external hardware, but you can check if this is a problem of the other ALSA driver or if there is anything else broken.

Re: Alsa-dmix not working

Posted: Mon Jan 16, 2017 12:06 pm
by ajithkarnik
RantyDave wrote:Yup, sure. It never returns. It's also definitely blocked waiting for the timer to tell it to "go".

I'm just going to have a go running Raspbian :)
Did you get the solution for this? I am also facing the same issue.

Re: Alsa-dmix not working

Posted: Tue Feb 14, 2017 2:37 pm
by lah
I've added a post about this issue, it links other posts related to this problemhttp://raspberrypi.stackexchange.com/qu ... 1974#61974