Amarok/Archives/Amarok 1.4/User Guide/Setting up Dmix for ALSA

Jump to: navigation, search

Setting Up DMix For Alsa

Below, you'll find an example configuration file, which will enable the Dmix plugin on your system.

  • Note that the instructions below are only necessary if the built-in dmix plugin distributed with alsa-lib (libasound2 on Debian-based systems) does not work! You can access this built-in, predefined dmix plugin by using "plug:dmix" as the virtual ALSA device.
  • Note also that "For ALSA 1.0.9rc2 and higher you don't need to setup dmix. Dmix is enabled as default for soundcards which don't support hw mixing." -- alsa wiki. so the simplest solution may be to remove all old configuration files and reinstall alsa (kernel modules might require a restart if it doesn't work initially). If you are running a recent version of alsa, and you can't get more than one sound at a time with the default configurations, THIS IS A BUG.

You can save the configuration file either in ~/.asoundrc (only affects your user) or in /etc/asound.conf (whole system). After editing these files, you need only to restart the ALSA application(s).

1pcm.ossmix {
   type dmix
   ipc_key 1024
   slave {
       pcm "hw:0,0"            # make sure this matches the actual device
       #period_time 0          # not necessary since ALSA 1.0pre
       period_size 1024        # Use a power of 2
       buffer_size 4096        # must be a multiple of period_size
       #rate 44100             # not necessary; let alsa-lib handle this
   }
   bindings {
       0 0
       1 1                     # bind only the first 2 channels
   }
}
pcm.duplex
{
   type asym
   playback.pcm "ossmix"
   capture.pcm "dsnoop"
}
# Everything shall be dmixed, so redefine "default":
# Note that this is _not_ a good idea, since dmix doesn't allow mmap access currently
#pcm.!default {
#   type plug
#   slave.pcm "duplex"
#}
# OSS via aoss should d(mix)stroyed:
pcm.dsp0 {
   type plug
   slave.pcm "duplex"
}
ctl.ossmix {
   type hw
   card 0
}

To test if dmix is working, you can run two or three instances of "alsaplayer" (or any other ALSA application, like amaroK) at the same time:

1alsaplayer -o alsa -d plug:ossmix some.mp3 

or

1aplay -D plug:ossmix some.mp3

If you get skipping in your applications when doing processor-intensive tasks, such as compiling or using OpenGL visualizations, increasing buffer_size in ~/.asoundrc can help. It should be increased by a power of 2, e.g.:

1pcm.ossmix {
   type dmix
   ipc_key 1024
   slave {
       pcm "hw:0,0"
       #period_time 0
       period_size 1024
       buffer_size 16384        # buffer size = 4096 x 2 x 2
       #rate 44100
   }
   bindings {
       0 0
       1 1
   }
}

This page was last edited on 7 December 2012, at 17:42. Content is available under Creative Commons License SA 4.0 unless otherwise noted.