mixer revision 240336
178344Sobrien#!/bin/sh - 278344Sobrien# 398184Sgordon# Copyright (c) 2004 The FreeBSD Project 478344Sobrien# All rights reserved. 578344Sobrien# 678344Sobrien# Redistribution and use in source and binary forms, with or without 778344Sobrien# modification, are permitted provided that the following conditions 8136224Smtm# are met: 978344Sobrien# 1. Redistributions of source code must retain the above copyright 1078344Sobrien# notice, this list of conditions and the following disclaimer. 1178344Sobrien# 2. Redistributions in binary form must reproduce the above copyright 1278344Sobrien# notice, this list of conditions and the following disclaimer in the 1378344Sobrien# documentation and/or other materials provided with the distribution. 1478344Sobrien# 1578344Sobrien# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1678344Sobrien# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1778344Sobrien# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1898184Sgordon# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1978344Sobrien# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20126862Skientzle# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21126862Skientzle# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2278344Sobrien# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2378344Sobrien# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2478344Sobrien# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2578344Sobrien# SUCH DAMAGE. 26179945Smtm# 27124618Smtm# $FreeBSD: head/etc/rc.d/mixer 240336 2012-09-11 05:04:59Z obrien $ 28124618Smtm# 29124618Smtm 3098184Sgordon# PROVIDE: mixer 31124618Smtm# REQUIRE: FILESYSTEMS 3298184Sgordon# KEYWORD: nojail shutdown 3378344Sobrien 3478344Sobrien. /etc/rc.subr 3578344Sobrien 3678344Sobrienname="mixer" 3778344Sobrienrcvar="mixer_enable" 3878344Sobrienstop_cmd="mixer_stop" 3978344Sobrienstart_cmd="mixer_start" 4078344Sobrienreload_cmd="mixer_start" 4178344Sobrienextra_commands="reload" 4278344Sobrien 4378344Sobrien# 4478344Sobrien# List current mixer devices to stdout. 4578344Sobrien# 4698184Sgordonlist_mixers() 47193944Savg{ 48193944Savg ( cd /dev ; ls mixer* 2>/dev/null ) 4998184Sgordon} 5098184Sgordon 5198184Sgordon# 5298184Sgordon# Save state of an individual mixer specified as $1 5398184Sgordon# 5498184Sgordonmixer_save() 5598184Sgordon{ 5698184Sgordon local dev 5798184Sgordon 5898184Sgordon dev="/dev/${1}" 5998184Sgordon if [ -r ${dev} ]; then 6098184Sgordon /usr/sbin/mixer -f ${dev} -s > /var/db/${1}-state 2>/dev/null 6198184Sgordon fi 6278344Sobrien} 6378344Sobrien 6478344Sobrien# 6578344Sobrien# Restore the state of an individual mixer specified as $1 6678344Sobrien# 6778344Sobrienmixer_restore() 6878344Sobrien{ 6978344Sobrien local file dev 7078344Sobrien 7178344Sobrien dev="/dev/${1}" 7278344Sobrien file="/var/db/${1}-state" 7378344Sobrien if [ -r ${dev} -a -r ${file} ]; then 7478344Sobrien /usr/sbin/mixer -f ${dev} `cat ${file}` > /dev/null 7578344Sobrien fi 7678344Sobrien} 7778344Sobrien 7878344Sobrien# 79# Restore state of all mixers 80# 81mixer_start() 82{ 83 local mixer 84 85 for mixer in `list_mixers`; do 86 mixer_restore ${mixer} 87 done 88} 89 90# 91# Save the state of all mixers 92# 93mixer_stop() 94{ 95 local mixer 96 97 for mixer in `list_mixers`; do 98 mixer_save ${mixer} 99 done 100} 101 102load_rc_config $name 103run_rc_command "$1" 104