Module Name: src Committed By: nia Date: Mon Oct 19 10:28:47 UTC 2020
Modified Files: src/lib/libossaudio: ossaudio.c soundcard.h Log Message: ossaudio(3): add some no-op defines for ossv4 compat. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/lib/libossaudio/ossaudio.c cvs rdiff -u -r1.27 -r1.28 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/ossaudio.c diff -u src/lib/libossaudio/ossaudio.c:1.51 src/lib/libossaudio/ossaudio.c:1.52 --- src/lib/libossaudio/ossaudio.c:1.51 Mon Oct 19 09:07:29 2020 +++ src/lib/libossaudio/ossaudio.c Mon Oct 19 10:28:47 2020 @@ -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 @@ __RCSID("$NetBSD: ossaudio.c,v 1.51 2020 * 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 void setblocksize(int, struct aud 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 @@ _oss_ioctl(int fd, unsigned long com, .. 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 @@ mixer_oss4_ioctl(int fd, unsigned long c } 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]; Index: src/lib/libossaudio/soundcard.h diff -u src/lib/libossaudio/soundcard.h:1.27 src/lib/libossaudio/soundcard.h:1.28 --- src/lib/libossaudio/soundcard.h:1.27 Mon Oct 19 09:01:24 2020 +++ src/lib/libossaudio/soundcard.h Mon Oct 19 10:28:47 2020 @@ -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_id_t[OSS_ID_SIZE]; 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 @@ typedef struct oss_mixext { 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,