#!/bin/sh /etc/rc.common
# Copyright (C) 2011 OpenWrt.org

START=65
STOP=65

USE_PROCD=1
PROG=/usr/bin/pulseaudio

start_service() {
	[ -d /var/run/pulse ] || {
		mkdir -m 0755 -p /var/run/pulse
		chmod 0750 /var/run/pulse
		chown pulse:pulse /var/run/pulse
	}
	[ -d /var/lib/pulse ] || {
		mkdir -m 0755 -p /var/lib/pulse
		chmod 0750 /var/lib/pulse
		chown pulse:pulse /var/lib/pulse
	}

	chown root:pulse /dev/snd/* /dev/mixer /dev/dsp
	chmod 664 /dev/snd/* /dev/mixer /dev/dsp

	procd_open_instance
	procd_set_param command $PROG --system --disallow-exit --disallow-module-loading --disable-shm --exit-idle-time=-1 --realtime=false
	procd_close_instance
}

