Use _PATH_SOUND etc, all fall back to _PATH_SOUND0 (etc.) if that fails.

This commit is contained in:
augustss 2002-01-31 00:03:23 +00:00
parent 458896425c
commit d1c426fe38
4 changed files with 27 additions and 28 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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 <sys/ioctl.h>
#include <sys/audioio.h>
#define MIXER "/dev/mixer0"
#define OLD_MIXER "/dev/mixer"
#include <paths.h>
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);