Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shairport Sync and Pipewire #1970

Closed
mikebrady opened this issue Feb 1, 2025 · 42 comments
Closed

Shairport Sync and Pipewire #1970

mikebrady opened this issue Feb 1, 2025 · 42 comments

Comments

@mikebrady
Copy link
Owner

Discussed in #1969

Originally posted by janstadt February 1, 2025
Ive looked through a lot of posts here about how Pipewire and PulseAudio is problematic, but i want to be able to push audio out of one speaker from multiple sources. I use homeassistant to push notifications and airplay to play music. if they both use airplay, the session interruption isnt reliable enough for the setup and i typically get an error where the annoucement doesnt play or is truncated. Enter pipewire. I followed this post and had it working for a while, but now i keep getting this error:

Jan 31 18:24:53 the-kitchen shairport-sync[557]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?

pipewire.service is running as a --user service as well as wireplumber.service.

I had working at one point, but now it no longer works on one of my devices (pi 3b with a hifiberry dac).

Version (built with pipewire):
4.3.5-AirPlay2-smi10-OpenSSL-Avahi-pw-soxr-metadata-mqtt-sysconfdir:/etc

Config

>> Display Config Start.

From "uname -a":
 Linux the-kitchen 6.6.62+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.62-1+rpt1 (2024-11-25) aarch64 GNU/Linux

From /etc/os-release:
 Debian GNU/Linux 12 (bookworm)

From /sys/firmware/devicetree/base/model:
 Raspberry Pi 3 Model B Rev 1.2

Shairport Sync Version String:
 4.3.5-AirPlay2-smi10-OpenSSL-Avahi-pw-soxr-metadata-mqtt-sysconfdir:/etc

Command Line:
 shairport-sync --displayConfig

Configuration File:
 /etc/shairport-sync.conf

Configuration File Settings:
 general : 
 {
   name = "The Kitchen";
   output_backend = "pw"; #i've tried with this line commented out as all i have is pw as an option and it shows pw (default)
 };
 sessioncontrol : 
 {
   allow_session_interruption = "yes";
 };
 pw : 
 {
 };

I use snapclient as my other protocol and that works still so i can get audio from there, but not from airplay. Any help would be greatly appreciated.

@mikebrady
Copy link
Owner Author

Thanks for the post. It could be that Shairport Sync is not properly closing the pipewire backend properly so that it can't reopen. Or something. If you could find a quick and reliable way to cause it to misbehave, it would be a big help!

@janstadt
Copy link

janstadt commented Feb 1, 2025

Thanks for creating an issue @mikebrady. I wasnt sure what your desired workflow was so i started with a discussion. Im not 100% certain how to reproduce the issue, but all of my devices are logging that message as well as a memory allocation issue:

Jan 29 17:08:49 lucys-room kernel: __vm_enough_memory: pid: 7641, comm: shairport-sync, not enough memory for the allocation

The devices are still for the most part performing, but there certainly is something happening with pipewire and shairport-sync. I'll take a look and see if i can come up with other ideas.

@janstadt
Copy link

janstadt commented Feb 2, 2025

× shairport-sync.service - Shairport Sync - AirPlay Audio Receiver
     Loaded: loaded (/home/tc/.config/systemd/user/shairport-sync.service; enabled; preset: enabled)
     Active: failed (Result: signal) since Sun 2025-02-02 10:18:50 CST; 2min 42s ago
   Duration: 1w 1d 22h 38min 28.355s
    Process: 540 ExecStart=/usr/local/bin/shairport-sync --log-to-syslog (code=killed, signal=KILL)
   Main PID: 540 (code=killed, signal=KILL)
        CPU: 8h 25min 2.629s

Jan 24 11:40:22 gretas-room systemd[522]: Started shairport-sync.service - Shairport Sync - AirPlay Audio Receiver.
Jan 24 15:19:06 gretas-room shairport-sync[540]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Jan 24 15:19:06 gretas-room shairport-sync[540]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Jan 24 15:19:06 gretas-room shairport-sync[540]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Jan 24 15:19:06 gretas-room shairport-sync[540]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:18:50 gretas-room systemd[522]: shairport-sync.service: Main process exited, code=killed, status=9/KILL
Feb 02 10:18:50 gretas-room systemd[522]: shairport-sync.service: Failed with result 'signal'.
Feb 02 10:18:50 gretas-room systemd[522]: shairport-sync.service: Consumed 8h 25min 2.629s CPU time.

Some additional information on another device with shairport that seems to have failed. Requires a restart in order for things to work. When i run systemctl --user restart shairport-sync.service i get:

