Description of problem: Start two XMMS instances. Set them playing at once. The second will not play. Expected results: dmix userspace mixing is used to allow them to play both at once. Additional info: You can make this work by copying /usr/share/alsa/alsa.conf to /etc/alsa.conf and then setting the device in XMMS to "dmix" rather than default but this is not the correct fix. The correct fix is to set the ALSA "default" PCM device to use dmix. This will allow sound-serverless mixing in userspace for ALSA apps.
Oops, I meant "asym" as that allows both playback and recording, not dmix sorry ... keeping dmix in the summary for search hits
Yeah, we really need to do this. My impression is that ALSA makes it fairly painful to do though. I'm going to go ahead and move this to ASSIGNED, I hope Bill won't jump on me :)
Here's some pages on this: http://www.pseudorandom.co.uk/2004/debian/alsa/ http://gentoo-wiki.com/HOWTO_ALSA_sound_mixer_aka_dmix http://www.thepenguin.org.uk/alsa/ Haven't looked in detail, but this looks doable as the default.
Ok, investigating a bit more, I see why using dmix is tricky. We need to pick a shmkey that is unique. One solution might be to have a little program that runs on X login and allocates the shmem segment itself, and writes ~/.asoundrc, with a magic comment. We barf if ~/.asoundrc already exists without the magic comment. Still investigating.
Hmm, are you sure? I seem to have used it before and never had to think about shmkeys ... I guess the default worked. Having said that, I've never run with dmix as the default. ALSA is still a bit buggy in general so I tend to use the OSS emulation <doh>
I have the following in my ~/.asoundrc, and everything just magically works (as long as it's using ALSA, that is.). FC3 is much better that FC2 in this respect. Don't ask me what most of that stuff actually does, though. pcm.!default { type plug slave.pcm "dmixer" } pcm.dsp0 { type plug slave.pcm "dmixer" } pcm.dmixer { type dmix ipc_key 1024 slave { pcm "hw:0,0" period_time 0 period_size 1024 buffer_size 8192 # periods 128 rate 44100 } bindings { 0 0 1 1 } } ctl.mixer0 { type hw card 0 }
That isn't quite correct, it won't work for the case of multiple apps attempting to record at once. You need to use the 'asym' plugin. But yes that's the basic idea. The SHM key problem is a bit annoying though. I wonder what the ALSA developers think about that?
For FC3 just put this in /etc/asound.conf pcm.!default { type plug slave.pcm "dmix" } In this case "dmix" should perhaps be "asym" however the default config file does not set up asym. Should probably be fixed upstream. Also kudzu would need to figure out if the sound card supports hardware mixing and if not put this in the right place.
Oh, final note, 1.0.7 may be needed to clear up some more dmix bugs.
*** Bug 142378 has been marked as a duplicate of this bug. ***
I have to say that editing (in fact creating) /etc/asound.conf with dmix, made mixing to work. Yet, at least in KDE, didn't test in gnome, the sound something done strange, and xmms played 1-2 songs then stoped without any error message. Changing dmix to asym didn't work at all. Yet the ~/asoundrc solution worked just fine to me. I do not record anything so this is the best solution for me.
I worked a bit on this, more info here: http://www.redhat.com/archives/fedora-desktop-list/2005-January/msg00011.html
dmix is known to deadlock the audio pipeline in the version shipped in FC3, that's probably what you're seeing Alexandre
I find putting this in /etc/asound.conf works best. ipc_perm lets different users access the plugins simultaneously. I think the real problem is selecting the right card. Is this something for kudzu to do? #asym fun start here. we define one pcm device called "dmixed" pcm.dmixed { ipc_key 1025 ipc_perm 0666 type dmix slave { pcm "hw:0,0" # you cannot use a "plug" device here, darn. period_time 0 period_size 1024 # must be power of 2 buffer_size 16384 } } #one called "dsnooped" for capturing pcm.dsnooped { ipc_key 1027 icp_perm 0666 type dsnoop slave.pcm "hw:0,0" } #and this is the real magic pcm.asymed { type asym playback.pcm "dmixed" capture.pcm "dsnooped" } #a quick plug plugin for above device to do the converting magic pcm.pasymed { type plug slave.pcm "asymed" } #a ctl device to keep xmms happy ctl.pasymed { type hw card 0 } #for aoss: pcm.dsp0 { type plug slave.pcm "asymed" } pcm.arts { type plug slave.pcm "asymed" } ctl.mixer0 { type hw card 0 } pcm.!default { type plug slave.pcm "asymed" } #done
First test version is here: http://people.redhat.com/stransky/ainit/
If i want to add dsnoop and asym, is it ok to just add %ipc_sem% again to asoundrc.template to get a new key, or is that not possible yet?
Yes, you can use dsnoop too, but you have to add all %% lines, not only %ipc_sem%.
Here is small example for asoundrc.template with asym. You have to change lines with "hw:1,0" and "hw:0,0" to your real record/playback device. pcm.!default { type plug slave.pcm "all" } pcm.dsp0 { type plug slave.pcm "all" } pcm.input { type dmix %ipc_sem% %ipc_mem_direct% %ipc_mem_plug% slave.pcm "hw:0,0" } pcm.output { type dsnoop %ipc_sem% %ipc_mem_direct% %ipc_mem_plug% slave { pcm "hw:1,0" channels 2 period_size 1024 buffer_size 4096 rate 44100 periods 0 period_time 0 } bindings { 0 0 0 1 } } pcm.all { type asym playback.pcm "output" capture.pcm "input" }
Just to clarify, there's a typo in the above where dmix and dsnoop are in the wrong places. asoundrc.template should be as follows: pcm.!default { type plug slave.pcm "asym" } pcm.input { type dsnoop %ipc_sem% %ipc_mem_direct% %ipc_mem_plug% slave.pcm "hw:0,0" } pcm.asym { type asym playback.pcm "output" capture.pcm "input" } pcm.dsp0 { type plug slave.pcm "asym" } pcm.output { type dmix %ipc_sem% %ipc_mem_direct% %ipc_mem_plug% slave { pcm "hw:0,0" period_time 0 period_size 1024 buffer_size 4096 rate 44100 } }
This was implemented with alsa 1.0.9rc2, in FC4t3 now. Ok to close?
No, I have to hack system-config-soundcard, it writes only minimal configuration to /etc/asound.conf and it turns off dmix/dsnoop for cards which need it. My current solution in 1.0.2rc2 isn't very good and I'll improve it.
http://people.redhat.com/stransky/alsa-dmix/alsa-lib-1.0.9rc2-5.src.rpm This package uses dmix/dsnoop only if the card needs it. But you MUST remove /etc/asound.conf and ~/.asoundrc. Eventually (if you want to have the first card as the default one) fill /etc/asound.conf with: defaults.pcm.card 0 defaults.ctl.card 0
Either I'm not getting it or this doesn't work at all. With the newer alsa-libs everything that uses esd locks up until you kill it if something else (such as xlite, the soft phone client) attempts to play sound. This is on a T40p with AC'97 audio (82801DBM).
Your applications have to use the "default" device. Dmix doesn't work if you use a hardware device (hw, plughw).