I was unable to find much information about this issue so it’s either somewhat obscure or I’m terrible at searching for things. Probably both.
I originally ran into this problem when trying to run Firefox in Firejail using the standard Firejail profile for Firefox. Firefox ran fine, except there was no audio. I found that this was a known issue documented here, but unfortunately none of the suggested fixes had any effect. The page states that newer versions of PulseAudio do not exhibit that issue, so that is not really surprising.
I did some searching and found others with related issues (see the related links at the end of this post), but no solutions matched my problem. Based on some of those discussions I tried to run
speaker-test with Firejail (both with and without
--noprofile), but I received a “connection refused” message in both cases. After some experimentation I found that if I ran
speaker-test in Firejail after booting up, but before starting X Windows, it worked. This was the case even if I first used an audio program in the terminal (e.g. a music player) before attempting to run a program with Firejail.
Extra background – The system in question runs Slackware Linux (-current) with PulseAudio 10, starts up into runlevel 3 and uses
startx to load X Windows.
I was able to resolve the issue by adding the following to my .xinitrc before starting the window manager. It starts PulseAudio via the
start-pulseaudio-x11 program, which (according to the man page) adds access credentials to the PulseAudio server to the X11 root window and registers it in the X11 session manager.
I doubt this is an issue for those that start their system using a graphic display manager, although I have not tested that.
Possibly Useful PulseAudio Links