summaryrefslogtreecommitdiff
path: root/setup/FreeBSD/sbin/soundoff
blob: 7cb4962aa88f5d4d1de2e236b11af3c0295bd97b (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
#!/bin/sh

if test -f /etc/oss.conf
then
  . /etc/oss.conf
else
  OSSLIBDIR=/usr/lib/oss
fi

if ! /sbin/kldstat | grep -q osscore.ko
then
  echo OSS not loaded.
  exit 0
fi

if ! test -f $OSSLIBDIR/etc/installed_drivers
then
	echo $OSSLIBDIR/etc/installed_drivers is missing.
	exit 1
fi

# Save mixer settings automatically if requested
if test -f $OSSLIBDIR/etc/userdefs && grep -q "autosave_mixer yes" $OSSLIBDIR/etc/userdefs
then
	/usr/sbin/savemixer 
fi

# Save legacy devices
/usr/sbin/ossdevlinks -N

PROGRAMS="`fstat /dev/mixer* /dev/dsp* /dev/midi* /dev/oss/*/* 2>/dev/null | sed '1 D'`"

if test "$PROGRAMS " != " "
then
  echo
  echo Some applications are still using OSS - cannot unload
  echo

  fstat /dev/mixer* /dev/dsp* /dev/midi* /dev/oss/*/* 2>/dev/null

  echo
  echo Please stop these applications and run soundoff again
  exit 2
fi

for n in `cat $OSSLIBDIR/etc/installed_drivers | sed 's/#.*//'`
do
    /sbin/kldunload $n > /dev/null 2>&1
done

/sbin/kldunload osscore

if ! /sbin/kldstat | grep -q osscore.ko # OSS gone?
then
  exit 0
fi

echo Cannot unload the OSS driver modules

exit 0