Changeset View
Changeset View
Standalone View
Standalone View
libexec/rc/rc.d/virtual_oss
- This file was added.
| #!/bin/sh | ||||||||||
| # PROVIDE: virtual_oss | ||||||||||
| # REQUIRE: kld ldconfig | ||||||||||
| # BEFORE: LOGIN sndiod | ||||||||||
| # KEYWORD: shutdown | ||||||||||
christos: Not really sure how to handle this either. This is only relevant if we have sndio support built. | ||||||||||
| . /etc/rc.subr | ||||||||||
| name="virtual_oss" | ||||||||||
| desc="Virtual OSS device manager" | ||||||||||
| rcvar="${name}_enable" | ||||||||||
| command="$(sysctl -n user.localbase)/sbin/${name}" | ||||||||||
| command_args="-B" | ||||||||||
Done Inline ActionsUse $(sysctl -n user.localbase) here instead. arrowd: Use `$(sysctl -n user.localbase)` here instead. | ||||||||||
| load_rc_config $name | ||||||||||
| start_precmd="${name}_precmd" | ||||||||||
| start_cmd="${name}_start" | ||||||||||
| stop_cmd="${name}_stop" | ||||||||||
| status_cmd="${name}_status" | ||||||||||
| configs= | ||||||||||
| pidpath="/var/run/${name}" | ||||||||||
| virtual_oss_default_args="\ | ||||||||||
| -S \ | ||||||||||
| -C 2 \ | ||||||||||
| -c 2 \ | ||||||||||
| -r 48000 \ | ||||||||||
| -b 24 \ | ||||||||||
| -s 8ms \ | ||||||||||
| -i 8 \ | ||||||||||
| -f /dev/dsp \ | ||||||||||
| -d dsp \ | ||||||||||
| -t vdsp.ctl" | ||||||||||
| # Set to NO by default. Set it to "YES" to enable virtual_oss. | ||||||||||
| : ${virtual_oss_enable:="NO"} | ||||||||||
| # List of configurations to use. Default is "dsp". | ||||||||||
| : ${virtual_oss_configs:="dsp"} | ||||||||||
| # Default (dsp) virtual_oss config. | ||||||||||
| : ${virtual_oss_dsp:="$virtual_oss_default_args"} | ||||||||||
| : ${virtual_oss_delay:=1} | ||||||||||
| virtual_oss() | ||||||||||
| { | ||||||||||
| # When running early we need to pre-load some libraries | ||||||||||
| env LD_PRELOAD=%%LIBFFTW3%% %%PREFIX%%/sbin/virtual_oss $* | ||||||||||
| } | ||||||||||
Done Inline ActionsDitto, but for virtual_equalizer support. christos: Ditto, but for virtual_equalizer support. | ||||||||||
| virtual_oss_pids() | ||||||||||
| { | ||||||||||
| pids=$(pgrep -d ' ' $name) | ||||||||||
| pids=${pids% } | ||||||||||
| printf "${pids}" | ||||||||||
| } | ||||||||||
| virtual_oss_precmd() | ||||||||||
| { | ||||||||||
| /usr/bin/install -d -m 0755 -o root ${pidpath} | ||||||||||
| load_kld cuse | ||||||||||
| } | ||||||||||
| start_instance() | ||||||||||
| { | ||||||||||
Done Inline Actions
This could be "$1" 0mp: This could be "$1" | ||||||||||
| config=$* | ||||||||||
| instance_args=$(eval "echo \$virtual_oss_${config}") | ||||||||||
| if [ -z "${instance_args}" ]; then | ||||||||||
Done Inline ActionsIt's better to one of the logging functions here like warn(). 0mp: It's better to one of the logging functions here like `warn()`. | ||||||||||
| echo "No such config ${config}" | ||||||||||
| else | ||||||||||
Done Inline ActionsWould be better to use startmsg here. This way the user has a way to mute those. 0mp: Would be better to use startmsg here. This way the user has a way to mute those. | ||||||||||
| echo -n "Starting Virtual OSS config ${config} ..." | ||||||||||
| ${command} \ | ||||||||||
| ${command_args} \ | ||||||||||
| -D ${pidpath}/${config}.pid \ | ||||||||||
| ${instance_args} | ||||||||||
| echo " done" | ||||||||||
| fi | ||||||||||
| } | ||||||||||
| stop_instance() | ||||||||||
| { | ||||||||||
| config=$* | ||||||||||
| instance_args=`eval "echo \$virtual_oss_${config}"` | ||||||||||
| if [ -z "${instance_args}" ]; then | ||||||||||
| echo "No such config ${config}" | ||||||||||
| else | ||||||||||
| echo -n "Stopping Virtual OSS config ${config} ... " | ||||||||||
| kill $(cat "${pidpath}/${config}.pid") | ||||||||||
| rm -f ${pidpath}/${config}.pid | ||||||||||
| echo "done" | ||||||||||
| fi | ||||||||||
| } | ||||||||||
| virtual_oss_start() | ||||||||||
| { | ||||||||||
| configs=$* | ||||||||||
| [ -z "${configs}" ] && configs="${virtual_oss_configs}" | ||||||||||
| for config in ${configs}; do | ||||||||||
| start_instance $config | ||||||||||
| sleep ${virtual_oss_delay} | ||||||||||
| done | ||||||||||
| } | ||||||||||
| virtual_oss_stop() | ||||||||||
| { | ||||||||||
| configs=$* | ||||||||||
| [ -z "${configs}" ] && configs="${virtual_oss_configs}" | ||||||||||
| for config in ${configs}; do | ||||||||||
| stop_instance ${config} | ||||||||||
| sleep ${virtual_oss_delay} | ||||||||||
| done | ||||||||||
| } | ||||||||||
| virtual_oss_status() | ||||||||||
| { | ||||||||||
| pids=$(virtual_oss_pids) | ||||||||||
| if [ "${pids}" ]; then | ||||||||||
| echo "${name} is running as pid ${pids}." | ||||||||||
| else | ||||||||||
| echo "${name} is not running." | ||||||||||
| return 1 | ||||||||||
| fi | ||||||||||
| } | ||||||||||
| run_rc_command $* | ||||||||||
Not really sure how to handle this either. This is only relevant if we have sndio support built.