NetBSD Problem Report #17446
Received: (qmail 464 invoked by uid 605); 30 Jun 2002 21:09:26 -0000
Message-Id: <20020630210930.2172111122@www.netbsd.org>
Date: Sun, 30 Jun 2002 14:09:30 -0700 (PDT)
From: christianbiere@gmx.de
Sender: gnats-bugs-owner@netbsd.org
Reply-To: christianbiere@gmx.de
To: gnats-bugs@gnats.netbsd.org
Subject: cmpci: audioctl -w play.channels=3 distorts or mutes sound
X-Send-Pr-Version: www-1.0
>Number: 17446
>Category: kern
>Synopsis: cmpci: audioctl -w play.channels=3 distorts or mutes sound
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: jmcneill
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jun 30 21:10:00 +0000 2002
>Closed-Date: Wed Nov 01 06:45:34 +0000 2006
>Last-Modified: Wed Nov 01 06:45:34 +0000 2006
>Originator: Christian Biere
>Release: 1.6A
>Organization:
>Environment:
NetBSD localhost 1.6A NetBSD 1.6A (DURON) #0: Wed Jun 26 19:03:57 CEST 2002
root@localhost:/usr/src/sys/arch/i386/compile/DURON i386
>Description:
If I use an invalid number of channels with audioctl -w play.channels=x the sound becomes distorted or muted. IMO an invalid setting should have no effect at all.
>How-To-Repeat:
Start some audio application. mpg123 or whatever.
$ audioctl -w play.channels=4
audioctl: set failed: Invalid argument
There's no sound anymore.
$ audioctl -w play.channels=2
play.channels: -> 2
There's still no sound. I have to restart the application which uses /dev/audio.
>Fix:
In cmpci.c, I see nothing wrong with this:
switch ( p->channels ) {
case 1:
md_format = CMPCI_REG_FORMAT_MONO;
break;
case 2:
md_format = CMPCI_REG_FORMAT_STEREO;
break;
default:
return (EINVAL);
}
Therefore (if I'm correct), the problem must be elsewhere.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: netbsd-admin->kern-bug-people
Responsible-Changed-By: martin
Responsible-Changed-When: Sun Jun 30 15:12:15 PDT 2002
Responsible-Changed-Why:
This is no admin problem.
Furthermore, please provide some dmesg output describing your sound hardware.
From: Christian Biere <christianbiere@gmx.de>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/17446: cmpci: audioctl -w play.channels=3 distorts or mutes sound
Date: Tue, 2 Jul 2002 21:36:19 +0200
Sorry,
this belongs to category kern, of course. I've forgotten to change it
and admin is the default. Here the missing device information from
dmesg:
cmpci0 at pci0 dev 15 function 0: vendor 0x13f6 product 0x0111 (rev.
0x10)
cmpci0: interrupting at irq 5
audio0 at cmpci0: full duplex, mmap, independent
opl at cmpci0 not configured
mpu at cmpci0 not configured
This means
vendor: C-Media Electronics Inc
product: CMI8738/C3DX PCI Audio Device
Christian
From: Christian Biere <christianbiere@gmx.de>
To: gnats-bugs@gnats.netbsd.org
Cc:
Subject: Re: kern/17446: cmpci: audioctl -w play.channels=3 distorts or
mutes sound
Date: Sat, 15 Nov 2003 02:12:49 +0100
This is a multi-part message in MIME format.
--Multipart=_Sat__15_Nov_2003_02_12_49_+0100_.NX2Xoe7CCqUD1Lo
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
I've found the problem and it concerns all audio drivers. In
sys/dev/pci/audio.c audiosetinfo() calls audio_clear() and if
the new parameters cannot be applied audiosetinfo() returns without
renabling play (or record) mode. I've tried to fix this and it
works so far. See my patch for details. However, someone should
verify the patch before applying it.
[Besides, it's a little ulgy that the audio drivers don't provide a function
which checks whether the parameters can be accepted or not. With such a
function audio_clear() wouldn't be necessary and there wouldn't be a
noteable pause during "audioctl -w play.channels=3".]
--Multipart=_Sat__15_Nov_2003_02_12_49_+0100_.NX2Xoe7CCqUD1Lo
Content-Type: text/plain;
name="audio.c.udif"
Content-Disposition: attachment;
filename="audio.c.udif"
Content-Transfer-Encoding: 7bit
Index: audio.c
===================================================================
RCS file: /cvsroot/src/sys/dev/audio.c,v
retrieving revision 1.181
diff -u -r1.181 audio.c
--- audio.c 2003/10/02 07:15:20 1.181
+++ audio.c 2003/11/15 00:31:01
@@ -2896,6 +2896,9 @@
sc->sc_mode &= ~AUMODE_RECORD;
}
+ oldpblksize = sc->sc_pr.blksize;
+ oldrblksize = sc->sc_rr.blksize;
+
if (modechange) {
int orig_p_channels, orig_p_rate;
int orig_r_channels, orig_r_rate;
@@ -2917,7 +2920,7 @@
error = hw->set_params(sc->hw_hdl, setmode,
sc->sc_mode & (AUMODE_PLAY | AUMODE_RECORD), &pp, &rp);
if (error)
- return (error);
+ goto cleanup;
if (np) {
if (orig_p_channels != pp.channels)
@@ -2926,7 +2929,7 @@
pp.hw_sample_rate = pp.sample_rate;
error = auconv_check_params(&pp);
if (error)
- return (error);
+ goto cleanup;
}
if (nr) {
if (orig_r_channels != rp.channels)
@@ -2935,7 +2938,7 @@
rp.hw_sample_rate = rp.sample_rate;
error = auconv_check_params(&rp);
if (error)
- return (error);
+ goto cleanup;
}
if (!indep) {
@@ -2976,7 +2979,7 @@
}
error = au_set_port(sc, &sc->sc_outports, p->port);
if (error)
- return(error);
+ goto cleanup;
}
if (r->port != ~0) {
if (!cleared) {
@@ -2985,32 +2988,32 @@
}
error = au_set_port(sc, &sc->sc_inports, r->port);
if (error)
- return(error);
+ goto cleanup;
}
if (p->gain != ~0) {
au_get_gain(sc, &sc->sc_outports, &gain, &balance);
error = au_set_gain(sc, &sc->sc_outports, p->gain, balance);
if (error)
- return(error);
+ goto cleanup;
}
if (r->gain != ~0) {
au_get_gain(sc, &sc->sc_inports, &gain, &balance);
error = au_set_gain(sc, &sc->sc_inports, r->gain, balance);
if (error)
- return(error);
+ goto cleanup;
}
if (p->balance != (u_char)~0) {
au_get_gain(sc, &sc->sc_outports, &gain, &balance);
error = au_set_gain(sc, &sc->sc_outports, gain, p->balance);
if (error)
- return(error);
+ goto cleanup;
}
if (r->balance != (u_char)~0) {
au_get_gain(sc, &sc->sc_inports, &gain, &balance);
error = au_set_gain(sc, &sc->sc_inports, gain, r->balance);
if (error)
- return(error);
+ goto cleanup;
}
if (ai->monitor_gain != ~0 &&
@@ -3023,7 +3026,7 @@
ct.un.value.level[AUDIO_MIXER_LEVEL_MONO] = ai->monitor_gain;
error = sc->hw_if->set_port(sc->hw_hdl, &ct);
if (error)
- return(error);
+ goto cleanup;
}
if (p->pause != (u_char)~0) {
@@ -3033,7 +3036,7 @@
error = audiostartp(sc);
splx(s);
if (error)
- return error;
+ goto cleanup;
}
}
if (r->pause != (u_char)~0) {
@@ -3044,7 +3047,7 @@
error = audiostartr(sc);
splx(s);
if (error)
- return error;
+ goto cleanup;
}
}
@@ -3074,9 +3077,11 @@
if (hw->commit_settings) {
error = hw->commit_settings(sc->hw_hdl);
if (error)
- return (error);
+ goto cleanup;
}
+cleanup:
+
if (cleared) {
s = splaudio();
error = audio_initbufs(sc);
@@ -3118,7 +3123,7 @@
sc->sc_pr.usedhigh - sc->sc_pr.blksize;
}
- return (0);
+ return error;
}
int
--Multipart=_Sat__15_Nov_2003_02_12_49_+0100_.NX2Xoe7CCqUD1Lo--
Responsible-Changed-From-To: kern-bug-people->jmcneill
Responsible-Changed-By: jmcneill@netbsd.org
Responsible-Changed-When: Mon, 24 Apr 2006 09:25:29 +0000
Responsible-Changed-Why:
I'll take this one.
State-Changed-From-To: open->closed
State-Changed-By: cbiere@netbsd.org
State-Changed-When: Wed, 01 Nov 2006 06:45:34 +0000
State-Changed-Why:
I committed an updated patch to restore the settings on error.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.