Subject: Let prinfo.{play,record}.{gain,ports} get the right mixers
To: None <tech-kern@netbsd.org>
From: Frederick Bruckman <fredb@immanent.net>
List: tech-kern
Date: 01/25/2003 16:06:04
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--0-67442996-1043532364=:395
Content-Type: TEXT/PLAIN; charset=US-ASCII

Hi,

Here's a fix for PR's kern/10221 and kern/17159. The problem is, the
simplified audio interface to the mixer controls hasn't been right for
a long time: With the eso device, for example, "audioctl -w
record.gain" does the same as "mixerctl -w inputs.mic", when it should
be doing the equivalent of "mixerctl -w record.mic"; "audioctl -w
play.gain" doesn't appear to work at all with *any* audio device since
1.4Y.

So, for the "play" case, this patch makes sc_outports->master the
identical mixer to mixerctl's "outputs.master", and the port selector,
sc_outports->ports, identical to "outputs.select". The latter can only
work on the eap device (not tested), but for all other devices, it'll
fall back to sc_outports->master, so setting info.play.gain for
AUDIOSETINFO(&info) will work again. For the "record" case, the
selector remains "record.source", and master "record.record", but we
now pass the class into au_portof(), so we can properly distinguish
the record mixers from the input mixers.

I've tested this only with the eso device, on 1.6_STABLE. The
"mplayer" keyboard shortcuts can now adjust the volume for the
unmodified "sun" audio output driver. For the record test, I tried
"cdplay play; audiorecord ... -p cd ...", and it seems to have the
desired effect. [The audiorecord man page has a wrong description
of -p, by the way, that looks like it was pasted from audoplay's.]

Oddly, "mixerctl -w record.cd=N" doesn't actually affect the final
result, but then again, neither does "inputs.cd". "mixerctl -w
record.record=N" does work. I think it would be nice to allow
"audioctl -w record.ports=0x0" to at least indicate the
sc_outports->master should be used to adjust "record.gain", or
even better, maybe activate the recording mixer so that adjusting
"record.{cd,line,mic}" actually combines inputs at varying levels,
but that would require changes to the underlying drivers (and may
be no more than wishful thinking).

What do you think?

Frederick

--0-67442996-1043532364=:395
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="audio-1.6M.diff"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.NEB.4.44.0301251606040.395@tautology.immanent.net>
Content-Description: 
Content-Disposition: attachment; filename="audio-1.6M.diff"

SW5kZXg6IGF1ZGlvLmMNCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NClJDUyBm
aWxlOiAvY3Zzcm9vdC9zcmMvc3lzL2Rldi9hdWRpby5jLHYNCnJldHJpZXZp
bmcgcmV2aXNpb24gMS4xNzINCmRpZmYgLXUgLXIxLjE3MiBhdWRpby5jDQot
LS0gYXVkaW8uYwkyMDAzLzAxLzAxIDAwOjEwOjE1CTEuMTcyDQorKysgYXVk
aW8uYwkyMDAzLzAxLzI1IDIxOjAxOjMzDQpAQCAtMTgwLDcgKzE4MCw3IEBA
DQogCQkJICAgICBpbnQgKiwgaW50ICpyKTsNCiBpbnQJYXVfc2V0X2xyX3Zh
bHVlKHN0cnVjdCBhdWRpb19zb2Z0YyAqLCBtaXhlcl9jdHJsX3QgKiwNCiAJ
CQkgICAgIGludCwgaW50KTsNCi1pbnQJYXVfcG9ydG9mKHN0cnVjdCBhdWRp
b19zb2Z0YyAqLCBjaGFyICopOw0KK2ludAlhdV9wb3J0b2Yoc3RydWN0IGF1
ZGlvX3NvZnRjICosIGNoYXIgKiwgaW50KTsNCiANCiBkZXZfdHlwZV9vcGVu
KGF1ZGlvb3Blbik7DQogZGV2X3R5cGVfY2xvc2UoYXVkaW9jbG9zZSk7DQpA
QCAtMzE1LDEwICszMTUsMTAgQEANCiAJCQlicmVhazsNCiAJCWlmIChtaS50
eXBlID09IEFVRElPX01JWEVSX0NMQVNTICYmDQogCQkgICAgc3RyY21wKG1p
LmxhYmVsLm5hbWUsIEF1ZGlvQ3JlY29yZCkgPT0gMCkNCi0JCQlpY2xhc3Mg
PSBtaS5pbmRleDsNCisJCQlpY2xhc3MgPSBtaS5taXhlcl9jbGFzczsNCiAJ
CWlmIChtaS50eXBlID09IEFVRElPX01JWEVSX0NMQVNTICYm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