Module Name:    src
Committed By:   riz
Date:           Mon May  7 16:55:33 UTC 2012

Modified Files:
        src/lib/libossaudio [netbsd-6]: Makefile ossaudio.c soundcard.h

Log Message:
Apply patches (requested by christos in ticket #225):
lib/libossaudio/Makefile                        patch
lib/libossaudio/ossaudio.c                      patch
lib/libossaudio/soundcard.h                     patch

        Fix compilation of ioctls without the 3rd argument in ossaudio.
        [christos, ticket #225]


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.8.1 src/lib/libossaudio/Makefile
cvs rdiff -u -r1.26 -r1.26.4.1 src/lib/libossaudio/ossaudio.c
cvs rdiff -u -r1.19 -r1.19.4.1 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.8 src/lib/libossaudio/Makefile:1.8.8.1
--- src/lib/libossaudio/Makefile:1.8	Thu Mar 12 13:52:47 2009
+++ src/lib/libossaudio/Makefile	Mon May  7 16:55:33 2012
@@ -1,4 +1,6 @@
-#	$NetBSD: Makefile,v 1.8 2009/03/12 13:52:47 wiz Exp $
+#	$NetBSD: Makefile,v 1.8.8.1 2012/05/07 16:55:33 riz Exp $
+
+WARNS=	5
 
 LIB=	ossaudio
 MAN=	ossaudio.3

Index: src/lib/libossaudio/ossaudio.c
diff -u src/lib/libossaudio/ossaudio.c:1.26 src/lib/libossaudio/ossaudio.c:1.26.4.1
--- src/lib/libossaudio/ossaudio.c:1.26	Tue Sep 13 19:10:18 2011
+++ src/lib/libossaudio/ossaudio.c	Mon May  7 16:55:33 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ossaudio.c,v 1.26 2011/09/13 19:10:18 christos Exp $	*/
+/*	$NetBSD: ossaudio.c,v 1.26.4.1 2012/05/07 16:55:33 riz Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: ossaudio.c,v 1.26 2011/09/13 19:10:18 christos Exp $");
+__RCSID("$NetBSD: ossaudio.c,v 1.26.4.1 2012/05/07 16:55:33 riz Exp $");
 
 /*
  * This is an OSS (Linux) sound API emulator.
@@ -44,6 +44,7 @@ __RCSID("$NetBSD: ossaudio.c,v 1.26 2011
 #include <sys/audioio.h>
 #include <sys/stat.h>
 #include <errno.h>
+#include <stdarg.h>
 
 #include "soundcard.h"
 #undef ioctl
@@ -59,15 +60,22 @@ static void setblocksize(int, struct aud
 
 static int audio_ioctl(int, unsigned long, void *);
 static int mixer_ioctl(int, unsigned long, void *);
-static int opaque_to_enum(struct audiodevinfo *di, audio_mixer_name_t *label, int opq);
-static int enum_to_ord(struct audiodevinfo *di, int enm);
-static int enum_to_mask(struct audiodevinfo *di, int enm);
+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);
 
 #define INTARG (*(int*)argp)
 
 int
-_oss_ioctl(int fd, unsigned long com, void *argp)
+_oss_ioctl(int fd, unsigned long com, ...)
 {
+	va_list ap;
+	void *argp;
+
+	va_start(ap, com);
+	argp = va_arg(ap, void *);
+	va_end(ap);
+
 	if (IOCGROUP(com) == 'P')
 		return audio_ioctl(fd, com, argp);
 	else if (IOCGROUP(com) == 'M')
@@ -352,10 +360,11 @@ audio_ioctl(int fd, unsigned long com, v
 			return retval;
 		setblocksize(fd, &tmpinfo);
 		bufinfo.fragsize = tmpinfo.blocksize;
-		bufinfo.fragments = tmpinfo.hiwat -
-			(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 = tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.play.seek;
+		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize
+		    - tmpinfo.play.seek;
 		*(struct audio_buf_info *)argp = bufinfo;
 		break;
 	case SNDCTL_DSP_GETISPACE:
@@ -364,10 +373,11 @@ audio_ioctl(int fd, unsigned long com, v
 			return retval;
 		setblocksize(fd, &tmpinfo);
 		bufinfo.fragsize = tmpinfo.blocksize;
-		bufinfo.fragments = tmpinfo.hiwat -
-			(tmpinfo.record.seek + tmpinfo.blocksize - 1)/tmpinfo.blocksize;
+		bufinfo.fragments = tmpinfo.hiwat - (tmpinfo.record.seek +
+		    tmpinfo.blocksize - 1) / tmpinfo.blocksize;
 		bufinfo.fragstotal = tmpinfo.hiwat;
-		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.record.seek;
+		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize
+		    - tmpinfo.record.seek;
 		*(struct audio_buf_info *)argp = bufinfo;
 		break;
 	case SNDCTL_DSP_NONBLOCK:
@@ -539,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 },
@@ -564,10 +574,10 @@ getdevinfo(int fd)
 /*		{ AudioNmixerout,	?? },*/
 		{ 0, -1 }
 	};
-	static struct audiodevinfo devcache = { 0 };
+	static struct audiodevinfo devcache = { .done = 0 };
 	struct audiodevinfo *di = &devcache;
 	struct stat sb;
-	int mlen, dlen;
+	size_t mlen, dlen;
 
 	/* Figure out what device it is so we can check if the
 	 * cached data is valid.
@@ -604,7 +614,8 @@ getdevinfo(int fd)
 				mlen = strlen(mi.label.name);
 				if (dlen < mlen
 				    && mi.label.name[mlen-dlen-1] == '.'
-				    && strcmp(dp->name, mi.label.name + mlen - dlen) == 0)
+				    && strcmp(dp->name,
+				    mi.label.name + mlen - dlen) == 0)
 					break;
 			}
 			if (dp->code >= 0) {
@@ -658,10 +669,10 @@ mixer_ioctl(int fd, unsigned long com, v
 	struct mixer_info *omi;
 	struct audio_device adev;
 	mixer_ctrl_t mc;
-	int idat;
+	u_long idat, n;
 	int i;
 	int retval;
-	int l, r, n, error, e;
+	int l, r, error, e;
 
 	idat = 0;
 	di = getdevinfo(fd);
@@ -739,7 +750,8 @@ mixer_ioctl(int fd, unsigned long com, v
 				if (idat & (1 << i)) {
 					if (di->devmap[i] == -1)
 						return EINVAL;
-					mc.un.mask |= enum_to_mask(di, di->devmap[i]);
+					mc.un.mask |=
+					    enum_to_mask(di, di->devmap[i]);
 				}
 			}
 		}
@@ -753,14 +765,16 @@ mixer_ioctl(int fd, unsigned long com, v
 			mc.dev = di->devmap[n];
 			mc.type = AUDIO_MIXER_VALUE;
 		    doread:
-			mc.un.value.num_channels = di->stereomask & (1<<n) ? 2 : 1;
+			mc.un.value.num_channels =
+			    di->stereomask & (1 << (u_int)n) ? 2 : 1;
 			retval = ioctl(fd, AUDIO_MIXER_READ, &mc);
 			if (retval < 0)
 				return retval;
 			if (mc.type != AUDIO_MIXER_VALUE)
 				return EINVAL;
 			if (mc.un.value.num_channels != 2) {
-				l = r = mc.un.value.level[AUDIO_MIXER_LEVEL_MONO];
+				l = r =
+				    mc.un.value.level[AUDIO_MIXER_LEVEL_MONO];
 			} else {
 				l = mc.un.value.level[AUDIO_MIXER_LEVEL_LEFT];
 				r = mc.un.value.level[AUDIO_MIXER_LEVEL_RIGHT];
@@ -775,17 +789,18 @@ mixer_ioctl(int fd, unsigned long com, v
 			if (di->devmap[n] == -1)
 				return EINVAL;
 			idat = INTARG;
-			l = FROM_OSSVOL( idat       & 0xff);
+			l = FROM_OSSVOL((u_int)idat & 0xff);
 			r = FROM_OSSVOL(((u_int)idat >> 8) & 0xff);
 			mc.dev = di->devmap[n];
 			mc.type = AUDIO_MIXER_VALUE;
-			if (di->stereomask & (1<<n)) {
+			if (di->stereomask & (1 << (u_int)n)) {
 				mc.un.value.num_channels = 2;
 				mc.un.value.level[AUDIO_MIXER_LEVEL_LEFT] = l;
 				mc.un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = r;
 			} else {
 				mc.un.value.num_channels = 1;
-				mc.un.value.level[AUDIO_MIXER_LEVEL_MONO] = (l+r)/2;
+				mc.un.value.level[AUDIO_MIXER_LEVEL_MONO] =
+				    (l + r) / 2;
 			}
 			retval = ioctl(fd, AUDIO_MIXER_WRITE, &mc);
 			if (retval < 0)
@@ -799,7 +814,7 @@ mixer_ioctl(int fd, unsigned long com, v
 			return -1;
 		}
 	}
-	INTARG = idat;
+	INTARG = (int)idat;
 	return 0;
 }
 
@@ -811,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.19 src/lib/libossaudio/soundcard.h:1.19.4.1
--- src/lib/libossaudio/soundcard.h:1.19	Tue Sep  6 01:20:18 2011
+++ src/lib/libossaudio/soundcard.h	Mon May  7 16:55:33 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: soundcard.h,v 1.19 2011/09/06 01:20:18 jmcneill Exp $	*/
+/*	$NetBSD: soundcard.h,v 1.19.4.1 2012/05/07 16:55:33 riz 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,z) _oss_ioctl(x,y,z)
-#endif
-
-#include <sys/cdefs.h>
-
+#else
 __BEGIN_DECLS
-int _oss_ioctl(int fd, unsigned long com, void *argp);
+int _oss_ioctl(int, unsigned long, ...);
 __END_DECLS
+#endif
 
 #endif /* !_SOUNDCARD_H_ */

Reply via email to