[Liboss-commit] CVS: liboss/lib liboss.c,1.2,1.3 Makefile.am,1.1.1.1,1.2
Brought to you by:
thesin
|
From: Dave V. <va...@us...> - 2002-05-09 07:48:35
|
Update of /cvsroot/liboss/liboss/lib
In directory usw-pr-cvs1:/tmp/cvs-serv11401/lib
Modified Files:
liboss.c Makefile.am
Log Message:
Compiles, but does nothing.
Index: liboss.c
===================================================================
RCS file: /cvsroot/liboss/liboss/lib/liboss.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- liboss.c 8 May 2002 21:21:59 -0000 1.2
+++ liboss.c 9 May 2002 07:48:32 -0000 1.3
@@ -42,35 +42,55 @@
* With some preprocessor magic it could be the same file.
*/
-#include <string.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <CoreAudio/CoreAudio.h>
+#include <sys/param.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
-#include "../include/soundcard.h"
-#undef ioctl
+#include <CoreAudio.framework/Headers/CoreAudio.h>
-#define GET_DEV(com) ((com) & 0xff)
+#include "soundcard.h"
+
+#undef ioctl
+#undef open
#define TO_OSSVOL(x) (((x) * 100 + 127) / 255)
#define FROM_OSSVOL(x) ((((x) > 100 ? 100 : (x)) * 255 + 50) / 100)
-static struct audiodevinfo *getdevinfo(int);
-
-static void setblocksize(int, struct audio_info *);
-
static int audio_ioctl(int, unsigned long, void *);
+static int audio_open(int flags);
static int mixer_ioctl(int, unsigned long, void *);
+
+/* Don't think we need this */
+#if 0
+static struct audiodevinfo *getdevinfo(int);
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);
+#endif
#define INTARG (*(int*)argp)
int
-_oss_ioctl(int fd, unsigned long com, void *argp)
+oss_open(const char *path, int flags, mode_t mode)
+{
+ static char buf[MAXPATHLEN];
+
+ if (realpath(path, buf) == NULL)
+ return open(path, flags, mode);
+
+ if (0 == strcmp("/dev/audio", buf)) {
+ return audio_open(flags);
+ } else {
+ /* FIXME: add mixer stuff */
+ return open(path, flags, mode);
+ }
+}
+
+int
+oss_ioctl(int fd, unsigned long com, void *argp)
{
if (IOCGROUP(com) == 'P')
return audio_ioctl(fd, com, argp);
@@ -81,119 +101,85 @@
}
static int
-audio_ioctl(int fd, unsigned long com, void *argp)
+audio_open(int flags)
{
+ /* FIXME: create sockets */
+ return 0;
+}
- struct audio_info tmpinfo;
- struct audio_offset tmpoffs;
- struct audio_buf_info bufinfo;
- struct count_info cntinfo;
- struct audio_encoding tmpenc;
- u_int u;
- int idat, idata;
- int retval;
+static int
+audio_ioctl(int fd, unsigned long com, void *argp)
+{
+ int retval = 0;
+ /* FIXME: implement */
switch (com) {
case SNDCTL_DSP_RESET:
- retval = ioctl(fd, AUDIO_FLUSH, 0);
+/* retval = ioctl(fd, AUDIO_FLUSH, 0);
if (retval < 0)
- return retval;
+ return retval; */
break;
case SNDCTL_DSP_SYNC:
- retval = ioctl(fd, AUDIO_DRAIN, 0);
+/* retval = ioctl(fd, AUDIO_DRAIN, 0);
if (retval < 0)
- return retval;
+ return retval; */
break;
case SNDCTL_DSP_POST:
/* This call is merely advisory, and may be a nop. */
+ /* Except that it is relevant for fragment implementations */
break;
case SNDCTL_DSP_SPEED:
- AUDIO_INITINFO(&tmpinfo);
- tmpinfo.play.sample_rate =
+/* tmpinfo.play.sample_rate =
tmpinfo.record.sample_rate = INTARG;
- (void) ioctl(fd, AUDIO_SETINFO, &tmpinfo);
+ (void) ioctl(fd, AUDIO_SETINFO, &tmpinfo); */
/* FALLTHRU */
case SOUND_PCM_READ_RATE:
- retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
+/* retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
if (retval < 0)
return retval;
- INTARG = tmpinfo.play.sample_rate;
+ INTARG = tmpinfo.play.sample_rate; */
break;
case SNDCTL_DSP_STEREO:
- AUDIO_INITINFO(&tmpinfo);
- tmpinfo.play.channels =
+/* tmpinfo.play.channels =
tmpinfo.record.channels = INTARG ? 2 : 1;
(void) ioctl(fd, AUDIO_SETINFO, &tmpinfo);
retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
if (retval < 0)
return retval;
- INTARG = tmpinfo.play.channels - 1;
+ INTARG = tmpinfo.play.channels - 1; */
break;
case SNDCTL_DSP_GETBLKSIZE:
- retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
+/* retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
if (retval < 0)
return retval;
setblocksize(fd, &tmpinfo);
- INTARG = tmpinfo.blocksize;
+ INTARG = tmpinfo.blocksize; */
break;
case SNDCTL_DSP_SETFMT:
- AUDIO_INITINFO(&tmpinfo);
- switch (INTARG) {
+ switch (INTARG) { /* FIXME: add 32-bit, _NE, etc; remove A_LAW? */
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;
default:
return EINVAL;
}
- (void) ioctl(fd, AUDIO_SETINFO, &tmpinfo);
+/* (void) ioctl(fd, AUDIO_SETINFO, &tmpinfo); */
/* FALLTHRU */
case SOUND_PCM_READ_BITS:
- retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
+/* retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
if (retval < 0)
return retval;
switch (tmpinfo.play.encoding) {
@@ -231,26 +217,25 @@
idat = AFMT_IMA_ADPCM;
break;
}
- INTARG = idat;
+ INTARG = idat; */
break;
case SNDCTL_DSP_CHANNELS:
- AUDIO_INITINFO(&tmpinfo);
- tmpinfo.play.channels =
+/* tmpinfo.play.channels =
tmpinfo.record.channels = INTARG;
- (void) ioctl(fd, AUDIO_SETINFO, &tmpinfo);
+ (void) ioctl(fd, AUDIO_SETINFO, &tmpinfo); */
/* FALLTHRU */
case SOUND_PCM_READ_CHANNELS:
- retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
+/* retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
if (retval < 0)
return retval;
- INTARG = tmpinfo.play.channels;
+ INTARG = tmpinfo.play.channels; */
break;
case SOUND_PCM_WRITE_FILTER:
case SOUND_PCM_READ_FILTER:
errno = EINVAL;
return -1; /* XXX unimplemented */
case SNDCTL_DSP_SUBDIVIDE:
- retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
+/* retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
if (retval < 0)
return retval;
setblocksize(fd, &tmpinfo);
@@ -263,17 +248,17 @@
retval = ioctl(fd, AUDIO_SETINFO, &tmpinfo);
if (retval < 0)
return retval;
- INTARG = tmpinfo.play.buffer_size / tmpinfo.blocksize;
+ INTARG = tmpinfo.play.buffer_size / tmpinfo.blocksize; */
break;
case SNDCTL_DSP_SETFRAGMENT:
- AUDIO_INITINFO(&tmpinfo);
+/* AUDIO_INITINFO(&tmpinfo);
idat = INTARG;
if ((idat & 0xffff) < 4 || (idat & 0xffff) > 17)
return EINVAL;
tmpinfo.blocksize = 1 << (idat & 0xffff);
tmpinfo.hiwat = ((unsigned)idat >> 16) & 0x7fff;
- if (tmpinfo.hiwat == 0) /* 0 means set to max */
- tmpinfo.hiwat = 65536;
+ if (tmpinfo.hiwat == 0) */ /* 0 means set to max */
+/* tmpinfo.hiwat = 65536;
(void) ioctl(fd, AUDIO_SETINFO, &tmpinfo);
retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
if (retval < 0)
@@ -282,10 +267,10 @@
for(idat = 0; u > 1; idat++, u >>= 1)
;
idat |= (tmpinfo.hiwat & 0x7fff) << 16;
- INTARG = idat;
+ INTARG = idat; */
break;
case SNDCTL_DSP_GETFMTS:
- for(idat = 0, tmpenc.index = 0;
+/* for(idat = 0, tmpenc.index = 0;
ioctl(fd, AUDIO_GETENC, &tmpenc) == 0;
tmpenc.index++) {
switch(tmpenc.encoding) {
@@ -332,10 +317,10 @@
break;
}
}
- INTARG = idat;
+ INTARG = idat; */
break;
case SNDCTL_DSP_GETOSPACE:
- retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
+/* retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
if (retval < 0)
return retval;
setblocksize(fd, &tmpinfo);
@@ -344,10 +329,10 @@
(tmpinfo.play.seek + tmpinfo.blocksize - 1)/tmpinfo.blocksize;
bufinfo.fragstotal = tmpinfo.hiwat;
bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.play.seek;
- *(struct audio_buf_info *)argp = bufinfo;
+ *(struct audio_buf_info *)argp = bufinfo; */
break;
case SNDCTL_DSP_GETISPACE:
- retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
+/* retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
if (retval < 0)
return retval;
setblocksize(fd, &tmpinfo);
@@ -356,38 +341,38 @@
(tmpinfo.record.seek + tmpinfo.blocksize - 1)/tmpinfo.blocksize;
bufinfo.fragstotal = tmpinfo.hiwat;
bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize - tmpinfo.record.seek;
- *(struct audio_buf_info *)argp = bufinfo;
+ *(struct audio_buf_info *)argp = bufinfo; */
break;
case SNDCTL_DSP_NONBLOCK:
- idat = 1;
+/* idat = 1;
retval = ioctl(fd, FIONBIO, &idat);
if (retval < 0)
- return retval;
+ return retval; */
break;
case SNDCTL_DSP_GETCAPS:
- retval = ioctl(fd, AUDIO_GETPROPS, &idata);
+/* retval = ioctl(fd, AUDIO_GETPROPS, &idata);
if (retval < 0)
return retval;
- idat = DSP_CAP_TRIGGER; /* pretend we have trigger */
- if (idata & AUDIO_PROP_FULLDUPLEX)
+ idat = DSP_CAP_TRIGGER; */ /* pretend we have trigger */
+/* if (idata & AUDIO_PROP_FULLDUPLEX)
idat |= DSP_CAP_DUPLEX;
if (idata & AUDIO_PROP_MMAP)
idat |= DSP_CAP_MMAP;
- INTARG = idat;
+ INTARG = idat; */
break;
-#if 0
case SNDCTL_DSP_GETTRIGGER:
- retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
+/* This was #if 0'd out. Why? */
+/* retval = ioctl(fd, AUDIO_GETINFO, &tmpinfo);
if (retval < 0)
return retval;
idat = (tmpinfo.play.pause ? 0 : PCM_ENABLE_OUTPUT) |
(tmpinfo.record.pause ? 0 : PCM_ENABLE_INPUT);
retval = copyout(&idat, SCARG(uap, data), sizeof idat);
if (retval < 0)
- return retval;
+ return retval; */
break;
case SNDCTL_DSP_SETTRIGGER:
- AUDIO_INITINFO(&tmpinfo);
+/* AUDIO_INITINFO(&tmpinfo);
retval = copyin(SCARG(uap, data), &idat, sizeof idat);
if (retval < 0)
return retval;
@@ -396,32 +381,25 @@
(void) ioctl(fd, AUDIO_SETINFO, &tmpinfo);
retval = copyout(&idat, SCARG(uap, data), sizeof idat);
if (retval < 0)
- return retval;
+ return retval; */
break;
-#else
- case SNDCTL_DSP_GETTRIGGER:
- case SNDCTL_DSP_SETTRIGGER:
- /* XXX Do nothing for now. */
- INTARG = PCM_ENABLE_OUTPUT;
- break;
-#endif
case SNDCTL_DSP_GETIPTR:
- retval = ioctl(fd, AUDIO_GETIOFFS, &tmpoffs);
+/* retval = ioctl(fd, AUDIO_GETIOFFS, &tmpoffs);
if (retval < 0)
return retval;
cntinfo.bytes = tmpoffs.samples;
cntinfo.blocks = tmpoffs.deltablks;
cntinfo.ptr = tmpoffs.offset;
- *(struct count_info *)argp = cntinfo;
+ *(struct count_info *)argp = cntinfo; */
break;
case SNDCTL_DSP_GETOPTR:
- retval = ioctl(fd, AUDIO_GETOOFFS, &tmpoffs);
+/* retval = ioctl(fd, AUDIO_GETOOFFS, &tmpoffs);
if (retval < 0)
return retval;
cntinfo.bytes = tmpoffs.samples;
cntinfo.blocks = tmpoffs.deltablks;
cntinfo.ptr = tmpoffs.offset;
- *(struct count_info *)argp = cntinfo;
+ *(struct count_info *)argp = cntinfo; */
break;
case SNDCTL_DSP_MAPINBUF:
case SNDCTL_DSP_MAPOUTBUF:
@@ -438,6 +416,8 @@
return 0;
}
+/* I don't think we need any of this stuff */
+#if 0
/* If the NetBSD mixer device should have more than NETBSD_MAXDEVS devices
* some will not be available to Linux */
@@ -613,10 +593,16 @@
return di;
}
+#endif /* Probably not needed */
+
int
mixer_ioctl(int fd, unsigned long com, void *argp)
{
- struct audiodevinfo *di;
+ /* FIXME: implement */
+ errno = EINVAL;
+ return -1;
+
+/* struct audiodevinfo *di;
struct mixer_info *omi;
struct audio_device adev;
mixer_ctrl_t mc;
@@ -761,26 +747,5 @@
}
}
INTARG = idat;
- return 0;
-}
-
-/*
- * Check that the blocksize is a power of 2 as OSS wants.
- * If not, set it to be.
- */
-static void
-setblocksize(int fd, struct audio_info *info)
-{
- struct audio_info set;
- int s;
-
- if (info->blocksize & (info->blocksize-1)) {
- for(s = 32; s < info->blocksize; s <<= 1)
- ;
- AUDIO_INITINFO(&set);
- set.blocksize = s;
- ioctl(fd, AUDIO_SETINFO, &set);
- ioctl(fd, AUDIO_GETINFO, info);
- }
+ return 0; */
}
-
Index: Makefile.am
===================================================================
RCS file: /cvsroot/liboss/liboss/lib/Makefile.am,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- Makefile.am 3 May 2002 16:20:02 -0000 1.1.1.1
+++ Makefile.am 9 May 2002 07:48:32 -0000 1.2
@@ -2,7 +2,7 @@
## Process this file with automake to produce Makefile.in
##
-CFLAGS = @CFLAGS@
+CFLAGS = @CFLAGS@ -L../include
lib_LTLIBRARIES = liboss.la
|