Mailing List Archive

Upgrade from 18.04 to 20.04 - pulseaudio
I have now upgraded two of my four MythTV PCs from Xubuntu 18.04 to
20.04. I have not had any major problems so far, but on my main
MythTV system an old annoying minor problem came back again. This is
where at random times during the day my Alsa S/PDIF output on the
motherboard sound card gets muted. I first had this with 18.04 and
eventually tracked it down to be a problem with pulseaudio, which I
solved by disabling pulseaudio by following some instructions about
how to modify its config files. With the upgrade to 20.04, those
modified files must have been overwritten and pulseaudio was running
again, and exhibiting the same bug. So this time I thought I would
track down where pulseaudio was being run from and disable it that
way.

It turns out that since 18.04 or maybe a little before that,
pulseaudio has been being run as a systemd user job, so that it gets
run once per user (not per session) under the userid of the user
running the desktop. You can see its status and journal with these
commands, run from the desktop user without sudo:

systemctl --user status pulseaudio.service
systemctl --user status pulseaudio.socket
journalctl --user-unit pulseaudio.service
journalctl --user-unit pulseaudio.socket

I then shut down pulseaudio using:

systemctl --user stop pulseaudio.service
systemctl --user stop pulseaudio.socket

and verified that the pulseaudio process was gone with:

ps -e | grep pulse

So then I tried to disable the pulseaudio units with:

systemctl --user disable pulseaudio.service
systemctl --user disable pulseaudio.socket

Those commands ran without any messages, but the command:

systemctl --user is-enabled pulseaudio.service

still reported that pulseaudio.service was enabled. Fortunately, I
was able to use:

locate pulseaudio.service

to find that /etc/systemd/user/ had links to the pulseaudio units:

root@mypvr:/etc/systemd/user/default.target.wants# ll
total 8
drwxr-xr-x 2 root root 4096 Oct 17 03:34 ./
drwxr-xr-x 4 root root 4096 Oct 17 03:34 ../
lrwxrwxrwx 1 root root 40 Oct 17 03:34 pulseaudio.service ->
/usr/lib/systemd/user/pulseaudio.service

root@mypvr:/etc/systemd/user/sockets.target.wants# ll
total 8
drwxr-xr-x 2 root root 4096 Oct 17 03:35 ./
drwxr-xr-x 4 root root 4096 Oct 17 03:34 ../
lrwxrwxrwx 1 root root 36 Oct 17 03:31 dirmngr.socket ->
/usr/lib/systemd/user/dirmngr.socket
lrwxrwxrwx 1 root root 46 Oct 17 03:35 gpg-agent-browser.socket ->
/usr/lib/systemd/user/gpg-agent-browser.socket
lrwxrwxrwx 1 root root 44 Oct 17 03:35 gpg-agent-extra.socket ->
/usr/lib/systemd/user/gpg-agent-extra.socket
lrwxrwxrwx 1 root root 38 Oct 17 03:35 gpg-agent.socket ->
/usr/lib/systemd/user/gpg-agent.socket
lrwxrwxrwx 1 root root 42 Oct 17 03:35 gpg-agent-ssh.socket ->
/usr/lib/systemd/user/gpg-agent-ssh.socket
lrwxrwxrwx 1 root root 46 Oct 17 03:32 pk-debconf-helper.socket ->
/usr/lib/systemd/user/pk-debconf-helper.socket
lrwxrwxrwx 1 root root 39 Oct 17 03:34 pulseaudio.socket ->
/usr/lib/systemd/user/pulseaudio.socket

The /etc/systemd/user directory is where packages install links to
make user systemd units run from each user, rather than just for one
user. But there does not seem to be any systemd command that will
install or remove those links, so I had to do it manually using a root
prompt rm command to delete both the pulseaudio.service and
pulseaudio.socket links. After that

systemctl --user is-enabled pulseaudio.service

from the desktop user reported that it was disabled.

I also found an entry in XFCE4's Settings > Session and Startup >
Application Autostart that would run pulseaudio, so I unticked that.
It is possible that was there because this system has been upgraded
from somewhere before Mythbuntu 14.04, and that is how pulseaudio used
to be run. It may not be there in new 20.04 installs. Gnome desktops
probably have an equivalent setting somewhere.

I then used alsamixer to unmute the S/PDIF output, and tried to play a
recording in mythfrontend. But mythfrontend complained that it could
not play the audio - the audio device was not working. And when I
tried to reconfigure the audio settings, selecting Alsa: Default again
as the output gave an error that the device did not exist.
Fortunately, shutting down mythfrontend and starting it again made
this problem go away, so mythfrontend must not have been seeing the
audio device changes that happened when pulseaudio was shut down.

So now pulseaudio dose not start up after I boot the PC, and I hope
that this problem is solved and will stay solved on future upgrades.

So, if you want to disable pulseaudio because it is causing problems,
do the above GUI setting change and then do this from a desktop user
prompt:

systemctl --user stop pulseaudio.service
systemctl --user stop pulseaudio.socket
sudo rm /etc/systemd/user/default.target.wants/pulseaudio.service
sudo rm /etc/systemd/user/sockets.target.wants/pulseaudio.socket

and then restart mythfrontend.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Upgrade from 18.04 to 20.04 - pulseaudio [ In reply to ]
On 10/18/20 8:53 AM, Stephen Worthington wrote:
> systemctl --user stop pulseaudio.service
> systemctl --user stop pulseaudio.socket
> sudo rm /etc/systemd/user/default.target.wants/pulseaudio.service
> sudo rm /etc/systemd/user/sockets.target.wants/pulseaudio.socket

I believe the approved way for removing the links is
systemctl --user disable pulseaudio.service
And for adding them back
systemctl --user enable pulseaudio.service

