Date: Fri, 8 Feb 2008 10:02:02 GMT From: Aragon Gouveia <aragon@phat.za.net> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/120406: Handling newly attached pcm devices (eg. via uaudio) Message-ID: <200802081002.m18A22ip016467@www.freebsd.org> Resent-Message-ID: <200802081010.m18AA0Hh069355@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 120406 >Category: misc >Synopsis: Handling newly attached pcm devices (eg. via uaudio) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Feb 08 10:10:00 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Aragon Gouveia >Release: 7.0-RC1 >Organization: >Environment: FreeBSD geek.pcs.intranet 7.0-RC1 FreeBSD 7.0-RC1 #0: Wed Jan 16 17:07:28 SAST 2008 root@geek.pcs.intranet:/usr/obj/usr/src/sys/GEEK i386 >Description: On my FreeBSD workstations I frequently use a USB sound device (headphone amplifier). I typically plug it in and out only when I need it, and expect (or hope!) for my system to use it when it's plugged in, but use the onboard sound when it is unplugged. On FreeBSD 7 I used to set hw.snd.default_unit to 1 (from 0) after plugging the device in and then set the mixer levels to how I want them. I've subsequently automated this ala devd and a shell script to do precisely the same thing, except the shell script also calls /etc/rc.d/mixer to restore the saved mixer settings in /var/db. I would like to PR my work in the hope of someone committing it as I think it might be useful to others. I've included a devd.conf addition and an rc script for inclusion to /etc/rc.d. The rc script only works if pcm_defaulthot is set to YES in /etc/rc.conf, and I would say it should be set to NO by default. >How-To-Repeat: >Fix: devd.conf entry: attach 100 { device-name "pcm[0-9]+"; action "/etc/rc.d/pcm start $device-name"; }; Patch attached with submission follows: #!/bin/sh # # PROVIDE: pcm # REQUIRE: DAEMON cleanvar # KEYWORD: nojail . /etc/rc.subr name=pcm rcvar="pcm_defaulthot" start_cmd="pcm_start" load_rc_config $name pcm_start() { local pcm_unit pcm_unit=${pcm_device#pcm} if [ "${pcm_unit}" -ge 0 ]; then sysctl -w hw.snd.default_unit=${pcm_unit} /etc/rc.d/mixer start mixer${pcm_unit} fi } if [ -n "$2" ]; then pcm_device=$2 run_rc_command $* fi >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802081002.m18A22ip016467>