I am trying to get Firefox 56.0 on Ubuntu 17.04 and 17.10 to play sound in videos in Facebook (not even sure it is specific to Facebook). I have isolated the problem down to pulseaudio not getting started when I play a video, or just not started at all. But if I execute pulseaudio from the command line, and then play the video from within Facebook, I get sound.
What is confusing me is trying to figure out what I should expect as to exactly when this pulseaudio UNIX process is supposed to be started.
- At boot time?
- At X11 startup time prior to user login?
- At user login (the "greeter" thing; GDM or whatever)?
- By Firefox when it executes code in some shared library that then demands that pulseaudio be started
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Running/ implies to me that it should be at user login time.
/etc/xdg/autostart is a directory that contains information about session services that graphical session managers should start automatically on user login. PulseAudio ships its own file there. pulseaudio.desktop tells the session manager to run start-pulseaudio-x11, which is a script that loads a few X11 related modules (and on KDE also module-device-manager, which is required by KDE's audio routing configuration tools). start-pulseaudio-x11 is usually the first thing that requires a running PulseAudio server, so usually the server gets started when the session manager runs start-pulseaudio-x11 in the beginning of the login session.
If autospawning is disabled, start-pulseaudio-x11 doesn't have effect, because start-pulseaudio-x11 doesn't start the server explicitly. It relies on autospawning when it loads the X11 modules. In this sense the script name is misleading. The start-pulseaudio-x11 script used to start the server explicitly in the past, which explains the script name.
Commands I've done recently to ensure I am starting from a good baseline, per instructions at http://support.system76.com/articles/audio/ (was done for different reasons, as the front audio connector in my machine was not working and doing the following fixed it):
rm -r ~/.config/pulse sudo apt install --reinstall alsa-base alsa-utils pulseaudio linux-sound-base libasound2
I am not at the moment thinking that the missing
~/.config/pulse directory is the culprit, but is it?
dmesg | grep pulse
shows nothing, so it is as if something is not even executing the right script at the right time.
What do I need to change to get this enabled? I don't want to manually invoke
pulseaudio each time I run firefox (I can kludge something up script-wise, but I don't wanna).
I conclude that autospawn is enabled since it is commented out (assuming commented out means the thing being commented out IS the program's default):
drunkard@norehab:~$ ps -ef --forest --cols=10000 | grep pulse drunkard 3448 2721 0 14:25 pts/0 00:00:00 | \_ grep pulse drunkard@norehab:~$ ls -ld ~/.config/pulse ls: cannot access '/home/drunkard/.config/pulse': No such file or directory drunkard@norehab:~$ ls -ld /etc/xdg/autostart/pulseaudio-kde.desktop ls: cannot access '/etc/xdg/autostart/pulseaudio-kde.desktop': No such file or directory drunkard@norehab:~$ ls -ld /etc/xdg/autostart/pulseaudio* -rw-r--r-- 1 root root 4836 Mar 29 2017 /etc/xdg/autostart/pulseaudio.desktop drunkard@norehab:~$ grep auto /etc/pulse/client.conf ; autospawn = yes ; auto-connect-localhost = no ; auto-connect-display = no drunkard@norehab:~$
I tried this:
cp -p /etc/pulse/client.conf ~/.config/pulse/client.conf
And rebooted and it is still not automatically starting.
The following proves to me that
/usr/bin/start-pulseaudio-x11 is NOT getting executed at all:
I saved off
drunkard@norehab:~$ sudo cp -p /usr/bin/start-pulseaudio-x11 /usr/bin/start-pulseaudio-x11.orig
Then added a line at the end that simply writes out the curent timestamp to a log file in
drunkard@norehab:~$ sudo sh -c 'echo "date >> /tmp/start-pulseaudio-x11.log" >> /usr/bin/start-pulseaudio-x11' drunkard@norehab:~$ tail /usr/bin/start-pulseaudio-x11 if [ x"$KDE_FULL_SESSION" = x"true" ]; then /usr/bin/pactl load-module module-device-manager "do_routing=1" > /dev/null fi if [ x"$SESSION_MANAGER" != x ] ; then /usr/bin/pactl load-module module-x11-xsmp "display=$DISPLAY session_manager=$SESSION_MANAGER" > /dev/null fi fi date >> /tmp/start-pulseaudio-x11.log drunkard@norehab:~$
Then reboot and logged in and found that the
/tmp/start-pulseaudio-x11.log was non-existent.
So whatever is supposed to invoke
/usr/bin/start-pulseaudio-x11 before or after login is not doing so.
This is still broken in Ubuntu 17.10. but the comment clued me in that my workaround can use
systemctl instead of direct execution.
But I say this is still broken because why is sound not enabled for all users that are using desktops? I mean, under no circumstances that I can think of would I ever NOT want to hear sound from videos played from any browsers. Whatever sound daemon (pulseaudio in this case but it doesn't matter) should be default to "enabled" for desktop users. Not so for server installations, but that is not the case here.