Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libossaudio - match regular ioctl prototype (3rd argumen...
details: https://anonhg.NetBSD.org/src/rev/82d096a2ef74
branches: trunk
changeset: 779113:82d096a2ef74
user: christos <christos%NetBSD.org@localhost>
date: Fri May 04 11:48:12 2012 +0000
description:
- match regular ioctl prototype (3rd argument is optional)
- fix lint issues
diffstat:
lib/libossaudio/ossaudio.c | 61 ++++++++++++++++++++++++++++----------------
lib/libossaudio/soundcard.h | 6 ++--
2 files changed, 41 insertions(+), 26 deletions(-)
diffs (200 lines):
diff -r 90ccbdff4f02 -r 82d096a2ef74 lib/libossaudio/ossaudio.c
--- a/lib/libossaudio/ossaudio.c Fri May 04 02:06:27 2012 +0000
+++ b/lib/libossaudio/ossaudio.c Fri May 04 11:48:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ossaudio.c,v 1.26 2011/09/13 19:10:18 christos Exp $ */
+/* $NetBSD: ossaudio.c,v 1.27 2012/05/04 11:48:12 christos 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.27 2012/05/04 11:48:12 christos Exp $");
/*
* This is an OSS (Linux) sound API emulator.
@@ -44,6 +44,7 @@
#include <sys/audioio.h>
#include <sys/stat.h>
#include <errno.h>
+#include <stdarg.h>
#include "soundcard.h"
#undef ioctl
@@ -59,15 +60,22 @@
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 @@
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 @@
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:
@@ -567,7 +577,7 @@
static struct audiodevinfo devcache = { 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
return -1;
}
}
- INTARG = idat;
+ INTARG = (int)idat;
return 0;
}
diff -r 90ccbdff4f02 -r 82d096a2ef74 lib/libossaudio/soundcard.h
--- a/lib/libossaudio/soundcard.h Fri May 04 02:06:27 2012 +0000
+++ b/lib/libossaudio/soundcard.h Fri May 04 11:48:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: soundcard.h,v 1.19 2011/09/06 01:20:18 jmcneill Exp $ */
+/* $NetBSD: soundcard.h,v 1.20 2012/05/04 11:48:12 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -302,13 +302,13 @@
* happening if it is pulled in later.
*/
#include <sys/ioctl.h>
-#define ioctl(x,y,z) _oss_ioctl(x,y,z)
+#define ioctl(x, y, ...) _oss_ioctl(x, y, __VA_ARGS__)
#endif
#include <sys/cdefs.h>
__BEGIN_DECLS
-int _oss_ioctl(int fd, unsigned long com, void *argp);
+int _oss_ioctl(int, unsigned long, ...);
__END_DECLS
#endif /* !_SOUNDCARD_H_ */
Home |
Main Index |
Thread Index |
Old Index