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/arch/i386/pci/auglx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'sys/arch') diff --git a/sys/arch/i386/pci/auglx.c b/sys/arch/i386/pci/auglx.c index c42bcec981d..c72587da196 100644 --- a/sys/arch/i386/pci/auglx.c +++ b/sys/arch/i386/pci/auglx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auglx.c,v 1.2 2008/07/09 02:47:03 brad Exp $ */ +/* $OpenBSD: auglx.c,v 1.3 2008/10/25 22:30:43 jakemsr Exp $ */ /* * Copyright (c) 2008 Marc Balmer @@ -575,6 +575,10 @@ auglx_set_params(void *v, int setmode, int usemode, struct audio_params *play, if (setmode & AUMODE_PLAY) { play->factor = 1; play->sw_code = NULL; + if (play->precision > 16) + play->precision = 16; + if (play->channels > 2) + play->channels = 2; switch(play->encoding) { case AUDIO_ENCODING_ULAW: switch (play->channels) { @@ -766,6 +770,10 @@ auglx_set_params(void *v, int setmode, int usemode, struct audio_params *play, if (setmode & AUMODE_RECORD) { rec->factor = 1; rec->sw_code = 0; + if (rec->precision > 16) + rec->precision = 16; + if (rec->channels > 2) + rec->channels = 2; switch(rec->encoding) { case AUDIO_ENCODING_ULAW: switch (rec->channels) { -- cgit v1.2.3