Alsa-dmix not working


8 posts
by RantyDave » Tue Dec 31, 2013 9:35 pm
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
Posts: 4
Joined: Tue Dec 31, 2013 3:02 am
by sdjf » Wed Jan 01, 2014 3:43 am
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?
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1292
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by RantyDave » Wed Jan 01, 2014 10:28 pm
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 :(
Posts: 4
Joined: Tue Dec 31, 2013 3:02 am
by sdjf » Wed Jan 01, 2014 11:16 pm
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?
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1292
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by RantyDave » Thu Jan 02, 2014 4:27 am
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...
Posts: 4
Joined: Tue Dec 31, 2013 3:02 am
by koalo » Fri Jan 03, 2014 2:43 pm
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)?
Posts: 121
Joined: Mon Feb 04, 2013 4:02 pm
by RantyDave » Sun Jan 05, 2014 10:33 pm
Yup, sure. It never returns. It's also definitely blocked waiting for the timer to tell it to "go".

Bugger it, I'm just going to have a go running Raspbian :)
Posts: 4
Joined: Tue Dec 31, 2013 3:02 am
by koalo » Mon Jan 06, 2014 8:58 am
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.
Posts: 121
Joined: Mon Feb 04, 2013 4:02 pm