How to make the sound work
From Multiseat
| Languages: |
English }">{{#if: |Português do Brasil| Português do Brasil}}|}} }">{{#if: |Español| Español}}|}} }">{{#if: |Français| Français}}|}} }">{{#if: |Deutsch| Deutsch}}|}} }">{{#if: |Русский| Русский}}|}} |
Introduction
Sound devices move around on boot. If the alsa driver supports it you can use index=X to create the device on a specific device but that doesn't help with multiseat sound.
Fortunately ALSA provides a way to set the alsa default sound card - simply set the ALSA_CARD env var for the bash session.
Setting up ALSA
Here's a hack for setting ALSA_CARD for each mdm seat.
First
cat /proc/asound/cards
You should see something like this:
0 [Audio ]: USB-Audio - USB Audio
C-Media INC. USB Audio at usb-0000:01:06.1-1, full speed
1 [Audio_1 ]: USB-Audio - USB Audio
C-Media INC. USB Audio at usb-0000:01:06.2-3.1, full speed
2 [NVidia ]: HDA-Intel - HDA NVidia
HDA NVidia at 0xfe020000 irq 20
3 [CX8801 ]: CX88x - Conexant CX8801
Conexant CX8801 at 0xfa000000
This system has 4 sound cards. Pick out an identifier that uniquely identifies the sound card you want to use for each seat. If you use USB sound, don't use the card name; these can move around with each reboot. I use the physical address of the usb sound card.
Then add a section to /etc/mdm/mdm.conf, identifying your sound card to use with each seat:
# Sound SOUND[1]="NVidia" SOUND[2]="usb-0000:01:06.1-1" SOUND[3]="usb-0000:01:06.2-3.1"
The hard part is done. Now we need to create a script that creates a short config file connecting our sound cards with our displays.
#!/bin/sh
config_file="/etc/mdm/mdm.conf"
[[ -f $config_file ]] || exit 1
. $config_file
ncards=${#SOUND[@]}
index=1
echo "#automatically created sound file DO NOT EDIT" > /etc/asound_card.conf
OIFS=$IFS
IFS=';'
for card in `awk '{i1=$0; getline ; i2=$0 ; x= i1 i2 ; print x ";"}' /proc/asound/cards` ; do
IFS=$OIFS
index=1
while [ "$index" -le "$ncards" ] ; do
if echo $card | grep ${SOUND[$index]} -qs ; then
echo SOUND$index=`echo $card | awk '{print $1}'`>> /etc/asound_card.conf
fi
let "index = $index + 1"
done
IFS=';'
done
Put this into /usr/local/bin/asound_config, make sure to
chmod +x /usr/local/bin/asound_config
and set it up so it runs on every boot, and before mdm. Now you're almost done.
Now you need to tell bash to add the alsa information to every shell. Edit /etc/profile and add the following lines to the front of the file:
if [ -n $DISPLAY ] ; then
[ -f /etc/asound_card.conf ] && . /etc/asound_card.conf
export ALSA_CARD=`eval echo '$SOUND'$(echo $DISPLAY | cut -f2 -d: | cut -f1 -d.)`
fi
Caveats and warnings
This only works with alsa-aware apps. You should set up the applications you use to use the default ALSA device.
You may need to use aoss for legacy oss apps.

