From fe8114f730e5473eba5ee55c81c541e29edbeea8 Mon Sep 17 00:00:00 2001 From: Jacob Meuser Date: Sat, 25 Oct 2008 22:30:44 +0000 Subject: audio(9) says low level drivers are allowed to change the requested values of the audio_params structure during AUDIO_SETINFO if the hardware cannot be set to exactly the requested mode. some drivers do this sometimes. others always return EINVAL if there isn't an exact match. be more consistent. only return EINVAL if an absurd parameter was requested, otherwise return a supported set of parameters, as close as possible to what was requested. with/ok ratchov@ --- sys/dev/pci/auixp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sys/dev/pci/auixp.c') diff --git a/sys/dev/pci/auixp.c b/sys/dev/pci/auixp.c index 9304863aca2..5fda4e24b1f 100644 --- a/sys/dev/pci/auixp.c +++ b/sys/dev/pci/auixp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auixp.c,v 1.21 2008/09/24 19:09:05 chl Exp $ */ +/* $OpenBSD: auixp.c,v 1.22 2008/10/25 22:30:43 jakemsr Exp $ */ /* $NetBSD: auixp.c,v 1.9 2005/06/27 21:13:09 thorpej Exp $ */ /* @@ -377,6 +377,10 @@ auixp_set_params(void *hdl, int setmode, int usemode, if (setmode & AUMODE_PLAY) { play->factor = 1; play->sw_code = NULL; + if (play->channels > 2) + play->channels = 2; + if (play->precision > 16) + play->precision = 16; switch(play->encoding) { case AUDIO_ENCODING_ULAW: switch (play->channels) { @@ -561,9 +565,13 @@ auixp_set_params(void *hdl, int setmode, int usemode, } - if (setmode & AUMODE_RECORD) { + if (setmode & AUMODE_RECORD) { rec->factor = 1; rec->sw_code = 0; + if (rec->channels > 2) + rec->channels = 2; + if (rec->precision > 16) + rec->precision = 16; switch(rec->encoding) { case AUDIO_ENCODING_ULAW: rec->sw_code = ulinear8_to_mulaw; -- cgit v1.2.3