mixer revision 127370
164562Sgshapiro#!/bin/sh - 264562Sgshapiro# 364562Sgshapiro# Copyright (c) 2004 The FreeBSD Project 464562Sgshapiro# All rights reserved. 564562Sgshapiro# 664562Sgshapiro# Redistribution and use in source and binary forms, with or without 764562Sgshapiro# modification, are permitted provided that the following conditions 864562Sgshapiro# are met: 964562Sgshapiro# 1. Redistributions of source code must retain the above copyright 1064562Sgshapiro# notice, this list of conditions and the following disclaimer. 1164562Sgshapiro# 2. Redistributions in binary form must reproduce the above copyright 1264562Sgshapiro# notice, this list of conditions and the following disclaimer in the 1364562Sgshapiro# documentation and/or other materials provided with the distribution. 1464562Sgshapiro# 1564562Sgshapiro# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1664562Sgshapiro# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1764562Sgshapiro# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1864562Sgshapiro# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1964562Sgshapiro# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2064562Sgshapiro# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2164562Sgshapiro# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2264562Sgshapiro# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2364562Sgshapiro# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2464562Sgshapiro# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2564562Sgshapiro# SUCH DAMAGE. 2664562Sgshapiro# 2764562Sgshapiro# $FreeBSD: head/etc/rc.d/mixer 127370 2004-03-24 12:49:34Z pjd $ 2864562Sgshapiro# 2964562Sgshapiro 3064562Sgshapiro# PROVIDE: mixer 3164562Sgshapiro# REQUIRE: LOGIN usbd 3264562Sgshapiro# KEYWORD: FreeBSD nojail 3364562Sgshapiro 3464562Sgshapiro. /etc/rc.subr 3564562Sgshapiro 3664562Sgshapironame="mixer" 3764562Sgshapirostop_cmd="mixer_stop" 3864562Sgshapirostart_cmd="mixer_start" 3964562Sgshapiroreload_cmd="mixer_start" 4064562Sgshapiroextra_commands="reload" 4164562Sgshapiro 4264562Sgshapiro# 4364562Sgshapiro# List current mixer devices to stdout. 4464562Sgshapiro# 4564562Sgshapirolist_mixers() 4664562Sgshapiro{ 4773188Sgshapiro 4873188Sgshapiro ( cd /dev ; ls mixer* 2>/dev/null ) 4973188Sgshapiro} 5073188Sgshapiro 5164562Sgshapiro# 5273188Sgshapiro# Echo state file name for an individual mixer ($1) to stdout 5364562Sgshapiro# 5464562Sgshapiromixer_statefile() 5564562Sgshapiro{ 5664562Sgshapiro echo "/var/db/${1}-state" 5764562Sgshapiro} 5864562Sgshapiro 5964562Sgshapiro# 6064562Sgshapiro# Save state of an individual mixer specified as $1 6164562Sgshapiro# 6264562Sgshapiromixer_save() 6364562Sgshapiro{ 6464562Sgshapiro local file dev 6564562Sgshapiro 6664562Sgshapiro dev="/dev/${1}" 6764562Sgshapiro file=`mixer_statefile $1` 6864562Sgshapiro if [ -r ${dev} ]; then 6964562Sgshapiro /usr/sbin/mixer -f ${dev} -s > ${file} 2>/dev/null 7064562Sgshapiro fi 7164562Sgshapiro} 7264562Sgshapiro 7364562Sgshapiro# 7464562Sgshapiro# Restore the state of an individual mixer specified as $1 7564562Sgshapiro# 7664562Sgshapiromixer_restore() 7764562Sgshapiro{ 7864562Sgshapiro local file dev 7966494Sgshapiro 8066494Sgshapiro dev="/dev/${1}" 8166494Sgshapiro file=`mixer_statefile $1` 8264562Sgshapiro if [ -r ${dev} -a -r ${file} ]; then 8364562Sgshapiro /usr/sbin/mixer -f ${dev} `cat ${file}` > /dev/null 8464562Sgshapiro fi 8564562Sgshapiro} 8664562Sgshapiro 8764562Sgshapiro# 8864562Sgshapiro# Restore state of all mixers 8964562Sgshapiro# 9064562Sgshapiromixer_start() 9164562Sgshapiro{ 9264562Sgshapiro local mixer 9364562Sgshapiro 9464562Sgshapiro for mixer in `list_mixers`; do 9564562Sgshapiro mixer_restore ${mixer} 9664562Sgshapiro done 9764562Sgshapiro} 9864562Sgshapiro 9966494Sgshapiro# 10066494Sgshapiro# Save the state of all mixers 10164562Sgshapiro# 10266494Sgshapiromixer_stop() 10366494Sgshapiro{ 10466494Sgshapiro local mixer 10566494Sgshapiro 10666494Sgshapiro for mixer in `list_mixers`; do 10766494Sgshapiro mixer_save ${mixer} 10866494Sgshapiro done 10966494Sgshapiro} 11066494Sgshapiro 11164562Sgshapiroload_rc_config $name 11264562Sgshapirorun_rc_command "$1" 11364562Sgshapiro