add daemon mode support to pulseaudio
authorJeremy Rosen <jeremy.rosen@openwide.fr>
Fri, 3 May 2013 02:35:22 +0000 (02:35 +0000)
committerPeter Korsgaard <jacmet@sunsite.dk>
Sat, 4 May 2013 15:16:20 +0000 (17:16 +0200)
pulseaudio documentation recommends not using the daemon mode unless you
are on a headless system, but since that is the common case for a
buildroot installation, install the related user and groups

[Peter: fix typos, ifeq check, unconditionally install into target]
Signed-off-by: Jérémy Rosen <jeremy.rosen@openwide.fr>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
package/multimedia/pulseaudio/Config.in
package/multimedia/pulseaudio/S50pulseaudio [new file with mode: 0755]
package/multimedia/pulseaudio/pulseaudio.mk

index 03c26137e52eae811b41cda73d328bf99f725529..9a6911e0ed0fb2da1d9fa7467a4d5600608c4183 100644 (file)
@@ -19,5 +19,13 @@ config BR2_PACKAGE_PULSEAUDIO
 
          http://pulseaudio.org
 
+config BR2_PACKAGE_PULSEAUDIO_DAEMON
+       bool "start as a system daemon"
+       depends on BR2_PACKAGE_PULSEAUDIO
+       help
+         PulseAudio can be started as a system daemon. This is not the
+         recommended way of using PulseAudio unless you are building a
+         headless system.
+
 comment "pulseaudio requires a toolchain with WCHAR, LARGEFILE and threads support"
        depends on !BR2_USE_WCHAR || !BR2_LARGEFILE || !BR2_TOOLCHAIN_HAS_THREADS
diff --git a/package/multimedia/pulseaudio/S50pulseaudio b/package/multimedia/pulseaudio/S50pulseaudio
new file mode 100755 (executable)
index 0000000..4c6877e
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# Starts pulseaudio.
+#
+
+
+start() {
+       echo -n "Starting pulseaudio: "
+       umask 077
+       /usr/bin/pulseaudio --system --daemonize
+       echo "OK"
+}
+stop() {
+       echo -n "Stopping pulseaudio: "
+       pulseaudio --kill
+       echo "OK"
+}
+restart() {
+       stop
+       start
+}
+
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  restart|reload)
+       restart
+       ;;
+  *)
+       echo "Usage: $0 {start|stop|restart}"
+       exit 1
+esac
+
+exit $?
+
index e78eb42ba6ffe071f42f9376a1616a99ac5a17ea..16df855557cd39357c437aa5a70013deeb806581 100644 (file)
@@ -84,4 +84,16 @@ endef
 PULSEAUDIO_POST_INSTALL_TARGET_HOOKS += PULSEAUDIO_REMOVE_VALA
 endif
 
+ifeq ($(BR2_PACKAGE_PULSEAUDIO_DAEMON),y)
+define PULSEAUDIO_USERS
+       pulse -1 pulse -1 * /var/run/pulse - audio,pulse-access
+endef
+
+define PULSEAUDIO_INSTALL_INIT_SYSV
+       $(INSTALL) -D -m 755 package/multimedia/pulseaudio/S50pulseaudio \
+               $(TARGET_DIR)/etc/init.d/S50pulseaudio
+endef
+
+endif
+
 $(eval $(autotools-package))