tc@gretas-room:~ $ systemctl --user restart shairport-sync.service 
Failed to restart shairport-sync.service: Unit avahi-daemon.service not found.

Its running though (as a system level service albeit):

tc@gretas-room:~ $ sudo systemctl status avahi-daemon.service
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
     Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; preset: enabled)
     Active: active (running) since Fri 2025-01-24 11:40:18 CST; 1 week 1 day ago
TriggeredBy: ● avahi-daemon.socket
   Main PID: 351 (avahi-daemon)
     Status: "avahi-daemon 0.8 starting up."
      Tasks: 2 (limit: 179)
        CPU: 59min 52.803s
     CGroup: /system.slice/avahi-daemon.service
             ├─351 "avahi-daemon: running [gretas-room.local]"
             └─380 "avahi-daemon: chroot helper"

Jan 24 11:40:21 gretas-room avahi-daemon[351]: Joining mDNS multicast group on interface wlan0.IPv6 with address fe80::e794:efe3:181a:c33d.
Jan 24 11:40:21 gretas-room avahi-daemon[351]: New relevant interface wlan0.IPv6 for mDNS.
Jan 24 11:40:21 gretas-room avahi-daemon[351]: Registering new address record for fe80::e794:efe3:181a:c33d on wlan0.*.
Jan 24 11:40:21 gretas-room avahi-daemon[351]: Joining mDNS multicast group on interface wlan0.IPv4 with address 192.168.1.252.
Jan 24 11:40:21 gretas-room avahi-daemon[351]: New relevant interface wlan0.IPv4 for mDNS.
Jan 24 11:40:21 gretas-room avahi-daemon[351]: Registering new address record for 192.168.1.252 on wlan0.IPv4.
Jan 24 11:40:22 gretas-room avahi-daemon[351]: Leaving mDNS multicast group on interface wlan0.IPv6 with address fe80::e794:efe3:181a:c33d.
Jan 24 11:40:22 gretas-room avahi-daemon[351]: Joining mDNS multicast group on interface wlan0.IPv6 with address fdfa:1a1d:3f01:4948:966c:c3ea:2f34:6f0b.
Jan 24 11:40:22 gretas-room avahi-daemon[351]: Registering new address record for fdfa:1a1d:3f01:4948:966c:c3ea:2f34:6f0b on wlan0.*.
Jan 24 11:40:22 gretas-room avahi-daemon[351]: Withdrawing address record for fe80::e794:efe3:181a:c33d on wlan0.

The service

[Unit]
Description=Shairport Sync - AirPlay Audio Receiver
After=sound.target
Requires=avahi-daemon.service
After=avahi-daemon.service
Wants=network-online.target
After=network.target network-online.target

[Service]
ExecStart=/usr/local/bin/shairport-sync --log-to-syslog

[Install]
WantedBy=default.target

After the restart the audio works, but i get a bunch more "Is Pipewire running?" logs from shairport-sync:

Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?

Im sharing different devices here but they're all configured identically with regard to shairport-sync/pipewire/etc.

@mikebrady
Copy link
Owner Author

Thanks. I’m way from machines just now, so it’ll be a few days before I can experiment.

But is it at all possible that the pipewire service has actually disappeared?

@janstadt
Copy link

janstadt commented Feb 3, 2025

Thanks mike. it shows that its still running and enabled but there are errors:

tc@master-bedroom:~ $ systemctl --user status pipewire.service
● pipewire.service - PipeWire Multimedia Service
     Loaded: loaded (/usr/lib/systemd/user/pipewire.service; enabled; preset: enabled)
     Active: active (running) since Fri 2025-01-24 11:21:29 CST; 1 week 2 days ago
TriggeredBy: ● pipewire.socket
   Main PID: 541 (pipewire)
      Tasks: 3 (limit: 179)
        CPU: 3.090s
     CGroup: /user.slice/user-1000.slice/[email protected]/session.slice/pipewire.service
             └─541 /usr/bin/pipewire

Jan 24 11:21:29 master-bedroom systemd[525]: Started pipewire.service - PipeWire Multimedia Service.
Jan 25 21:48:17 master-bedroom pipewire[541]: pw.node: (alsa_output.usb-TTGK_Technology_Co._Ltd_CX31993_384Khz_HIFI_AUDIO-00.analog-stereo-70) graph xrun not-triggered (0 suppressed)
Jan 25 21:48:17 master-bedroom pipewire[541]: pw.node: (alsa_output.usb-TTGK_Technology_Co._Ltd_CX31993_384Khz_HIFI_AUDIO-00.analog-stereo-70) xrun state:0x7f90f06008 pending:1/2 s:124006418639829 a:124006418757849 f:124006418926911 waiting:118020 process:169062 status>
Jan 25 21:48:17 master-bedroom pipewire[541]: pw.node: (Shairport Sync-66) xrun state:0x7f914f2008 pending:0/1 s:124010267038183 a:124006418684933 f:124006418714932 waiting:18446744069861198366 process:29999 status:triggered

