Complete Communications Engineering

One way is to use the ALSA dmix plugin to create an alias for the device that can be used by multiple processes simultaneously.  The alias works like a new ALSA device and any software that uses ALSA for audio input and output can open it like any other device.  When a process opens an ALSA hardware device, it is usually granted exclusive access to the hardware and no other process can use it at the same time.  When using the dmix plugin, the plugin takes exclusive access to the hardware and it allows multiple processes to use the new dmix device at once.  The audio from each process is mixed before it is sent to the hardware.

Setting up a dmix plugin usually involves creating a hidden file in your home directory called ‘.asoundrc’.  The following example shows one way to create a dmix device using this file:

.asoundrc

pcm.dmix_out {

     type dmix

     ipc_key 63720

     slave.pcm “hw:0,0”

     slave.rate 44100

}

This example creates a dmix device called ‘dmix_out’.  This is the name that ALSA software will use to open the device.  The ‘ipc_key’ is a unique number used for inter-process communication.  It should be unique for the slave pcm device.  It is possible to create multiple dmix devices that use the same hardware device, and those dmix devices should use the same ‘ipc_key’.  The ‘slave’ properties describe the ALSA hardware device the dmix device is tied to.  When any ALSA software opens the dmix device, the dmix plugin will open this hardware device on behalf of the ALSA software.  The ‘dmix_out’ device can be opened by multiple processes simultaneously, and the audio generated by each will be mixed before it goes out to the hardware device (hw:0,0 in this example).