Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libossaudio ossaudio(3): add some no-op defines for ossv...



details:   https://anonhg.NetBSD.org/src/rev/76ef69345424
branches:  trunk
changeset: 977250:76ef69345424
user:      nia <nia%NetBSD.org@localhost>
date:      Mon Oct 19 10:28:47 2020 +0000

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

diffstat:

 lib/libossaudio/ossaudio.c  |  40 +++++++++++++++++++++++++++++++++++++---
 lib/libossaudio/soundcard.h |  17 ++++++++++++++++-
 2 files changed, 53 insertions(+), 4 deletions(-)

diffs (120 lines):

diff -r 0931e6c9958b -r 76ef69345424 lib/libossaudio/ossaudio.c
--- a/lib/libossaudio/ossaudio.c        Mon Oct 19 09:07:29 2020 +0000
+++ b/lib/libossaudio/ossaudio.c        Mon Oct 19 10:28:47 2020 +0000
@@ -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 <sys/cdefs.h>
-__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 @@
  * 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 <string.h>
@@ -79,6 +79,7 @@
 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 @@
                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 @@
 }
 
 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];
diff -r 0931e6c9958b -r 76ef69345424 lib/libossaudio/soundcard.h
--- a/lib/libossaudio/soundcard.h       Mon Oct 19 09:07:29 2020 +0000
+++ b/lib/libossaudio/soundcard.h       Mon Oct 19 10:28:47 2020 +0000
@@ -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_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 @@
        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 <sys/ioctl.h>, then we define our own prototype,



Home | Main Index | Thread Index | Old Index