From d1c426fe383158bbed44c5920175ba471130424a Mon Sep 17 00:00:00 2001 From: augustss Date: Thu, 31 Jan 2002 00:03:23 +0000 Subject: [PATCH] Use _PATH_SOUND etc, all fall back to _PATH_SOUND0 (etc.) if that fails. --- usr.bin/audio/ctl/ctl.c | 10 ++++------ usr.bin/audio/play/play.c | 18 ++++++++---------- usr.bin/audio/record/record.c | 9 +++++++-- usr.bin/mixerctl/mixerctl.c | 18 ++++++++---------- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/usr.bin/audio/ctl/ctl.c b/usr.bin/audio/ctl/ctl.c index 61f66976843b..42a3b914fdff 100644 --- a/usr.bin/audio/ctl/ctl.c +++ b/usr.bin/audio/ctl/ctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: ctl.c,v 1.30 2002/01/27 18:21:52 jdolecek Exp $ */ +/* $NetBSD: ctl.c,v 1.31 2002/01/31 00:03:23 augustss Exp $ */ /* * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -345,7 +345,7 @@ main(argc, argv) const char *sep = "="; file = getenv("AUDIOCTLDEVICE"); - if (file == 0) + if (file == NULL) file = _PATH_AUDIOCTL; while ((ch = getopt(argc, argv, "ad:f:nw")) != -1) { @@ -374,15 +374,13 @@ main(argc, argv) fd = open(file, O_WRONLY); if (fd < 0) fd = open(file, O_RDONLY); -#ifdef _PATH_OAUDIOCTL - /* Allow the non-unit device to be used. */ if (fd < 0 && file == _PATH_AUDIOCTL) { - file = _PATH_OAUDIOCTL; + file = _PATH_AUDIOCTL0; fd = open(file, O_WRONLY); if (fd < 0) fd = open(file, O_RDONLY); } -#endif + if (fd < 0) err(1, "%s", file); diff --git a/usr.bin/audio/play/play.c b/usr.bin/audio/play/play.c index 215aeb38a562..58f77823d5e5 100644 --- a/usr.bin/audio/play/play.c +++ b/usr.bin/audio/play/play.c @@ -1,4 +1,4 @@ -/* $NetBSD: play.c,v 1.31 2002/01/15 17:00:53 mrg Exp $ */ +/* $NetBSD: play.c,v 1.32 2002/01/31 00:03:23 augustss Exp $ */ /* * Copyright (c) 1999 Matthew R. Green @@ -79,8 +79,8 @@ main(argc, argv) int ch; int iflag = 0; int verbose = 0; - const char *device = 0; - const char *ctldev = 0; + const char *device = NULL; + const char *ctldev = NULL; while ((ch = getopt(argc, argv, "b:C:c:d:e:fhip:P:qs:Vv:")) != -1) { switch (ch) { @@ -162,19 +162,17 @@ main(argc, argv) if (device == NULL && (device = getenv("AUDIODEVICE")) == NULL && (device = getenv("AUDIODEV")) == NULL) /* Sun compatibility */ - device = _PATH_AUDIO; + device = _PATH_SOUND; if (ctldev == NULL && (ctldev = getenv("AUDIOCTLDEVICE")) == NULL) ctldev = _PATH_AUDIOCTL; audiofd = open(device, O_WRONLY); -#ifdef _PATH_OAUDIO - /* Allow the non-unit device to be used. */ - if (audiofd < 0 && device == _PATH_AUDIO) { - device = _PATH_OAUDIO; - ctldev = _PATH_OAUDIOCTL; + if (audiofd < 0 && device == _PATH_SOUND) { + device = _PATH_SOUND0; + ctldev = _PATH_AUDIOCTL0; audiofd = open(device, O_WRONLY); } -#endif + if (audiofd < 0) err(1, "failed to open %s", device); ctlfd = open(ctldev, O_RDWR); diff --git a/usr.bin/audio/record/record.c b/usr.bin/audio/record/record.c index 1a393873ef16..2aa09ebf1ac3 100644 --- a/usr.bin/audio/record/record.c +++ b/usr.bin/audio/record/record.c @@ -1,4 +1,4 @@ -/* $NetBSD: record.c,v 1.21 2002/01/15 23:48:53 mrg Exp $ */ +/* $NetBSD: record.c,v 1.22 2002/01/31 00:03:24 augustss Exp $ */ /* * Copyright (c) 1999 Matthew R. Green @@ -188,11 +188,16 @@ main(argc, argv) */ if (device == NULL && (device = getenv("AUDIODEVICE")) == NULL && (device = getenv("AUDIODEV")) == NULL) /* Sun compatibility */ - device = _PATH_AUDIO; + device = _PATH_SOUND; if (ctldev == NULL && (ctldev = getenv("AUDIOCTLDEVICE")) == NULL) ctldev = _PATH_AUDIOCTL; audiofd = open(device, O_RDONLY); + if (audiofd < 0 && device == _PATH_SOUND) { + device = _PATH_SOUND0; + ctldev = _PATH_AUDIOCTL0; + audiofd = open(device, O_WRONLY); + } if (audiofd < 0) err(1, "failed to open %s", device); ctlfd = open(ctldev, O_RDWR); diff --git a/usr.bin/mixerctl/mixerctl.c b/usr.bin/mixerctl/mixerctl.c index d8dd656e639d..a1dfa23b3fdd 100644 --- a/usr.bin/mixerctl/mixerctl.c +++ b/usr.bin/mixerctl/mixerctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: mixerctl.c,v 1.16 2002/01/27 10:09:55 jdolecek Exp $ */ +/* $NetBSD: mixerctl.c,v 1.17 2002/01/31 00:03:24 augustss Exp $ */ /* * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -45,8 +45,7 @@ #include #include -#define MIXER "/dev/mixer0" -#define OLD_MIXER "/dev/mixer" +#include FILE *out = stdout; int vflag = 0; @@ -319,8 +318,8 @@ main(int argc, char **argv) int ndev; file = getenv("MIXERDEVICE"); - if (file == 0) - file = MIXER; + if (file == NULL) + file = _PATH_MIXER; prog = *argv; @@ -355,13 +354,12 @@ main(int argc, char **argv) argv += optind; fd = open(file, O_RDWR); -#ifdef OLD_MIXER - /* Allow the non-unit device to be used. */ - if (fd < 0 && file == MIXER) { - file = OLD_MIXER; + /* Try with mixer0. */ + if (fd < 0 && file == _PATH_MIXER) { + file = _PATH_MIXER0; fd = open(file, O_RDWR); } -#endif + if (fd < 0) err(1, "%s", file);