summaryrefslogtreecommitdiff
path: root/extra/ossp/osspd.rc.d
blob: 78d7602ae0015b32e9a05955909a4973a7f79b26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/osspd


if [[ -z "$DSP_SLAVE" ]]; then
  # Autodetect
  if [[ -x /usr/bin/pulseaudio ]]; then
    DSP_SLAVE="/usr/sbin/ossp-padsp"
  else
    DSP_SLAVE="/usr/sbin/ossp-alsap"
  fi
fi

preclaim_oss=/sys/module/soundcore/parameters/preclaim_oss

PID=`pidof -o %PPID /usr/sbin/osspd`
case "$1" in
  start)
    stat_busy "Starting OSS userspace bridge"
    if [ -z "$PID" ]; then 
      if [[ -r $preclaim_oss && "$(cat $preclaim_oss)" -eq 1 ]]; then
        echo "Must boot with soundcore.preclaim_oss=0"
        stat_die
      fi
      modprobe cuse &>/dev/null
      modprobe -r snd-pcm-oss snd-mixer-oss &>/dev/null
      sleep 0.1
      /usr/sbin/osspd --dsp-slave="$DSP_SLAVE"
    fi
    if [ -n "$PID" -o $? -gt 0 ]; then
      stat_fail
    else
      add_daemon osspd
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping OSS userspace bridge"
    [ -n "$PID" ] && kill $PID &>/dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon osspd
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac

# vim:set ft=sh: