CVS commit: src/lib/libossaudio

2021-06-09 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Jun  9 14:49:13 UTC 2021

Modified Files:
src/lib/libossaudio: oss_caps.c

Log Message:
ossaudio(3): continue getting capabilities if AUDIO_GETFORMAT fails

we want this to work on mixer devices too


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libossaudio/oss_caps.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/oss_caps.c
diff -u src/lib/libossaudio/oss_caps.c:1.1 src/lib/libossaudio/oss_caps.c:1.2
--- src/lib/libossaudio/oss_caps.c:1.1	Tue Jun  8 18:43:54 2021
+++ src/lib/libossaudio/oss_caps.c	Wed Jun  9 14:49:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: oss_caps.c,v 1.1 2021/06/08 18:43:54 nia Exp $	*/
+/*	$NetBSD: oss_caps.c,v 1.2 2021/06/09 14:49:13 nia Exp $	*/
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -41,27 +41,26 @@ _oss_get_caps(int fd, int *out)
 	if (ioctl(fd, AUDIO_GETPROPS, ) < 0)
 		return -1;
 
-	if (ioctl(fd, AUDIO_GETFORMAT, ) < 0)
-		return -1;
-
 	caps = 0;
 	caps |= PCM_CAP_TRIGGER;
 	caps |= PCM_CAP_MULTI;
 	caps |= PCM_CAP_FREERATE;
 
-	nchannels = (props & AUDIO_PROP_PLAYBACK) ?
-	info.play.channels : info.record.channels;
-
-	switch (nchannels) {
-	case 2:
-		caps |= DSP_CH_STEREO;
-		break;
-	case 1:
-		caps |= DSP_CH_MONO;
-		break;
-	default:
-		caps |= DSP_CH_MULTI;
-		break;
+	if (ioctl(fd, AUDIO_GETFORMAT, ) != -1) {
+		nchannels = (props & AUDIO_PROP_PLAYBACK) ?
+		info.play.channels : info.record.channels;
+
+		switch (nchannels) {
+		case 2:
+			caps |= DSP_CH_STEREO;
+			break;
+		case 1:
+			caps |= DSP_CH_MONO;
+			break;
+		default:
+			caps |= DSP_CH_MULTI;
+			break;
+		}
 	}
 
 	if (props & AUDIO_PROP_FULLDUPLEX)



CVS commit: src/lib/libossaudio

2021-06-09 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Jun  9 14:49:13 UTC 2021

Modified Files:
src/lib/libossaudio: oss_caps.c

Log Message:
ossaudio(3): continue getting capabilities if AUDIO_GETFORMAT fails

we want this to work on mixer devices too


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libossaudio/oss_caps.c

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



CVS commit: src/lib/libossaudio

2021-06-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Jun  8 19:26:48 UTC 2021

Modified Files:
src/lib/libossaudio: oss_dsp.c

Log Message:
ossaudio(3): nested switch statements are hard to read, refactor


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libossaudio/oss_dsp.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/oss_dsp.c
diff -u src/lib/libossaudio/oss_dsp.c:1.1 src/lib/libossaudio/oss_dsp.c:1.2
--- src/lib/libossaudio/oss_dsp.c:1.1	Tue Jun  8 18:43:54 2021
+++ src/lib/libossaudio/oss_dsp.c	Tue Jun  8 19:26:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: oss_dsp.c,v 1.1 2021/06/08 18:43:54 nia Exp $	*/
+/*	$NetBSD: oss_dsp.c,v 1.2 2021/06/08 19:26:48 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997-2021 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: oss_dsp.c,v 1.1 2021/06/08 18:43:54 nia Exp $");
+__RCSID("$NetBSD: oss_dsp.c,v 1.2 2021/06/08 19:26:48 nia Exp $");
 
 #include 
 #include 
@@ -38,6 +38,9 @@ __RCSID("$NetBSD: oss_dsp.c,v 1.1 2021/0
 	(((info)->mode == AUMODE_RECORD) \
 	? (info)->record.name : (info)->play.name)
 
+static int encoding_to_format(u_int, u_int);
+static int format_to_encoding(int, struct audio_info *);
+
 static int get_vol(u_int, u_char);
 static void set_vol(int, int, bool);
 
@@ -54,8 +57,6 @@ _oss_dsp_ioctl(int fd, unsigned long com
 	struct count_info cntinfo;
 	struct audio_encoding tmpenc;
 	u_int u;
-	u_int encoding;
-	u_int precision;
 	int perrors, rerrors;
 	static int totalperrors = 0;
 	static int totalrerrors = 0;
@@ -173,82 +174,8 @@ _oss_dsp_ioctl(int fd, unsigned long com
 		break;
 	case SNDCTL_DSP_SETFMT:
 		AUDIO_INITINFO();
-		switch (INTARG) {
-		case AFMT_MU_LAW:
-			tmpinfo.play.precision =
-			tmpinfo.record.precision = 8;
-			tmpinfo.play.encoding =
-			tmpinfo.record.encoding = AUDIO_ENCODING_ULAW;
-			break;
-		case AFMT_A_LAW:
-			tmpinfo.play.precision =
-			tmpinfo.record.precision = 8;
-			tmpinfo.play.encoding =
-			tmpinfo.record.encoding = AUDIO_ENCODING_ALAW;
-			break;
-		case AFMT_U8:
-			tmpinfo.play.precision =
-			tmpinfo.record.precision = 8;
-			tmpinfo.play.encoding =
-			tmpinfo.record.encoding = AUDIO_ENCODING_ULINEAR;
-			break;
-		case AFMT_S8:
-			tmpinfo.play.precision =
-			tmpinfo.record.precision = 8;
-			tmpinfo.play.encoding =
-			tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR;
-			break;
-		case AFMT_S16_LE:
-			tmpinfo.play.precision =
-			tmpinfo.record.precision = 16;
-			tmpinfo.play.encoding =
-			tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR_LE;
-			break;
-		case AFMT_S16_BE:
-			tmpinfo.play.precision =
-			tmpinfo.record.precision = 16;
-			tmpinfo.play.encoding =
-			tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR_BE;
-			break;
-		case AFMT_U16_LE:
-			tmpinfo.play.precision =
-			tmpinfo.record.precision = 16;
-			tmpinfo.play.encoding =
-			tmpinfo.record.encoding = AUDIO_ENCODING_ULINEAR_LE;
-			break;
-		case AFMT_U16_BE:
-			tmpinfo.play.precision =
-			tmpinfo.record.precision = 16;
-			tmpinfo.play.encoding =
-			tmpinfo.record.encoding = AUDIO_ENCODING_ULINEAR_BE;
-			break;
-		/*
-		 * XXX: When the kernel supports 24-bit LPCM by default,
-		 * the 24-bit formats should be handled properly instead
-		 * of falling back to 32 bits.
-		 */
-		case AFMT_S24_PACKED:
-		case AFMT_S24_LE:
-		case AFMT_S32_LE:
-			tmpinfo.play.precision =
-			tmpinfo.record.precision = 32;
-			tmpinfo.play.encoding =
-			tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR_LE;
-			break;
-		case AFMT_S24_BE:
-		case AFMT_S32_BE:
-			tmpinfo.play.precision =
-			tmpinfo.record.precision = 32;
-			tmpinfo.play.encoding =
-			tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR_BE;
-			break;
-		case AFMT_AC3:
-			tmpinfo.play.precision =
-			tmpinfo.record.precision = 16;
-			tmpinfo.play.encoding =
-			tmpinfo.record.encoding = AUDIO_ENCODING_AC3;
-			break;
-		default:
+		retval = format_to_encoding(INTARG, );
+		if (retval < 0) {
 			/*
 			 * OSSv4 specifies that if an invalid format is chosen
 			 * by an application then a sensible format supported
@@ -270,7 +197,6 @@ _oss_dsp_ioctl(int fd, unsigned long com
 			tmpinfo.record.precision =
 			(tmpinfo.mode == AUMODE_RECORD) ?
 			hwfmt.record.precision : hwfmt.play.precision ;
-			break;
 		}
 		/*
 		 * In the post-kernel-mixer world, assume that any error means
@@ -284,55 +210,17 @@ _oss_dsp_ioctl(int fd, unsigned long com
 		retval = ioctl(fd, AUDIO_GETBUFINFO, );
 		if (retval < 0)
 			return retval;
-		encoding = GETPRINFO(, encoding);
-		precision = GETPRINFO(, precision);
-		switch (encoding) {
-		case AUDIO_ENCODING_ULAW:
-			idat = AFMT_MU_LAW;
-			break;
-		case AUDIO_ENCODING_ALAW:
-			idat = AFMT_A_LAW;
-			break;
-		case AUDIO_ENCODING_SLINEAR_LE:
-			if (precision == 32)
-idat = AFMT_S32_LE;
-			else if (precision == 24)
-idat = AFMT_S24_LE;
-			else if (precision == 

CVS commit: src/lib/libossaudio

2021-06-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Jun  8 19:26:48 UTC 2021

Modified Files:
src/lib/libossaudio: oss_dsp.c

Log Message:
ossaudio(3): nested switch statements are hard to read, refactor


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libossaudio/oss_dsp.c

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



CVS commit: src/lib/libossaudio

2021-06-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Jun  8 18:43:54 UTC 2021

Modified Files:
src/lib/libossaudio: Makefile
Added Files:
src/lib/libossaudio: internal.h oss3_mixer.c oss4_global.c oss4_mixer.c
oss_caps.c oss_dsp.c oss_ioctl.c
Removed Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): refactor library into separate files


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libossaudio/Makefile
cvs rdiff -u -r0 -r1.1 src/lib/libossaudio/internal.h \
src/lib/libossaudio/oss3_mixer.c src/lib/libossaudio/oss4_global.c \
src/lib/libossaudio/oss4_mixer.c src/lib/libossaudio/oss_caps.c \
src/lib/libossaudio/oss_dsp.c src/lib/libossaudio/oss_ioctl.c
cvs rdiff -u -r1.68 -r0 src/lib/libossaudio/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/Makefile
diff -u src/lib/libossaudio/Makefile:1.10 src/lib/libossaudio/Makefile:1.11
--- src/lib/libossaudio/Makefile:1.10	Sat May  5 15:57:45 2012
+++ src/lib/libossaudio/Makefile	Tue Jun  8 18:43:54 2021
@@ -1,11 +1,13 @@
-#	$NetBSD: Makefile,v 1.10 2012/05/05 15:57:45 christos Exp $
+#	$NetBSD: Makefile,v 1.11 2021/06/08 18:43:54 nia Exp $
 
 WARNS=	5
 
 LIB=	ossaudio
 MAN=	ossaudio.3
 
-SRCS=	ossaudio.c
+SRCS=	oss_caps.c oss_dsp.c oss_ioctl.c
+SRCS+=	oss3_mixer.c oss4_mixer.c
+SRCS+=	oss4_global.c
 
 CPPFLAGS+= -I${.CURDIR}
 

Added files:

Index: src/lib/libossaudio/internal.h
diff -u /dev/null src/lib/libossaudio/internal.h:1.1
--- /dev/null	Tue Jun  8 18:43:54 2021
+++ src/lib/libossaudio/internal.h	Tue Jun  8 18:43:54 2021
@@ -0,0 +1,53 @@
+/*	$NetBSD: internal.h,v 1.1 2021/06/08 18:43:54 nia Exp $	*/
+
+/*-
+ * Copyright (c) 1997-2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef OSSAUDIO_INTERNAL_H
+#define OSSAUDIO_INTERNAL_H
+
+#include 
+#include "soundcard.h"
+#undef ioctl
+
+#define TO_OSSVOL(x)	(((x) * 100 + 127) / 255)
+#define FROM_OSSVOL(x)	x) > 100 ? 100 : (x)) * 255 + 50) / 100)
+
+#define INTARG		(*(int*)argp)
+
+#define GET_DEV(com)	((com) & 0xff)
+
+#define oss_private	__attribute__((__visibility__("hidden")))
+
+int _oss_ioctl(int, unsigned long, ...);
+
+oss_private int _oss_dsp_ioctl(int, unsigned long, void *);
+oss_private int _oss_get_caps(int, int *);
+oss_private int _oss3_mixer_ioctl(int, unsigned long, void *);
+oss_private int _oss4_mixer_ioctl(int, unsigned long, void *);
+oss_private int _oss4_global_ioctl(int, unsigned long, void *);
+
+#endif
Index: src/lib/libossaudio/oss3_mixer.c
diff -u /dev/null src/lib/libossaudio/oss3_mixer.c:1.1
--- /dev/null	Tue Jun  8 18:43:54 2021
+++ src/lib/libossaudio/oss3_mixer.c	Tue Jun  8 18:43:54 2021
@@ -0,0 +1,393 @@
+/*	$NetBSD: oss3_mixer.c,v 1.1 2021/06/08 18:43:54 nia Exp $	*/
+
+/*-
+ * Copyright (c) 1997-2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE 

CVS commit: src/lib/libossaudio

2021-06-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Jun  8 18:43:54 UTC 2021

Modified Files:
src/lib/libossaudio: Makefile
Added Files:
src/lib/libossaudio: internal.h oss3_mixer.c oss4_global.c oss4_mixer.c
oss_caps.c oss_dsp.c oss_ioctl.c
Removed Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): refactor library into separate files


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libossaudio/Makefile
cvs rdiff -u -r0 -r1.1 src/lib/libossaudio/internal.h \
src/lib/libossaudio/oss3_mixer.c src/lib/libossaudio/oss4_global.c \
src/lib/libossaudio/oss4_mixer.c src/lib/libossaudio/oss_caps.c \
src/lib/libossaudio/oss_dsp.c src/lib/libossaudio/oss_ioctl.c
cvs rdiff -u -r1.68 -r0 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2021-05-09 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sun May  9 12:51:45 UTC 2021

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio: Set handle on OSSv4 mixer devices


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2021-05-09 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sun May  9 12:51:45 UTC 2021

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio: Set handle on OSSv4 mixer devices


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/lib/libossaudio/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.67 src/lib/libossaudio/ossaudio.c:1.68
--- src/lib/libossaudio/ossaudio.c:1.67	Sun May  9 11:28:25 2021
+++ src/lib/libossaudio/ossaudio.c	Sun May  9 12:51:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.67 2021/05/09 11:28:25 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.68 2021/05/09 12:51:45 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997-2021 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.67 2021/05/09 11:28:25 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.68 2021/05/09 12:51:45 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -1240,6 +1240,7 @@ mixer_oss4_ioctl(int fd, unsigned long c
 			return retval;
 		}
 		strlcpy(mi->id, devname, sizeof(mi->id));
+		strlcpy(mi->handle, devname, sizeof(mi->handle));
 		snprintf(mi->name, sizeof(mi->name),
 		"%s %s", dev.name, dev.version);
 		mi->card_number = mi->dev;



CVS commit: src/lib/libossaudio

2021-05-09 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sun May  9 11:28:25 UTC 2021

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
libossaudio: Various OSSv4 fixes to allow reference programs to compile

- Define various new AFMT_*. These are not returned as supported
  formats by SNDCTL_DSP_GETFMTS, because it would be very silly to
  have Vorbis in the kernel.

- Implement PLAYTGT and RECSRC. For each NetBSD audio device
  we only return one playback and recording source, "primary".

- Return preferred channel configuration in capabilities.
  Either DSP_CH_STEREO, DSP_CH_MONO, or DSP_CH_MULTI
  depending on the current hardware format.

- SNDCTL_DSP_HALT_* simply flushes the audio device.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.33 -r1.34 src/lib/libossaudio/soundcard.h

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.66 src/lib/libossaudio/ossaudio.c:1.67
--- src/lib/libossaudio/ossaudio.c:1.66	Mon Mar 15 10:58:05 2021
+++ src/lib/libossaudio/ossaudio.c	Sun May  9 11:28:25 2021
@@ -1,7 +1,7 @@
-/*	$NetBSD: ossaudio.c,v 1.66 2021/03/15 10:58:05 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.67 2021/05/09 11:28:25 nia Exp $	*/
 
 /*-
- * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997-2021 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.66 2021/03/15 10:58:05 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.67 2021/05/09 11:28:25 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -127,6 +127,7 @@ audio_ioctl(int fd, unsigned long com, v
 	int perrors, rerrors;
 	static int totalperrors = 0;
 	static int totalrerrors = 0;
+	oss_mixer_enuminfo *ei;
 	oss_count_t osscount;
 	int idat;
 	int retval;
@@ -134,6 +135,8 @@ audio_ioctl(int fd, unsigned long com, v
 	idat = 0;
 
 	switch (com) {
+	case SNDCTL_DSP_HALT_INPUT:
+	case SNDCTL_DSP_HALT_OUTPUT:
 	case SNDCTL_DSP_RESET:
 		retval = ioctl(fd, AUDIO_FLUSH, 0);
 		if (retval < 0)
@@ -293,6 +296,7 @@ audio_ioctl(int fd, unsigned long com, v
 		 * the 24-bit formats should be handled properly instead
 		 * of falling back to 32 bits.
 		 */
+		case AFMT_S24_PACKED:
 		case AFMT_S24_LE:
 		case AFMT_S32_LE:
 			tmpinfo.play.precision =
@@ -434,10 +438,6 @@ audio_ioctl(int fd, unsigned long com, v
 	case SNDCTL_DSP_SETFRAGMENT:
 		AUDIO_INITINFO();
 		idat = INTARG;
-		if ((idat & 0x) < 4 || (idat & 0x) > 17) {
-			errno = EINVAL;
-			return -1;
-		}
 		tmpinfo.blocksize = 1 << (idat & 0x);
 		tmpinfo.hiwat = ((unsigned)idat >> 16) & 0x7fff;
 		if (tmpinfo.hiwat == 0)	/* 0 means set to max */
@@ -662,6 +662,21 @@ audio_ioctl(int fd, unsigned long com, v
 	case SNDCTL_DSP_SETSYNCRO:
 		errno = EINVAL;
 		return -1; /* XXX unimplemented */
+	case SNDCTL_DSP_GET_PLAYTGT_NAMES:
+	case SNDCTL_DSP_GET_RECSRC_NAMES:
+		ei = (oss_mixer_enuminfo *)argp;
+		ei->nvalues = 1;
+		ei->version = 0;
+		ei->strindex[0] = 0;
+		strlcpy(ei->strings, "primary", OSS_ENUM_STRINGSIZE);
+		break;
+	case SNDCTL_DSP_SET_PLAYTGT:
+	case SNDCTL_DSP_SET_RECSRC:
+	case SNDCTL_DSP_GET_PLAYTGT:
+	case SNDCTL_DSP_GET_RECSRC:
+		/* We have one recording source and play target. */
+		INTARG = 0;
+		break;
 	default:
 		errno = EINVAL;
 		return -1;
@@ -1114,7 +1129,7 @@ mixer_oss4_ioctl(int fd, unsigned long c
 		"%s %s", dev.name, dev.version);
 		tmpai->busy = 0;
 		tmpai->pid = -1;
-		ioctl(newfd, SNDCTL_DSP_GETFMTS, >iformats);
+		audio_ioctl(newfd, SNDCTL_DSP_GETFMTS, >iformats);
 		tmpai->oformats = tmpai->iformats;
 		tmpai->magic = -1; /* reserved for "internal use" */
 		memset(tmpai->cmd, 0, sizeof(tmpai->cmd));
@@ -1603,17 +1618,40 @@ global_oss4_ioctl(int fd, unsigned long 
 static int
 getcaps(int fd, int *out)
 {
+	struct audio_info info;
 	int props, caps;
+	int nchannels;
 
 	if (ioctl(fd, AUDIO_GETPROPS, ) < 0)
 		return -1;
 
-	caps = DSP_CAP_TRIGGER;
+	if (ioctl(fd, AUDIO_GETFORMAT, ) < 0)
+		return -1;
+
+	caps = 0;
+	caps |= PCM_CAP_TRIGGER;
+	caps |= PCM_CAP_MULTI;
+	caps |= PCM_CAP_FREERATE;
+
+	nchannels = (props & AUDIO_PROP_PLAYBACK) ?
+	info.play.channels : info.record.channels;
+
+	switch (nchannels) {
+	case 2:
+		caps |= DSP_CH_STEREO;
+		break;
+	case 1:
+		caps |= DSP_CH_MONO;
+		break;
+	default:
+		caps |= DSP_CH_MULTI;
+		break;
+	}
 
 	if (props & AUDIO_PROP_FULLDUPLEX)
-		caps |= DSP_CAP_DUPLEX;
+		caps |= PCM_CAP_DUPLEX;
 	if (props & AUDIO_PROP_MMAP)
-		caps |= DSP_CAP_MMAP;
+		caps |= PCM_CAP_MMAP;
 	if (props & AUDIO_PROP_CAPTURE)
 		caps |= PCM_CAP_INPUT;
 	if (props & AUDIO_PROP_PLAYBACK)

Index: src/lib/libossaudio/soundcard.h
diff -u 

CVS commit: src/lib/libossaudio

2021-05-09 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sun May  9 11:28:25 UTC 2021

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
libossaudio: Various OSSv4 fixes to allow reference programs to compile

- Define various new AFMT_*. These are not returned as supported
  formats by SNDCTL_DSP_GETFMTS, because it would be very silly to
  have Vorbis in the kernel.

- Implement PLAYTGT and RECSRC. For each NetBSD audio device
  we only return one playback and recording source, "primary".

- Return preferred channel configuration in capabilities.
  Either DSP_CH_STEREO, DSP_CH_MONO, or DSP_CH_MULTI
  depending on the current hardware format.

- SNDCTL_DSP_HALT_* simply flushes the audio device.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.33 -r1.34 src/lib/libossaudio/soundcard.h

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



CVS commit: src/lib/libossaudio

2021-03-15 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Mar 15 10:58:05 UTC 2021

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossv4 mixer API: be extra careful with the inputs to AUDIO_MIXER_READ.

some drivers (not hdaudio(4), but uaudio(4), eap(4), sb(4), various other
old cards) will return error if a AUDIO_MIXER_VALUE is requested and the
number of channels is not specified as input. this is not documented as
well as it should be, unfortunately.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2021-03-15 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Mar 15 10:58:05 UTC 2021

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossv4 mixer API: be extra careful with the inputs to AUDIO_MIXER_READ.

some drivers (not hdaudio(4), but uaudio(4), eap(4), sb(4), various other
old cards) will return error if a AUDIO_MIXER_VALUE is requested and the
number of channels is not specified as input. this is not documented as
well as it should be, unfortunately.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/lib/libossaudio/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.65 src/lib/libossaudio/ossaudio.c:1.66
--- src/lib/libossaudio/ossaudio.c:1.65	Sat Dec 19 12:55:28 2020
+++ src/lib/libossaudio/ossaudio.c	Mon Mar 15 10:58:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.65 2020/12/19 12:55:28 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.66 2021/03/15 10:58:05 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.65 2020/12/19 12:55:28 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.66 2021/03/15 10:58:05 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -1442,6 +1442,7 @@ mixer_oss4_ioctl(int fd, unsigned long c
 			errno = tmperrno;
 			return retval;
 		}
+		mc.type = mdi.type;
 		switch (mdi.type) {
 		case AUDIO_MIXER_ENUM:
 			if (mv->value >= mdi.un.e.num_mem) {
@@ -1469,6 +1470,7 @@ mixer_oss4_ioctl(int fd, unsigned long c
 #endif
 			break;
 		case AUDIO_MIXER_VALUE:
+			mc.un.value.num_channels = mdi.un.v.num_channels;
 			if (mdi.un.v.num_channels != 2) {
 for (i = 0; i < mdi.un.v.num_channels; ++i) {
 	mc.un.value.level[i] = mv->value;
@@ -1512,6 +1514,9 @@ mixer_oss4_ioctl(int fd, unsigned long c
 			return retval;
 		}
 		mc.dev = mdi.index;
+		mc.type = mdi.type;
+		if (mdi.type == AUDIO_MIXER_VALUE)
+			mc.un.value.num_channels = mdi.un.v.num_channels;
 		retval = ioctl(newfd, AUDIO_MIXER_READ, );
 		if (retval < 0) {
 			tmperrno = errno;



CVS commit: src/lib/libossaudio

2020-12-19 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Dec 19 12:55:28 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Do not reuse results from AUDIO_GETBUFINFO in SETINFO

Should help PR 55876.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/lib/libossaudio/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.64 src/lib/libossaudio/ossaudio.c:1.65
--- src/lib/libossaudio/ossaudio.c:1.64	Fri Nov 13 09:02:39 2020
+++ src/lib/libossaudio/ossaudio.c	Sat Dec 19 12:55:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.64 2020/11/13 09:02:39 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.65 2020/12/19 12:55:28 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.64 2020/11/13 09:02:39 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.65 2020/12/19 12:55:28 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -183,7 +183,6 @@ audio_ioctl(int fd, unsigned long com, v
 		/* This call is merely advisory, and may be a nop. */
 		break;
 	case SNDCTL_DSP_SPEED:
-		AUDIO_INITINFO();
 		/*
 		 * In Solaris, 0 is used a special value to query the
 		 * current rate. This seems useful to support.
@@ -208,6 +207,7 @@ audio_ioctl(int fd, unsigned long com, v
 			INTARG = 1000;
 		if (INTARG > 192000)
 			INTARG = 192000;
+		AUDIO_INITINFO();
 		tmpinfo.play.sample_rate =
 		tmpinfo.record.sample_rate = INTARG;
 		retval = ioctl(fd, AUDIO_SETINFO, );



CVS commit: src/lib/libossaudio

2020-12-19 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Dec 19 12:55:28 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Do not reuse results from AUDIO_GETBUFINFO in SETINFO

Should help PR 55876.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-12-03 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Thu Dec  3 22:10:21 UTC 2020

Modified Files:
src/lib/libossaudio: soundcard.h

Log Message:
Add some missing channel order related ioctl defines.

These are no-ops (unimplemented) on both FreeBSD and Solaris
and the one piece of code I've found that uses it seems to assume the
call will fail so it should be safe to leave this returning EINVAL.

However, it does need the definitions to compile...


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libossaudio/soundcard.h

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/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.32 src/lib/libossaudio/soundcard.h:1.33
--- src/lib/libossaudio/soundcard.h:1.32	Tue Nov  3 09:33:53 2020
+++ src/lib/libossaudio/soundcard.h	Thu Dec  3 22:10:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.32 2020/11/03 09:33:53 nia Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.33 2020/12/03 22:10:21 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -358,6 +358,21 @@ typedef struct buffmem_desc {
 #define SNDCTL_DSP_CURRENT_IPTR		_IOR ('P',35, oss_count_t)
 #define SNDCTL_DSP_CURRENT_OPTR		_IOR ('P',36, oss_count_t)
 
+#define SNDCTL_DSP_GET_CHNORDER		_IOR ('P',42, unsigned long long)
+#define SNDCTL_DSP_SET_CHNORDER		_IOWR ('P',42, unsigned long long)
+
+#define CHID_UNDEF	0
+#define CHID_L		1
+#define CHID_R		2
+#define CHID_C		3
+#define CHID_LFE	4
+#define CHID_LS		5
+#define CHID_RS		6
+#define CHID_LR		7
+#define CHID_RR		8
+#define CHNORDER_UNDEF	0xULL
+#define CHNORDER_NORMAL	0x87654321ULL
+
 typedef struct {
 	long long samples;
 	int fifo_samples;



CVS commit: src/lib/libossaudio

2020-12-03 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Thu Dec  3 22:10:21 UTC 2020

Modified Files:
src/lib/libossaudio: soundcard.h

Log Message:
Add some missing channel order related ioctl defines.

These are no-ops (unimplemented) on both FreeBSD and Solaris
and the one piece of code I've found that uses it seems to assume the
call will fail so it should be safe to leave this returning EINVAL.

However, it does need the definitions to compile...


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libossaudio/soundcard.h

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



CVS commit: src/lib/libossaudio

2020-11-13 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Nov 13 09:02:39 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Clone some useful behaviour from the Solaris kernel

Both SNDCTL_DSP_SPEED and SNDCTL_DSP_CHANNELS support a special value
0 to "query the configured value without changing it". In our case,
this actually means setting and querying the hardware rate.

I don't know if OSSv3 or FreeBSD or other implementations also do this.
But it seems safe and sensible to support.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-11-13 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Nov 13 09:02:39 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Clone some useful behaviour from the Solaris kernel

Both SNDCTL_DSP_SPEED and SNDCTL_DSP_CHANNELS support a special value
0 to "query the configured value without changing it". In our case,
this actually means setting and querying the hardware rate.

I don't know if OSSv3 or FreeBSD or other implementations also do this.
But it seems safe and sensible to support.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/lib/libossaudio/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.63 src/lib/libossaudio/ossaudio.c:1.64
--- src/lib/libossaudio/ossaudio.c:1.63	Wed Nov  4 22:59:24 2020
+++ src/lib/libossaudio/ossaudio.c	Fri Nov 13 09:02:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.63 2020/11/04 22:59:24 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.64 2020/11/13 09:02:39 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.63 2020/11/04 22:59:24 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.64 2020/11/13 09:02:39 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -184,7 +184,26 @@ audio_ioctl(int fd, unsigned long com, v
 		break;
 	case SNDCTL_DSP_SPEED:
 		AUDIO_INITINFO();
-		/* Conform to kernel limits. */
+		/*
+		 * In Solaris, 0 is used a special value to query the
+		 * current rate. This seems useful to support.
+		 */
+		if (INTARG == 0) {
+			retval = ioctl(fd, AUDIO_GETBUFINFO, );
+			if (retval < 0)
+return retval;
+			retval = ioctl(fd, AUDIO_GETFORMAT, );
+			if (retval < 0)
+return retval;
+			INTARG = (tmpinfo.mode == AUMODE_RECORD) ?
+			hwfmt.record.sample_rate :
+			hwfmt.play.sample_rate;
+		}
+		/*
+		 * Conform to kernel limits.
+		 * NetBSD will reject unsupported sample rates, but OSS
+		 * applications need to be able to negotiate a supported one.
+		 */
 		if (INTARG < 1000)
 			INTARG = 1000;
 		if (INTARG > 192000)
@@ -1708,6 +1727,8 @@ setvol(int fd, int volume, bool record)
  * case an application is abusing SNDCTL_DSP_CHANNELS - OSSv4 always sets and
  * returns a reasonable value, even if it wasn't what the user requested.
  *
+ * Solaris guarantees this behaviour if nchannels = 0.
+ *
  * XXX: If a device is opened for both playback and recording, and supports
  * fewer channels for recording than playback, applications that do both will
  * behave very strangely. OSS doesn't allow for reporting separate channel



CVS commit: src/lib/libossaudio

2020-11-04 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Nov  4 22:59:24 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Set errno and return -1 rather than returning errno.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/lib/libossaudio/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.62 src/lib/libossaudio/ossaudio.c:1.63
--- src/lib/libossaudio/ossaudio.c:1.62	Tue Nov  3 09:46:00 2020
+++ src/lib/libossaudio/ossaudio.c	Wed Nov  4 22:59:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.62 2020/11/03 09:46:00 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.63 2020/11/04 22:59:24 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.62 2020/11/03 09:46:00 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.63 2020/11/04 22:59:24 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -146,8 +146,10 @@ audio_ioctl(int fd, unsigned long com, v
 		break;
 	case SNDCTL_DSP_GETERROR:
 		tmperrinfo = (struct audio_errinfo *)argp;
-		if (tmperrinfo == NULL)
-			return EINVAL;
+		if (tmperrinfo == NULL) {
+			errno = EINVAL;
+			return -1;
+		}
 		memset(tmperrinfo, 0, sizeof(struct audio_errinfo));
 		if ((retval = ioctl(fd, AUDIO_GETBUFINFO, )) < 0)
 			return retval;
@@ -413,8 +415,10 @@ audio_ioctl(int fd, unsigned long com, v
 	case SNDCTL_DSP_SETFRAGMENT:
 		AUDIO_INITINFO();
 		idat = INTARG;
-		if ((idat & 0x) < 4 || (idat & 0x) > 17)
-			return EINVAL;
+		if ((idat & 0x) < 4 || (idat & 0x) > 17) {
+			errno = EINVAL;
+			return -1;
+		}
 		tmpinfo.blocksize = 1 << (idat & 0x);
 		tmpinfo.hiwat = ((unsigned)idat >> 16) & 0x7fff;
 		if (tmpinfo.hiwat == 0)	/* 0 means set to max */
@@ -613,8 +617,9 @@ audio_ioctl(int fd, unsigned long com, v
 		INTARG = getvol(tmpinfo.record.gain, tmpinfo.record.balance);
 		break;
 	case SNDCTL_DSP_SKIP:
-	case SNDCTL_DSP_SILENCE:
-		return EINVAL;
+	case SNDCTL_DSP_SILENCE: 
+		errno = EINVAL;
+		return -1;
 	case SNDCTL_DSP_SETDUPLEX:
 		idat = 1;
 		retval = ioctl(fd, AUDIO_SETFD, );
@@ -865,8 +870,10 @@ mixer_oss3_ioctl(int fd, unsigned long c
 		strlcpy(omi->name, adev.name, sizeof omi->name);
 		return 0;
 	case SOUND_MIXER_READ_RECSRC:
-		if (di->source == -1)
-			return EINVAL;
+		if (di->source == -1) {
+			errno = EINVAL;
+			return -1;
+		}
 		mc.dev = di->source;
 		if (di->caps & SOUND_CAP_EXCL_INPUT) {
 			mc.type = AUDIO_MIXER_ENUM;
@@ -900,8 +907,10 @@ mixer_oss3_ioctl(int fd, unsigned long c
 		break;
 	case SOUND_MIXER_WRITE_RECSRC:
 	case SOUND_MIXER_WRITE_R_RECSRC:
-		if (di->source == -1)
-			return EINVAL;
+		if (di->source == -1) {
+			errno = EINVAL;
+			return -1;
+		}
 		mc.dev = di->source;
 		idat = INTARG;
 		if (di->caps & SOUND_CAP_EXCL_INPUT) {
@@ -910,16 +919,20 @@ mixer_oss3_ioctl(int fd, unsigned long c
 if (idat & (1 << i))
 	break;
 			if (i >= SOUND_MIXER_NRDEVICES ||
-			di->devmap[i] == -1)
-return EINVAL;
+			di->devmap[i] == -1) {
+errno = EINVAL;
+return -1;
+			}
 			mc.un.ord = enum_to_ord(di, di->devmap[i]);
 		} else {
 			mc.type = AUDIO_MIXER_SET;
 			mc.un.mask = 0;
 			for(i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
 if (idat & (1 << i)) {
-	if (di->devmap[i] == -1)
-		return EINVAL;
+	if (di->devmap[i] == -1) {
+		errno = EINVAL;
+		return -1;
+	}
 	mc.un.mask |=
 	enum_to_mask(di, di->devmap[i]);
 }
@@ -930,8 +943,10 @@ mixer_oss3_ioctl(int fd, unsigned long c
 		if (MIXER_READ(SOUND_MIXER_FIRST) <= com &&
 		com < MIXER_READ(SOUND_MIXER_NRDEVICES)) {
 			n = GET_DEV(com);
-			if (di->devmap[n] == -1)
-return EINVAL;
+			if (di->devmap[n] == -1) {
+errno = EINVAL;
+return -1;
+			}
 			mc.dev = di->devmap[n];
 			mc.type = AUDIO_MIXER_VALUE;
 		doread:
@@ -940,8 +955,10 @@ mixer_oss3_ioctl(int fd, unsigned long c
 			retval = ioctl(fd, AUDIO_MIXER_READ, );
 			if (retval < 0)
 return retval;
-			if (mc.type != AUDIO_MIXER_VALUE)
-return EINVAL;
+			if (mc.type != AUDIO_MIXER_VALUE) {
+errno = EINVAL;
+return -1;
+			}
 			if (mc.un.value.num_channels != 2) {
 l = r =
 mc.un.value.level[AUDIO_MIXER_LEVEL_MONO];
@@ -956,8 +973,10 @@ mixer_oss3_ioctl(int fd, unsigned long c
 			   (MIXER_WRITE(SOUND_MIXER_FIRST) <= com &&
 			   com < MIXER_WRITE(SOUND_MIXER_NRDEVICES))) {
 			n = GET_DEV(com);
-			if (di->devmap[n] == -1)
-return EINVAL;
+			if (di->devmap[n] == -1) {
+errno = EINVAL;
+return -1;
+			}
 			idat = INTARG;
 			l = FROM_OSSVOL((u_int)idat & 0xff);
 			r = FROM_OSSVOL(((u_int)idat >> 8) & 0xff);
@@ -1114,8 +1133,10 @@ mixer_oss4_ioctl(int fd, unsigned long c
 		break;
 	case SNDCTL_CARDINFO:
 		cardinfo = 

CVS commit: src/lib/libossaudio

2020-11-04 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Nov  4 22:59:24 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Set errno and return -1 rather than returning errno.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-11-03 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Nov  3 09:46:01 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Reduce code duplication for querying capabilities


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/lib/libossaudio/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.61 src/lib/libossaudio/ossaudio.c:1.62
--- src/lib/libossaudio/ossaudio.c:1.61	Tue Nov  3 09:36:12 2020
+++ src/lib/libossaudio/ossaudio.c	Tue Nov  3 09:46:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.61 2020/11/03 09:36:12 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.62 2020/11/03 09:46:00 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.61 2020/11/03 09:36:12 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.62 2020/11/03 09:46:00 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -71,6 +71,8 @@ static int getaudiocount(void);
 static int getmixercount(void);
 static int getmixercontrolcount(int);
 
+static int getcaps(int, int *);
+
 static int getvol(u_int, u_char);
 static void setvol(int, int, bool);
 
@@ -126,7 +128,7 @@ audio_ioctl(int fd, unsigned long com, v
 	static int totalperrors = 0;
 	static int totalrerrors = 0;
 	oss_count_t osscount;
-	int idat, idata;
+	int idat;
 	int retval;
 
 	idat = 0;
@@ -520,19 +522,9 @@ audio_ioctl(int fd, unsigned long com, v
 			return retval;
 		break;
 	case SNDCTL_DSP_GETCAPS:
-		retval = ioctl(fd, AUDIO_GETPROPS, );
+		retval = getcaps(fd, (int *)argp);
 		if (retval < 0)
 			return retval;
-		idat = DSP_CAP_TRIGGER;
-		if (idata & AUDIO_PROP_FULLDUPLEX)
-			idat |= DSP_CAP_DUPLEX;
-		if (idata & AUDIO_PROP_MMAP)
-			idat |= DSP_CAP_MMAP;
-		if (idata & AUDIO_PROP_CAPTURE)
-			idat |= DSP_CAP_INPUT;
-		if (idata & AUDIO_PROP_PLAYBACK)
-			idat |= DSP_CAP_OUTPUT;
-		INTARG = idat;
 		break;
 	case SNDCTL_DSP_SETTRIGGER:
 		retval = ioctl(fd, AUDIO_GETBUFINFO, );
@@ -1018,7 +1010,6 @@ mixer_oss4_ioctl(int fd, unsigned long c
 	int newfd = -1, tmperrno;
 	int i, noffs;
 	int retval;
-	int props, caps;
 
 	/*
 	 * Note: it is difficult to translate the NetBSD concept of a "set"
@@ -1075,27 +1066,16 @@ mixer_oss4_ioctl(int fd, unsigned long c
 			errno = tmperrno;
 			return retval;
 		}
-		retval = ioctl(newfd, AUDIO_GETPROPS, );
-		if (retval < 0) {
+		if (getcaps(newfd, >caps) < 0) {
 			tmperrno = errno;
 			close(newfd);
 			errno = tmperrno;
 			return retval;
 		}
-		caps = DSP_CAP_TRIGGER;
-		if (props & AUDIO_PROP_FULLDUPLEX)
-			caps |= DSP_CAP_DUPLEX;
-		if (props & AUDIO_PROP_MMAP)
-			caps |= DSP_CAP_MMAP;
-		if (props & AUDIO_PROP_CAPTURE)
-			caps |= PCM_CAP_INPUT;
-		if (props & AUDIO_PROP_PLAYBACK)
-			caps |= PCM_CAP_OUTPUT;
 		snprintf(tmpai->name, sizeof(tmpai->name),
 		"%s %s", dev.name, dev.version);
 		tmpai->busy = 0;
 		tmpai->pid = -1;
-		tmpai->caps = caps;
 		ioctl(newfd, SNDCTL_DSP_GETFMTS, >iformats);
 		tmpai->oformats = tmpai->iformats;
 		tmpai->magic = -1; /* reserved for "internal use" */
@@ -1576,6 +1556,29 @@ global_oss4_ioctl(int fd, unsigned long 
 }
 
 static int
+getcaps(int fd, int *out)
+{
+	int props, caps;
+
+	if (ioctl(fd, AUDIO_GETPROPS, ) < 0)
+		return -1;
+
+	caps = DSP_CAP_TRIGGER;
+
+	if (props & AUDIO_PROP_FULLDUPLEX)
+		caps |= DSP_CAP_DUPLEX;
+	if (props & AUDIO_PROP_MMAP)
+		caps |= DSP_CAP_MMAP;
+	if (props & AUDIO_PROP_CAPTURE)
+		caps |= PCM_CAP_INPUT;
+	if (props & AUDIO_PROP_PLAYBACK)
+		caps |= PCM_CAP_OUTPUT;
+
+	*out = caps;
+	return 0;
+}
+
+static int
 getaudiocount(void)
 {
 	char devname[32];



CVS commit: src/lib/libossaudio

2020-11-03 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Nov  3 09:46:01 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Reduce code duplication for querying capabilities


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-11-03 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Nov  3 09:36:12 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Return device playback and capture capabilities in GETCAPS


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/lib/libossaudio/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.60 src/lib/libossaudio/ossaudio.c:1.61
--- src/lib/libossaudio/ossaudio.c:1.60	Tue Nov  3 08:24:33 2020
+++ src/lib/libossaudio/ossaudio.c	Tue Nov  3 09:36:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.60 2020/11/03 08:24:33 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.61 2020/11/03 09:36:12 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.60 2020/11/03 08:24:33 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.61 2020/11/03 09:36:12 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -528,6 +528,10 @@ audio_ioctl(int fd, unsigned long com, v
 			idat |= DSP_CAP_DUPLEX;
 		if (idata & AUDIO_PROP_MMAP)
 			idat |= DSP_CAP_MMAP;
+		if (idata & AUDIO_PROP_CAPTURE)
+			idat |= DSP_CAP_INPUT;
+		if (idata & AUDIO_PROP_PLAYBACK)
+			idat |= DSP_CAP_OUTPUT;
 		INTARG = idat;
 		break;
 	case SNDCTL_DSP_SETTRIGGER:



CVS commit: src/lib/libossaudio

2020-11-03 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Nov  3 09:36:12 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Return device playback and capture capabilities in GETCAPS


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-11-03 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Nov  3 09:33:53 UTC 2020

Modified Files:
src/lib/libossaudio: soundcard.h

Log Message:
ossaudio(3): More capability defines from OSSv4


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libossaudio/soundcard.h

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/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.31 src/lib/libossaudio/soundcard.h:1.32
--- src/lib/libossaudio/soundcard.h:1.31	Fri Oct 23 09:05:20 2020
+++ src/lib/libossaudio/soundcard.h	Tue Nov  3 09:33:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.31 2020/10/23 09:05:20 nia Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.32 2020/11/03 09:33:53 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -81,17 +81,42 @@
 #define SNDCTL_DSP_GETISPACE		_IOR ('P',13, struct audio_buf_info)
 #define SNDCTL_DSP_NONBLOCK		_IO  ('P',14)
 #define SNDCTL_DSP_GETCAPS		_IOR ('P',15, int)
-# define DSP_CAP_REVISION		0x00ff
-# define DSP_CAP_DUPLEX			0x0100
-# define DSP_CAP_REALTIME		0x0200
-# define DSP_CAP_BATCH			0x0400
-# define DSP_CAP_COPROC			0x0800
-# define DSP_CAP_TRIGGER		0x1000
-# define DSP_CAP_MMAP			0x2000
-# define PCM_CAP_INPUT			0x4000
-# define PCM_CAP_OUTPUT			0x8000
-# define PCM_CAP_MODEM			0x0001
-# define PCM_CAP_HIDDEN			0x0002
+/* PCM_CAP_* were known as DSP_CAP_ before OSS 4.0 */
+# define DSP_CAP_REVISION		PCM_CAP_REVISION
+# define DSP_CAP_DUPLEX			PCM_CAP_DUPLEX
+# define DSP_CAP_REALTIME		PCM_CAP_REALTIME
+# define DSP_CAP_BATCH			PCM_CAP_BATCH
+# define DSP_CAP_COPROC			PCM_CAP_COPROC
+# define DSP_CAP_TRIGGER		PCM_CAP_TRIGGER
+# define DSP_CAP_MMAP			PCM_CAP_MMAP
+# define DSP_CAP_INPUT			PCM_CAP_INPUT
+# define DSP_CAP_OUTPUT			PCM_CAP_OUTPUT
+# define DSP_CAP_MODEM			PCM_CAP_MODEM
+# define DSP_CAP_HIDDEN			PCM_CAP_HIDDEN
+# define DSP_CAP_VIRTUAL		PCM_CAP_VIRTUAL
+# define DSP_CAP_ANALOGOUT		PCM_CAP_ANALOGOUT
+# define DSP_CAP_ANALOGIN		PCM_CAP_ANALOGIN
+# define DSP_CAP_DIGITALOUT		PCM_CAP_DIGITALOUT
+# define DSP_CAP_DIGITALIN		PCM_CAP_DIGITALIN
+# define DSP_CAP_ADMASK			PCM_CAP_ADMASK
+# define PCM_CAP_REVISION		0x00ff	/* Unused in NetBSD */
+# define PCM_CAP_DUPLEX			0x0100	/* Full duplex */
+# define PCM_CAP_REALTIME		0x0200	/* Unused in NetBSD */
+# define PCM_CAP_BATCH			0x0400	/* Unused in NetBSD */
+# define PCM_CAP_COPROC			0x0800	/* Unused in NetBSD */
+# define PCM_CAP_TRIGGER		0x1000	/* Supports SETTRIGGER */
+# define PCM_CAP_MMAP			0x2000	/* Supports mmap() */
+# define PCM_CAP_INPUT			0x4000	/* Recording device */
+# define PCM_CAP_OUTPUT			0x8000	/* Playback device */
+# define PCM_CAP_MODEM			0x0001	/* Unused in NetBSD */
+# define PCM_CAP_HIDDEN			0x0002	/* Unused in NetBSD */
+# define PCM_CAP_VIRTUAL		0x0004	/* Unused in NetBSD */
+# define PCM_CAP_ANALOGOUT		0x0010	/* Unused in NetBSD */
+# define PCM_CAP_ANALOGIN		0x0020	/* Unused in NetBSD */
+# define PCM_CAP_DIGITALOUT		0x0040	/* Unused in NetBSD */
+# define PCM_CAP_DIGITALIN		0x0080	/* Unused in NetBSD */
+# define PCM_CAP_ADMASK			0x00f0	/* Unused in NetBSD */
+# define PCM_CAP_SPECIAL		0x0100	/* Unused in NetBSD */
 #define SNDCTL_DSP_GETTRIGGER		_IOR ('P', 16, int)
 #define SNDCTL_DSP_SETTRIGGER		_IOW ('P', 16, int)
 # define PCM_ENABLE_INPUT		0x0001



CVS commit: src/lib/libossaudio

2020-11-03 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Nov  3 09:33:53 UTC 2020

Modified Files:
src/lib/libossaudio: soundcard.h

Log Message:
ossaudio(3): More capability defines from OSSv4


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libossaudio/soundcard.h

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



CVS commit: src/lib/libossaudio

2020-11-03 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Nov  3 08:24:33 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): return correctly initialized return value in unlikely
error case. pointed out by tnn.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/lib/libossaudio/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.59 src/lib/libossaudio/ossaudio.c:1.60
--- src/lib/libossaudio/ossaudio.c:1.59	Fri Oct 30 21:44:49 2020
+++ src/lib/libossaudio/ossaudio.c	Tue Nov  3 08:24:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.59 2020/10/30 21:44:49 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.60 2020/11/03 08:24:33 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.59 2020/10/30 21:44:49 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.60 2020/11/03 08:24:33 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -187,9 +187,9 @@ audio_ioctl(int fd, unsigned long com, v
 			INTARG = 192000;
 		tmpinfo.play.sample_rate =
 		tmpinfo.record.sample_rate = INTARG;
-		if (ioctl(fd, AUDIO_SETINFO, ) < 0) {
+		retval = ioctl(fd, AUDIO_SETINFO, );
+		if (retval < 0)
 			return retval;
-		}
 		/* FALLTHRU */
 	case SOUND_PCM_READ_RATE:
 		retval = ioctl(fd, AUDIO_GETBUFINFO, );



CVS commit: src/lib/libossaudio

2020-11-03 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Nov  3 08:24:33 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): return correctly initialized return value in unlikely
error case. pointed out by tnn.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 30 21:44:49 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Simplify setting rate (try to supply the nearest one possible)


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/lib/libossaudio/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.58 src/lib/libossaudio/ossaudio.c:1.59
--- src/lib/libossaudio/ossaudio.c:1.58	Sat Oct 24 14:43:53 2020
+++ src/lib/libossaudio/ossaudio.c	Fri Oct 30 21:44:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.58 2020/10/24 14:43:53 roy Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.59 2020/10/30 21:44:49 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.58 2020/10/24 14:43:53 roy Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.59 2020/10/30 21:44:49 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -180,36 +180,15 @@ audio_ioctl(int fd, unsigned long com, v
 		break;
 	case SNDCTL_DSP_SPEED:
 		AUDIO_INITINFO();
+		/* Conform to kernel limits. */
+		if (INTARG < 1000)
+			INTARG = 1000;
+		if (INTARG > 192000)
+			INTARG = 192000;
 		tmpinfo.play.sample_rate =
 		tmpinfo.record.sample_rate = INTARG;
-		/*
-		 * The default NetBSD behavior if an unsupported sample rate
-		 * is set is to return an error code and keep the rate at the
-		 * default of 8000 Hz.
-		 * 
-		 * However, OSS specifies that a sample rate supported by the
-		 * hardware is returned if the exact rate could not be set.
-		 * 
-		 * So, if the chosen sample rate is invalid, set and return
-		 * the current hardware rate.
-		 */
 		if (ioctl(fd, AUDIO_SETINFO, ) < 0) {
-			/* Don't care that SETINFO failed the first time... */
-			errno = 0;
-			retval = ioctl(fd, AUDIO_GETFORMAT, );
-			if (retval < 0)
-return retval;
-			retval = ioctl(fd, AUDIO_GETINFO, );
-			if (retval < 0)
-return retval;
-			tmpinfo.play.sample_rate =
-			tmpinfo.record.sample_rate =
-			(tmpinfo.mode == AUMODE_RECORD) ?
-			hwfmt.record.sample_rate :
-			hwfmt.play.sample_rate;
-			retval = ioctl(fd, AUDIO_SETINFO, );
-			if (retval < 0)
-return retval;
+			return retval;
 		}
 		/* FALLTHRU */
 	case SOUND_PCM_READ_RATE:



CVS commit: src/lib/libossaudio

2020-10-30 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 30 21:44:49 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Simplify setting rate (try to supply the nearest one possible)


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-10-24 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Oct 24 14:43:53 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
libossaudio: return newfd here as we return retval elsewhere


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-10-24 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Oct 24 14:43:53 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
libossaudio: return newfd here as we return retval elsewhere


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/lib/libossaudio/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.57 src/lib/libossaudio/ossaudio.c:1.58
--- src/lib/libossaudio/ossaudio.c:1.57	Fri Oct 23 12:13:04 2020
+++ src/lib/libossaudio/ossaudio.c	Sat Oct 24 14:43:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.57 2020/10/23 12:13:04 wiz Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.58 2020/10/24 14:43:53 roy Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.57 2020/10/23 12:13:04 wiz Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.58 2020/10/24 14:43:53 roy Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -1158,7 +1158,7 @@ mixer_oss4_ioctl(int fd, unsigned long c
 			"/dev/audio%d", cardinfo->card);
 			newfd = open(devname, O_RDONLY);
 			if (newfd < 0)
-return retval;
+return newfd;
 		} else {
 			newfd = fd;
 		}



CVS commit: src/lib/libossaudio

2020-10-23 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Oct 23 12:13:04 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-10-23 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Oct 23 12:13:04 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/lib/libossaudio/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.56 src/lib/libossaudio/ossaudio.c:1.57
--- src/lib/libossaudio/ossaudio.c:1.56	Fri Oct 23 09:05:20 2020
+++ src/lib/libossaudio/ossaudio.c	Fri Oct 23 12:13:04 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.56 2020/10/23 09:05:20 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.57 2020/10/23 12:13:04 wiz Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.56 2020/10/23 09:05:20 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.57 2020/10/23 12:13:04 wiz Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -1179,7 +1179,7 @@ mixer_oss4_ioctl(int fd, unsigned long c
 		 * OSSv4 does not document this ioctl, and claims it should
 		 * not be used by applications and is provided for "utiltiy
 		 * programs included in OSS". We follow the Solaris
-		 * implementation (which is doucmented) and leave these fields
+		 * implementation (which is documented) and leave these fields
 		 * unset.
 		 */
 		cardinfo->flags = 0;



CVS commit: src/lib/libossaudio

2020-10-23 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 23 09:05:20 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
ossaudio(3): Add an implementation of SNDCTL_CARDINFO

Correct some of the counts returned by SNDCTL_SYSINFO so this works.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.30 -r1.31 src/lib/libossaudio/soundcard.h

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



CVS commit: src/lib/libossaudio

2020-10-23 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 23 09:05:20 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
ossaudio(3): Add an implementation of SNDCTL_CARDINFO

Correct some of the counts returned by SNDCTL_SYSINFO so this works.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.30 -r1.31 src/lib/libossaudio/soundcard.h

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.55 src/lib/libossaudio/ossaudio.c:1.56
--- src/lib/libossaudio/ossaudio.c:1.55	Thu Oct 22 19:39:48 2020
+++ src/lib/libossaudio/ossaudio.c	Fri Oct 23 09:05:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.55 2020/10/22 19:39:48 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.56 2020/10/23 09:05:20 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.55 2020/10/22 19:39:48 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.56 2020/10/23 09:05:20 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -67,6 +67,7 @@ __RCSID("$NetBSD: ossaudio.c,v 1.55 2020
 
 static struct audiodevinfo *getdevinfo(int);
 
+static int getaudiocount(void);
 static int getmixercount(void);
 static int getmixercontrolcount(int);
 
@@ -1016,6 +1017,7 @@ static int
 mixer_oss4_ioctl(int fd, unsigned long com, void *argp)
 {
 	oss_audioinfo *tmpai;
+	oss_card_info *cardinfo;
 	oss_mixext *ext;
 	oss_mixext_root root;
 	oss_mixer_enuminfo *ei;
@@ -1147,6 +1149,43 @@ mixer_oss4_ioctl(int fd, unsigned long c
 		argp = tmpai;
 		close(newfd);
 		break;
+	case SNDCTL_CARDINFO:
+		cardinfo = (oss_card_info *)argp;
+		if (cardinfo == NULL)
+			return EINVAL;
+		if (cardinfo->card != -1) {
+			snprintf(devname, sizeof(devname),
+			"/dev/audio%d", cardinfo->card);
+			newfd = open(devname, O_RDONLY);
+			if (newfd < 0)
+return retval;
+		} else {
+			newfd = fd;
+		}
+		retval = ioctl(newfd, AUDIO_GETDEV, );
+		tmperrno = errno;
+		if (newfd != fd)
+			close(newfd);
+		if (retval < 0) {
+			errno = tmperrno;
+			return retval;
+		}
+		strlcpy(cardinfo->shortname, dev.name,
+		sizeof(cardinfo->shortname));
+		snprintf(cardinfo->longname, sizeof(cardinfo->longname),
+		"%s %s %s", dev.name, dev.version, dev.config);
+		memset(cardinfo->hw_info, 0, sizeof(cardinfo->hw_info));
+		/*
+		 * OSSv4 does not document this ioctl, and claims it should
+		 * not be used by applications and is provided for "utiltiy
+		 * programs included in OSS". We follow the Solaris
+		 * implementation (which is doucmented) and leave these fields
+		 * unset.
+		 */
+		cardinfo->flags = 0;
+		cardinfo->intr_count = 0;
+		cardinfo->ack_count = 0;
+		break;
 	case SNDCTL_SYSINFO:
 		memset(, 0, sizeof(sysinfo));
 		strlcpy(sysinfo.product,
@@ -1156,13 +1195,14 @@ mixer_oss4_ioctl(int fd, unsigned long c
 		strlcpy(sysinfo.license,
 		"BSD", sizeof(sysinfo.license));
 		sysinfo.versionnum = SOUND_VERSION;
-		sysinfo.numaudios = OSS_MAX_AUDIO_DEVS;
+		sysinfo.numaudios = 
+		sysinfo.numcards =
+			getaudiocount();
 		sysinfo.numaudioengines = 1;
 		sysinfo.numsynths = 1;
 		sysinfo.nummidis = -1;
 		sysinfo.numtimers = -1;
-		sysinfo.nummixers = OSS_MAX_AUDIO_DEVS;
-		sysinfo.numcards = 1;
+		sysinfo.nummixers = getmixercount();
 		*(struct oss_sysinfo *)argp = sysinfo;
 		break;
 	case SNDCTL_MIXERINFO:
@@ -1553,6 +1593,27 @@ global_oss4_ioctl(int fd, unsigned long 
 }
 
 static int
+getaudiocount(void)
+{
+	char devname[32];
+	int ndevs = 0;
+	int tmpfd;
+	int tmperrno = errno;
+
+	do {
+		snprintf(devname, sizeof(devname),
+		"/dev/audio%d", ndevs);
+		if ((tmpfd = open(devname, O_RDONLY)) != -1 ||
+		(tmpfd = open(devname, O_WRONLY)) != -1) {
+			ndevs++;
+			close(tmpfd);
+		}
+	} while (tmpfd != -1);
+	errno = tmperrno;
+	return ndevs;
+}
+
+static int
 getmixercount(void)
 {
 	char devname[32];

Index: src/lib/libossaudio/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.30 src/lib/libossaudio/soundcard.h:1.31
--- src/lib/libossaudio/soundcard.h:1.30	Tue Oct 20 08:57:45 2020
+++ src/lib/libossaudio/soundcard.h	Fri Oct 23 09:05:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.30 2020/10/20 08:57:45 nia Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.31 2020/10/23 09:05:20 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -407,6 +407,17 @@ typedef struct oss_audioinfo {
 	int filler[184];			/* For expansion */
 } oss_audioinfo;
 
+typedef struct oss_card_info {
+	int card;
+	char shortname[16];
+	char longname[128];
+	int flags;
+	char hw_info[400];
+	int intr_count;
+	int ack_count;
+	int filler[154];
+} oss_card_info;
+
 #define SNDCTL_SYSINFO		_IOR ('X', 1, oss_sysinfo)
 #define OSS_SYSINFO		SNDCTL_SYSINFO /* Old name */
 #define 

CVS commit: src/lib/libossaudio

2020-10-22 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Thu Oct 22 19:39:48 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): This is not compat_linux


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-10-22 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Thu Oct 22 19:39:48 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): This is not compat_linux


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/lib/libossaudio/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.54 src/lib/libossaudio/ossaudio.c:1.55
--- src/lib/libossaudio/ossaudio.c:1.54	Tue Oct 20 08:57:45 2020
+++ src/lib/libossaudio/ossaudio.c	Thu Oct 22 19:39:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.54 2020/10/20 08:57:45 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.55 2020/10/22 19:39:48 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.54 2020/10/20 08:57:45 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.55 2020/10/22 19:39:48 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -672,7 +672,7 @@ audio_ioctl(int fd, unsigned long com, v
 
 
 /* If the NetBSD mixer device should have more than NETBSD_MAXDEVS devices
- * some will not be available to Linux */
+ * some will not be available to OSS applications */
 #define NETBSD_MAXDEVS 64
 struct audiodevinfo {
 	int done;
@@ -733,7 +733,7 @@ enum_to_mask(struct audiodevinfo *di, in
 
 /*
  * Collect the audio device information to allow faster
- * emulation of the Linux mixer ioctls.  Cache the information
+ * emulation of the OSSv3 mixer ioctls.  Cache the information
  * to eliminate the overhead of repeating all the ioctls needed
  * to collect the information.
  */



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 08:57:45 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
ossaudio(3): Add SNDCTL_AUDIOINFO_EX as an alias of SNDCTL_AUDIOINFO


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.29 -r1.30 src/lib/libossaudio/soundcard.h

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



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 08:57:45 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
ossaudio(3): Add SNDCTL_AUDIOINFO_EX as an alias of SNDCTL_AUDIOINFO


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.29 -r1.30 src/lib/libossaudio/soundcard.h

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.53 src/lib/libossaudio/ossaudio.c:1.54
--- src/lib/libossaudio/ossaudio.c:1.53	Tue Oct 20 06:53:37 2020
+++ src/lib/libossaudio/ossaudio.c	Tue Oct 20 08:57:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.53 2020/10/20 06:53:37 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.54 2020/10/20 08:57:45 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.53 2020/10/20 06:53:37 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.54 2020/10/20 08:57:45 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -1045,6 +1045,13 @@ mixer_oss4_ioctl(int fd, unsigned long c
 
 	switch (com) {
 	case SNDCTL_AUDIOINFO:
+	/*
+	 * SNDCTL_AUDIOINFO_EX is intended for underlying hardware devices
+	 * that are to be opened in "exclusive mode" (bypassing the normal
+	 * kernel mixer for exclusive control). NetBSD does not support
+	 * bypassing the kernel mixer, so it's an alias of SNDCTL_AUDIOINFO.
+	 */
+	case SNDCTL_AUDIOINFO_EX:
 	case SNDCTL_ENGINEINFO:
 		devno = 0;
 		tmpai = (struct oss_audioinfo*)argp;

Index: src/lib/libossaudio/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.29 src/lib/libossaudio/soundcard.h:1.30
--- src/lib/libossaudio/soundcard.h:1.29	Tue Oct 20 06:33:52 2020
+++ src/lib/libossaudio/soundcard.h	Tue Oct 20 08:57:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.29 2020/10/20 06:33:52 nia Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.30 2020/10/20 08:57:45 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -418,6 +418,7 @@ typedef struct oss_audioinfo {
 #define SNDCTL_MIX_ENUMINFO	_IOWR ('X',8, oss_mixer_enuminfo)
 #define SNDCTL_MIXERINFO	_IOWR ('X',10, oss_mixerinfo)
 #define SNDCTL_ENGINEINFO	_IOWR ('X',12, oss_audioinfo)
+#define SNDCTL_AUDIOINFO_EX	_IOWR ('X',13, oss_audioinfo)
 #define SNDCTL_MIX_DESCRIPTION	_IOWR ('X',14, oss_mixer_enuminfo)
 
 #define MIXT_DEVROOT	 	0 /* Used for default classes */



CVS commit: src/lib/libossaudio

2020-10-20 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Oct 20 07:52:05 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libossaudio/ossaudio.3

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.3
diff -u src/lib/libossaudio/ossaudio.3:1.26 src/lib/libossaudio/ossaudio.3:1.27
--- src/lib/libossaudio/ossaudio.3:1.26	Tue Oct 20 06:43:55 2020
+++ src/lib/libossaudio/ossaudio.3	Tue Oct 20 07:52:04 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ossaudio.3,v 1.26 2020/10/20 06:43:55 nia Exp $
+.\"	$NetBSD: ossaudio.3,v 1.27 2020/10/20 07:52:04 wiz Exp $
 .\"
 .\" Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -115,7 +115,7 @@ is not currently implemented as in OSSv4
 global volume.
 Applications need to provide samples with the appropriate gain.
 .It
-Linux, 
+Linux,
 .Fx ,
 and Solaris provide
 .Pa /dev/dsp



CVS commit: src/lib/libossaudio

2020-10-20 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Oct 20 07:52:05 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libossaudio/ossaudio.3

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



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 06:53:38 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Plug a fd leak in the new mixer API


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/lib/libossaudio/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.52 src/lib/libossaudio/ossaudio.c:1.53
--- src/lib/libossaudio/ossaudio.c:1.52	Mon Oct 19 10:28:47 2020
+++ src/lib/libossaudio/ossaudio.c	Tue Oct 20 06:53:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.52 2020/10/19 10:28:47 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.53 2020/10/20 06:53:37 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.52 2020/10/19 10:28:47 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.53 2020/10/20 06:53:37 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -1328,9 +1328,9 @@ mixer_oss4_ioctl(int fd, unsigned long c
 			return newfd;
 		mdi.index = ei->ctrl - 1;
 		retval = ioctl(newfd, AUDIO_MIXER_DEVINFO, );
+		tmperrno = errno;
+		close(newfd);
 		if (retval < 0) {
-			tmperrno = errno;
-			close(newfd);
 			errno = tmperrno;
 			return retval;
 		}
@@ -1343,7 +1343,6 @@ mixer_oss4_ioctl(int fd, unsigned long c
 ei->strindex[i] = noffs;
 len = strlen(mdi.un.e.member[i].label.name) + 1;
 if ((noffs + len) >= sizeof(ei->strings)) {
-close(newfd);
 errno = ENOMEM;
 return -1;
 }
@@ -1359,7 +1358,6 @@ mixer_oss4_ioctl(int fd, unsigned long c
 ei->strindex[i] = noffs;
 len = strlen(mdi.un.s.member[i].label.name) + 1;
 if ((noffs + len) >= sizeof(ei->strings)) {
-close(newfd);
 errno = ENOMEM;
 return -1;
 }
@@ -1369,7 +1367,6 @@ mixer_oss4_ioctl(int fd, unsigned long c
 			}
 			break;
 		default:
-			close(newfd);
 			errno = EINVAL;
 			return -1;
 		}



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 06:53:38 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): Plug a fd leak in the new mixer API


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 06:43:56 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
ossaudio.3: Bump date


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libossaudio/ossaudio.3

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.3
diff -u src/lib/libossaudio/ossaudio.3:1.25 src/lib/libossaudio/ossaudio.3:1.26
--- src/lib/libossaudio/ossaudio.3:1.25	Tue Oct 20 06:43:34 2020
+++ src/lib/libossaudio/ossaudio.3	Tue Oct 20 06:43:55 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ossaudio.3,v 1.25 2020/10/20 06:43:34 nia Exp $
+.\"	$NetBSD: ossaudio.3,v 1.26 2020/10/20 06:43:55 nia Exp $
 .\"
 .\" Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 16, 2020
+.Dd October 20, 2020
 .Dt OSSAUDIO 3
 .Os
 .Sh NAME



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 06:43:34 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
ossaudio(3): Turn BUGS section into a list of potential compat issues


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libossaudio/ossaudio.3

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.3
diff -u src/lib/libossaudio/ossaudio.3:1.24 src/lib/libossaudio/ossaudio.3:1.25
--- src/lib/libossaudio/ossaudio.3:1.24	Sat Oct 17 09:04:59 2020
+++ src/lib/libossaudio/ossaudio.3	Tue Oct 20 06:43:34 2020
@@ -1,10 +1,10 @@
-.\"	$NetBSD: ossaudio.3,v 1.24 2020/10/17 09:04:59 wiz Exp $
+.\"	$NetBSD: ossaudio.3,v 1.25 2020/10/20 06:43:34 nia Exp $
 .\"
 .\" Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
 .\"
 .\" This code is derived from software contributed to The NetBSD Foundation
-.\" by Lennart Augustsson,
+.\" by Lennart Augustsson and Nia Alarie.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -50,7 +50,7 @@ interfaces for new programs, and this em
 building code written for other operating systems.
 .Ss Mixer Control Map
 The following table summarizes the mappings from native interface
-device names to OSS mixer controls.
+device names to OSSv3 mixer controls.
 .Bl -column ".Sy Native Device Name" "SOUND_MIXER_SPEAKER"
 .It Sy "Native Device Name" Ta Sy "OSS Mixer Control"
 .It *.mic Ta SOUND_MIXER_MIC
@@ -98,16 +98,24 @@ It remains the preferred API in
 .Fx
 and Solaris, and a large body of code exists supporting it.
 .Sh BUGS
-The emulation is incomplete, covering most of OSSv3 and some of OSSv4.
-Some obscure features are not included, but the essential ioctls used
-by the majority of software are covered.
-.Pp
-The emulation uses a #define for
-.Fn ioctl
-so some obscure programs
-can fail to compile.
-.Pp
-Linux,
+.Bl -bullet
+.It
+The emulation is incomplete.
+Some less popular features are not emulated (e.g. sync groups), but the
+essential ioctls used by the majority of software are covered.
+.It
+.Nx
+.Dv AUDIO_MIXER_SET
+control types cannot be accurately represented in the OSSv4 mixer API,
+so are treated as enums.
+.It
+Per-stream volume (i.e.
+.Dv SNDCTL_DSP_SETPLAYVOL )
+is not currently implemented as in OSSv4, and will instead modify the
+global volume.
+Applications need to provide samples with the appropriate gain.
+.It
+Linux, 
 .Fx ,
 and Solaris provide
 .Pa /dev/dsp
@@ -120,7 +128,7 @@ and
 devices this compatibility layer must be accessed through on
 .Nx .
 However, changing this is typically trivial when porting programs.
-.Pp
+.It
 The emulation only covers
 .Fn ioctl ,
 there are other differences as well.
@@ -131,3 +139,9 @@ whereas
 .Nx 1.3
 returns
 .Dv EAGAIN .
+.It
+The emulation uses a #define for
+.Fn ioctl
+so some obscure programs
+can fail to compile.
+.El



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 06:43:56 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
ossaudio.3: Bump date


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libossaudio/ossaudio.3

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



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 06:43:34 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
ossaudio(3): Turn BUGS section into a list of potential compat issues


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libossaudio/ossaudio.3

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



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 06:33:52 UTC 2020

Modified Files:
src/lib/libossaudio: soundcard.h

Log Message:
ossaudio(3): Add some endian-specific U16 formats

for compatibility with FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libossaudio/soundcard.h

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/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.28 src/lib/libossaudio/soundcard.h:1.29
--- src/lib/libossaudio/soundcard.h:1.28	Mon Oct 19 10:28:47 2020
+++ src/lib/libossaudio/soundcard.h	Tue Oct 20 06:33:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.28 2020/10/19 10:28:47 nia Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.29 2020/10/20 06:33:52 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -111,6 +111,8 @@
 /* Need native 16 bit format which depends on byte order */
 #include 
 #if _BYTE_ORDER == _LITTLE_ENDIAN
+#define  AFMT_U16_NE AFMT_U16_LE
+#define  AFMT_U16_OE AFMT_U16_BE
 #define  AFMT_S16_NE AFMT_S16_LE
 #define  AFMT_S16_OE AFMT_S16_BE
 #define  AFMT_S24_NE AFMT_S24_LE
@@ -118,6 +120,8 @@
 #define  AFMT_S32_NE AFMT_S32_LE
 #define  AFMT_S32_OE AFMT_S32_BE
 #else
+#define  AFMT_U16_NE AFMT_U16_BE
+#define  AFMT_U16_OE AFMT_U16_LE
 #define  AFMT_S16_NE AFMT_S16_BE
 #define  AFMT_S16_OE AFMT_S16_LE
 #define  AFMT_S24_NE AFMT_S24_BE



CVS commit: src/lib/libossaudio

2020-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Oct 20 06:33:52 UTC 2020

Modified Files:
src/lib/libossaudio: soundcard.h

Log Message:
ossaudio(3): Add some endian-specific U16 formats

for compatibility with FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libossaudio/soundcard.h

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



CVS commit: src/lib/libossaudio

2020-10-19 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Oct 19 10:28:47 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
ossaudio(3): add some no-op defines for ossv4 compat.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.27 -r1.28 src/lib/libossaudio/soundcard.h

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.51 src/lib/libossaudio/ossaudio.c:1.52
--- src/lib/libossaudio/ossaudio.c:1.51	Mon Oct 19 09:07:29 2020
+++ src/lib/libossaudio/ossaudio.c	Mon Oct 19 10:28:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.51 2020/10/19 09:07:29 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.52 2020/10/19 10:28:47 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.51 2020/10/19 09:07:29 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.52 2020/10/19 10:28:47 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -37,7 +37,7 @@ __RCSID("$NetBSD: ossaudio.c,v 1.51 2020
  * http://manuals.opensound.com/developer/
  * 
  * This file is similar to sys/compat/ossaudio.c with additional OSSv4
- * compatibility - with some preprocessor magic it could be the same file.
+ * compatibility.
  */
 
 #include 
@@ -79,6 +79,7 @@ static void setblocksize(int, struct aud
 static int audio_ioctl(int, unsigned long, void *);
 static int mixer_oss3_ioctl(int, unsigned long, void *);
 static int mixer_oss4_ioctl(int, unsigned long, void *);
+static int global_oss4_ioctl(int, unsigned long, void *);
 static int opaque_to_enum(struct audiodevinfo *, audio_mixer_name_t *, int);
 static int enum_to_ord(struct audiodevinfo *, int);
 static int enum_to_mask(struct audiodevinfo *, int);
@@ -101,6 +102,8 @@ _oss_ioctl(int fd, unsigned long com, ..
 		return mixer_oss3_ioctl(fd, com, argp);
 	else if (IOCGROUP(com) == 'X')
 		return mixer_oss4_ioctl(fd, com, argp);
+	else if (IOCGROUP(com) == 'Y')
+		return global_oss4_ioctl(fd, com, argp);
 	else
 		return ioctl(fd, com, argp);
 }
@@ -1515,6 +1518,37 @@ mixer_oss4_ioctl(int fd, unsigned long c
 }
 
 static int
+global_oss4_ioctl(int fd, unsigned long com, void *argp)
+{
+	int retval = 0;
+
+	switch (com) {
+	/*
+	 * These ioctls were added in OSSv4 with the idea that
+	 * applications could apply strings to audio devices to
+	 * display what they are using them for (e.g. with song
+	 * names) in mixer applications. In practice, the popular
+	 * implementations of the API in FreeBSD and Solaris treat
+	 * these as a no-op and return EINVAL, and no software in the
+	 * wild seems to use them.
+	 */
+	case SNDCTL_SETSONG:
+	case SNDCTL_GETSONG:
+	case SNDCTL_SETNAME:
+	case SNDCTL_SETLABEL:
+	case SNDCTL_GETLABEL:
+		errno = EINVAL;
+		retval = -1;
+		break;
+	default:
+		errno = EINVAL;
+		retval = -1;
+		break;
+	}
+	return retval;
+}
+
+static int
 getmixercount(void)
 {
 	char devname[32];

Index: src/lib/libossaudio/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.27 src/lib/libossaudio/soundcard.h:1.28
--- src/lib/libossaudio/soundcard.h:1.27	Mon Oct 19 09:01:24 2020
+++ src/lib/libossaudio/soundcard.h	Mon Oct 19 10:28:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.27 2020/10/19 09:01:24 nia Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.28 2020/10/19 10:28:47 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -475,6 +475,10 @@ typedef char oss_id_t[OSS_ID_SIZE];
 typedef char oss_devnode_t[OSS_DEVNODE_SIZE];
 #define OSS_HANDLE_SIZE		32
 typedef char oss_handle_t[OSS_HANDLE_SIZE];
+#define	OSS_LONGNAME_SIZE	64
+typedef char oss_longname_t[OSS_LONGNAME_SIZE];
+#define	OSS_LABEL_SIZE		16
+typedef char oss_label_t[OSS_LABEL_SIZE];
 
 typedef struct oss_mixext_root {
 	oss_id_t id;
@@ -542,6 +546,17 @@ typedef struct oss_mixext {
 	int filler[6];
 } oss_mixext;
 
+
+/*
+ * These are no-ops on FreeBSD, NetBSD, and Solaris,
+ * but are defined for compatibility with OSSv4.
+ */
+#define SNDCTL_SETSONG		_IOW ('Y',2, oss_longname_t)
+#define SNDCTL_GETSONG		_IOR ('Y',2, oss_longname_t)
+#define SNDCTL_SETNAME		_IOW ('Y',3, oss_longname_t)
+#define SNDCTL_SETLABEL		_IOW ('Y',4, oss_label_t)
+#define SNDCTL_GETLABEL		_IOR ('Y',4, oss_label_t)
+
 #define ioctl _oss_ioctl
 /*
  * If we already included , then we define our own prototype,



CVS commit: src/lib/libossaudio

2020-10-19 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Oct 19 10:28:47 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
ossaudio(3): add some no-op defines for ossv4 compat.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.27 -r1.28 src/lib/libossaudio/soundcard.h

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



CVS commit: src/lib/libossaudio

2020-10-19 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Oct 19 09:07:29 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): these ioctls need to return samples, not bytes


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/lib/libossaudio/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.50 src/lib/libossaudio/ossaudio.c:1.51
--- src/lib/libossaudio/ossaudio.c:1.50	Mon Oct 19 09:01:24 2020
+++ src/lib/libossaudio/ossaudio.c	Mon Oct 19 09:07:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.50 2020/10/19 09:01:24 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.51 2020/10/19 09:07:29 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.50 2020/10/19 09:01:24 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.51 2020/10/19 09:07:29 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -584,8 +584,12 @@ audio_ioctl(int fd, unsigned long com, v
 			return retval;
 		/* XXX: 'samples' may wrap */
 		memset(osscount.filler, 0, sizeof(osscount.filler));
-		osscount.samples = tmpinfo.record.samples;
-		osscount.fifo_samples = tmpinfo.record.seek;
+		osscount.samples = tmpinfo.record.samples /
+		((tmpinfo.record.precision / NBBY) *
+			tmpinfo.record.channels);
+		osscount.fifo_samples = tmpinfo.record.seek /
+		((tmpinfo.record.precision / NBBY) *
+			tmpinfo.record.channels);
 		*(oss_count_t *)argp = osscount;
 		break;
 	case SNDCTL_DSP_GETOPTR:
@@ -603,8 +607,12 @@ audio_ioctl(int fd, unsigned long com, v
 			return retval;
 		/* XXX: 'samples' may wrap */
 		memset(osscount.filler, 0, sizeof(osscount.filler));
-		osscount.samples = tmpinfo.play.samples;
-		osscount.fifo_samples = tmpinfo.play.seek;
+		osscount.samples = tmpinfo.play.samples /
+		((tmpinfo.play.precision / NBBY) *
+			tmpinfo.play.channels);
+		osscount.fifo_samples = tmpinfo.play.seek /
+		((tmpinfo.play.precision / NBBY) *
+			tmpinfo.play.channels);
 		*(oss_count_t *)argp = osscount;
 		break;
 	case SNDCTL_DSP_SETPLAYVOL:



CVS commit: src/lib/libossaudio

2020-10-19 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Oct 19 09:07:29 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio(3): these ioctls need to return samples, not bytes


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-10-19 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Oct 19 09:01:24 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
ossaudio(3): Add SNDCTL_DSP_CURRENT_(I|O)PTR

In OSSv4 these are supposed to avoid the wrapping problems with the
older GET(I|O)PTR ioctls but we don't quite get the same benefit here.

XXX: We could probably fake it by maintaining some state in-between calls.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.26 -r1.27 src/lib/libossaudio/soundcard.h

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.49 src/lib/libossaudio/ossaudio.c:1.50
--- src/lib/libossaudio/ossaudio.c:1.49	Sat Oct 17 23:23:06 2020
+++ src/lib/libossaudio/ossaudio.c	Mon Oct 19 09:01:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.49 2020/10/17 23:23:06 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.50 2020/10/19 09:01:24 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.49 2020/10/17 23:23:06 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.50 2020/10/19 09:01:24 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -121,6 +121,7 @@ audio_ioctl(int fd, unsigned long com, v
 	int perrors, rerrors;
 	static int totalperrors = 0;
 	static int totalrerrors = 0;
+	oss_count_t osscount;
 	int idat, idata;
 	int retval;
 
@@ -577,6 +578,16 @@ audio_ioctl(int fd, unsigned long com, v
 		cntinfo.ptr = tmpoffs.offset;
 		*(struct count_info *)argp = cntinfo;
 		break;
+	case SNDCTL_DSP_CURRENT_IPTR:
+		retval = ioctl(fd, AUDIO_GETBUFINFO, );
+		if (retval < 0)
+			return retval;
+		/* XXX: 'samples' may wrap */
+		memset(osscount.filler, 0, sizeof(osscount.filler));
+		osscount.samples = tmpinfo.record.samples;
+		osscount.fifo_samples = tmpinfo.record.seek;
+		*(oss_count_t *)argp = osscount;
+		break;
 	case SNDCTL_DSP_GETOPTR:
 		retval = ioctl(fd, AUDIO_GETOOFFS, );
 		if (retval < 0)
@@ -586,6 +597,16 @@ audio_ioctl(int fd, unsigned long com, v
 		cntinfo.ptr = tmpoffs.offset;
 		*(struct count_info *)argp = cntinfo;
 		break;
+	case SNDCTL_DSP_CURRENT_OPTR:
+		retval = ioctl(fd, AUDIO_GETBUFINFO, );
+		if (retval < 0)
+			return retval;
+		/* XXX: 'samples' may wrap */
+		memset(osscount.filler, 0, sizeof(osscount.filler));
+		osscount.samples = tmpinfo.play.samples;
+		osscount.fifo_samples = tmpinfo.play.seek;
+		*(oss_count_t *)argp = osscount;
+		break;
 	case SNDCTL_DSP_SETPLAYVOL:
 		setvol(fd, INTARG, false);
 		/* FALLTHRU */

Index: src/lib/libossaudio/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.26 src/lib/libossaudio/soundcard.h:1.27
--- src/lib/libossaudio/soundcard.h:1.26	Sat Oct 17 23:23:06 2020
+++ src/lib/libossaudio/soundcard.h	Mon Oct 19 09:01:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.26 2020/10/17 23:23:06 nia Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.27 2020/10/19 09:01:24 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -326,6 +326,14 @@ typedef struct buffmem_desc {
 #define SNDCTL_DSP_SILENCE		_IO ('P',32)
 #define SNDCTL_DSP_COOKEDMODE		_IOW ('P',33, int)
 #define SNDCTL_DSP_GETERROR		_IOR ('P',34, struct audio_errinfo)
+#define SNDCTL_DSP_CURRENT_IPTR		_IOR ('P',35, oss_count_t)
+#define SNDCTL_DSP_CURRENT_OPTR		_IOR ('P',36, oss_count_t)
+
+typedef struct {
+	long long samples;
+	int fifo_samples;
+	int filler[32];			/* "Future use" */
+} oss_count_t;
 
 typedef struct audio_errinfo {
 	int play_underruns;



CVS commit: src/lib/libossaudio

2020-10-19 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Oct 19 09:01:24 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
ossaudio(3): Add SNDCTL_DSP_CURRENT_(I|O)PTR

In OSSv4 these are supposed to avoid the wrapping problems with the
older GET(I|O)PTR ioctls but we don't quite get the same benefit here.

XXX: We could probably fake it by maintaining some state in-between calls.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.26 -r1.27 src/lib/libossaudio/soundcard.h

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



CVS commit: src/lib/libossaudio

2020-10-17 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 17 23:23:06 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
ossaudio(3): Add initial support for the OSSv4.1 Mixer API

One or two calls from this API were supported previously and have been
moved to the correct place.

Mapping the controls correctly is a difficult task. There is a define
hidden in the OSS headers that would allow an AUDIO_MIXER_SET control
to be represented perfectly, but it seems to _only_ exist there, and
no software supports it. So for now only one member of a set can be
set at a time - unfortunate. I've hidden code that should unlock
doing this the proper way under #notyet.

I'm not too happy with the way this code is managing file descriptors.
Currently it has to open a new fd for each ioctl due to OSSv4 deciding
to specify the device number in a structure rather than in the filename.
In the future, we could reuse the file descriptor if the correct one is
detected open.

This allows the mixer programs provided with the OSSv4 sources to compile
and work cleanly. I've observed problems with it failing to work on
secondary devices, and should investigate this later. There may be
a fd leak somewhere.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.25 -r1.26 src/lib/libossaudio/soundcard.h

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



CVS commit: src/lib/libossaudio

2020-10-17 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 17 23:23:06 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
ossaudio(3): Add initial support for the OSSv4.1 Mixer API

One or two calls from this API were supported previously and have been
moved to the correct place.

Mapping the controls correctly is a difficult task. There is a define
hidden in the OSS headers that would allow an AUDIO_MIXER_SET control
to be represented perfectly, but it seems to _only_ exist there, and
no software supports it. So for now only one member of a set can be
set at a time - unfortunate. I've hidden code that should unlock
doing this the proper way under #notyet.

I'm not too happy with the way this code is managing file descriptors.
Currently it has to open a new fd for each ioctl due to OSSv4 deciding
to specify the device number in a structure rather than in the filename.
In the future, we could reuse the file descriptor if the correct one is
detected open.

This allows the mixer programs provided with the OSSv4 sources to compile
and work cleanly. I've observed problems with it failing to work on
secondary devices, and should investigate this later. There may be
a fd leak somewhere.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.25 -r1.26 src/lib/libossaudio/soundcard.h

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.48 src/lib/libossaudio/ossaudio.c:1.49
--- src/lib/libossaudio/ossaudio.c:1.48	Fri Oct 16 20:24:35 2020
+++ src/lib/libossaudio/ossaudio.c	Sat Oct 17 23:23:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.48 2020/10/16 20:24:35 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.49 2020/10/17 23:23:06 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.48 2020/10/16 20:24:35 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.49 2020/10/17 23:23:06 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -49,6 +49,7 @@ __RCSID("$NetBSD: ossaudio.c,v 1.48 2020
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -66,6 +67,9 @@ __RCSID("$NetBSD: ossaudio.c,v 1.48 2020
 
 static struct audiodevinfo *getdevinfo(int);
 
+static int getmixercount(void);
+static int getmixercontrolcount(int);
+
 static int getvol(u_int, u_char);
 static void setvol(int, int, bool);
 
@@ -73,7 +77,8 @@ static void setchannels(int, int, int);
 static void setblocksize(int, struct audio_info *);
 
 static int audio_ioctl(int, unsigned long, void *);
-static int mixer_ioctl(int, unsigned long, void *);
+static int mixer_oss3_ioctl(int, unsigned long, void *);
+static int mixer_oss4_ioctl(int, unsigned long, void *);
 static int opaque_to_enum(struct audiodevinfo *, audio_mixer_name_t *, int);
 static int enum_to_ord(struct audiodevinfo *, int);
 static int enum_to_mask(struct audiodevinfo *, int);
@@ -93,7 +98,9 @@ _oss_ioctl(int fd, unsigned long com, ..
 	if (IOCGROUP(com) == 'P')
 		return audio_ioctl(fd, com, argp);
 	else if (IOCGROUP(com) == 'M')
-		return mixer_ioctl(fd, com, argp);
+		return mixer_oss3_ioctl(fd, com, argp);
+	else if (IOCGROUP(com) == 'X')
+		return mixer_oss4_ioctl(fd, com, argp);
 	else
 		return ioctl(fd, com, argp);
 }
@@ -105,17 +112,9 @@ audio_ioctl(int fd, unsigned long com, v
 	struct audio_info tmpinfo, hwfmt;
 	struct audio_offset tmpoffs;
 	struct audio_buf_info bufinfo;
-	struct audio_format_query fmtq;
 	struct audio_errinfo *tmperrinfo;
 	struct count_info cntinfo;
 	struct audio_encoding tmpenc;
-	struct oss_sysinfo tmpsysinfo;
-	struct oss_audioinfo *tmpaudioinfo;
-	audio_device_t tmpaudiodev;
-	struct stat tmpstat;
-	dev_t devno;
-	char version[32] = "4.01";
-	char license[16] = "NetBSD";
 	u_int u;
 	u_int encoding;
 	u_int precision;
@@ -123,9 +122,7 @@ audio_ioctl(int fd, unsigned long com, v
 	static int totalperrors = 0;
 	static int totalrerrors = 0;
 	int idat, idata;
-	int props;
 	int retval;
-	int newfd;
 
 	idat = 0;
 
@@ -589,117 +586,6 @@ audio_ioctl(int fd, unsigned long com, v
 		cntinfo.ptr = tmpoffs.offset;
 		*(struct count_info *)argp = cntinfo;
 		break;
-	case SNDCTL_SYSINFO:
-		strlcpy(tmpsysinfo.product, "OSS/NetBSD",
-		sizeof tmpsysinfo.product);
-		strlcpy(tmpsysinfo.version, version, sizeof tmpsysinfo.version);
-		strlcpy(tmpsysinfo.license, license, sizeof tmpsysinfo.license);
-		tmpsysinfo.versionnum = SOUND_VERSION;
-		memset(tmpsysinfo.options, 0, 8);
-		tmpsysinfo.numaudios = OSS_MAX_AUDIO_DEVS;
-		tmpsysinfo.numaudioengines = 1;
-		memset(tmpsysinfo.openedaudio, 0, sizeof(tmpsysinfo.openedaudio));
-		tmpsysinfo.numsynths = 1;
-		tmpsysinfo.nummidis = -1;
-		tmpsysinfo.numtimers = -1;
-		tmpsysinfo.nummixers = 1;
-		tmpsysinfo.numcards = 1;
-		

CVS commit: src/lib/libossaudio

2020-10-17 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Oct 17 09:04:59 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
Use Fx and Nx. End Rs block. Remove trailing whitespace.
Remove unnecessary Pp.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libossaudio/ossaudio.3

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.3
diff -u src/lib/libossaudio/ossaudio.3:1.23 src/lib/libossaudio/ossaudio.3:1.24
--- src/lib/libossaudio/ossaudio.3:1.23	Fri Oct 16 20:51:54 2020
+++ src/lib/libossaudio/ossaudio.3	Sat Oct 17 09:04:59 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ossaudio.3,v 1.23 2020/10/16 20:51:54 nia Exp $
+.\"	$NetBSD: ossaudio.3,v 1.24 2020/10/17 09:04:59 wiz Exp $
 .\"
 .\" Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -51,7 +51,6 @@ building code written for other operatin
 .Ss Mixer Control Map
 The following table summarizes the mappings from native interface
 device names to OSS mixer controls.
-.Pp
 .Bl -column ".Sy Native Device Name" "SOUND_MIXER_SPEAKER"
 .It Sy "Native Device Name" Ta Sy "OSS Mixer Control"
 .It *.mic Ta SOUND_MIXER_MIC
@@ -77,9 +76,10 @@ described in:
 .Pp
 .Rs
 .%A 4Front Technologies
-.%T OSS 4.x Programmer's Guide 
+.%T OSS 4.x Programmer's Guide
 .%U http://manuals.opensound.com/developer/
 .%D 2007
+.Re
 .Sh SEE ALSO
 .Xr ioctl 2 ,
 .Xr audio 4 ,
@@ -94,10 +94,10 @@ library first appeared in
 The Open Sound System up to version 3 was originally the preferred
 API for writing audio code under Linux until ALSA became the new default
 in Linux 2.6.
-It remains the preferred API in FreeBSD and Solaris, and a large body
-of code exists supporting it.
+It remains the preferred API in
+.Fx
+and Solaris, and a large body of code exists supporting it.
 .Sh BUGS
-.Pp
 The emulation is incomplete, covering most of OSSv3 and some of OSSv4.
 Some obscure features are not included, but the essential ioctls used
 by the majority of software are covered.
@@ -107,7 +107,9 @@ The emulation uses a #define for
 so some obscure programs
 can fail to compile.
 .Pp
-Linux, FreeBSD, and Solaris provide
+Linux,
+.Fx ,
+and Solaris provide
 .Pa /dev/dsp
 and
 .Pa /dev/mixer
@@ -115,7 +117,8 @@ devices in place of the
 .Pa /dev/audio
 and
 .Pa /dev/mixer
-devices this compatibility layer must be accessed through on NetBSD.
+devices this compatibility layer must be accessed through on
+.Nx .
 However, changing this is typically trivial when porting programs.
 .Pp
 The emulation only covers



CVS commit: src/lib/libossaudio

2020-10-17 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Oct 17 09:04:59 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
Use Fx and Nx. End Rs block. Remove trailing whitespace.
Remove unnecessary Pp.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libossaudio/ossaudio.3

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



CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 20:51:54 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
ossaudio.3: note this is most/all of ossv3 and some of ossv4


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libossaudio/ossaudio.3

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.3
diff -u src/lib/libossaudio/ossaudio.3:1.22 src/lib/libossaudio/ossaudio.3:1.23
--- src/lib/libossaudio/ossaudio.3:1.22	Fri Oct 16 16:48:07 2020
+++ src/lib/libossaudio/ossaudio.3	Fri Oct 16 20:51:54 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ossaudio.3,v 1.22 2020/10/16 16:48:07 nia Exp $
+.\"	$NetBSD: ossaudio.3,v 1.23 2020/10/16 20:51:54 nia Exp $
 .\"
 .\" Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -98,7 +98,7 @@ It remains the preferred API in FreeBSD 
 of code exists supporting it.
 .Sh BUGS
 .Pp
-The emulation is incomplete.
+The emulation is incomplete, covering most of OSSv3 and some of OSSv4.
 Some obscure features are not included, but the essential ioctls used
 by the majority of software are covered.
 .Pp



CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 20:51:54 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
ossaudio.3: note this is most/all of ossv3 and some of ossv4


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libossaudio/ossaudio.3

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



CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 20:24:35 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
ossaudio(3): Add SNDCTL_DSP_COOKEDMODE, SNDCTL_DSP_GETERROR

SNDCTL_DSP_COOKEDMODE simply always returns 1.
"Cooked mode" is a silly way the OSSv4 authors chose to refer to allowing
for reprocessed streams. The NetBSD kernel always performs format
conversion and it can't be turned off.

SNDCTL_DSP_GETERROR provides access to the read/write over/underrun
counters. There are other things it might return, but they don't make
sense for our implementation.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.24 -r1.25 src/lib/libossaudio/soundcard.h

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



CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 20:24:35 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
ossaudio(3): Add SNDCTL_DSP_COOKEDMODE, SNDCTL_DSP_GETERROR

SNDCTL_DSP_COOKEDMODE simply always returns 1.
"Cooked mode" is a silly way the OSSv4 authors chose to refer to allowing
for reprocessed streams. The NetBSD kernel always performs format
conversion and it can't be turned off.

SNDCTL_DSP_GETERROR provides access to the read/write over/underrun
counters. There are other things it might return, but they don't make
sense for our implementation.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.24 -r1.25 src/lib/libossaudio/soundcard.h

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.47 src/lib/libossaudio/ossaudio.c:1.48
--- src/lib/libossaudio/ossaudio.c:1.47	Fri Oct 16 15:40:16 2020
+++ src/lib/libossaudio/ossaudio.c	Fri Oct 16 20:24:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.47 2020/10/16 15:40:16 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.48 2020/10/16 20:24:35 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.47 2020/10/16 15:40:16 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.48 2020/10/16 20:24:35 nia Exp $");
 
 /*
  * This is an Open Sound System compatibility layer, which provides
@@ -106,6 +106,7 @@ audio_ioctl(int fd, unsigned long com, v
 	struct audio_offset tmpoffs;
 	struct audio_buf_info bufinfo;
 	struct audio_format_query fmtq;
+	struct audio_errinfo *tmperrinfo;
 	struct count_info cntinfo;
 	struct audio_encoding tmpenc;
 	struct oss_sysinfo tmpsysinfo;
@@ -118,6 +119,9 @@ audio_ioctl(int fd, unsigned long com, v
 	u_int u;
 	u_int encoding;
 	u_int precision;
+	int perrors, rerrors;
+	static int totalperrors = 0;
+	static int totalrerrors = 0;
 	int idat, idata;
 	int props;
 	int retval;
@@ -136,6 +140,39 @@ audio_ioctl(int fd, unsigned long com, v
 		if (retval < 0)
 			return retval;
 		break;
+	case SNDCTL_DSP_GETERROR:
+		tmperrinfo = (struct audio_errinfo *)argp;
+		if (tmperrinfo == NULL)
+			return EINVAL;
+		memset(tmperrinfo, 0, sizeof(struct audio_errinfo));
+		if ((retval = ioctl(fd, AUDIO_GETBUFINFO, )) < 0)
+			return retval;
+		/*
+		 * OSS requires that we return counters that are relative to
+		 * the last call. We must maintain state here...
+		 */
+		if (ioctl(fd, AUDIO_PERROR, ) != -1) {
+			perrors /= ((tmpinfo.play.precision / NBBY) *
+			tmpinfo.play.channels);
+			tmperrinfo->play_underruns =
+			(perrors / tmpinfo.blocksize) - totalperrors;
+			totalperrors += tmperrinfo->play_underruns;
+		}
+		if (ioctl(fd, AUDIO_RERROR, ) != -1) {
+			rerrors /= ((tmpinfo.record.precision / NBBY) *
+			tmpinfo.record.channels);
+			tmperrinfo->rec_overruns =
+			(rerrors / tmpinfo.blocksize) - totalrerrors;
+			totalrerrors += tmperrinfo->rec_overruns;
+		}
+		break;
+	case SNDCTL_DSP_COOKEDMODE:
+		/*
+		 * NetBSD is always running in "cooked mode" - the kernel
+		 * always performs format conversions.
+		 */
+		INTARG = 1;
+		break;
 	case SNDCTL_DSP_POST:
 		/* This call is merely advisory, and may be a nop. */
 		break;

Index: src/lib/libossaudio/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.24 src/lib/libossaudio/soundcard.h:1.25
--- src/lib/libossaudio/soundcard.h:1.24	Tue Sep  9 10:45:18 2014
+++ src/lib/libossaudio/soundcard.h	Fri Oct 16 20:24:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.24 2014/09/09 10:45:18 nat Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.25 2020/10/16 20:24:35 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -327,6 +327,22 @@ typedef struct buffmem_desc {
 #define SNDCTL_DSP_SETRECVOL		_IOW ('P',30, uint)
 #define SNDCTL_DSP_SKIP			_IO ('P',31)
 #define SNDCTL_DSP_SILENCE		_IO ('P',32)
+#define SNDCTL_DSP_COOKEDMODE		_IOW ('P',33, int)
+#define SNDCTL_DSP_GETERROR		_IOR ('P',34, struct audio_errinfo)
+
+typedef struct audio_errinfo {
+	int play_underruns;
+	int rec_overruns;
+	unsigned int play_ptradjust;	/* Obsolete */
+	unsigned int rec_ptradjust;	/* Obsolete */
+	int play_errorcount;		/* Unused */
+	int rec_errorcount;		/* Unused */
+	int play_lasterror;		/* Unused */
+	int rec_lasterror;		/* Unused */
+	int play_errorparm;		/* Unused */
+	int rec_errorparm;		/* Unused */
+	int filler[16];			/* Unused */
+} audio_errinfo;
 
 typedef struct oss_sysinfo {
 	char product[32];



CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 16:48:07 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
ossaudio.3: Sort sections.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libossaudio/ossaudio.3

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.3
diff -u src/lib/libossaudio/ossaudio.3:1.21 src/lib/libossaudio/ossaudio.3:1.22
--- src/lib/libossaudio/ossaudio.3:1.21	Fri Oct 16 16:30:53 2020
+++ src/lib/libossaudio/ossaudio.3	Fri Oct 16 16:48:07 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ossaudio.3,v 1.21 2020/10/16 16:30:53 nia Exp $
+.\"	$NetBSD: ossaudio.3,v 1.22 2020/10/16 16:48:07 nia Exp $
 .\"
 .\" Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -69,6 +69,17 @@ device names to OSS mixer controls.
 .It *.fmsynth Ta SOUND_MIXER_SYNTH
 .It *.midi Ta SOUND_MIXER_SYNTH
 .El
+.Sh COMPATIBILITY
+The
+.Nm
+interface aims to be compatible with the Open Sound System version 4, as
+described in:
+.Pp
+.Rs
+.%A 4Front Technologies
+.%T OSS 4.x Programmer's Guide 
+.%U http://manuals.opensound.com/developer/
+.%D 2007
 .Sh SEE ALSO
 .Xr ioctl 2 ,
 .Xr audio 4 ,
@@ -85,17 +96,6 @@ API for writing audio code under Linux u
 in Linux 2.6.
 It remains the preferred API in FreeBSD and Solaris, and a large body
 of code exists supporting it.
-.Sh COMPATIBILITY
-The
-.Nm
-interface aims to be compatible with the Open Sound System version 4, as
-described in:
-.Pp
-.Rs
-.%A 4Front Technologies
-.%T OSS 4.x Programmer's Guide 
-.%U http://manuals.opensound.com/developer/
-.%D 2007
 .Sh BUGS
 .Pp
 The emulation is incomplete.



CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 16:48:07 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
ossaudio.3: Sort sections.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libossaudio/ossaudio.3

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



CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 16:30:53 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
ossaudio.3: More information about the history and status of this API


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libossaudio/ossaudio.3

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



CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 16:30:53 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.3

Log Message:
ossaudio.3: More information about the history and status of this API


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libossaudio/ossaudio.3

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.3
diff -u src/lib/libossaudio/ossaudio.3:1.20 src/lib/libossaudio/ossaudio.3:1.21
--- src/lib/libossaudio/ossaudio.3:1.20	Thu Mar 12 12:33:46 2009
+++ src/lib/libossaudio/ossaudio.3	Fri Oct 16 16:30:53 2020
@@ -1,6 +1,6 @@
-.\"	$NetBSD: ossaudio.3,v 1.20 2009/03/12 12:33:46 joerg Exp $
+.\"	$NetBSD: ossaudio.3,v 1.21 2020/10/16 16:30:53 nia Exp $
 .\"
-.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
+.\" Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
 .\" All rights reserved.
 .\"
 .\" This code is derived from software contributed to The NetBSD Foundation
@@ -27,12 +27,12 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 3, 2009
+.Dd October 16, 2020
 .Dt OSSAUDIO 3
 .Os
 .Sh NAME
 .Nm ossaudio
-.Nd OSS audio emulation
+.Nd Open Sound System emulation
 .Sh LIBRARY
 .Lb libossaudio
 .Sh SYNOPSIS
@@ -40,11 +40,14 @@
 .Sh DESCRIPTION
 The
 .Nm
-library provides an emulation of the OSS (Linux) audio
-interface.
+library provides an emulation of the Open Sound System audio interface.
 .Pp
-Use the native interface for new programs and the emulation
-library only for porting programs.
+Use the native
+.Xr audio 4
+and
+.Xr mixer 4
+interfaces for new programs, and this emulation library only for
+building code written for other operating systems.
 .Ss Mixer Control Map
 The following table summarizes the mappings from native interface
 device names to OSS mixer controls.
@@ -67,20 +70,53 @@ device names to OSS mixer controls.
 .It *.midi Ta SOUND_MIXER_SYNTH
 .El
 .Sh SEE ALSO
+.Xr ioctl 2 ,
 .Xr audio 4 ,
-.Xr midi 4
+.Xr midi 4 ,
+.Xr mixer 4
 .Sh HISTORY
 The
 .Nm
 library first appeared in
 .Nx 1.3 .
+.Pp
+The Open Sound System up to version 3 was originally the preferred
+API for writing audio code under Linux until ALSA became the new default
+in Linux 2.6.
+It remains the preferred API in FreeBSD and Solaris, and a large body
+of code exists supporting it.
+.Sh COMPATIBILITY
+The
+.Nm
+interface aims to be compatible with the Open Sound System version 4, as
+described in:
+.Pp
+.Rs
+.%A 4Front Technologies
+.%T OSS 4.x Programmer's Guide 
+.%U http://manuals.opensound.com/developer/
+.%D 2007
 .Sh BUGS
+.Pp
+The emulation is incomplete.
+Some obscure features are not included, but the essential ioctls used
+by the majority of software are covered.
+.Pp
 The emulation uses a #define for
 .Fn ioctl
 so some obscure programs
 can fail to compile.
 .Pp
-The emulation is incomplete.
+Linux, FreeBSD, and Solaris provide
+.Pa /dev/dsp
+and
+.Pa /dev/mixer
+devices in place of the
+.Pa /dev/audio
+and
+.Pa /dev/mixer
+devices this compatibility layer must be accessed through on NetBSD.
+However, changing this is typically trivial when porting programs.
 .Pp
 The emulation only covers
 .Fn ioctl ,



CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 15:40:16 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio: Bump copyright date and improve description.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/lib/libossaudio/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.46 src/lib/libossaudio/ossaudio.c:1.47
--- src/lib/libossaudio/ossaudio.c:1.46	Fri Oct 16 12:36:01 2020
+++ src/lib/libossaudio/ossaudio.c	Fri Oct 16 15:40:16 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: ossaudio.c,v 1.46 2020/10/16 12:36:01 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.47 2020/10/16 15:40:16 nia Exp $	*/
 
 /*-
- * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,15 +27,17 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.46 2020/10/16 12:36:01 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.47 2020/10/16 15:40:16 nia Exp $");
 
 /*
- * This is an OSS (Linux) sound API emulator.
- * It provides the essentials of the API.
- */
-
-/* XXX This file is essentially the same as sys/compat/ossaudio.c.
- * With some preprocessor magic it could be the same file.
+ * This is an Open Sound System compatibility layer, which provides
+ * fairly complete ioctl emulation for OSSv3 and some of OSSv4.
+ *
+ * The canonical OSS specification is available at
+ * http://manuals.opensound.com/developer/
+ * 
+ * This file is similar to sys/compat/ossaudio.c with additional OSSv4
+ * compatibility - with some preprocessor magic it could be the same file.
  */
 
 #include 



CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 15:40:16 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio: Bump copyright date and improve description.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 12:36:01 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio: Add comments for the more obscure parts of SNDCTL_AUDIOINFO


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/lib/libossaudio/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.45 src/lib/libossaudio/ossaudio.c:1.46
--- src/lib/libossaudio/ossaudio.c:1.45	Fri Oct 16 12:23:34 2020
+++ src/lib/libossaudio/ossaudio.c	Fri Oct 16 12:36:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.45 2020/10/16 12:23:34 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.46 2020/10/16 12:36:01 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.45 2020/10/16 12:23:34 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.46 2020/10/16 12:36:01 nia Exp $");
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -574,6 +574,15 @@ audio_ioctl(int fd, unsigned long com, v
 		tmpaudioinfo = (struct oss_audioinfo*)argp;
 		if (tmpaudioinfo == NULL)
 			return EINVAL;
+
+		/*
+		 * Takes the audio dev node as input, since this ioctl is
+		 * supposed to work on the OSS /dev/mixer to query all
+		 * all available audio devices.
+		 *
+		 * If the input device is -1, guess the device related to
+		 * the open mixer device.
+		 */
 		if (tmpaudioinfo->dev < 0) {
 			fstat(fd, );
 			if ((tmpstat.st_rdev & 0xff00) == 0x2a00)
@@ -619,7 +628,7 @@ audio_ioctl(int fd, unsigned long com, v
 		tmpaudioinfo->caps = idat;
 		ioctl(newfd, SNDCTL_DSP_GETFMTS, >iformats);
 		tmpaudioinfo->oformats = tmpaudioinfo->iformats;
-		tmpaudioinfo->magic = -1;
+		tmpaudioinfo->magic = -1; /* reserved for "internal use" */
 		memset(tmpaudioinfo->cmd, 0, sizeof(tmpaudioinfo->cmd));
 		tmpaudioinfo->card_number = -1;
 		memset(tmpaudioinfo->song_name, 0,
@@ -627,10 +636,10 @@ audio_ioctl(int fd, unsigned long com, v
 		memset(tmpaudioinfo->label, 0, sizeof(tmpaudioinfo->label));
 		tmpaudioinfo->port_number = 0;
 		tmpaudioinfo->mixer_dev = tmpaudioinfo->dev;
-		tmpaudioinfo->legacy_device = -1;
+		tmpaudioinfo->legacy_device = tmpaudioinfo->dev;
 		tmpaudioinfo->enabled = 1;
-		tmpaudioinfo->flags = -1;
-		tmpaudioinfo->min_rate = 8000;
+		tmpaudioinfo->flags = -1; /* reserved for "future versions" */
+		tmpaudioinfo->min_rate = 1000;
 		tmpaudioinfo->max_rate = 192000;
 		tmpaudioinfo->nrates = 0;
 		tmpaudioinfo->min_channels = 1;
@@ -639,8 +648,12 @@ audio_ioctl(int fd, unsigned long com, v
 			if (fmtq.fmt.channels > (unsigned)tmpaudioinfo->max_channels)
 tmpaudioinfo->max_channels = fmtq.fmt.channels;
 		}
-		tmpaudioinfo->binding = -1;
+		tmpaudioinfo->binding = -1; /* reserved for "future versions" */
 		tmpaudioinfo->rate_source = -1;
+		/*
+		 * 'handle' is supposed to be globally unique. The closest
+		 * we have to that is probably device nodes.
+		 */
 		strlcpy(tmpaudioinfo->handle, tmpaudioinfo->devnode,
 		sizeof(tmpaudioinfo->handle));
 		tmpaudioinfo->next_play_engine = 0;



CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 12:36:01 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio: Add comments for the more obscure parts of SNDCTL_AUDIOINFO


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 12:23:34 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio: Various OSSv4 fixes for SNDCTL_AUDIOINFO

- Per OSSv4, make this ioctl work on the main mixer device.
  Since the native NetBSD API uses queries on individual audio devices,
  we have to reopen the correct audio device specified in the input to the
  ioctl and fetch information from that.
- Correctly return whether the device is for playback, capture, or both.
- Return the full name of the device in the name field.
- The "handle" has to be a globally unique identifier. The closest thing
  we have to that is device numbers, so use device numbers.
- Return reasonable values in min_rate/max_rate and min_channels/max_channels.

This should allow Mumble's device enumeration to work with a lot less
patching.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/lib/libossaudio/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.44 src/lib/libossaudio/ossaudio.c:1.45
--- src/lib/libossaudio/ossaudio.c:1.44	Mon Apr 20 12:01:44 2020
+++ src/lib/libossaudio/ossaudio.c	Fri Oct 16 12:23:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.44 2020/04/20 12:01:44 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.45 2020/10/16 12:23:34 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.44 2020/04/20 12:01:44 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.45 2020/10/16 12:23:34 nia Exp $");
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -103,6 +103,7 @@ audio_ioctl(int fd, unsigned long com, v
 	struct audio_info tmpinfo, hwfmt;
 	struct audio_offset tmpoffs;
 	struct audio_buf_info bufinfo;
+	struct audio_format_query fmtq;
 	struct count_info cntinfo;
 	struct audio_encoding tmpenc;
 	struct oss_sysinfo tmpsysinfo;
@@ -116,8 +117,9 @@ audio_ioctl(int fd, unsigned long com, v
 	u_int encoding;
 	u_int precision;
 	int idat, idata;
+	int props;
 	int retval;
-	int i;
+	int newfd;
 
 	idat = 0;
 
@@ -583,53 +585,68 @@ audio_ioctl(int fd, unsigned long com, v
 			tmpaudioinfo->dev = 0;
 
 		snprintf(tmpaudioinfo->devnode, OSS_DEVNODE_SIZE,
-		"/dev/audio%d", tmpaudioinfo->dev); 
+		"/dev/audio%d", tmpaudioinfo->dev);
 
-		retval = ioctl(fd, AUDIO_GETDEV, );
-		if (retval < 0)
-			return retval;
-		retval = ioctl(fd, AUDIO_GETINFO, );
-		if (retval < 0)
+		if ((newfd = open(tmpaudioinfo->devnode, O_WRONLY)) < 0) {
+			if ((newfd = open(tmpaudioinfo->devnode, O_RDONLY)) < 0) {
+return newfd;
+			}
+		}
+
+		retval = ioctl(newfd, AUDIO_GETDEV, );
+		if (retval < 0) {
+			close(newfd);
 			return retval;
-		retval = ioctl(fd, AUDIO_GETPROPS, );
-		if (retval < 0)
+		}
+		retval = ioctl(newfd, AUDIO_GETPROPS, );
+		if (retval < 0) {
+			close(newfd);
 			return retval;
+		}
 		idat = DSP_CAP_TRIGGER;
-		if (idata & AUDIO_PROP_FULLDUPLEX)
+		if (props & AUDIO_PROP_FULLDUPLEX)
 			idat |= DSP_CAP_DUPLEX;
-		if (idata & AUDIO_PROP_MMAP)
+		if (props & AUDIO_PROP_MMAP)
 			idat |= DSP_CAP_MMAP;
-		idat = PCM_CAP_INPUT | PCM_CAP_OUTPUT;
-		strlcpy(tmpaudioinfo->name, tmpaudiodev.name,
-		sizeof tmpaudioinfo->name);
-		tmpaudioinfo->busy = tmpinfo.play.open;
+		if (props & AUDIO_PROP_CAPTURE)
+			idat |= PCM_CAP_INPUT;
+		if (props & AUDIO_PROP_PLAYBACK)
+			idat |= PCM_CAP_OUTPUT;
+		snprintf(tmpaudioinfo->name, sizeof(tmpaudioinfo->name),
+		"%s %s", tmpaudiodev.name, tmpaudiodev.version);
+		tmpaudioinfo->busy = 0;
 		tmpaudioinfo->pid = -1;
 		tmpaudioinfo->caps = idat;
-		ioctl(fd, SNDCTL_DSP_GETFMTS, >iformats);
+		ioctl(newfd, SNDCTL_DSP_GETFMTS, >iformats);
 		tmpaudioinfo->oformats = tmpaudioinfo->iformats;
 		tmpaudioinfo->magic = -1;
-		memset(tmpaudioinfo->cmd, 0, 64);
+		memset(tmpaudioinfo->cmd, 0, sizeof(tmpaudioinfo->cmd));
 		tmpaudioinfo->card_number = -1;
-		memset(tmpaudioinfo->song_name, 0, 64);
-		memset(tmpaudioinfo->label, 0, 16);
-		tmpaudioinfo->port_number = tmpinfo.play.port;
+		memset(tmpaudioinfo->song_name, 0,
+		sizeof(tmpaudioinfo->song_name));
+		memset(tmpaudioinfo->label, 0, sizeof(tmpaudioinfo->label));
+		tmpaudioinfo->port_number = 0;
 		tmpaudioinfo->mixer_dev = tmpaudioinfo->dev;
 		tmpaudioinfo->legacy_device = -1;
 		tmpaudioinfo->enabled = 1;
 		tmpaudioinfo->flags = -1;
-		tmpaudioinfo->min_rate = tmpinfo.play.sample_rate;
-		tmpaudioinfo->max_rate = tmpinfo.play.sample_rate;
-		tmpaudioinfo->nrates = 2;
-		for (i = 0; i < tmpaudioinfo->nrates; i++)
-			tmpaudioinfo->rates[i] = tmpinfo.play.sample_rate;
-		tmpaudioinfo->min_channels = tmpinfo.play.channels;
-		tmpaudioinfo->max_channels = tmpinfo.play.channels;
+		tmpaudioinfo->min_rate = 8000;
+		tmpaudioinfo->max_rate = 192000;
+		tmpaudioinfo->nrates = 0;
+		tmpaudioinfo->min_channels 

CVS commit: src/lib/libossaudio

2020-10-16 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct 16 12:23:34 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio: Various OSSv4 fixes for SNDCTL_AUDIOINFO

- Per OSSv4, make this ioctl work on the main mixer device.
  Since the native NetBSD API uses queries on individual audio devices,
  we have to reopen the correct audio device specified in the input to the
  ioctl and fetch information from that.
- Correctly return whether the device is for playback, capture, or both.
- Return the full name of the device in the name field.
- The "handle" has to be a globally unique identifier. The closest thing
  we have to that is device numbers, so use device numbers.
- Return reasonable values in min_rate/max_rate and min_channels/max_channels.

This should allow Mumble's device enumeration to work with a lot less
patching.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-04-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Apr 20 12:01:44 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio: removed outdated comment


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2020-04-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Apr 20 12:01:44 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio: removed outdated comment


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/lib/libossaudio/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.43 src/lib/libossaudio/ossaudio.c:1.44
--- src/lib/libossaudio/ossaudio.c:1.43	Sun Apr 19 13:44:50 2020
+++ src/lib/libossaudio/ossaudio.c	Mon Apr 20 12:01:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.43 2020/04/19 13:44:50 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.44 2020/04/20 12:01:44 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.43 2020/04/19 13:44:50 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.44 2020/04/20 12:01:44 nia Exp $");
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -594,7 +594,7 @@ audio_ioctl(int fd, unsigned long com, v
 		retval = ioctl(fd, AUDIO_GETPROPS, );
 		if (retval < 0)
 			return retval;
-		idat = DSP_CAP_TRIGGER; /* pretend we have trigger */
+		idat = DSP_CAP_TRIGGER;
 		if (idata & AUDIO_PROP_FULLDUPLEX)
 			idat |= DSP_CAP_DUPLEX;
 		if (idata & AUDIO_PROP_MMAP)



CVS commit: src/lib/libossaudio

2020-04-19 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sun Apr 19 11:27:40 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio: Make SNDCTL_DSP_[GET|SET][PLAY|RECORD]VOL closer to OSSv4

Problems in the previous code include returning values in the 0-255
range NetBSD uses instead of the 0-100 range OSSv4 expects, using
AUDIO_GETBUFINFO (which doesn't even return the mixer bits), and
not encoding channels as specified: "level=(left)|(right << 8)".

In reality, setting the gain in this way (through /dev/audio rather
than /dev/mixer) doesn't seem to work properly, and the mixer-set
value seems to be retained.

However, these changes at least ensure that the return values are
correct and the balance is set correctly.

I've only found one application using this API (audio/audacious), and
OSSv4 support in it is currently disabled precisely because it breaks
when it attempts to set the track volume using it.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/lib/libossaudio/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.41 src/lib/libossaudio/ossaudio.c:1.42
--- src/lib/libossaudio/ossaudio.c:1.41	Wed Apr 15 16:39:06 2020
+++ src/lib/libossaudio/ossaudio.c	Sun Apr 19 11:27:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.41 2020/04/15 16:39:06 nia Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.42 2020/04/19 11:27:40 nia Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.41 2020/04/15 16:39:06 nia Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.42 2020/04/19 11:27:40 nia Exp $");
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -48,6 +48,7 @@ __RCSID("$NetBSD: ossaudio.c,v 1.41 2020
 #include 
 #include 
 #include 
+#include 
 
 #include "soundcard.h"
 #undef ioctl
@@ -63,6 +64,9 @@ __RCSID("$NetBSD: ossaudio.c,v 1.41 2020
 
 static struct audiodevinfo *getdevinfo(int);
 
+static int getvol(u_int, u_char);
+static void setvol(int, int, bool);
+
 static void setchannels(int, int, int);
 static void setblocksize(int, struct audio_info *);
 
@@ -635,41 +639,23 @@ audio_ioctl(int fd, unsigned long com, v
 		tmpaudioinfo->next_rec_engine = 0;
 		argp = tmpaudioinfo;
 		break;
-	case SNDCTL_DSP_GETPLAYVOL:
-		retval = ioctl(fd, AUDIO_GETBUFINFO, );
-		if (retval < 0)
-			return retval;
-		*(uint *)argp = tmpinfo.play.gain;
-		break;
 	case SNDCTL_DSP_SETPLAYVOL:
-		retval = ioctl(fd, AUDIO_GETBUFINFO, );
-		if (retval < 0)
-			return retval;
-		if (*(uint *)argp > 255)
-			tmpinfo.play.gain = 255;
-		else
-			tmpinfo.play.gain = *(uint *)argp;
-		retval = ioctl(fd, AUDIO_SETINFO, );
-		if (retval < 0)
-			return retval;
-		break;
-	case SNDCTL_DSP_GETRECVOL:
-		retval = ioctl(fd, AUDIO_GETBUFINFO, );
+		setvol(fd, INTARG, false);
+		/* FALLTHRU */
+	case SNDCTL_DSP_GETPLAYVOL:
+		retval = ioctl(fd, AUDIO_GETINFO, );
 		if (retval < 0)
 			return retval;
-		*(uint *)argp = tmpinfo.record.gain;
+		INTARG = getvol(tmpinfo.play.gain, tmpinfo.play.balance);
 		break;
 	case SNDCTL_DSP_SETRECVOL:
-		retval = ioctl(fd, AUDIO_GETBUFINFO, );
-		if (retval < 0)
-			return retval;
-		if (*(uint *)argp > 255)
-			tmpinfo.record.gain = 255;
-		else
-			tmpinfo.record.gain = *(uint *)argp;
-		retval = ioctl(fd, AUDIO_SETINFO, );
+		setvol(fd, INTARG, true);
+		/* FALLTHRU */
+	case SNDCTL_DSP_GETRECVOL:
+		retval = ioctl(fd, AUDIO_GETINFO, );
 		if (retval < 0)
 			return retval;
+		INTARG = getvol(tmpinfo.record.gain, tmpinfo.record.balance);
 		break;
 	case SNDCTL_DSP_SKIP:
 	case SNDCTL_DSP_SILENCE:
@@ -1047,6 +1033,53 @@ mixer_ioctl(int fd, unsigned long com, v
 	return 0;
 }
 
+static int
+getvol(u_int gain, u_char balance)
+{
+	u_int l, r;
+
+	if (balance == AUDIO_MID_BALANCE) {
+		l = r = gain;
+	} else if (balance < AUDIO_MID_BALANCE) {
+		l = gain;
+		r = (balance * gain) / AUDIO_MID_BALANCE;
+	} else {
+		r = gain;
+		l = ((AUDIO_RIGHT_BALANCE - balance) * gain)
+		/ AUDIO_MID_BALANCE;
+	}
+
+	return TO_OSSVOL(l) | (TO_OSSVOL(r) << 8);
+}
+
+static void
+setvol(int fd, int volume, bool record)
+{
+	u_int lgain, rgain;
+	struct audio_info tmpinfo;
+	struct audio_prinfo *prinfo;
+
+	AUDIO_INITINFO();
+	prinfo = record ?  : 
+
+	lgain = FROM_OSSVOL((volume >> 0) & 0xff);
+	rgain = FROM_OSSVOL((volume >> 8) & 0xff);
+
+	if (lgain == rgain) {
+		prinfo->gain = lgain;
+		prinfo->balance = AUDIO_MID_BALANCE;
+	} else if (lgain < rgain) {
+		prinfo->gain = rgain;
+		prinfo->balance = AUDIO_RIGHT_BALANCE -
+		(AUDIO_MID_BALANCE * lgain) / rgain;
+	} else {
+		prinfo->gain = lgain;
+		prinfo->balance = (AUDIO_MID_BALANCE * rgain) / lgain;
+	}
+
+	(void)ioctl(fd, AUDIO_SETINFO, );
+}
+
 /*
  * When AUDIO_SETINFO fails to set a channel count, the application's chosen
  * number is out of range of what the kernel allows.



CVS commit: src/lib/libossaudio

2020-04-19 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sun Apr 19 11:27:40 UTC 2020

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
ossaudio: Make SNDCTL_DSP_[GET|SET][PLAY|RECORD]VOL closer to OSSv4

Problems in the previous code include returning values in the 0-255
range NetBSD uses instead of the 0-100 range OSSv4 expects, using
AUDIO_GETBUFINFO (which doesn't even return the mixer bits), and
not encoding channels as specified: "level=(left)|(right << 8)".

In reality, setting the gain in this way (through /dev/audio rather
than /dev/mixer) doesn't seem to work properly, and the mixer-set
value seems to be retained.

However, these changes at least ensure that the return values are
correct and the balance is set correctly.

I've only found one application using this API (audio/audacious), and
OSSv4 support in it is currently disabled precisely because it breaks
when it attempts to set the track volume using it.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2019-11-02 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Nov  2 11:48:23 UTC 2019

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
Use record.sample_rate for recording on SNDCTL_DSP_SPEED.
Fix PR lib/54667.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2019-11-02 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Nov  2 11:48:23 UTC 2019

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
Use record.sample_rate for recording on SNDCTL_DSP_SPEED.
Fix PR lib/54667.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libossaudio/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.37
--- src/lib/libossaudio/ossaudio.c:1.36	Sat Feb  2 04:52:16 2019
+++ src/lib/libossaudio/ossaudio.c	Sat Nov  2 11:48:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.36 2019/02/02 04:52:16 isaki Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.37 2019/11/02 11:48:23 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.36 2019/02/02 04:52:16 isaki Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.37 2019/11/02 11:48:23 isaki Exp $");
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -134,7 +134,10 @@ audio_ioctl(int fd, unsigned long com, v
 		retval = ioctl(fd, AUDIO_GETBUFINFO, );
 		if (retval < 0)
 			return retval;
-		INTARG = tmpinfo.play.sample_rate;
+		if (tmpinfo.mode == AUMODE_RECORD)
+			INTARG = tmpinfo.record.sample_rate;
+		else
+			INTARG = tmpinfo.play.sample_rate;
 		break;
 	case SNDCTL_DSP_STEREO:
 		AUDIO_INITINFO();



CVS commit: src/lib/libossaudio

2019-01-29 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Jan 29 11:54:02 UTC 2019

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
Revert a wrong SNDCTL_DSP_GETOSPACE part of rev1.33.
- 'fragments' is the number of full free blocks and should not be
  negative value.
- 'bytes' should not be rounded down.
It makes mpv work correctly (fixes a second half of kern/53028).
Reviewed by mlelstv@


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2019-01-29 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Jan 29 11:54:02 UTC 2019

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
Revert a wrong SNDCTL_DSP_GETOSPACE part of rev1.33.
- 'fragments' is the number of full free blocks and should not be
  negative value.
- 'bytes' should not be rounded down.
It makes mpv work correctly (fixes a second half of kern/53028).
Reviewed by mlelstv@


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/lib/libossaudio/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.34 src/lib/libossaudio/ossaudio.c:1.35
--- src/lib/libossaudio/ossaudio.c:1.34	Wed Jan 23 00:08:06 2019
+++ src/lib/libossaudio/ossaudio.c	Tue Jan 29 11:54:02 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.34 2019/01/23 00:08:06 mrg Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.35 2019/01/29 11:54:02 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.34 2019/01/23 00:08:06 mrg Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.35 2019/01/29 11:54:02 isaki Exp $");
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -411,11 +411,11 @@ audio_ioctl(int fd, unsigned long com, v
 			return retval;
 		setblocksize(fd, );
 		bufinfo.fragsize = tmpinfo.blocksize;
-		bufinfo.fragments = (tmpinfo.hiwat * tmpinfo.blocksize -
-		(tmpinfo.play.seek + tmpinfo.blocksize -1)) /
-		tmpinfo.blocksize;
+		bufinfo.fragments = tmpinfo.hiwat - (tmpinfo.play.seek
+		+ tmpinfo.blocksize - 1) / tmpinfo.blocksize;
 		bufinfo.fragstotal = tmpinfo.hiwat;
-		bufinfo.bytes = bufinfo.fragments * tmpinfo.blocksize;
+		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize
+		- tmpinfo.play.seek;
 		*(struct audio_buf_info *)argp = bufinfo;
 		break;
 	case SNDCTL_DSP_GETISPACE:



CVS commit: src/lib/libossaudio

2019-01-22 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jan 23 00:08:06 UTC 2019

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
memset to zero the entire array, not just 8 bytes of it.

picked up by gcc7's checker that the array size has not
been multipled by the member size.

here, we had 8 but should have had 8 * sizeof(int).

XXX: real bug - pullup-7, pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/lib/libossaudio/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.33 src/lib/libossaudio/ossaudio.c:1.34
--- src/lib/libossaudio/ossaudio.c:1.33	Thu Mar 23 15:50:48 2017
+++ src/lib/libossaudio/ossaudio.c	Wed Jan 23 00:08:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.33 2017/03/23 15:50:48 nat Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.34 2019/01/23 00:08:06 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.33 2017/03/23 15:50:48 nat Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.34 2019/01/23 00:08:06 mrg Exp $");
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -503,13 +503,13 @@ audio_ioctl(int fd, unsigned long com, v
 		memset(tmpsysinfo.options, 0, 8);
 		tmpsysinfo.numaudios = OSS_MAX_AUDIO_DEVS;
 		tmpsysinfo.numaudioengines = 1;
-		memset(tmpsysinfo.openedaudio, 0, 8);
+		memset(tmpsysinfo.openedaudio, 0, sizeof(tmpsysinfo.openedaudio));
 		tmpsysinfo.numsynths = 1;
 		tmpsysinfo.nummidis = -1;
 		tmpsysinfo.numtimers = -1;
 		tmpsysinfo.nummixers = 1;
 		tmpsysinfo.numcards = 1;
-		memset(tmpsysinfo.openedmidi, 0, 8);
+		memset(tmpsysinfo.openedmidi, 0, sizeof(tmpsysinfo.openedmidi));
 		*(struct oss_sysinfo *)argp = tmpsysinfo;
 		break;
 	case SNDCTL_ENGINEINFO:



CVS commit: src/lib/libossaudio

2019-01-22 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jan 23 00:08:06 UTC 2019

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
memset to zero the entire array, not just 8 bytes of it.

picked up by gcc7's checker that the array size has not
been multipled by the member size.

here, we had 8 but should have had 8 * sizeof(int).

XXX: real bug - pullup-7, pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2017-02-10 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Feb 10 08:52:04 UTC 2017

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
speed limit is 80 (missed this one)


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libossaudio/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.31 src/lib/libossaudio/ossaudio.c:1.32
--- src/lib/libossaudio/ossaudio.c:1.31	Fri Feb 10 08:50:27 2017
+++ src/lib/libossaudio/ossaudio.c	Fri Feb 10 08:52:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.31 2017/02/10 08:50:27 maya Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.32 2017/02/10 08:52:04 maya Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.31 2017/02/10 08:50:27 maya Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.32 2017/02/10 08:52:04 maya Exp $");
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -497,7 +497,8 @@ audio_ioctl(int fd, unsigned long com, v
 		*(struct count_info *)argp = cntinfo;
 		break;
 	case SNDCTL_SYSINFO:
-		strlcpy(tmpsysinfo.product, "OSS/NetBSD", sizeof tmpsysinfo.product);
+		strlcpy(tmpsysinfo.product, "OSS/NetBSD",
+		sizeof tmpsysinfo.product);
 		strlcpy(tmpsysinfo.version, version, sizeof tmpsysinfo.version);
 		strlcpy(tmpsysinfo.license, license, sizeof tmpsysinfo.license);
 		tmpsysinfo.versionnum = SOUND_VERSION;



CVS commit: src/lib/libossaudio

2017-02-10 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Feb 10 08:52:04 UTC 2017

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
speed limit is 80 (missed this one)


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2017-02-10 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Feb 10 08:50:27 UTC 2017

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
strncpy->strlcpy. use sizeof instead of numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/lib/libossaudio/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.30 src/lib/libossaudio/ossaudio.c:1.31
--- src/lib/libossaudio/ossaudio.c:1.30	Tue Sep  9 10:45:18 2014
+++ src/lib/libossaudio/ossaudio.c	Fri Feb 10 08:50:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.30 2014/09/09 10:45:18 nat Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.31 2017/02/10 08:50:27 maya Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: ossaudio.c,v 1.30 2014/09/09 10:45:18 nat Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.31 2017/02/10 08:50:27 maya Exp $");
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -497,12 +497,9 @@ audio_ioctl(int fd, unsigned long com, v
 		*(struct count_info *)argp = cntinfo;
 		break;
 	case SNDCTL_SYSINFO:
-		strncpy(tmpsysinfo.product, "OSS/NetBSD", 31);
-		tmpsysinfo.product[31] = 0; 
-		strncpy(tmpsysinfo.version, version, 31); 
-		tmpsysinfo.version[31] = 0; 
-		strncpy(tmpsysinfo.license, license, 15);
-		tmpsysinfo.license[15] = 0; 
+		strlcpy(tmpsysinfo.product, "OSS/NetBSD", sizeof tmpsysinfo.product);
+		strlcpy(tmpsysinfo.version, version, sizeof tmpsysinfo.version);
+		strlcpy(tmpsysinfo.license, license, sizeof tmpsysinfo.license);
 		tmpsysinfo.versionnum = SOUND_VERSION;
 		memset(tmpsysinfo.options, 0, 8);
 		tmpsysinfo.numaudios = OSS_MAX_AUDIO_DEVS;
@@ -550,8 +547,8 @@ audio_ioctl(int fd, unsigned long com, v
 		if (idata & AUDIO_PROP_MMAP)
 			idat |= DSP_CAP_MMAP;
 		idat = PCM_CAP_INPUT | PCM_CAP_OUTPUT;
-		strncpy(tmpaudioinfo->name, tmpaudiodev.name, 64);
-		tmpaudioinfo->name[63] = 0;
+		strlcpy(tmpaudioinfo->name, tmpaudiodev.name,
+		sizeof tmpaudioinfo->name);
 		tmpaudioinfo->busy = tmpinfo.play.open;
 		tmpaudioinfo->pid = -1;
 		tmpaudioinfo->caps = idat;
@@ -799,7 +796,7 @@ getdevinfo(int fd)
 di->devmask |= 1 << dp->code;
 if (mi.un.v.num_channels == 2)
 	di->stereomask |= 1 << dp->code;
-strncpy(di->names[i], mi.label.name, 
+strlcpy(di->names[i], mi.label.name,
 	sizeof di->names[i]);
 			}
 			break;
@@ -866,8 +863,8 @@ mixer_ioctl(int fd, unsigned long com, v
 		omi = argp;
 		if (com == SOUND_MIXER_INFO)
 			omi->modify_counter = 1;
-		strncpy(omi->id, adev.name, sizeof omi->id);
-		strncpy(omi->name, adev.name, sizeof omi->name);
+		strlcpy(omi->id, adev.name, sizeof omi->id);
+		strlcpy(omi->name, adev.name, sizeof omi->name);
 		return 0;
 	case SOUND_MIXER_READ_RECSRC:
 		if (di->source == -1)



CVS commit: src/lib/libossaudio

2017-02-10 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Feb 10 08:50:27 UTC 2017

Modified Files:
src/lib/libossaudio: ossaudio.c

Log Message:
strncpy->strlcpy. use sizeof instead of numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/lib/libossaudio/ossaudio.c

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



CVS commit: src/lib/libossaudio

2014-09-09 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue Sep  9 10:45:18 UTC 2014

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
Add missing defines for 16, 24 and 32 bit NE and OE formats.
Add the ability to set 24 and 32 bit precision.

This commit was approved by wiz@


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.23 -r1.24 src/lib/libossaudio/soundcard.h

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.29 src/lib/libossaudio/ossaudio.c:1.30
--- src/lib/libossaudio/ossaudio.c:1.29	Sat May 17 12:38:42 2014
+++ src/lib/libossaudio/ossaudio.c	Tue Sep  9 10:45:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.29 2014/05/17 12:38:42 nat Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.30 2014/09/09 10:45:18 nat Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: ossaudio.c,v 1.29 2014/05/17 12:38:42 nat Exp $);
+__RCSID($NetBSD: ossaudio.c,v 1.30 2014/09/09 10:45:18 nat Exp $);
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -204,6 +204,30 @@ audio_ioctl(int fd, unsigned long com, v
 			tmpinfo.play.encoding =
 			tmpinfo.record.encoding = AUDIO_ENCODING_ULINEAR_BE;
 			break;
+		case AFMT_S24_LE:
+			tmpinfo.play.precision =
+			tmpinfo.record.precision = 24;
+			tmpinfo.play.encoding =
+			tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR_LE;
+			break;
+		case AFMT_S24_BE:
+			tmpinfo.play.precision =
+			tmpinfo.record.precision = 24;
+			tmpinfo.play.encoding =
+			tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR_BE;
+			break;
+		case AFMT_S32_LE:
+			tmpinfo.play.precision =
+			tmpinfo.record.precision = 32;
+			tmpinfo.play.encoding =
+			tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR_LE;
+			break;
+		case AFMT_S32_BE:
+			tmpinfo.play.precision =
+			tmpinfo.record.precision = 32;
+			tmpinfo.play.encoding =
+			tmpinfo.record.encoding = AUDIO_ENCODING_SLINEAR_BE;
+			break;
 		case AFMT_AC3:
 			tmpinfo.play.precision =
 			tmpinfo.record.precision = 16;
@@ -227,13 +251,21 @@ audio_ioctl(int fd, unsigned long com, v
 			idat = AFMT_A_LAW;
 			break;
 		case AUDIO_ENCODING_SLINEAR_LE:
-			if (tmpinfo.play.precision == 16)
+			if (tmpinfo.play.precision == 32)
+idat = AFMT_S32_LE;
+			else if (tmpinfo.play.precision == 24)
+idat = AFMT_S24_LE;
+			else if (tmpinfo.play.precision == 16)
 idat = AFMT_S16_LE;
 			else
 idat = AFMT_S8;
 			break;
 		case AUDIO_ENCODING_SLINEAR_BE:
-			if (tmpinfo.play.precision == 16)
+			if (tmpinfo.play.precision == 32)
+idat = AFMT_S32_BE;
+			else if (tmpinfo.play.precision == 24)
+idat = AFMT_S24_BE;
+			else if (tmpinfo.play.precision == 16)
 idat = AFMT_S16_BE;
 			else
 idat = AFMT_S8;

Index: src/lib/libossaudio/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.23 src/lib/libossaudio/soundcard.h:1.24
--- src/lib/libossaudio/soundcard.h:1.23	Sat May 17 12:38:42 2014
+++ src/lib/libossaudio/soundcard.h	Tue Sep  9 10:45:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.23 2014/05/17 12:38:42 nat Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.24 2014/09/09 10:45:18 nat Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -66,7 +66,6 @@
 #define	 AFMT_S24_BE			0x1000
 #define	 AFMT_S32_LE			0x2000
 #define	 AFMT_S32_BE			0x4000
-#define	 AFMT_S32_NE			0x8000
 #define SNDCTL_DSP_SAMPLESIZE		SNDCTL_DSP_SETFMT
 #define	SOUND_PCM_READ_BITS		_IOR ('P', 5, int)
 #define	SNDCTL_DSP_CHANNELS		_IOWR('P', 6, int)
@@ -113,8 +112,18 @@
 #include machine/endian_machdep.h
 #if _BYTE_ORDER == _LITTLE_ENDIAN
 #define  AFMT_S16_NE AFMT_S16_LE
+#define  AFMT_S16_OE AFMT_S16_BE
+#define  AFMT_S24_NE AFMT_S24_LE
+#define  AFMT_S24_OE AFMT_S24_BE
+#define  AFMT_S32_NE AFMT_S32_LE
+#define  AFMT_S32_OE AFMT_S32_BE
 #else
 #define  AFMT_S16_NE AFMT_S16_BE
+#define  AFMT_S16_OE AFMT_S16_LE
+#define  AFMT_S24_NE AFMT_S24_BE
+#define  AFMT_S24_OE AFMT_S24_LE
+#define  AFMT_S32_NE AFMT_S32_BE
+#define  AFMT_S32_OE AFMT_S32_LE
 #endif
 
 /* Aliases */



CVS commit: src/lib/libossaudio

2014-09-09 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Tue Sep  9 10:45:18 UTC 2014

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
Add missing defines for 16, 24 and 32 bit NE and OE formats.
Add the ability to set 24 and 32 bit precision.

This commit was approved by wiz@


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.23 -r1.24 src/lib/libossaudio/soundcard.h

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



CVS commit: src/lib/libossaudio

2014-05-18 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sun May 18 10:38:40 UTC 2014

Modified Files:
src/lib/libossaudio: shlib_version

Log Message:
libossaudio minor version bump to signify new ioctls.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libossaudio/shlib_version

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/shlib_version
diff -u src/lib/libossaudio/shlib_version:1.6 src/lib/libossaudio/shlib_version:1.7
--- src/lib/libossaudio/shlib_version:1.6	Sun Jan 11 03:07:49 2009
+++ src/lib/libossaudio/shlib_version	Sun May 18 10:38:40 2014
@@ -1,5 +1,5 @@
-#	$NetBSD: shlib_version,v 1.6 2009/01/11 03:07:49 christos Exp $
+#	$NetBSD: shlib_version,v 1.7 2014/05/18 10:38:40 nat Exp $
 #	Remember to update distrib/sets/lists/base/shl.* when changing
 #
 major=1
-minor=0
+minor=1



CVS commit: src/lib/libossaudio

2014-05-18 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sun May 18 10:38:40 UTC 2014

Modified Files:
src/lib/libossaudio: shlib_version

Log Message:
libossaudio minor version bump to signify new ioctls.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libossaudio/shlib_version

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



Re: CVS commit: src/lib/libossaudio

2014-05-17 Thread Izumi Tsutsui
nat@ wrote:

 Module Name:  src
 Committed By: nat
 Date: Sat May 17 12:38:42 UTC 2014
 
 Modified Files:
   src/lib/libossaudio: ossaudio.c soundcard.h
 
 Log Message:
 Adds ioctls and defines for OSSv4 compatibility.
 
 The ioctl definitions and accompanying structures were
 taken from FreeBSD's soundcard.h, hopefully providing
 some binary compatibility.

If new ioctls are added, shouldn't we bump at least minor in shlib_version
to denote API additions?

---
Izumi Tsutsui


re: CVS commit: src/lib/libossaudio

2014-05-17 Thread matthew green

Izumi Tsutsui writes:
 nat@ wrote:
 
  Module Name:src
  Committed By:   nat
  Date:   Sat May 17 12:38:42 UTC 2014
  
  Modified Files:
  src/lib/libossaudio: ossaudio.c soundcard.h
  
  Log Message:
  Adds ioctls and defines for OSSv4 compatibility.
  
  The ioctl definitions and accompanying structures were
  taken from FreeBSD's soundcard.h, hopefully providing
  some binary compatibility.
 
 If new ioctls are added, shouldn't we bump at least minor in shlib_version
 to denote API additions?

good point!  nat, can you handle this?


.mrg.


CVS commit: src/lib/libossaudio

2014-05-17 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sat May 17 12:38:42 UTC 2014

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
Adds ioctls and defines for OSSv4 compatibility.

The ioctl definitions and accompanying structures were
taken from FreeBSD's soundcard.h, hopefully providing
some binary compatibility.

The ioctls are as follows:
SNDCTL_SYSINFO: Returns a structure containing
details about the audio device.
SNDCTL_ENGINEINFO - SNDCTL_AUDIOINFO: Returns a
structure with playback/recording
characteristics.
SNDCTL_DSP_GETPLAYVOL, SNDCTL_DSP_SETPLAYVOL,
SNDCTL_DSP_GETRECVOL, SNDCTL_DSP_SETRECVOL:
Retrieves/Sets Playback/Recording volume.
SNDCTL_DSP_SKIP - SNDCTL_DSP_SILENCE: These ioctls
were intended to manipulate the underlying
audio buffer skip or insert silence.  These
return EINVAL.

SOUND_VERSION is unchanged, but is definable,  It will be
changed when the mixer OSSv4 ioctls are written.

Addresses PR 46611
This commit was approved by wiz@.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libossaudio/soundcard.h

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.28 src/lib/libossaudio/ossaudio.c:1.29
--- src/lib/libossaudio/ossaudio.c:1.28	Sat May  5 15:57:45 2012
+++ src/lib/libossaudio/ossaudio.c	Sat May 17 12:38:42 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.28 2012/05/05 15:57:45 christos Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.29 2014/05/17 12:38:42 nat Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: ossaudio.c,v 1.28 2012/05/05 15:57:45 christos Exp $);
+__RCSID($NetBSD: ossaudio.c,v 1.29 2014/05/17 12:38:42 nat Exp $);
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -44,6 +44,9 @@ __RCSID($NetBSD: ossaudio.c,v 1.28 2012
 #include sys/audioio.h
 #include sys/stat.h
 #include errno.h
+#include fcntl.h
+#include stdio.h
+#include unistd.h
 #include stdarg.h
 
 #include soundcard.h
@@ -93,9 +96,17 @@ audio_ioctl(int fd, unsigned long com, v
 	struct audio_buf_info bufinfo;
 	struct count_info cntinfo;
 	struct audio_encoding tmpenc;
+	struct oss_sysinfo tmpsysinfo;
+	struct oss_audioinfo *tmpaudioinfo;
+	audio_device_t tmpaudiodev;
+	struct stat tmpstat;
+	dev_t devno;
+	char version[32] = 4.01;
+	char license[16] = NetBSD;
 	u_int u;
 	int idat, idata;
 	int retval;
+	int i;
 
 	idat = 0;
 
@@ -316,13 +327,21 @@ audio_ioctl(int fd, unsigned long com, v
 idat |= AFMT_S8;
 break;
 			case AUDIO_ENCODING_SLINEAR_LE:
-if (tmpenc.precision == 16)
+if (tmpenc.precision == 32)
+	idat |= AFMT_S32_LE;
+else if (tmpenc.precision == 24)
+	idat |= AFMT_S24_LE;
+else if (tmpenc.precision == 16)
 	idat |= AFMT_S16_LE;
 else
 	idat |= AFMT_S8;
 break;
 			case AUDIO_ENCODING_SLINEAR_BE:
-if (tmpenc.precision == 16)
+if (tmpenc.precision == 32)
+	idat |= AFMT_S32_BE;
+else if (tmpenc.precision == 24)
+	idat |= AFMT_S24_BE;
+else if (tmpenc.precision == 16)
 	idat |= AFMT_S16_BE;
 else
 	idat |= AFMT_S8;
@@ -445,6 +464,130 @@ audio_ioctl(int fd, unsigned long com, v
 		cntinfo.ptr = tmpoffs.offset;
 		*(struct count_info *)argp = cntinfo;
 		break;
+	case SNDCTL_SYSINFO:
+		strncpy(tmpsysinfo.product, OSS/NetBSD, 31);
+		tmpsysinfo.product[31] = 0; 
+		strncpy(tmpsysinfo.version, version, 31); 
+		tmpsysinfo.version[31] = 0; 
+		strncpy(tmpsysinfo.license, license, 15);
+		tmpsysinfo.license[15] = 0; 
+		tmpsysinfo.versionnum = SOUND_VERSION;
+		memset(tmpsysinfo.options, 0, 8);
+		tmpsysinfo.numaudios = OSS_MAX_AUDIO_DEVS;
+		tmpsysinfo.numaudioengines = 1;
+		memset(tmpsysinfo.openedaudio, 0, 8);
+		tmpsysinfo.numsynths = 1;
+		tmpsysinfo.nummidis = -1;
+		tmpsysinfo.numtimers = -1;
+		tmpsysinfo.nummixers = 1;
+		tmpsysinfo.numcards = 1;
+		memset(tmpsysinfo.openedmidi, 0, 8);
+		*(struct oss_sysinfo *)argp = tmpsysinfo;
+		break;
+	case SNDCTL_ENGINEINFO:
+	case SNDCTL_AUDIOINFO:
+		devno = 0;
+		tmpaudioinfo = (struct oss_audioinfo*)argp;
+		if (tmpaudioinfo == NULL)
+			return EINVAL;
+		if (tmpaudioinfo-dev  0) {
+			fstat(fd, tmpstat);
+			if ((tmpstat.st_rdev  0xff00) == 0x2a00)
+devno = tmpstat.st_rdev  0xff;
+			if (devno = 0x80)
+tmpaudioinfo-dev = devno  0x7f;
+		}
+		if (tmpaudioinfo-dev  0)
+			tmpaudioinfo-dev = 0;
+
+		snprintf(tmpaudioinfo-devnode, OSS_DEVNODE_SIZE,
+		/dev/audio%d, tmpaudioinfo-dev); 
+
+		retval = ioctl(fd, AUDIO_GETDEV, tmpaudiodev);
+		if (retval  0)
+			return retval;
+		retval = ioctl(fd, AUDIO_GETINFO, tmpinfo);
+		if (retval  0)
+			return retval;
+		

CVS commit: src/lib/libossaudio

2014-05-17 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sat May 17 12:38:42 UTC 2014

Modified Files:
src/lib/libossaudio: ossaudio.c soundcard.h

Log Message:
Adds ioctls and defines for OSSv4 compatibility.

The ioctl definitions and accompanying structures were
taken from FreeBSD's soundcard.h, hopefully providing
some binary compatibility.

The ioctls are as follows:
SNDCTL_SYSINFO: Returns a structure containing
details about the audio device.
SNDCTL_ENGINEINFO - SNDCTL_AUDIOINFO: Returns a
structure with playback/recording
characteristics.
SNDCTL_DSP_GETPLAYVOL, SNDCTL_DSP_SETPLAYVOL,
SNDCTL_DSP_GETRECVOL, SNDCTL_DSP_SETRECVOL:
Retrieves/Sets Playback/Recording volume.
SNDCTL_DSP_SKIP - SNDCTL_DSP_SILENCE: These ioctls
were intended to manipulate the underlying
audio buffer skip or insert silence.  These
return EINVAL.

SOUND_VERSION is unchanged, but is definable,  It will be
changed when the mixer OSSv4 ioctls are written.

Addresses PR 46611
This commit was approved by wiz@.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libossaudio/soundcard.h

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



CVS commit: src/lib/libossaudio

2012-05-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May  5 15:04:58 UTC 2012

Modified Files:
src/lib/libossaudio: soundcard.h

Log Message:
avoid using cpp variadic macros and explain why.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libossaudio/soundcard.h

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/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.20 src/lib/libossaudio/soundcard.h:1.21
--- src/lib/libossaudio/soundcard.h:1.20	Fri May  4 07:48:12 2012
+++ src/lib/libossaudio/soundcard.h	Sat May  5 11:04:57 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.20 2012/05/04 11:48:12 christos Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.21 2012/05/05 15:04:57 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -291,24 +291,18 @@ typedef struct buffmem_desc {
 	int size;
 } buffmem_desc;
 
-#if 0
-/* This is what we'd like to have, but it causes prototype conflicts. */
 #define ioctl _oss_ioctl
-#else
 /*
- * XXX force inclusion of sys/ioctl.h before we redefine
- * ioctl() to avoid a prototype conflict.
- * Its multiple inclusion protection will keep this from
- * happening if it is pulled in later.
+ * If we already included sys/ioctl.h, then we define our own prototype,
+ * else we depend on sys/ioctl.h to do it for us. We do it this way, so
+ * that we don't define the prototype twice.
  */
+#ifndef _SYS_IOCTL_H
 #include sys/ioctl.h
-#define ioctl(x, y, ...) _oss_ioctl(x, y, __VA_ARGS__)
-#endif
-
-#include sys/cdefs.h
-
+#else
 __BEGIN_DECLS
 int _oss_ioctl(int, unsigned long, ...);
 __END_DECLS
+#endif
 
 #endif /* !_SOUNDCARD_H_ */



CVS commit: src/lib/libossaudio

2012-05-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May  5 15:57:45 UTC 2012

Modified Files:
src/lib/libossaudio: Makefile ossaudio.c soundcard.h

Log Message:
fix typo, WARNS=5


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libossaudio/Makefile
cvs rdiff -u -r1.27 -r1.28 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.21 -r1.22 src/lib/libossaudio/soundcard.h

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/Makefile
diff -u src/lib/libossaudio/Makefile:1.9 src/lib/libossaudio/Makefile:1.10
--- src/lib/libossaudio/Makefile:1.9	Wed Mar 21 06:08:30 2012
+++ src/lib/libossaudio/Makefile	Sat May  5 11:57:45 2012
@@ -1,6 +1,6 @@
-#	$NetBSD: Makefile,v 1.9 2012/03/21 10:08:30 matt Exp $
+#	$NetBSD: Makefile,v 1.10 2012/05/05 15:57:45 christos Exp $
 
-WARNS=	2
+WARNS=	5
 
 LIB=	ossaudio
 MAN=	ossaudio.3

Index: src/lib/libossaudio/ossaudio.c
diff -u src/lib/libossaudio/ossaudio.c:1.27 src/lib/libossaudio/ossaudio.c:1.28
--- src/lib/libossaudio/ossaudio.c:1.27	Fri May  4 07:48:12 2012
+++ src/lib/libossaudio/ossaudio.c	Sat May  5 11:57:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.27 2012/05/04 11:48:12 christos Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.28 2012/05/05 15:57:45 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: ossaudio.c,v 1.27 2012/05/04 11:48:12 christos Exp $);
+__RCSID($NetBSD: ossaudio.c,v 1.28 2012/05/05 15:57:45 christos Exp $);
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -549,7 +549,7 @@ getdevinfo(int fd)
 	mixer_devinfo_t mi;
 	int i, j, e;
 	static struct {
-		char *name;
+		const char *name;
 		int code;
 	} *dp, devs[] = {
 		{ AudioNmicrophone,	SOUND_MIXER_MIC },
@@ -574,7 +574,7 @@ getdevinfo(int fd)
 /*		{ AudioNmixerout,	?? },*/
 		{ 0, -1 }
 	};
-	static struct audiodevinfo devcache = { 0 };
+	static struct audiodevinfo devcache = { .done = 0 };
 	struct audiodevinfo *di = devcache;
 	struct stat sb;
 	size_t mlen, dlen;
@@ -826,7 +826,7 @@ static void
 setblocksize(int fd, struct audio_info *info)
 {
 	struct audio_info set;
-	int s;
+	size_t s;
 
 	if (info-blocksize  (info-blocksize-1)) {
 		for(s = 32; s  info-blocksize; s = 1)

Index: src/lib/libossaudio/soundcard.h
diff -u src/lib/libossaudio/soundcard.h:1.21 src/lib/libossaudio/soundcard.h:1.22
--- src/lib/libossaudio/soundcard.h:1.21	Sat May  5 11:04:57 2012
+++ src/lib/libossaudio/soundcard.h	Sat May  5 11:57:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.21 2012/05/05 15:04:57 christos Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.22 2012/05/05 15:57:45 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -297,7 +297,7 @@ typedef struct buffmem_desc {
  * else we depend on sys/ioctl.h to do it for us. We do it this way, so
  * that we don't define the prototype twice.
  */
-#ifndef _SYS_IOCTL_H
+#ifndef _SYS_IOCTL_H_
 #include sys/ioctl.h
 #else
 __BEGIN_DECLS



CVS commit: src/lib/libossaudio

2012-05-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May  5 15:04:58 UTC 2012

Modified Files:
src/lib/libossaudio: soundcard.h

Log Message:
avoid using cpp variadic macros and explain why.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libossaudio/soundcard.h

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



CVS commit: src/lib/libossaudio

2012-05-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May  5 15:57:45 UTC 2012

Modified Files:
src/lib/libossaudio: Makefile ossaudio.c soundcard.h

Log Message:
fix typo, WARNS=5


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libossaudio/Makefile
cvs rdiff -u -r1.27 -r1.28 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.21 -r1.22 src/lib/libossaudio/soundcard.h

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



  1   2   >