When i try to restart shairport-sync (which is running as a user service) I get this message even though avahi is there (running as a system service):

tc@master-bedroom:/usr/share/pipewire $ systemctl --user restart shairport-sync.service 
Failed to restart shairport-sync.service: Unit avahi-daemon.service not found.
tc@master-bedroom:/usr/share/pipewire $ sudo systemctl status avahi-daemon.service
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
     Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; preset: enabled)
     Active: active (running) since Fri 2025-01-24 11:21:24 CST; 1 week 2 days ago
TriggeredBy: ● avahi-daemon.socket
   Main PID: 376 (avahi-daemon)
     Status: "avahi-daemon 0.8 starting up."
      Tasks: 2 (limit: 179)
        CPU: 1h 2min 23.996s
     CGroup: /system.slice/avahi-daemon.service
             ├─376 "avahi-daemon: running [master-bedroom.local]"
             └─399 "avahi-daemon: chroot helper"

Jan 24 11:21:27 master-bedroom avahi-daemon[376]: Joining mDNS multicast group on interface wlan0.IPv6 with address fe80::ed30:4cd0:c8a6:ddf6.
Jan 24 11:21:27 master-bedroom avahi-daemon[376]: New relevant interface wlan0.IPv6 for mDNS.
Jan 24 11:21:27 master-bedroom avahi-daemon[376]: Registering new address record for fe80::ed30:4cd0:c8a6:ddf6 on wlan0.*.
Jan 24 11:21:27 master-bedroom avahi-daemon[376]: Joining mDNS multicast group on interface wlan0.IPv4 with address 192.168.1.218.
Jan 24 11:21:27 master-bedroom avahi-daemon[376]: New relevant interface wlan0.IPv4 for mDNS.
Jan 24 11:21:27 master-bedroom avahi-daemon[376]: Registering new address record for 192.168.1.218 on wlan0.IPv4.
Jan 24 11:21:29 master-bedroom avahi-daemon[376]: Leaving mDNS multicast group on interface wlan0.IPv6 with address fe80::ed30:4cd0:c8a6:ddf6.
Jan 24 11:21:29 master-bedroom avahi-daemon[376]: Joining mDNS multicast group on interface wlan0.IPv6 with address fdfa:1a1d:3f01:4948:891c:4686:5dca:67ed.
Jan 24 11:21:29 master-bedroom avahi-daemon[376]: Registering new address record for fdfa:1a1d:3f01:4948:891c:4686:5dca:67ed on wlan0.*.
Jan 24 11:21:29 master-bedroom avahi-daemon[376]: Withdrawing address record for fe80::ed30:4cd0:c8a6:ddf6 on wlan0.
tc@master-bedroom:/usr/share/pipewire $ 

Any ideas why that would happen?

@mikebrady
Copy link
Owner Author

Thanks for the information. I’m afraid I have no real suggestions about the Avahi messages until I get to experiment a bit.

@janstadt
Copy link

janstadt commented Feb 4, 2025

Unsure if this is at all helpful but here is the raspinfo dump: https://paste.debian.net/hidden/e1a9513a/

Just a reminder (and this is completely my bad btw) that i have included outputs from multiple devices so when you see lucys-room and master-bedroom, yes they are different devices, but they're configured identically (all except the-kitchen are running on pi zero w2 devices). Its kinda turning into wack-a-mole here with each device failing at random intervals. Apologies.

@mikebrady
Copy link
Owner Author

Thanks for that. I kind-of guessed that they were different machines alright, no worries.

@mikebrady
Copy link
Owner Author

mikebrady commented Feb 5, 2025

Just beginning to have a look at this. A quick play around with Shairport Sync using the PipeWire backend isn't yielding any particular problems. A few quick questions, please:

  1. You have snapclient running as well. Does that also output to PipeWire?
  2. Do your automations start and stop Shairport Sync or is it intended that it is left running all the time?
  3. [Updated] Is it the case that different AirPlay sources interrupt an existing AirPlay session to play their own stuff often?

@janstadt
Copy link

janstadt commented Feb 5, 2025

Hey @mikebrady. Snapclient is configured to output to PulseAudio but i believe pipewire controls pulse as well as alsa.

