Re: cleanup ossaudio compat

2013-03-27 Thread Tim van der Molen
On Tue, 26 Mar 2013 07:28:20 +0100, Ted Unangst wrote:
> As much as it pains me to submit a diff that contains + in the compat
> directory, this is still mostly -. Calling our mixer devices NetBSD
> devices doesn't make a whole lot of sense. Also kill some other dead
> code.

The below diff reflects your changes to src/lib/libossaudio.

> The comment still doesn't make a lot of sense to me. The comment says
> only 32 devices are available, but OSS_SOUND_MIXER_NRDEVICES is
> defined to be 17. I leave the thinking to somebody else.

> -/* If the NetBSD mixer device should have more than 32 devices
> +/* If the mixer device should have more than 32 devices
>   * some will not be available to Linux */
> -#define NETBSD_MAXDEVS 64
> +#define MAX_MIXER_DEVS 64

Based on the comment in the below diff, I think that NETBSD_MAXDEVS used
to be set to 32. Then someone increased it to 64, but forgot to update
the comment. In that case, the "32" in the above comment should be
changed to "MAX_MIXER_DEVS". But perhaps I shouldn't be doing the
thinking either.

Index: ossaudio.c
===
RCS file: /cvs/src/lib/libossaudio/ossaudio.c,v
retrieving revision 1.16
diff -p -u -r1.16 ossaudio.c
--- ossaudio.c  26 Jun 2008 05:42:05 -  1.16
+++ ossaudio.c  27 Mar 2013 18:52:40 -
@@ -456,17 +456,17 @@ audio_ioctl(int fd, unsigned long com, v
 }
 
 
-/* If the NetBSD mixer device should have more than NETBSD_MAXDEVS devices
+/* If the mixer device should have more than MAX_MIXER_DEVS devices
  * some will not be available to Linux */
-#define NETBSD_MAXDEVS 64
+#define MAX_MIXER_DEVS 64
 struct audiodevinfo {
int done;
dev_t dev;
ino_t ino;
int16_t devmap[SOUND_MIXER_NRDEVICES],
-   rdevmap[NETBSD_MAXDEVS];
-   char names[NETBSD_MAXDEVS][MAX_AUDIO_DEV_LEN];
-   int enum2opaque[NETBSD_MAXDEVS];
+   rdevmap[MAX_MIXER_DEVS];
+   char names[MAX_MIXER_DEVS][MAX_AUDIO_DEV_LEN];
+   int enum2opaque[MAX_MIXER_DEVS];
 u_long devmask, recmask, stereomask;
u_long caps, recsource;
 };
