summaryrefslogtreecommitdiffstats
path: root/abs/mv-core/oss-sound/rc.oss-linux-free
blob: 48b65e044ea3493c8a63af6e3f5036ad9a3acf8a (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash

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

terminateapps() {
    # Thanks to the Gentoo ebuild/start script for the following
    # http://bugs.gentoo.org/show_bug.cgi?id=184123
    # http://bugs.gentoo.org/attachment.cgi?id=153689
    devs=`perl -e '{while (<>) {m/^(\S*)/; print "/dev/$1\n"}}' \
		< /proc/opensound/devfiles`
    fuser -k ${devs}  >/dev/null 2>/dev/null
}

case "$1" in
  start)
    stat_busy "Starting OSS/Open source driver"
    # start
    /usr/sbin/soundon
    if [ $? -gt 0 ]; then
      stat_fail
    else
      grep '^softoss' /proc/modules >/dev/null 2>/dev/null
      if [ $? -eq 0 ]; then
        stat_busy "Replacing old \"softoss\" module with \"vmix\""
        rmmod softoss
        modprobe vmix
        sed -i 's/^softoss.*$/vmix/' /usr/lib/oss/etc/installed_drivers
      fi
      add_daemon oss-linux-free
      stat_done
    fi
    ;;
  stop)
    stat_busy "Saving OSS mixer"
    /usr/sbin/savemixer
    if [ $? -gt 0 ]; then
      stat_fail
    else
      stat_done
    fi
    grep '^"cuckoo"' /proc/modules >/dev/null 2>/dev/null
    if [ $? -eq 0 ]; then
      stat_busy "Removing \"cuckoo\" module"
      rmmod cuckoo
    fi
    stat_busy "Killing processes using OSS"
    terminateapps
    stat_done
    # It doesn't matter if it didnt kill anything!
    stat_busy "Stopping OSS/Open source driver"
    /usr/sbin/soundoff
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon oss-linux-free
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  terminateapps)
    stat_busy "Killing processes using OSS"
    terminateapps
    stat_done
    # It doesn't matter if it didnt kill anything!
  ;;
  *)
    echo "usage: $0 {start|stop|restart|terminateapps}"
esac