LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   play multiple sound streams on ALSA dmix (http://www.linuxquestions.org/questions/programming-9/play-multiple-sound-streams-on-alsa-dmix-823255/)

knobby67 07-31-2010 11:11 AM

play multiple sound streams on ALSA dmix
 
Hi all,
I'm having trouble getting ALSA to play multiple sound streams (multiple sounds at once). My code is running on an embedded ARM board using a AC97 sound. It will only play one without any mixing, I have to use pure ALSA as higher sound mixers are a nightmare to cross compile for ARM.

I've tested my system with aplay for example

aplay -D plughw:0,1 bang.wav

works fine. So I tried dmix with

aplay -D plug:dmix Win.wav

That gave the following error

ALSA lib pcm_direct.c:1587:(snd_pcm_direct_parse_open_conf) The field ipc_gid must be a valid group (create group audio)

aplay: main:550: audio open error: Invalid argument


I checked asound with
/etc # cat asound.conf


pcm.EP93XX {

type hw

card 0

device 0

mmap_emulation on

}

pcm_slave.multi2 {

pcm EP93XX

channels 2

}



pcm_slave.multi4 {

pcm EP93XX

channels 4

}



pcm_slave.multi6 {

pcm EP93XX

channels 6

}



pcm.channels2 {

type plug

slave multi2

route_policy "duplicate"

}





pcm.channels4 {

type plug

slave multi4

route_policy "duplicate"

}



pcm.channels6 {

type plug

slave multi6

route_policy "duplicate"

}



no sign of dmix, when I check my version ect I can see

/proc/asound # cat pcm version


Advanced Linux Sound Architecture Driver Version 1.0.14rc1 (Tue Jan 09 09:56:17 2007 UTC).



/proc/asound # cat default cards


0 [default ]: CS4271 - Cirrus Logic I2S Audio

Cirrus Logic I2S Audio with CS4271




Does this mean dmix will not work? Is there someway with the above setup I can play multiple sounds?
I have to use the vendor ALSA build (so can't update ALSA), I can change the .confs however. Also because I'm cross compiling things like pulseaudio SDL are very difficult to get working, so I basically need to use the above ALSA. Is there anyway I can find if dmix exists on the system?

Should add aplay -L does show dmix ?
iec958 'cards.pcm.iec958'

spdif 'cards.pcm.iec958'

modem 'cards.pcm.modem'

phoneline 'cards.pcm.phoneline'

default 'cards.pcm.default'

dmix 'cards.pcm.dmix'

dsnoop 'cards.pcm.dsnoop'



Thanks!

jlinkels 07-31-2010 01:11 PM

Quote:

Originally Posted by knobby67 (Post 4051023)
aplay -D plughw:0,1 bang.wav

The nature of ALSA is that it is a server, and that you can send multiple streams at the same time. ALSA takes care of mixing. What happens if you start two processes at the same time, both addressing the same device? I.e.:
Code:

aplay -D plughw:0,1 bang.wav &
aplay -D plughw:0,1 harderbang.wav

I am not surprised that the device dmix is not accepted, it does not exist. Check that with aplay -L and aplay -l

jlinkels

knobby67 07-31-2010 06:51 PM

Hi yep did aplay -L (bottom of my post) it seems to show dmix, but I have no idea how to access it? Or even if it is accessible or it's indicatiing dmix is present? I've tried to check all ALSA mans but can't fully find an explination.




Should add aplay -L does show dmix ?
iec958 'cards.pcm.iec958'

spdif 'cards.pcm.iec958'

modem 'cards.pcm.modem'

phoneline 'cards.pcm.phoneline'

default 'cards.pcm.default'

dmix 'cards.pcm.dmix'

dsnoop 'cards.pcm.dsnoop'



I've tried to access 2 processes at once with the ampersand switch on aplay, however I can't access command prompt until sound has stopped.

jlinkels 07-31-2010 07:14 PM

You are right, missed that one.

But then again, this is not exactly the standard output for aplay -L. Check that on your regular desktop and you see a lot of difference. Also, dmix is not usually one of them.

I can't imagine why you cannot access the command line again after you backgrounded your job.

I am beginning to think that you have a heavily modified Linux system which does not behave as a standard system. That renders me incapable of giving some useful advice, sorry.

jlinkels

matthewpiatt 10-06-2011 12:37 PM

if you look closely at the program output, you will see at the end, it tells you exactly what to do:

ALSA lib pcm_direct.c:1587snd_pcm_direct_parse_open_conf) The field ipc_gid must be a valid group (create group audio)

check the output of ls -al /dev/snd/. who is the group owner? in the end, it needs to match a line in your /usr/share/alsa/alsa.conf. if the owner is root, go into /usr/share/alsa/alsa.conf - change defaults.pcm.ipc_gid audio to defaults.pcm.ipc_gid root

you will notice if you run ls -al /dev/snd the group owner is audio, so i didn't have to change mine.

Code:

$ ls -al /dev/snd/                     
total 0
drwxr-xr-x  2 root root      220 2011-09-27 10:30 .
drwxr-xr-x  16 root root    13980 2011-10-05 17:51 ..
crw-rw----+  1 root audio 116,  5 2011-09-27 10:30 controlC0
crw-rw----+  1 root audio 116,  8 2011-09-27 10:30 controlC1
crw-rw----+  1 root audio 116,  4 2011-09-27 10:30 hwC0D0
crw-rw----+  1 root audio 116,  7 2011-09-27 10:30 hwC1D0
crw-rw----+  1 root audio 116,  3 2011-10-04 14:44 pcmC0D0c
crw-rw----+  1 root audio 116,  2 2011-10-05 17:32 pcmC0D0p
crw-rw----+  1 root audio 116,  6 2011-09-27 10:30 pcmC1D3p
crw-rw----+  1 root audio 116,  1 2011-09-27 10:30 seq
crw-rw----+  1 root audio 116, 33 2011-09-27 10:30 timer



All times are GMT -5. The time now is 02:07 AM.