A Weird Imagination

Application bypassing PulseAudio

Posted in

The problem

Recently I ran a game1 and instead of the expected music, got distorted noise. At first I thought there was something physically wrong with my speakers or the connection to them, but running any other program resulted in normal sound, albeit mixed with the distorted sound of the game. Even more strangely, changing the volume in the game changed the volume of the distorted noise, implying the game was in fact generating the right thing but it was being misinterpreted, so the culprit was neither the game nor the sound driver but somewhere in between them.

As I had recently set up PulseAudio2, I suspected it was to blame. I opened up pavucontrol to find the game omitted from the list of applications producing sound, which suggested the problem was caused by the game trying to use some way to produce sound that PulseAudio was not capturing.

The solution

The short version is that the problem was solved by restarting PulseAudio:

$ killall -9 pulseaudio

The details

Sound APIs and compability

The actual kernel-level sound subsystem in Linux is ALSA. ALSA's predecessor was OSS; ALSA supports applications targeting OSS via a compatibility layer, so applications written for either will work on a modern Linux system which uses ALSA for its sound drivers.

PulseAudio, like other sound servers, sits between applications and the kernel's sound subsystem in order to add features like application-specific volume controls. It has to support ALSA as its output because that's how the sound must eventually get to the actual sound card.

Just like ALSA maintains OSS compatibility for old applications, PulseAudio supports ALSA and OSS applications.

Compability layer missing

Knowing that, I suspected that my PulseAudio install was missing a compatibility layer for the sound API the game was using. I guessed the game was using OSS and found padsp which redirects accesses to the OSS APIs through PulseAudio. This fixed the audio on the game, but caused other problems.3

Restarting PulseAudio

Then I remembered the recommendation to fix any PulseAudio problems with

$ killall -9 pulseaudio

which, to my surprise, fixed the issue. Even more surprisingly, once it worked, the game showed up in pavucontrol not as an OSS source, but as an ALSA source.

The bug still happens occasionally and I'm not sure why, but restarting PulseAudio fixes it every time.

Xfce mixer

As an additional detail, the volume control plugin for the Xfce panel stops working for controlling the PulseAudio volume when PulseAudio is restarted. As a workaround, removing it from the panel and adding it back again fixes it.

  1. The same one from this post

  2. Despite the date on that post, I really am running PulseAudio. 

  3. The online features of the game did not work when run this way, likely due to not being run through Steam


Have something to add? Post a comment by sending an email to comments@aweirdimagination.net. You may use Markdown for formatting.

There are no comments yet.