I had always used a different method to disable pulseaudio:

In /etc/pulse/client.conf, uncomment the line autospawn=yes and replace
the yes with a "no".
kill currently running copy: pulseaudio -k
also disable in window manager startup (Settings -> Session and startup)

I did not realize that there is a pulsaudio.service.

Did you not also have to remove it from window manager startup? I see it
is there and that may start it again next time you log on, in spite of
having the service disabled?

Peter


_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Upgrade from 18.04 to 20.04 - pulseaudio [ In reply to ]
On Sun, 18 Oct 2020 09:23:10 -0400, you wrote:

>
>On 10/18/20 8:53 AM, Stephen Worthington wrote:
>> systemctl --user stop pulseaudio.service
>> systemctl --user stop pulseaudio.socket
>> sudo rm /etc/systemd/user/default.target.wants/pulseaudio.service
>> sudo rm /etc/systemd/user/sockets.target.wants/pulseaudio.socket
>
>I believe the approved way for removing the links is
>systemctl --user disable pulseaudio.service
>And for adding them back
>systemctl --user enable pulseaudio.service

No, as I said, there seems to be no systemctl command that will remove
or add the user "template" links. The commands you gave are for links
under ~/.config/systemd/user which are local to each user. The
template links under /etc/systemd/user are applied to all users when
they are first started and a user mode systemd executable is run for
them.

>I had always used a different method to disable pulseaudio:
>
>In /etc/pulse/client.conf, uncomment the line autospawn=yes and replace
>the yes with a "no".
>kill currently running copy: pulseaudio -k
>also disable in window manager startup (Settings -> Session and startup)
>
>I did not realize that there is a pulsaudio.service.

Yes, it appears that is the way I disabled it in 18.04. I have just
checked my /etc/pulse/client.conf file and it has been edited to have
"autospawn=no". But in 20.04, pulseaudio was running again, so it
must be ignoring that option now, or how it works has changed.

>Did you not also have to remove it from window manager startup? I see it
>is there and that may start it again next time you log on, in spite of
>having the service disabled?

Yes, in XFCE4 that is in Settings > Session and Startup >
Application Autostart as I mentioned. With the service disabled, I
suspect that this option might well have started pulseaudio, so I
disabled it there too. With pulseaudio already running courtesy of
the user systemd instance, I expect that the Application Autostart
option (if enabled) will start another copy of pulseaudio which will
see that the original copy is running and shut itself down again. But
I have not tested that.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Upgrade from 18.04 to 20.04 - pulseaudio [ In reply to ]
On 10/18/20 5:53 AM, Stephen Worthington wrote:
> I have now upgraded two of my four MythTV PCs from Xubuntu 18.04 to
> 20.04. I have not had any major problems so far, but on my main
> MythTV system an old annoying minor problem came back again. This is
> where at random times during the day my Alsa S/PDIF output on the
> motherboard sound card gets muted. I first had this with 18.04 and
> eventually tracked it down to be a problem with pulseaudio, which I
> solved by disabling pulseaudio by following some instructions about
> how to modify its config files. With the upgrade to 20.04, those
> modified files must have been overwritten and pulseaudio was running
> again, and exhibiting the same bug. So this time I thought I would
> track down where pulseaudio was being run from and disable it that
> way.
>
> It turns out that since 18.04 or maybe a little before that,
> pulseaudio has been being run as a systemd user job, so that it gets
> run once per user (not per session) under the userid of the user
> running the desktop. You can see its status and journal with these
> commands, run from the desktop user without sudo:
> .....

For years (and many upgrades) I fought against pulseaudio and its overly
complex configuration and the way the distros integrate it into
everything, its tentacles invading every aspect of my system and apps
depending on it and packages breaking without it, etc, etc.  I, too, use
SPDIF passthrough to my receiver which complicates things immensely
since that seems to be an atypical (but optimum) configuration, ignored
by many default configurations and settings.

Then I discovered whole-house audio.  I have my main system in the
living room, hosting all of our media, including surround sound;  the
heart of our network.  Then there's the remote frontend/slave backend in
the bedroom with small but very high quality speakers, the laptop in the
office with its own receiver and decent speakers, the frontend in the
dining/kitchen area with decent speakers and the system in the
garage/patio, also a frontend with its own receiver/speakers.  All of
them are GB wired network and can play MythTV live TV and recordings,
but the coup de grace is their ability to play CD quality audio served
by the main server in the living room (which doesn't necessarily need to
be playing the same audio) in absolutely perfect sync and all have the
ability to control the whole system, including the
volume/playlist/playback of the whole system or any of the individual
systems.  I don't have my phone playing the audio (yet) but I have the
same control over volume/playback.  It's more than I had hoped for when
I began the project, and it's all possible thanks to pulseaudio.

mythfrontend is able to start multiple instances of itself and double
button presses on the remote would result in two (or more!) instances
running and competing for the display and sound. Results were odd, at
best, so I long ago wrote a script for starting it up that first checks
for a running instance and, if found, kills it first (in case it's not
visible for some reason). It handles a few other things that I've added
over the years, including this:

pactl suspend-sink alsa_output.pci-0000_00_1f.3.iec958-stereo yes

and, after mythfrontend exits

pactl suspend-sink alsa_output.pci-0000_00_1f.3.iec958-stereo no

There may be more elegant ways (and may not even be necessary with
current versions), but this works and has survived many upgrades.

Since giving in and embracing pulse, I have learned that in spite of its
complexity, it provides a great deal of functionality and is worth
learning how to work with.  It's not really much more work than figuring
out how to remove or disable it with every new upgrade.

Dave D.


_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org