Skip to content

Instantly share code, notes, and snippets.

@erdoukki
Last active February 24, 2023 23:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erdoukki/8bd2c1f5651a9c67c7822c2bfb875643 to your computer and use it in GitHub Desktop.
Save erdoukki/8bd2c1f5651a9c67c7822c2bfb875643 to your computer and use it in GitHub Desktop.
SQUEEZELITE ISSUE - LINUXMINT - ROOT INITD - USER SYSTEMD - PULSE - AUDIO FIXME
KEYWORDS:
- SQUEEZELITE ISSUE
- LINUXMINT / UBUNTU
- USER vs ROOT
- INITD vs SYSTEMD
- DBUS ERROR
- PULSE EROR
- AUDIO OUTPUT (root to computer speaker only / user )
- AUDIO OUTPUT DEVICES USER ON-THE-FLY CONFIGURATION (SPEAKER, BLUETOOTH, ...)
- XDG
REFERENCES:
- https://linuxaudiofoundation.org/musiclounge-squeezelite-player/
- https://forums.raspberrypi.com/viewtopic.php?t=303367
- https://www.mankier.com/7/squeezelite.service
- http://www.compu-tek.fr/blog/tutoriel-installer-squeezelite-sur-raspbian/
- https://doc.ubuntu-fr.org/squeezelite
- https://nts.strzibny.name/systemd-user-services/
- https://unix.stackexchange.com/questions/75984/trouble-with-dbus-and-systemd-user#80576
- https://dbus.freedesktop.org/doc/dbus-launch.1.html
RESOLUTION:
$ sudo cat /etc/systemd/user/squeezelite.service
[Unit]
Description=Sound Service
# We require pulseaudio.socket to be active before starting the daemon, because
# while it is possible to use the service without the socket, it is not clear
# why it would be desirable.
#
# A user installing pulseaudio and doing `systemctl --user start pulseaudio`
# will not get the socket started, which might be confusing and problematic if
# the server is to be restarted later on, as the client autospawn feature
# might kick in. Also, a start of the socket unit will fail, adding to the
# confusion.
#
# After=pulseaudio.socket is not needed, as it is already implicit in the
# socket-service relationship, see systemd.socket(5).
Requires=pulseaudio.socket
ConditionUser=!root
# Automatically generated by systemd-sysv-generator
##[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/init.d/squeezelite
Description=LSB: Lightweight headless Squeezebox emulator
Before=multi-user.target
Before=multi-user.target
Before=multi-user.target
Before=graphical.target
After=network-online.target
After=remote-fs.target
Wants=network-online.target
[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
SuccessExitStatus=5 6
#ExecStart=/etc/init.d/squeezelite start
ExecStart=/usr/bin/squeezelite -n PRECISION -f /var/log/squeezelite.log -d all=debug -C 5 -v -z
#ExecStop=/etc/init.d/squeezelite stop
ExecStop=killall squeezelite
[Install]
Also=pulseaudio.socket
WantedBy=default.target
$ systemctl disable --user squeezelite.service
$ systemctl enable --user squeezelite.service
$ systemctl disable --user squeezelite.service
Removed /home/gke/.config/systemd/user/default.target.wants/squeezelite.service.
Removed /home/gke/.config/systemd/user/sockets.target.wants/pulseaudio.socket.
$ systemctl enable --user squeezelite.service
Created symlink /home/gke/.config/systemd/user/default.target.wants/squeezelite.service → /etc/xdg/systemd/user/squeezelite.service.
Created symlink /home/gke/.config/systemd/user/sockets.target.wants/pulseaudio.socket → /usr/lib/systemd/user/pulseaudio.socket.
$ systemctl restart --user squeezelite.service
$ systemctl status --user squeezelite.service
● squeezelite.service - LSB: Lightweight headless Squeezebox emulator
Loaded: loaded (/etc/init.d/squeezelite; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-02-12 15:15:11 CET; 8s ago
Docs: man:systemd-sysv-generator(8)
Process: 34828 ExecStart=/usr/bin/squeezelite -n PRECISION -f /var/log/squeezelite.log -d all=debug -C 5 -v -z (code=exited, status=0/SUCCESS)
CGroup: /user.slice/user-1000.slice/user@1000.service/squeezelite.service
└─34829 /usr/bin/squeezelite -n PRECISION -f /var/log/squeezelite.log -d all debug -C 5 -v -z
févr. 12 15:15:11 PRECISION systemd[1198]: Starting LSB: Lightweight headless Squeezebox emulator...
févr. 12 15:15:11 PRECISION systemd[1198]: Started LSB: Lightweight headless Squeezebox emulator.
//FIXME
$ sudo service squeezelite restart
$ ps aux | grep squezelite
root 34476 7.0 0.4 363252 156180 ? SLl 15:12 0:00 /usr/bin/squeezelite -n PRECISION -f /var/log/squeezelite.log -d all debug -C 5 -v
//FIXED
$ ps aux | grep squeezelite
gke 32976 1.7 0.0 698784 17984 ? Ssl 15:00 0:13 /usr/bin/squeezelite -n PRECISION -f /var/log/squeezelite.log -d all debug -C 5 -v -z
$ whoami
gke
// KO (ROOT USER)
$ sudo squeezelite -l
Output devices:
surround21 - 2.1 Surround output to Front and Subwoofer speakers
surround40 - 4.0 Surround output to Front and Rear speakers
surround41 - 4.1 Surround output to Front, Rear and Subwoofer speakers
surround50 - 5.0 Surround output to Front, Center and Rear speakers
surround51 - 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71 - 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
null - Discard all samples (playback) or generate zero samples (capture)
samplerate - Rate Converter Plugin Using Samplerate Library
speexrate - Rate Converter Plugin Using Speex Resampler
jack - JACK Audio Connection Kit
oss - Open Sound System
pulse - PulseAudio Sound Server
upmix - Plugin for channel upmix (4,6,8)
vdownmix - Plugin for channel downmix (stereo) with a simple spacialization
default:CARD=PCH - HDA Intel PCH, ALC3246 Analog - Default Audio Device
sysdefault:CARD=PCH - HDA Intel PCH, ALC3246 Analog - Default Audio Device
front:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - Front speakers
surround21:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - 2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - 4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - 4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - 5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
hdmi:CARD=PCH,DEV=0 - HDA Intel PCH, HDMI 0 - HDMI Audio Output
hdmi:CARD=PCH,DEV=1 - HDA Intel PCH, HDMI 1 - HDMI Audio Output
hdmi:CARD=PCH,DEV=2 - HDA Intel PCH, HDMI 2 - HDMI Audio Output
hdmi:CARD=PCH,DEV=3 - HDA Intel PCH, HDMI 3 - HDMI Audio Output
hdmi:CARD=PCH,DEV=4 - HDA Intel PCH, HDMI 4 - HDMI Audio Output
dmix:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - Direct sample mixing device
dmix:CARD=PCH,DEV=3 - HDA Intel PCH, HDMI 0 - Direct sample mixing device
dmix:CARD=PCH,DEV=7 - HDA Intel PCH, HDMI 1 - Direct sample mixing device
dmix:CARD=PCH,DEV=8 - HDA Intel PCH, HDMI 2 - Direct sample mixing device
dmix:CARD=PCH,DEV=9 - HDA Intel PCH, HDMI 3 - Direct sample mixing device
dmix:CARD=PCH,DEV=10 - HDA Intel PCH, HDMI 4 - Direct sample mixing device
dsnoop:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - Direct sample snooping device
dsnoop:CARD=PCH,DEV=3 - HDA Intel PCH, HDMI 0 - Direct sample snooping device
dsnoop:CARD=PCH,DEV=7 - HDA Intel PCH, HDMI 1 - Direct sample snooping device
dsnoop:CARD=PCH,DEV=8 - HDA Intel PCH, HDMI 2 - Direct sample snooping device
dsnoop:CARD=PCH,DEV=9 - HDA Intel PCH, HDMI 3 - Direct sample snooping device
dsnoop:CARD=PCH,DEV=10 - HDA Intel PCH, HDMI 4 - Direct sample snooping device
hw:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - Direct hardware device without any conversions
hw:CARD=PCH,DEV=3 - HDA Intel PCH, HDMI 0 - Direct hardware device without any conversions
hw:CARD=PCH,DEV=7 - HDA Intel PCH, HDMI 1 - Direct hardware device without any conversions
hw:CARD=PCH,DEV=8 - HDA Intel PCH, HDMI 2 - Direct hardware device without any conversions
hw:CARD=PCH,DEV=9 - HDA Intel PCH, HDMI 3 - Direct hardware device without any conversions
hw:CARD=PCH,DEV=10 - HDA Intel PCH, HDMI 4 - Direct hardware device without any conversions
plughw:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - Hardware device with all software conversions
plughw:CARD=PCH,DEV=3 - HDA Intel PCH, HDMI 0 - Hardware device with all software conversions
plughw:CARD=PCH,DEV=7 - HDA Intel PCH, HDMI 1 - Hardware device with all software conversions
plughw:CARD=PCH,DEV=8 - HDA Intel PCH, HDMI 2 - Hardware device with all software conversions
plughw:CARD=PCH,DEV=9 - HDA Intel PCH, HDMI 3 - Hardware device with all software conversions
plughw:CARD=PCH,DEV=10 - HDA Intel PCH, HDMI 4 - Hardware device with all software conversions
usbstream:CARD=PCH - HDA Intel PCH - USB Stream Output
// OK (NORMAL USER)
$ squeezelite -l
Output devices:
default - Playback/recording through the PulseAudio sound server
surround21 - 2.1 Surround output to Front and Subwoofer speakers
surround40 - 4.0 Surround output to Front and Rear speakers
surround41 - 4.1 Surround output to Front, Rear and Subwoofer speakers
surround50 - 5.0 Surround output to Front, Center and Rear speakers
surround51 - 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71 - 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
null - Discard all samples (playback) or generate zero samples (capture)
samplerate - Rate Converter Plugin Using Samplerate Library
speexrate - Rate Converter Plugin Using Speex Resampler
jack - JACK Audio Connection Kit
oss - Open Sound System
pulse - PulseAudio Sound Server
upmix - Plugin for channel upmix (4,6,8)
vdownmix - Plugin for channel downmix (stereo) with a simple spacialization
sysdefault:CARD=PCH - HDA Intel PCH, ALC3246 Analog - Default Audio Device
front:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - Front speakers
surround21:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - 2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - 4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - 4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - 5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
hdmi:CARD=PCH,DEV=0 - HDA Intel PCH, HDMI 0 - HDMI Audio Output
hdmi:CARD=PCH,DEV=1 - HDA Intel PCH, HDMI 1 - HDMI Audio Output
hdmi:CARD=PCH,DEV=2 - HDA Intel PCH, HDMI 2 - HDMI Audio Output
hdmi:CARD=PCH,DEV=3 - HDA Intel PCH, HDMI 3 - HDMI Audio Output
hdmi:CARD=PCH,DEV=4 - HDA Intel PCH, HDMI 4 - HDMI Audio Output
dmix:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - Direct sample mixing device
dmix:CARD=PCH,DEV=3 - HDA Intel PCH, HDMI 0 - Direct sample mixing device
dmix:CARD=PCH,DEV=7 - HDA Intel PCH, HDMI 1 - Direct sample mixing device
dmix:CARD=PCH,DEV=8 - HDA Intel PCH, HDMI 2 - Direct sample mixing device
dmix:CARD=PCH,DEV=9 - HDA Intel PCH, HDMI 3 - Direct sample mixing device
dmix:CARD=PCH,DEV=10 - HDA Intel PCH, HDMI 4 - Direct sample mixing device
dsnoop:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - Direct sample snooping device
dsnoop:CARD=PCH,DEV=3 - HDA Intel PCH, HDMI 0 - Direct sample snooping device
dsnoop:CARD=PCH,DEV=7 - HDA Intel PCH, HDMI 1 - Direct sample snooping device
dsnoop:CARD=PCH,DEV=8 - HDA Intel PCH, HDMI 2 - Direct sample snooping device
dsnoop:CARD=PCH,DEV=9 - HDA Intel PCH, HDMI 3 - Direct sample snooping device
dsnoop:CARD=PCH,DEV=10 - HDA Intel PCH, HDMI 4 - Direct sample snooping device
hw:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - Direct hardware device without any conversions
hw:CARD=PCH,DEV=3 - HDA Intel PCH, HDMI 0 - Direct hardware device without any conversions
hw:CARD=PCH,DEV=7 - HDA Intel PCH, HDMI 1 - Direct hardware device without any conversions
hw:CARD=PCH,DEV=8 - HDA Intel PCH, HDMI 2 - Direct hardware device without any conversions
hw:CARD=PCH,DEV=9 - HDA Intel PCH, HDMI 3 - Direct hardware device without any conversions
hw:CARD=PCH,DEV=10 - HDA Intel PCH, HDMI 4 - Direct hardware device without any conversions
plughw:CARD=PCH,DEV=0 - HDA Intel PCH, ALC3246 Analog - Hardware device with all software conversions
plughw:CARD=PCH,DEV=3 - HDA Intel PCH, HDMI 0 - Hardware device with all software conversions
plughw:CARD=PCH,DEV=7 - HDA Intel PCH, HDMI 1 - Hardware device with all software conversions
plughw:CARD=PCH,DEV=8 - HDA Intel PCH, HDMI 2 - Hardware device with all software conversions
plughw:CARD=PCH,DEV=9 - HDA Intel PCH, HDMI 3 - Hardware device with all software conversions
plughw:CARD=PCH,DEV=10 - HDA Intel PCH, HDMI 4 - Hardware device with all software conversions
usbstream:CARD=PCH - HDA Intel PCH - USB Stream Output
// ISSUE (NORMAL USER vs ROOT USER)
$ squeezelite -l
Output devices:
default - Playback/recording through the PulseAudio sound server
>> MISSING default Output device with ROOT USER
// ERROR (DEBUG)
$ sudo squeezelite -o pulse -d all=debug
[15:20:58.980448] stream_init:290 init stream
[15:20:58.980480] stream_init:291 streambuf size: 2097152
[15:20:58.981079] output_init_alsa:817 init output
[15:20:58.981088] output_init_alsa:846 requested alsa_buffer: 40 alsa_period: 4 format: any mmap: 1
[15:20:58.981092] output_init_common:346 outputbuf size: 3528000
[15:20:58.981111] output_init_common:370 idle timeout: 0
[15:20:58.983572] ALSA pulse_connect:242 PulseAudio: Unable to connect: Connection refused
[15:20:58.983641] test_open:294 playback open error: Connection refused
[15:20:58.983647] output_init_common:381 unable to open output device
// WORKING MODE (DEBUG)
$ squeezelite -o pulse -d all=debug
gke@PRECISION:~$ squeezelite -o pulse -d all=debug
[15:22:04.700141] stream_init:290 init stream
[15:22:04.700171] stream_init:291 streambuf size: 2097152
[15:22:04.700761] output_init_alsa:817 init output
[15:22:04.700769] output_init_alsa:846 requested alsa_buffer: 40 alsa_period: 4 format: any mmap: 1
[15:22:04.700773] output_init_common:346 outputbuf size: 3528000
[15:22:04.700787] output_init_common:370 idle timeout: 0
[15:22:04.705148] output_init_common:410 supported rates: 384000 352800 192000 176400 96000 88200 48000 44100 32000 24000 22500 16000 12000 11025 8000
[15:22:04.705199] output_init_alsa:860 unable to lock memory: Cannot allocate memory
[15:22:04.706272] output_init_alsa:883 unable to set output sched fifo: Operation not permitted
[15:22:04.706292] decode_init:129 init decode, include codecs: exclude codecs:
[15:22:04.706312] register_dsd:624 using dsd to decode dsf,dff
[15:22:04.706302] output_thread:638 open output device: pulse
[15:22:04.706330] register_ff:731 using ffmpeg to decode alc
[15:22:04.706330] alsa_open:355 opening device at: 44100
[15:22:04.706337] register_ff:715 using ffmpeg to decode wma,wmap,wmal
[15:22:04.706348] register_faad:640 using faad to decode aac
[15:22:04.706352] register_vorbis:329 using vorbis to decode ogg
[15:22:04.706355] register_flac:286 using flac to decode flc
[15:22:04.706359] register_pcm:384 using pcm to decode aif,pcm
[15:22:04.706363] register_mad:412 using mad to decode mp3
[15:22:04.706401] discover_server:756 sending discovery
[15:22:04.707166] alsa_open:406 opened device pulse using format: S32_LE sample rate: 44100 mmap: 0
[15:22:04.707185] alsa_open:485 buffer: 40 period: 4 -> buffer size: 1764 period size: 441
@rmduk
Copy link

rmduk commented Feb 24, 2023

Thanks so much for this. I was trying to setup squeezelite as a system service and having all kinds of problems getting audio working correctly. Tried your user service file and all working perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment