Module Name: src
Committed By: isaki
Date: Sun Nov 3 11:13:46 UTC 2019
Modified Files:
src/lib/libossaudio: ossaudio.c
src/sys/compat/ossaudio: ossaudio.c
Log Message:
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.37 -r1.38 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.77 -r1.78 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.37 src/lib/libossaudio/ossaudio.c:1.38
--- src/lib/libossaudio/ossaudio.c:1.37 Sat Nov 2 11:48:23 2019
+++ src/lib/libossaudio/ossaudio.c Sun Nov 3 11:13:45 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ossaudio.c,v 1.37 2019/11/02 11:48:23 isaki Exp $ */
+/* $NetBSD: ossaudio.c,v 1.38 2019/11/03 11:13:45 isaki Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: ossaudio.c,v 1.37 2019/11/02 11:48:23 isaki Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.38 2019/11/03 11:13:45 isaki Exp $");
/*
* This is an OSS (Linux) sound API emulator.
@@ -57,6 +57,10 @@ __RCSID("$NetBSD: ossaudio.c,v 1.37 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,10 +140,7 @@ audio_ioctl(int fd, unsigned long com, v
retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo);
if (retval < 0)
return retval;
- if (tmpinfo.mode == AUMODE_RECORD)
- INTARG = tmpinfo.record.sample_rate;
- else
- INTARG = tmpinfo.play.sample_rate;
+ INTARG = GETPRINFO(&tmpinfo, sample_rate);
break;
case SNDCTL_DSP_STEREO:
AUDIO_INITINFO(&tmpinfo);
@@ -147,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);
@@ -246,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;
@@ -254,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;
@@ -306,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.77 src/sys/compat/ossaudio/ossaudio.c:1.78
--- src/sys/compat/ossaudio/ossaudio.c:1.77 Sat Nov 2 11:56:34 2019
+++ src/sys/compat/ossaudio/ossaudio.c Sun Nov 3 11:13:46 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ossaudio.c,v 1.77 2019/11/02 11:56:34 isaki Exp $ */
+/* $NetBSD: ossaudio.c,v 1.78 2019/11/03 11:13:46 isaki 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.77 2019/11/02 11:56:34 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.78 2019/11/03 11:13:46 isaki 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,10 +244,7 @@ oss_ioctl_audio(struct lwp *l, const str
__func__, error));
goto out;
}
- if (tmpinfo.mode == AUMODE_RECORD)
- idat = tmpinfo.record.sample_rate;
- else
- 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) {
@@ -272,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",
@@ -383,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;
@@ -391,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;
@@ -460,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) {