How to Run PulseAudio as a Service via systemd for Root User?

Hi @ferranmc !

I tried a bit and this worked for me, but with one issue (shared below):

root@verdin-imx8mm-06827711:~# cat /etc/systemd/system/pulseaudio-bluealsa.service
[Unit]
Description=Pulseaudio and Bluetooth for calls
After=sound.target dbus.service bluetooth.service
Requires=dbus.service bluetooth.service

[Service]
Type=simple
ExecStart=/usr/bin/sh /root/script.sh
Restart=on-failure
RemainAfterExit=yes

[Install]
Also=pulseaudio.socket
WantedBy=multi-user.target

To run it upon boot:

systemctl enable pulseaudio-bluealsa

Could you please test on your side and share your results? The script at /root/script.sh is the script shared by @bruno.tx in Pulseaudio and module-echo-cancel YOCTO recipe - #15 by bruno.tx.

The current issue I am facing is that the first call after a reboot is a loud noise. Please be careful to not hurt your ears! The next calls work well.

I still need to understand why the first call presents this issue.

Best regards,