From owner-freebsd-bugs@FreeBSD.ORG Fri Feb 8 10:10:00 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D1C8E16A468 for ; Fri, 8 Feb 2008 10:10:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B42AA13C474 for ; Fri, 8 Feb 2008 10:10:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m18AA0h4069356 for ; Fri, 8 Feb 2008 10:10:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m18AA0Hh069355; Fri, 8 Feb 2008 10:10:00 GMT (envelope-from gnats) Resent-Date: Fri, 8 Feb 2008 10:10:00 GMT Resent-Message-Id: <200802081010.m18AA0Hh069355@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Aragon Gouveia Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C076D16A418 for ; Fri, 8 Feb 2008 10:04:09 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id B2A0013C455 for ; Fri, 8 Feb 2008 10:04:09 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m18A239W016468 for ; Fri, 8 Feb 2008 10:02:03 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m18A22ip016467; Fri, 8 Feb 2008 10:02:02 GMT (envelope-from nobody) Message-Id: <200802081002.m18A22ip016467@www.freebsd.org> Date: Fri, 8 Feb 2008 10:02:02 GMT From: Aragon Gouveia To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/120406: Handling newly attached pcm devices (eg. via uaudio) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Feb 2008 10:10:00 -0000 >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: