source: src-qt4/xtrafiles/local/share/pcbsd/scripts/sound-dev-changed.sh @ 1620346

9.1-release9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3
Last change on this file since 1620346 was 1620346, checked in by Kris Moore <kris@…>, 18 months ago

Initial import of PC-BSD /current/ SVN repo

  • Property mode set to 100755
File size: 1.6 KB
Line 
1#!/bin/sh
2
3# Action can be add / del
4action=$1
5cdev=$2
6
7regen_ossconf()
8{
9PCM_OSS_CONF_DIR=/compat/linux/etc/alsa/pcm/
10PCM_OSS_CONF=${PCM_OSS_CONF_DIR}pcm-oss.conf
11
12if [ ! -d $PCM_OSS_CONF_DIR ]; then
13  return
14fi
15
16PCM=`egrep -o 'pcm[0-9]+' /dev/sndstat | egrep -o '[0-9]+'`
17OSSCONF=`cat <<EOF
18# pcm-oss plugin configuration
19# generated by ${0}
20
21pcm.oss {
22        type oss
23        device /dev/dsp
24        hint {
25                description "Open Sound System"
26        }
27}
28
29ctl.oss {
30        type oss
31        device /dev/mixer
32        hint {
33                description "Open Sound System"
34        }
35}
36EOF`
37
38for NUM in $PCM; do
39  UNIT_DESC=`sysctl -in dev.pcm.${NUM}.%desc`
40 
41  OSSCONF_UNITS=${OSSCONF_UNITS}`cat <<EOF
42
43 
44pcm.oss${NUM} {
45        type oss
46        device /dev/dsp${NUM}
47        hint {
48                description "oss${NUM}: ${UNIT_DESC}"
49        }
50}
51
52ctl.oss${NUM} {
53        type oss
54        device /dev/mixer${NUM}
55        hint {
56                description "oss${NUM}: ${UNIT_DESC}"
57        }
58}
59EOF`
60done
61
62echo "${OSSCONF}${OSSCONF_UNITS}" > $PCM_OSS_CONF
63}
64
65set_new_dev()
66{
67   # Dont keep changing the device at bootup, wait until after the system loads before enabling this
68   ps -axoargs | grep -q "^/usr/libexec/getty "
69   if [ $? -ne 0 ] ; then
70      return
71   fi
72
73   mixerNum=`echo ${cdev} | egrep -o '[0-9]+'`
74
75   # Can new dev play?
76   cat /dev/sndstat | grep pcm${mixerNum} | grep -q play
77   if [ $? -ne 0 ] ; then
78      return
79   fi
80
81   # make new device the default one
82   sysctl hw.snd.default_unit=$mixerNum
83
84}
85
86# Update device based upon action
87case $action in
88   add) set_new_dev ;;
89     *) ;;
90esac
91
92# Re-Create the linux OSS conf
93regen_ossconf
94
95exit 0
Note: See TracBrowser for help on using the repository browser.