Pulseaudio and Audio routing... or how to make Jitsi stream game audio and the microphone

3 minute read Published: 2020-04-28

I kind of wonder why there's no decent user interface for pulseaudio - or if it exists, why it's unknown. Pulseaudio is pretty powerful, but the usability is bad. A simple graph application that lets you connect the dots would go a long way. I remember something like that on Windows about 15 years ago, you could throw in various inputs, outputs and filters and just connect them by dragging lines. Not sure if it still exists or is usable.

Here's what I want to do:

  1. Play a game
  2. Talk on the microphone
  3. Listen to other people on Jitsi

So I have three inputs: Game, Jitsi, Microphone The game sound has to go to both headset and Jitsi recording. The Jitsi output only goes to my headset. The Microphone only goes to the Jitsi recording.

Pulseaudio can create the missing points in betweern very easily. You need two things here:

  1. The sink name of your headset output, for me that's alsa_output.usb-Logitech_PRO_X_000000000000-00.analog-stereo.
  2. The source name of your headset microphone, for me that's alsa_input.usb-Logitech_PRO_X_000000000000-00.mono-fallback. You can use the following two commands to find them:
# List current sinks:
pactl list short sinks
# List current sources:
pactl list short sources

Then you create the missing points. First the game sink, this will be the output that the game will use:

pactl load-module module-null-sink sink_name=game sink_properties=device.description=game

The you create the sink that Jitsi can record:

pactl load-module module-null-sink sink_name=streamout sink_properties=device.description=streamout

Finally you tell pulseaudio what audio needs to be sent where:

# Loop the microphone into streamout
pactl load-module module-loopback source=alsa_input.usb-Logitech_PRO_X_000000000000-00.mono-fallback sink=streamout
# Loop the game into streamout
pactl load-module module-loopback source=game.monitor sink=streamout
# Loop the game into headset
pactl load-module module-loopback source=game.monitor sink=alsa_output.usb-Logitech_PRO_X_000000000000-00.analog-stereo

Sadly at this point pulseaudio will already start to generate CPU load for copying around and resampling silence...

Now start your game (or any other application) and have it play some sound. Then start pavucontrol. On the first tab named "Playback", you can find the currently playing applications. There should be a button on the right that lists the current output the game is using. Click it and select "game". You should now hear it on your headset or whatever output you have decided to use. Next start Jitsi and have it record the "Monitor of streamout". Finally verify that your microphone is working and you're done.