● snapclient.service - Snapcast client
     Loaded: loaded (/home/tc/.config/systemd/user/snapclient.service; enabled; preset: enabled)
     Active: active (running) since Fri 2025-01-24 11:29:34 CST; 1 week 4 days ago
       Docs: man:snapclient(1)
   Main PID: 549 (snapclient)
      Tasks: 2 (limit: 179)
        CPU: 27min 7.351s
     CGroup: /user.slice/user-1000.slice/[email protected]/app.slice/snapclient.service
             └─549 /usr/bin/snapclient --player pulse -h 192.168.1.68 --logsink=system

My automations dont toggle power to shairport-sync as far as i can tell and it should be left running all the time.

The session interruption is something that i configured but no, it shouldnt happen all that often. Are you thinking the combination of session interruption and pipewire is a potential culprit?

@mikebrady
Copy link
Owner Author

Thanks. I'm just trying to get a handle on the environment in which Shairport Sync is running...

@janstadt
Copy link

janstadt commented Feb 5, 2025

This guide: https://www.reddit.com/r/linux4noobs/comments/18yhs7r/success_story_using_a_raspberry_pi_with_pipewire/ is how i set up the devices. I have roughly 8 pi zero w2s, a pi 3b and a pi 4 and the 3b and 4 have a hifiberry dac while the pi zeros all have cheap usb dacs. The only difference in setup for each is that the config.txt file in pi os references my hifiberrydac-plus vs the pi zeros follow the guide settings. I replaced the settings for plexamp in the guide with snapclient but i dont seem to have issues with that install, just the shairport service.

@janstadt
Copy link

janstadt commented Feb 5, 2025

I documented my specific steps if that is of any help:

Install Raspberry Pi OS Lite

  • Edit the config.txt file.
    • before putting the sd card back in the device.
    • If you already installed the sd card, you can find the file at /boot/firmware/config.txt.
    • If installing on a device with a USB DAC, modify the following lines:
dtparam=audio=off
dtoverlay=vc4-kms-v3d,noaudio
  • If installing on a device with a DAC HAT, modify the following lines:
dtparam=audio=off
dtoverlay=hifiberry-dacplus  # aplay -L will tell you what your audio device is called.
sudo apt update && sudo apt upgrade -y

sudo apt install -y --no-install-recommends build-essential git autoconf automake libtool 
libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev 
libsoxr-dev libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev uuid- 
dev libgcrypt-dev xxd

sudo apt install -y jq libpipewire-0.3-dev libspa-0.2-bluetooth python3-dbus libdaemon-dev 
xmltoman pipewire wireplumber pipewire-alsa pipewire-pulse nodejs libmosquitto-dev
  • Ensure that the services are running. You may have to run systemctl --user enable pipewire.service as that one doesnt seem to be auto starting.

Install NQPTP

git clone https://github.com/mikebrady/nqptp.git
cd nqptp
autoreconf -fi
./configure --with-systemd-startup
make
sudo make install
sudo systemctl enable nqptp
sudo systemctl start nqptp

Install Shairport-Sync

git clone https://github.com/mikebrady/shairport-sync.git
cd shairport-sync
autoreconf -fi
./configure --sysconfdir=/etc --with-pw --with-mqtt-client \
    --with-soxr --with-avahi --with-ssl=openssl --with-systemd --with-airplay-2
make
sudo make install
sudo systemctl disable shairport-sync #disable the system level instance.
  • Create ~/.config/systemd/user/shairport-sync.service and place the following code in it:
[Unit]
Description=Shairport Sync - AirPlay Audio Receiver
After=sound.target
Requires=avahi-daemon.service
After=avahi-daemon.service
Wants=network-online.target
After=network.target network-online.target

[Service]
ExecStart=/usr/local/bin/shairport-sync --log-to-syslog