@@ -476,7 +476,7 @@ opaque_to_enum(struct audiodevinfo *di, 
 {
int i, o;
 
-   for (i = 0; i < NETBSD_MAXDEVS; i++) {
+   for (i = 0; i < MAX_MIXER_DEVS; i++) {
o = di->enum2opaque[i];
if (o == opq)
break;
@@ -486,7 +486,7 @@ opaque_to_enum(struct audiodevinfo *di, 
break;
}
}
-   if (i >= NETBSD_MAXDEVS)
+   if (i >= MAX_MIXER_DEVS)
i = -1;
/*printf("opq_to_enum %s %d -> %d\n", label->name, opq, i);*/
return (i);
@@ -495,7 +495,7 @@ opaque_to_enum(struct audiodevinfo *di, 
 static int
 enum_to_ord(struct audiodevinfo *di, int enm)
 {
-   if (enm >= NETBSD_MAXDEVS)
+   if (enm >= MAX_MIXER_DEVS)
return (-1);
 
/*printf("enum_to_ord %d -> %d\n", enm, di->enum2opaque[enm]);*/
@@ -506,7 +506,7 @@ static int
 enum_to_mask(struct audiodevinfo *di, int enm)
 {
int m;
-   if (enm >= NETBSD_MAXDEVS)
+   if (enm >= MAX_MIXER_DEVS)
return (0);
 
m = di->enum2opaque[enm];
@@ -541,16 +541,10 @@ getdevinfo(int fd)
{ AudioNtreble, SOUND_MIXER_TREBLE },
{ AudioNbass,   SOUND_MIXER_BASS },
{ AudioNspeaker,SOUND_MIXER_SPEAKER },
-/* { AudioNheadphone,  ?? },*/
{ AudioNoutput, SOUND_MIXER_OGAIN },
{ AudioNinput,  SOUND_MIXER_IGAIN },
-/* { AudioNmaster, SOUND_MIXER_SPEAKER },*/
-/* { AudioNstereo, ?? },*/
-/* { AudioNmono,   ?? },*/
{ AudioNfmsynth,SOUND_MIXER_SYNTH },
-/* { AudioNwave,   SOUND_MIXER_PCM },*/
{ AudioNmidi,   SOUND_MIXER_SYNTH },
-/* { AudioNmixerout,   ?? },*/
{ 0, -1 }
};
static struct audiodevinfo devcache = { 0 };
@@ -575,12 +569,12 @@ getdevinfo(int fd)
di->caps = 0;
for(i = 0; i < SOUND_MIXER_NRDEVICES; i++)
di->devmap[i] = -1;
-   for(i = 0; i < NETBSD_MAXDEVS; i++) {
+   for(i = 0; i < MAX_MIXER_DEVS; i++) {
di->rdevmap[i] = -1;
di->names[i][0] = '\0';
di->enum2opaque[i] = -1;
}
-   for(i = 0; i < NETBSD_MAXDEVS; i++) {
+   for(i = 0; i < MAX_MIXER_DEVS; i++) {
mi.index = i;
if (ioctl(fd, AUDIO_MIXER_DEVINFO, &mi) < 0)
break;
@@ -601,7 +595,7 @@ getdevinfo(int fd)
break;
}
}
-   for(i = 0; i < NETBSD_MAXDEVS; i++) {
+   for(i = 0; i < MAX_MIXER_DEVS; i++) {
mi.index = i;
if (ioctl(fd, AUDIO_MIXER_DEVINFO, &mi) < 0)
  

cleanup ossaudio compat

2013-03-25 Thread Ted Unangst
As much as it pains me to submit a diff that contains + in the compat
directory, this is still mostly -. Calling our mixer devices NetBSD
devices doesn't make a whole lot of sense. Also kill some other dead
code.

The comment still doesn't make a lot of sense to me. The comment says
only 32 devices are available, but OSS_SOUND_MIXER_NRDEVICES is
defined to be 17. I leave the thinking to somebody else.

Index: ossaudio.c
===
RCS file: /cvs/src/sys/compat/ossaudio/ossaudio.c,v
retrieving revision 1.14
diff -u -p -r1.14 ossaudio.c
--- ossaudio.c  22 Apr 2012 05:43:14 -  1.14
+++ ossaudio.c  26 Mar 2013 06:21:55 -
@@ -494,14 +494,14 @@ oss_ioctl_audio(p, uap, retval)
return (error);
 }
 
-/* If the NetBSD mixer device should have more than 32 devices
+/* If the mixer device should have more than 32 devices
  * some will not be available to Linux */
-#define NETBSD_MAXDEVS 64
+#define MAX_MIXER_DEVS 64
 struct audiodevinfo {
int done;
dev_t dev;
int16_t devmap[OSS_SOUND_MIXER_NRDEVICES], 
-   rdevmap[NETBSD_MAXDEVS];
+   rdevmap[MAX_MIXER_DEVS];
 u_long devmask, recmask, stereomask;
u_long caps, source;
 };
@@ -532,16 +532,10 @@ getdevinfo(fp, p)
{ AudioNtreble, OSS_SOUND_MIXER_TREBLE },
{ AudioNbass,   OSS_SOUND_MIXER_BASS },
{ AudioNspeaker,OSS_SOUND_MIXER_SPEAKER },
-/* { AudioNheadphone,  ?? },*/
{ AudioNoutput, OSS_SOUND_MIXER_OGAIN },
{ AudioNinput,  OSS_SOUND_MIXER_IGAIN },
-/* { AudioNmaster, OSS_SOUND_MIXER_SPEAKER },*/
-/* { AudioNstereo, ?? },*/
-/* { AudioNmono,   ?? },*/
{ AudioNfmsynth,OSS_SOUND_MIXER_SYNTH },
-/* { AudioNwave,   OSS_SOUND_MIXER_PCM },*/
{ AudioNmidi,   OSS_SOUND_MIXER_SYNTH },
-/* { AudioNmixerout,   ?? },*/
{ 0, -1 }
};
register const struct oss_devs *dp;
@@ -572,9 +566,9 @@ getdevinfo(fp, p)
di->caps = 0;
for(i = 0; i < OSS_SOUND_MIXER_NRDEVICES; i++)
di->devmap[i] = -1;
-   for(i = 0; i < NETBSD_MAXDEVS; i++)
+   for(i = 0; i < MAX_MIXER_DEVS; i++)
di->rdevmap[i] = -1;
-   for(i = 0; i < NETBSD_MAXDEVS; i++) {
+   for(i = 0; i < MAX_MIXER_DEVS; i++) {
mi.index = i;
if (ioctlf(fp, AUDIO_MIXER_DEVINFO, (caddr_t)&mi, p) < 0)
break;
@@ -822,11 +816,6 @@ oss_ioctl_sequencer(p, uap, retval)
 { 
struct file *fp;
struct filedesc *fdp;
-#if 0
-   u_long com;
-   int idat;
-   int error;
-#endif
 
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, SCARG(uap, fd))) == NULL)
@@ -835,9 +824,6 @@ oss_ioctl_sequencer(p, uap, retval)
if ((fp->f_flag & (FREAD | FWRITE)) == 0)
return (EBADF);
 
-#if 0
-   com = SCARG(uap, com);
-#endif
retval[0] = 0;
 
return EINVAL;