You can configure ALSA's dmix
plugin to allow multiple applications to share input/output devices.
An example configuration to do this is below:
pcm.dmixed {
type dmix
ipc_key 1024
ipc_key_add_uid 0
slave.pcm "hw:0,0"
}
pcm.dsnooped {
type dsnoop
ipc_key 1025
slave.pcm "hw:0,0"
}
pcm.duplex {
type asym
playback.pcm "dmixed"
capture.pcm "dsnooped"
}
# Instruct ALSA to use pcm.duplex as the default device
pcm.!default {
type plug
slave.pcm "duplex"
}
ctl.!default {
type hw
card 0
}
This does the following:
- creates a new device using the
dmix
plugin, which allows multiple apps to share the output stream
- creates another using
dsnoop
which does the same thing for the input stream
- merges these into a new
duplex
device that will support input and output using the asym
plugin
- tell ALSA to use the new
duplex
device as the default device
- tell ALSA to use
hw:0
to control the default device (alsamixer and so on)
Stick this in either ~/.asoundrc
or /etc/asound.conf
and you should be good to go.
For more information see http://www.alsa-project.org/main/index.php/Asoundrc#Software_mixing.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…