shairport-sync: stop MPD before playing
authorHugo Villeneuve <hugo@hugovil.com>
Fri, 1 Mar 2024 04:41:14 +0000 (23:41 -0500)
committerHugo Villeneuve <hugo@hugovil.com>
Tue, 28 May 2024 19:00:29 +0000 (15:00 -0400)
recipes-multimedia/shairport-sync/files/mpc-stop.sh [new file with mode: 0644]
recipes-multimedia/shairport-sync/shairport-sync_git.bb

diff --git a/recipes-multimedia/shairport-sync/files/mpc-stop.sh b/recipes-multimedia/shairport-sync/files/mpc-stop.sh
new file mode 100644 (file)
index 0000000..03fa34c
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# This script is used by shairport-sync to stop MPD
+# before starting a new playback session, so that it can
+# access the sound card.
+
+mpc stop
index 9b3d826..9c104dd 100644 (file)
@@ -9,6 +9,7 @@ SRC_URI = "git://github.com/mikebrady/shairport-sync;protocol=https;branch=${SRC
 SRC_URI += " \
     file://0001-yocto-disable-user-group-creation.patch \
     file://shairport-sync.conf.in \
+    file://mpc-stop.sh \
 "
 
 S = "${WORKDIR}/git"
@@ -34,6 +35,13 @@ do_install:append() {
         ${WORKDIR}/shairport-sync.conf.in > ${WORKDIR}/shairport-sync.conf
     install -d ${D}${sysconfdir}/
     install -m 0644 ${WORKDIR}/shairport-sync.conf ${D}${sysconfdir}/
+
+    # Modify shairport-sync start arguments to always stop MPD before playing:
+    sed -i -e "s@^\(ExecStart=.*\)@\1 -w --on-start=${bindir}/mpc-stop.sh@g" \
+        ${D}${systemd_unitdir}/system/shairport-sync.service
+
+    install -d ${D}${bindir}
+    install -m 0755 ${WORKDIR}/mpc-stop.sh ${D}${bindir}
 }
 
 SYSTEMD_SERVICE:${PN} = " \