multiseat linux : system-wide pulseaudio for routing sounds

many users - one machineWhen using a multi-seat linux – multiseat : I really mean there are several users using one machine with numerous keyboards, mice and screens, each user having its own X at the same time – it used to be rather difficult to route sounds towards the proper output devices, or even to share the (very often only) available sound card ; pulseaudio system-wide daemon is an elegant solution …

Obviously any process wants its  own sound device. That’s why sound servers were introduced after the inititial oss design. From the past, I used to tweak multiseat configs a lot with every last trend of sound servers, oss, esd, alsa, even tried jackd which isn’t really suited for general use. Finally, when I switched from debian to ubuntu for desktop use, I took a glance at pulseaudio.

Pulseaudio has one main point against the others : it is ubuntu’s current choice and it comes with a rather simple and convenient front-end for setting processes sound-volume individually (pavucontrol – Pulse Audio Volume Control).

With the multiseat constraints, I could not get a decent stable system keeping the initial per-user design ; this document mainly details most tricks needed to switch from a per-user to a system-wide pulseaudio daemon.

/etc/default/pulseaudio

The system-wide daemon is started once for all at the starting of the machine by it’s /etc/init.d/pulseaudio startup script.

PULSEAUDIO_SYSTEM_START=1

/etc/group

One main trouble when sharing sound devices is all those old binaries that try to steal /dev/dsp one to each other, but the same trouble may occur on /dev/snd/*/* device files ; that’s why I finally choosed to

  • remove all users from audio group except pulse
  • put back all users into pulse-access group

this way, stealing to each other is much more difficult (though pulseaudio daemon is a setuid application so some more has to be done, see below).

/etc/pulse/system.pa

load-module module-alsa-sink device="front:Intel" sink_name=global
load-module module-remap-sink sink_name=big channels=2 channel_map=right,left master_channel_map=right,left remix=no
load-module module-remap-sink sink_name=small channels=2 channel_map=right,left master_channel_map=rear-left,rear-right remix=no
; those three lines permit splitting a unique common multi-channel sound card to a pair of stereo sinks
; one using the front jack, the other the rear output jack.

.../...

# pulseaudio system-wide deamon keep the sound card for himself ...
# load-module module-suspend-on-idle

/etc/pulse/daemon.conf

# on my box, 2.6.33 introduced some troubles around there ...
no-cpu-limit = yes
# this one is for enabling four channel on the global sink (for watching movies ?)
default-sample-channels = 4

/etc/pulse/client.conf

; don't let user launch pulseaudio deamons at need, there's already one
autospawn=no

/etc/profile.d/pulseaudio-client.sh

as the environment variable $PULSE_SINK takes precedence over global or file tunings, another entry into /etc/profile.d sounds efficient :

#!/bin/sh

# in oder to match a screen-set to a pulseaudio sink :
# pour le cas ou l'on veut faire correspondre a un terminal un canal pulseaudio :
if [ "$DISPLAY" ]
then
    if [ "$DISPLAY" = ":0" ]
    then
        PULSE_SINK="big"
    fi
    if [ "$DISPLAY" = ":1" ]
    then
        PULSE_SINK="small"
    fi
fi

this script has to be usable by anyone :

# chmod 755 /etc/profile.d/pulseaudio-client.sh

update all ~users/.asoundrc

I confess I’m not (yet) sure for that one, I should start over with a clean ubuntu to check about it, anyway it shouldn’t hurt much : for each user, play :

> asoundconf set-pulseaudio

in order to get a default alsa mapping to pulse.

~/.pulse/client.conf

Any user may have its own additional settings, but should take care of eventually erasing the $PULSE_SINK var if needed (for example, my children have sound following their seats whilst I always have the big loudspeakers).

default-sink=small
; probablement mieux de ne pas avoir de pulseaudio lancés par les users
autospawn=no

there we are

Eventually /etc/group changes won’t be effective before X-session endings, the system-wide daemon has to be launched after killing anything in the way to soundcards, but at this point things should work, no more “release the sound for me please” battleground !

1 Comment

  1. [...] This post was mentioned on Twitter by jean-daniel pauget. jean-daniel pauget said: linux : the soundcard fight solved http://wik.io/gKPA [...]

Sorry, the comment form is closed at this time.

macports and upgrading to mavericks

This is mainly a reminder of some light troubles encountered whilst upgrading from moutain-lion to mavericks. Certainly, many people could be concerned because Apple decided to give this upgrade for free (which is a good turn in my opinion). Most of the troubles come from the upgrade process, a fresh maverick installation might have much less problems. upgrading [...]
the_title(); ?>

tempelhof

one should scroll to the left, and then to the right.
the_title(); ?>
White Box - PurForm

White Box – PurForm

Grande narration noisy qui parcours le lisse, les moires, les coincidences géométriques, en son et en video.
the_title(); ?>
In C - Terry Riley - Orchestre de Bretagne

In C de Terry Riley par l’Orchestre de Bretagne

Exceptionnel : une oeuvre du courant minimaliste américain jouée en grandeur nature [...]
the_title(); ?>
our galaxy as seen from makhtech-ramon

Makhtesh Ramon, moonless night.

Makhtech Ramon is a huge erosion valley in the middle of negev desert. Stepping into a desert is really something worth trying, you'll have the sensation of being invited by nature to shortly visit a place where humans are not really supposed to be.
the_title(); ?>
James Lick refractor

James Lick refractor

a small blog entry to host the full-size original of this pic taken when I passed by mount hamilton and bumped into one’s child dream. this pic is currently illustrating wikipedia’s James Lick telescope entry. One may use it, conforming with Creative Commons attribution license.
the_title(); ?>
korg kaoss pad (by acidpix)

42

Utilisez le TLD 42 ! ce site est désormais accessible via : http://disjunkt.42/jd [...]
the_title(); ?>

bien nommer les choses

Dans la classique saga terremer, nommer les choses, plus précisement connaître leur nom, donne le pouvoir de les contrôler. Avec unix c’est pareil, connaitre le nom du point d’entrée d’un fichier exécutable permet de “l’invoquer“. Et ce depuis une ligne de commande, ou l’interieur de n’importe quel script ! C’est en étant appelés les uns [...]
the_title(); ?>
Hiroshi Yoshino, Charles Vannier, Kaya Sasaki, Hervé le Bitter.

Hiroshi Yoshino et Hervé le Bitter à la bascule

Duo de contrebassistes qui se rencontrent pour la première fois. Présentés l’un à l’autre par le danseur Charles Vannier, ils ont juste fait une balance de son de quinze minutes dans l’après midi. Ce fut donc une véritable improvisation. Comme à la bascule l’espace est petit, on est vite au courant de tout et la confession [...]
the_title(); ?>
bulgy capacitors - condensateurs gonflés/boursouflés

la peste des condensateurs, obsolescence programmée ?

Lorsque soudain un moniteur acheté un peu plus cher que la moyenne tombe en quasi-panne juste peu après les 3 années de garantie généreusement offertes par le constructeur, je maudis le sort. Et de rage je démonte, par acquis de conscience la bestiole. C’est qu’elle rendait une belle image, alors vraiment si je pouvais trouver [...]
the_title(); ?>