Module Name:    src
Committed By:   martin
Date:           Tue Nov 19 11:01:27 UTC 2019

Modified Files:
        src/lib/libossaudio [netbsd-9]: ossaudio.c
        src/sys/compat/ossaudio [netbsd-9]: ossaudio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #446):
        lib/libossaudio/ossaudio.c: revision 1.37
        lib/libossaudio/ossaudio.c: revision 1.38
        sys/compat/ossaudio/ossaudio.c: revision 1.77
        sys/compat/ossaudio/ossaudio.c: revision 1.78
Use record.sample_rate for recording on SNDCTL_DSP_SPEED.
Fix PR lib/54667.
Use record.sample_rate for recording on SNDCTL_DSP_SPEED.
It's kernel side of PR lib/54667.
Use record field for recording even on
SNDCTL_DSP_STEREO, SNDCTL_DSP_SETFMT, and SNDCTL_DSP_CHANNELS.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.36.2.1 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.74.4.1 -r1.74.4.2 src/sys/compat/ossaudio/ossaudio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libossaudio/ossaudio.c
diff -u src/lib/libossaudio/ossaudio.c:1.36 src/lib/libossaudio/ossaudio.c:1.36.2.1
--- src/lib/libossaudio/ossaudio.c:1.36	Sat Feb  2 04:52:16 2019
+++ src/lib/libossaudio/ossaudio.c	Tue Nov 19 11:01:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.36 2019/02/02 04:52:16 isaki Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.36.2.1 2019/11/19 11:01:27 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: ossaudio.c,v 1.36 2019/02/02 04:52:16 isaki Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.36.2.1 2019/11/19 11:01:27 martin Exp $");
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -57,6 +57,10 @@ __RCSID("$NetBSD: ossaudio.c,v 1.36 2019
 #define TO_OSSVOL(x)	(((x) * 100 + 127) / 255)
 #define FROM_OSSVOL(x)	((((x) > 100 ? 100 : (x)) * 255 + 50) / 100)
 
+#define GETPRINFO(info, name)	\
+	(((info)->mode == AUMODE_RECORD) \
+	    ? (info)->record.name : (info)->play.name)
+
 static struct audiodevinfo *getdevinfo(int);
 
 static void setblocksize(int, struct audio_info *);
@@ -104,6 +108,8 @@ audio_ioctl(int fd, unsigned long com, v
 	char version[32] = "4.01";
 	char license[16] = "NetBSD";
 	u_int u;
+	u_int encoding;
+	u_int precision;
 	int idat, idata;
 	int retval;
 	int i;
@@ -134,7 +140,7 @@ audio_ioctl(int fd, unsigned long com, v
 		retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo);
 		if (retval < 0)
 			return retval;
-		INTARG = tmpinfo.play.sample_rate;
+		INTARG = GETPRINFO(&tmpinfo, sample_rate);
 		break;
 	case SNDCTL_DSP_STEREO:
 		AUDIO_INITINFO(&tmpinfo);
@@ -144,7 +150,7 @@ audio_ioctl(int fd, unsigned long com, v
 		retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo);
 		if (retval < 0)
 			return retval;
-		INTARG = tmpinfo.play.channels - 1;
+		INTARG = GETPRINFO(&tmpinfo, channels) - 1;
 		break;
 	case SNDCTL_DSP_GETBLKSIZE:
 		retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo);
@@ -243,7 +249,9 @@ audio_ioctl(int fd, unsigned long com, v
 		retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo);
 		if (retval < 0)
 			return retval;
-		switch (tmpinfo.play.encoding) {
+		encoding = GETPRINFO(&tmpinfo, encoding);
+		precision = GETPRINFO(&tmpinfo, precision);
+		switch (encoding) {
 		case AUDIO_ENCODING_ULAW:
 			idat = AFMT_MU_LAW;
 			break;
@@ -251,33 +259,33 @@ audio_ioctl(int fd, unsigned long com, v
 			idat = AFMT_A_LAW;
 			break;
 		case AUDIO_ENCODING_SLINEAR_LE:
-			if (tmpinfo.play.precision == 32)
+			if (precision == 32)
 				idat = AFMT_S32_LE;
-			else if (tmpinfo.play.precision == 24)
+			else if (precision == 24)
 				idat = AFMT_S24_LE;
-			else if (tmpinfo.play.precision == 16)
+			else if (precision == 16)
 				idat = AFMT_S16_LE;
 			else
 				idat = AFMT_S8;
 			break;
 		case AUDIO_ENCODING_SLINEAR_BE:
-			if (tmpinfo.play.precision == 32)
+			if (precision == 32)
 				idat = AFMT_S32_BE;
-			else if (tmpinfo.play.precision == 24)
+			else if (precision == 24)
 				idat = AFMT_S24_BE;
-			else if (tmpinfo.play.precision == 16)
+			else if (precision == 16)
 				idat = AFMT_S16_BE;
 			else
 				idat = AFMT_S8;
 			break;
 		case AUDIO_ENCODING_ULINEAR_LE:
-			if (tmpinfo.play.precision == 16)
+			if (precision == 16)
 				idat = AFMT_U16_LE;
 			else
 				idat = AFMT_U8;
 			break;
 		case AUDIO_ENCODING_ULINEAR_BE:
-			if (tmpinfo.play.precision == 16)
+			if (precision == 16)
 				idat = AFMT_U16_BE;
 			else
 				idat = AFMT_U8;
@@ -303,7 +311,7 @@ audio_ioctl(int fd, unsigned long com, v
 		retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo);
 		if (retval < 0)
 			return retval;
-		INTARG = tmpinfo.play.channels;
+		INTARG = GETPRINFO(&tmpinfo, channels);
 		break;
 	case SOUND_PCM_WRITE_FILTER:
 	case SOUND_PCM_READ_FILTER:

Index: src/sys/compat/ossaudio/ossaudio.c
diff -u src/sys/compat/ossaudio/ossaudio.c:1.74.4.1 src/sys/compat/ossaudio/ossaudio.c:1.74.4.2
--- src/sys/compat/ossaudio/ossaudio.c:1.74.4.1	Fri Sep 13 06:25:26 2019
+++ src/sys/compat/ossaudio/ossaudio.c	Tue Nov 19 11:01:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.74.4.1 2019/09/13 06:25:26 martin Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.74.4.2 2019/11/19 11:01:27 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.74.4.1 2019/09/13 06:25:26 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.74.4.2 2019/11/19 11:01:27 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -59,6 +59,10 @@ int ossdebug = 0;
 #define TO_OSSVOL(x)	(((x) * 100 + 127) / 255)
 #define FROM_OSSVOL(x)	((((x) > 100 ? 100 : (x)) * 255 + 50) / 100)
 
+#define GETPRINFO(info, name)	\
+	(((info)->mode == AUMODE_RECORD) \
+	    ? (info)->record.name : (info)->play.name)
+
 static struct audiodevinfo *getdevinfo(file_t *);
 static int opaque_to_enum(struct audiodevinfo *di, audio_mixer_name_t *label, int opq);
 static int enum_to_ord(struct audiodevinfo *di, int enm);
@@ -177,6 +181,8 @@ oss_ioctl_audio(struct lwp *l, const str
 	struct oss_count_info cntinfo;
 	struct audio_encoding tmpenc;
 	u_int u;
+	u_int encoding;
+	u_int precision;
 	int idat, idata;
 	int error = 0;
 	int (*ioctlf)(file_t *, u_long, void *);
@@ -238,7 +244,7 @@ oss_ioctl_audio(struct lwp *l, const str
 			 __func__, error));
 			goto out;
 		}
-		idat = tmpinfo.play.sample_rate;
+		idat = GETPRINFO(&tmpinfo, sample_rate);
 		DPRINTF(("%s: SNDCTL_PCM_READ_RATE < %d\n", __func__, idat));
 		error = copyout(&idat, SCARG(uap, data), sizeof idat);
 		if (error) {
@@ -269,7 +275,7 @@ oss_ioctl_audio(struct lwp *l, const str
 			     __func__, error));
 			goto out;
 		}
-		idat = tmpinfo.play.channels - 1;
+		idat = GETPRINFO(&tmpinfo, channels) - 1;
 		error = copyout(&idat, SCARG(uap, data), sizeof idat);
 		if (error) {
 			DPRINTF(("%s: SNDCTL_DSP_STEREO %d = %d\n",
@@ -380,7 +386,9 @@ oss_ioctl_audio(struct lwp *l, const str
 			     __func__, error));
 			goto out;
 		}
-		switch (tmpinfo.play.encoding) {
+		encoding = GETPRINFO(&tmpinfo, encoding);
+		precision = GETPRINFO(&tmpinfo, precision);
+		switch (encoding) {
 		case AUDIO_ENCODING_ULAW:
 			idat = OSS_AFMT_MU_LAW;
 			break;
@@ -388,25 +396,25 @@ oss_ioctl_audio(struct lwp *l, const str
 			idat = OSS_AFMT_A_LAW;
 			break;
 		case AUDIO_ENCODING_SLINEAR_LE:
-			if (tmpinfo.play.precision == 16)
+			if (precision == 16)
 				idat = OSS_AFMT_S16_LE;
 			else
 				idat = OSS_AFMT_S8;
 			break;
 		case AUDIO_ENCODING_SLINEAR_BE:
-			if (tmpinfo.play.precision == 16)
+			if (precision == 16)
 				idat = OSS_AFMT_S16_BE;
 			else
 				idat = OSS_AFMT_S8;
 			break;
 		case AUDIO_ENCODING_ULINEAR_LE:
-			if (tmpinfo.play.precision == 16)
+			if (precision == 16)
 				idat = OSS_AFMT_U16_LE;
 			else
 				idat = OSS_AFMT_U8;
 			break;
 		case AUDIO_ENCODING_ULINEAR_BE:
-			if (tmpinfo.play.precision == 16)
+			if (precision == 16)
 				idat = OSS_AFMT_U16_BE;
 			else
 				idat = OSS_AFMT_U8;
@@ -457,7 +465,7 @@ oss_ioctl_audio(struct lwp *l, const str
 			     __func__, error));
 			goto out;
 		}
-		idat = tmpinfo.play.channels;
+		idat = GETPRINFO(&tmpinfo, channels);
 		DPRINTF(("%s: SOUND_PCM_READ_CHANNELS < %d\n", __func__, idat));
 		error = copyout(&idat, SCARG(uap, data), sizeof idat);
 		if (error) {

Reply via email to