[Install]
WantedBy=default.target
  • Enable user level service: systemctl --user enable shairport-sync.service
  • Modify the /etc/shairport-sync.config file to your liking. Most notably change the Name of the device otherwise it will use the hostname.
  • Install SnapClient
    • https://github.com/badaix/snapcast/blob/develop/doc/install.md#debian to get latest version. You may also be able to install it via sudo apt install snapclient otherwise, find the file you downloaded to the device and install it sudo apt install snap.deb.
    • sudo systemctl disable snapclient.service
    • Create file `~/.config/systemd/user/snapclient.service' and put the following code in it:
[Unit]
Description=Snapcast client
Documentation=man:snapclient(1)
Wants=avahi-daemon.service
After=network-online.target time-sync.target sound.target avahi-daemon.service
 
[Service]
EnvironmentFile=/etc/default/snapclient
ExecStart=/usr/bin/snapclient --player pulse --logsink=system $SNAPCLIENT_OPTS
#User=snapclient
#Group=snapclient
Restart=on-failure
 
[Install]
WantedBy=default.target
 * `systemctl --user enable snapclient.service`

Configure Auto Login

  • Enable auto login inside sudo raspi-config > System Option > Boot / Auto Login > Console Autologin > Finish > Reboot

@mikebrady
Copy link
Owner Author

Thanks for all this.

One very slight thing is that the sequence of:

Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?
Feb 02 10:29:38 gretas-room shairport-sync[541]: warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?

is not significant, so long as it stops after a while (on a Pi 5, after about 20 repeats...). It's a byproduct of waiting for the PipeWire client to start working after Shairport Sync initialises it. We are probably just being a bit too impatient.

It doesn't move us forward though.

@janstadt
Copy link

janstadt commented Feb 5, 2025

Thats good to know. Curious if it should be dropped down to an info log or something? I do see it stopping on most devices so thats good. I also see a lot of memory allocation logs as well on some of the devices.

Feb 02 19:52:06 the-kitchen shairport-sync[581]: warning: dacp_id or dacp_server.dacp_id NULL detected
Feb 02 20:11:05 the-kitchen kernel: __vm_enough_memory: pid: 2197, comm: shairport-sync, not enough memory for the allocation
Feb 02 20:11:05 the-kitchen kernel: __vm_enough_memory: pid: 2197, comm: shairport-sync, not enough memory for the allocation
Feb 02 20:11:05 the-kitchen kernel: __vm_enough_memory: pid: 2197, comm: shairport-sync, not enough memory for the allocation
Feb 02 20:11:05 the-kitchen kernel: __vm_enough_memory: pid: 2197, comm: shairport-sync, not enough memory for the allocation
Feb 02 20:11:05 the-kitchen kernel: __vm_enough_memory: pid: 2197, comm: shairport-sync, not enough memory for the allocation
Feb 02 20:11:05 the-kitchen kernel: __vm_enough_memory: pid: 2197, comm: shairport-sync, not enough memory for the allocation
Feb 02 20:11:05 the-kitchen kernel: __vm_enough_memory: pid: 2197, comm: shairport-sync, not enough memory for the allocation
Feb 02 20:11:05 the-kitchen kernel: __vm_enough_memory: pid: 2197, comm: shairport-sync, not enough memory for the allocation
Feb 02 20:11:05 the-kitchen kernel: __vm_enough_memory: pid: 2197, comm: shairport-sync, not enough memory for the allocation
Feb 02 20:11:05 the-kitchen kernel: __vm_enough_memory: pid: 2197, comm: shairport-sync, not enough memory for the allocation
Feb 03 16:47:55 the-kitchen kernel: __vm_enough_memory: pid: 2851, comm: shairport-sync, not enough memory for the allocation
Feb 03 16:47:55 the-kitchen kernel: __vm_enough_memory: pid: 2851, comm: shairport-sync, not enough memory for the allocation
Feb 03 16:47:55 the-kitchen kernel: __vm_enough_memory: pid: 2851, comm: shairport-sync, not enough memory for the allocation
Feb 03 16:47:55 the-kitchen kernel: __vm_enough_memory: pid: 2851, comm: shairport-sync, not enough memory for the allocation
Feb 03 16:47:55 the-kitchen kernel: __vm_enough_memory: pid: 2851, comm: shairport-sync, not enough memory for the allocation
Feb 03 16:47:55 the-kitchen kernel: __vm_enough_memory: pid: 2851, comm: shairport-sync, not enough memory for the allocation
Feb 03 16:47:55 the-kitchen kernel: __vm_enough_memory: pid: 2851, comm: shairport-sync, not enough memory for the allocation
Feb 03 16:47:55 the-kitchen kernel: __vm_enough_memory: pid: 2851, comm: shairport-sync, not enough memory for the allocation
Feb 03 16:47:55 the-kitchen kernel: __vm_enough_memory: pid: 2851, comm: shairport-sync, not enough memory for the allocation
Feb 03 16:47:55 the-kitchen kernel: __vm_enough_memory: pid: 2851, comm: shairport-sync, not enough memory for the allocation
Feb 03 19:13:06 the-kitchen shairport-sync[581]: warning: dacp_id or dacp_server.dacp_id NULL detected
Feb 03 19:43:37 the-kitchen kernel: __vm_enough_memory: pid: 2931, comm: shairport-sync, not enough memory for the allocation
Feb 03 19:43:37 the-kitchen kernel: __vm_enough_memory: pid: 2931, comm: shairport-sync, not enough memory for the allocation
Feb 03 19:43:37 the-kitchen kernel: __vm_enough_memory: pid: 2931, comm: shairport-sync, not enough memory for the allocation
Feb 03 19:43:37 the-kitchen kernel: __vm_enough_memory: pid: 2931, comm: shairport-sync, not enough memory for the allocation
Feb 03 19:43:37 the-kitchen kernel: __vm_enough_memory: pid: 2931, comm: shairport-sync, not enough memory for the allocation
Feb 03 19:43:37 the-kitchen kernel: __vm_enough_memory: pid: 2931, comm: shairport-sync, not enough memory for the allocation
Feb 03 19:43:37 the-kitchen kernel: __vm_enough_memory: pid: 2931, comm: shairport-sync, not enough memory for the allocation
Feb 03 19:43:37 the-kitchen kernel: __vm_enough_memory: pid: 2931, comm: shairport-sync, not enough memory for the allocation
Feb 03 19:43:37 the-kitchen kernel: __vm_enough_memory: pid: 2931, comm: shairport-sync, not enough memory for the allocation
Feb 03 19:43:37 the-kitchen kernel: __vm_enough_memory: pid: 2931, comm: shairport-sync, not enough memory for the allocation

the-kitchen is a pi 3b . sorry for the huge log.

@mikebrady
Copy link
Owner Author

mikebrady commented Feb 5, 2025

Thanks. The log size is no problem. I see from the log above that the Process ID -- the pid -- of Shairport Sync is 581, and the __vm_enough_memory... error is for the process with a pid of 2851. Can you tell what process that is, please? Something like:

$ ps aux | grep 2851

might work...

@mikebrady
Copy link
Owner Author

In fact, there are a number of separate processes... It would be nice to see what's going on with them.

@janstadt
Copy link

janstadt commented Feb 5, 2025

tc 4252 0.0 0.2 6088 1920 pts/0 S+ 10:23 0:00 grep --color=auto 2851

I honestly had the same thoughts so i looked at htop and in tree view shairport-sync has a bunch of separate pids running:

Image

Is that expected? These arent the same pids from the logs though, but i wonder if i wait long enough to start seeing the memory logs that it might be those pids that show up? Could it be that every time i login via ssh, a new tc user is created and since its a user level service and i have it configured to autologin that its automatically creating a new instance of shairport-sync? These are all headless devices as of now, so i dont login outside of ssh'ing.

@mikebrady
Copy link
Owner Author

Yeah, the entries with numbers 581 -- 668 are fine; they are separate threads running in Shairport Sync, and that is indicated by the lines showing, e.g. 658 is subsidiary to 581, the main thread.

It's the processes that are generating the vm errors that are interesting. Are they disappearing?

@mikebrady
Copy link
Owner Author

I'd have to check about multiple instances, I just don't know, but I'd be surprised if new instances of shairport sync are created.

@mikebrady
Copy link
Owner Author

I'm wondering if there's something else running on your systems. A backup or some other utility software?

@janstadt
Copy link

janstadt commented Feb 5, 2025

I can look what the default pi os lite installs but the only things i've installed are the packages above in the installation guide i provided.

@mikebrady
Copy link
Owner Author

mikebrady commented Feb 5, 2025

Thanks -- there's no need to go digging.

Just one thing, in your guide you write:

./configure --sysconfdir=/etc --with-alsa \
    --with-soxr --with-avahi --with-ssl=openssl --with-systemd --with-airplay-2

That is, with the alsa backend, but not with the pipewire (pw) backend. It also looks like you have MQTT and metadata enabled. (?)

@janstadt
Copy link

janstadt commented Feb 5, 2025

Whoops. Yeah, that's a mistake. I replaced --with-alsa with --with-pw and added --with-metadata --with-mqtt-client. I'll update the comment. Question. What would happen if i passed in both --with-alsa --with-pw when building the binary? My intentions for using mqtt on here was to use the https://github.com/parautenbach/hass-shairport-sync/ HACS integration for homeassistant in a last ditch effort to remove music-assistant from my stack but it sounds like that integration has some issues with remote controlling shairport-sync.

@mikebrady
Copy link
Owner Author

Thanks. If you pass in both --with-alsa --with-pw then Shairport Sync will choose the alsa backend by default at startup. You'd need to add output_backend = "pw"; to choose the PipeWire backend at startup.

MQTT is fine -- the remote control problem is that recent versions of Apple Music do not respond to remote control requests coming from Shairport Sync because the protocols have changed in a way that we haven't figured out.

My initial tests aren't showing up any problems with Shairport Sync, so I'll have to build a system based on this and see what happens.

@janstadt
Copy link

janstadt commented Feb 6, 2025

Out of curiosity, what OS or installation do you typically run your shairport-sync on for raspberry pis? I initially ran picoreplayer for a long time wihtout much issues, but that was using squeezelite for most of my integrations (HASS/MASS). Installing shairport worked but there was issues with the device not switching between squeeze and airplay properly. Then i tried volumio, moode, etc all with the same outcome. I finally ended here with pipewire on pios lite so i can simultaneously play music from two different sources so i dont have to worry about losing any audio source based on what was playing first (snap/squeeze or airplay). My use case might be extremely unique but figure i'd ask.

@mikebrady
Copy link
Owner Author

mikebrady commented Feb 6, 2025

Good question!

My needs are simply for AirPlay 2, so I only install Shairport Sync -- no other audio apps. I'm always looking for the highest fidelity -- always trying to get the audio signal to the output device with the minimum of modification or alteration. Therefore, Raspberry Pi OS Lite is my go-to choice. I make no changes to /boot/firmware/config.txt except to add the overlays to drive HiFiBerry-compatible or IQaudIO DACs where necessary. I see no need to disable onboard audio or mess with video drivers; in fact, I try to leave everything as close to default as possible.

I always try to output directly to the output DAC, thus to a device beginning with hw:... or hdmi:... and try to avoid the default output and devices with names beginning with plug... because they typically include ALSA functionality that could potentially transcode or otherwise modify the output, which I really want to avoid.

PulseAudio and PipeWire can also transcode and indeed can delay audio, so I also try to avoid them. The extra complication of having to do a login is something else I'd prefer to avoid too. Having said that, I am very impressed with PipeWire lately -- it seems to be very stable as far as output delays are concerned.

I don't really have any need for remote control facilities -- nice if you can get it and use it, but not vital.

It's very nice to be able to incorporate the Shairport Sync device in the Apple Home; even though it's not great, it is possible to make use of it with Siri and so on.

So, summarising -- I'm a bit of a purist: plain vanilla Raspberry Pi OS Lite, minimally modified, with output directly to hardware ALSA DACs.

@mikebrady
Copy link
Owner Author

So, I did a setup based on your guide and that of Gwouigwoui you referenced above.

>> Display Config Start.

From "uname -a":
 Linux RaspberryPi3B 6.6.74+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.74-1+rpt1 (2025-01-27) aarch64 GNU/Linux

From /etc/os-release:
 Debian GNU/Linux 12 (bookworm)

From /sys/firmware/devicetree/base/model:
 Raspberry Pi 3 Model B Rev 1.2

Shairport Sync Version String:
 4.3.8-dev-2-ga19554a7-AirPlay2-smi10-OpenSSL-Avahi-pw-soxr-metadata-mqtt-sysconfdir:/etc

Command Line:
 ./shairport-sync --displayConfig

Configuration File:
 /etc/shairport-sync.conf

Configuration File Settings:
 pw : 
 {
 };

>> Display Config End.
>> Goodbye!

It is very interesting indeed -- thanks for bringing it to notice! I'm going to experiment some more and see what I can find. So far, though, everything seems to be behaving itself.

@janstadt
Copy link

janstadt commented Feb 7, 2025

Have you noticed anything in your logs like this:

__vm_enough_memory: pid: 7331, comm: shairport-sync, not enough memory for the allocation

I get this error a lot. It shows up in journalctl quite a bit but not in any of the shairport-sync logs. Whats odd is i dont see that process id when running ps aux or ps -e so i assume the process gets killed? I dont know enough about linux to know if this is relevant or not.

@mikebrady
Copy link
Owner Author

Hi Jake. Haven’t gotten it so far, but still experimenting.
I can’t help thinking that the vm… error is from some other program, but I don’t have anything to go on… 🤷‍♂️

@janstadt
Copy link

janstadt commented Feb 7, 2025

One thing im going to experiment is swapping out snapcast with squeezelite and see if that is more stable.

@mikebrady
Copy link
Owner Author

mikebrady commented Feb 8, 2025

I've been experimenting with your setup and have noticed that you're installing more than is apparently needed. The line in your comment above:

...
$ sudo apt install -y jq libpipewire-0.3-dev libspa-0.2-bluetooth python3-dbus libdaemon-dev 
xmltoman pipewire wireplumber pipewire-alsa pipewire-pulse nodejs libmosquitto-dev
...

is a bit puzzling. All I needed to add here was:

$ sudo apt install pipewire

to get all the PipeWire runtime stuff installed, including wireplumber. Then, to allow Shairport Sync to be built with PipeWire and MQTT support:

$ sudo apt install libpipewire-0.3-dev libmosquitto-dev

In particular, I don't see any need for nodejs and, since it's a runtime environment for JavaScript programs, I wonder if it is the cause of these vm... "storms".

This is a screenshot of everything that is running on the Pi 3, including SnapClient, NQPTP and Shairport Sync.

Image

This is the Shairport Sync user service file at ~/.config/systemd/user/shairport-sync.service:

[Unit]
Description=Shairport Sync - AirPlay Audio Receiver
After=sound.target

[Service]
ExecStart=/usr/local/bin/shairport-sync --log-to-syslog

[Install]
WantedBy=default.target

@janstadt
Copy link

janstadt commented Feb 8, 2025

Oooooh, very interesting. My main installs were copied from the reddit article and that user wanted plexamp and bluetooth as options so i wonder if all the other stuff is unnecessary for my use case? I'll give it a try.

@mikebrady
Copy link
Owner Author

Exactly -- TBH I just don't know if it'll make a difference, but if you don't need them, it would be good to be rid of them. At least it'll make it easier to debug. 🤷‍♂️

@mikebrady
Copy link
Owner Author

I'm running this system now for a few hours. Nothing to report, except lots of this:

Feb 08 16:52:23 RaspberryPi3B snapclient[591]: (Browser) CACHE_EXHAUSTED
Feb 08 16:52:24 RaspberryPi3B snapclient[584]: (Browser) CACHE_EXHAUSTED
Feb 08 16:52:24 RaspberryPi3B snapclient[591]: (Browser) CACHE_EXHAUSTED
Feb 08 16:52:25 RaspberryPi3B snapclient[584]: (Browser) CACHE_EXHAUSTED
Feb 08 16:52:25 RaspberryPi3B snapclient[591]: (Browser) CACHE_EXHAUSTED
Feb 08 16:52:26 RaspberryPi3B snapclient[584]: (Browser) CACHE_EXHAUSTED
Feb 08 16:52:26 RaspberryPi3B snapclient[591]: (Browser) CACHE_EXHAUSTED

I think I will disable it.

@janstadt
Copy link

janstadt commented Feb 9, 2025

So far so good on my installs, as well as squeezelite. Do you think that perhaps the timing error we saw earlier is due to the fact that NQPTP is running as a system level service instead of at the user level or does that not make a difference?

@mikebrady
Copy link
Owner Author

mikebrady commented Feb 9, 2025

Yeah, me too. It's been running -- playing a radio station from an app called Broadcast on a macOS -- for about 16 hours continuously and is absolutely fine. I've even played sounds over them with:

$ pw-cat -p /usr/share/sounds/alsa/Front_Left.wav

many times, and everything is fine.

If by timing errors you mean these:

warning: Shairport Sync's PipeWire backend can not get timing information from the PipeWire system. Is PipeWire running?

then they mean nothing when they occur at the start of a play -- they are an artefact of the debugger and will be removed in an update.

... NQPTP is running as a system level service instead of at the user level or does that not make a difference?

NQPTP needs access to ports 319 and 320. If it didn't have that, it would terminate. Then Shairport Sync would terminate with an error message in the log. So, if Shairport Sync continues to run, it means that NQPTP is okay.

@mikebrady
Copy link
Owner Author

Just wondering if things are still okay? It's just fine here...

@janstadt
Copy link

Yeah for the most part things are working as expected. One final question for you wrt shairport. Is there an optimal setting that would allow the audio to start immediately? I have noticed that if i send audio to a speaker from HASS or music assistant that sometimes the first part of the audio is clipped. This certainly could be my amp auto starting slower (although i've never had this issue with squeeze), or HASS/MASS misbehaving, but i figure i'd ask if there was a setting in the configs that might make it so that there isnt any latency when sending audio to shairpot speakers.

@mikebrady
Copy link
Owner Author

Yeah for the most part things are working as expected.

That's good!

Is there an optimal setting that would allow the audio to start immediately?

The run_this_before_entering_active_state hook (see the sample configuration file for more) is called as soon as an intent to play is detected, even before audio starts arriving. In AirPlay 2, that may be half a second or a bit less before audio starts playing. In classic AirPlay it could be around two seconds. Unfortunately, there is no earlier indication coming from the audio source.

@janstadt
Copy link

Ok thanks. Figured i'd check! Thanks again for all the help! I'll close this out as i think things are looking good. Oh, it shows that i dont have permissions to close the issue out so feel free to close it @mikebrady. Thanks again.

@mikebrady
Copy link
Owner Author

Great stuff, thanks.

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

No branches or pull requests

2 participants