diff options
author | Jason Wright <jason@cvs.openbsd.org> | 2003-02-01 18:09:28 +0000 |
---|---|---|
committer | Jason Wright <jason@cvs.openbsd.org> | 2003-02-01 18:09:28 +0000 |
commit | 0924f9a6718dce35c8f160dfb11babe9fad9f512 (patch) | |
tree | 216067951563e926b141020d0db9bace860aa132 | |
parent | 979f6a882bc0d78a80ff1c4c6a57f06b7027a2b0 (diff) |
add -f flag so the device can be specified, and make sure the device is
an audio device (ioctl(... AUDIO_GETINFO ...) should do).
-rw-r--r-- | regress/sys/dev/audio/autest.1 | 13 | ||||
-rw-r--r-- | regress/sys/dev/audio/autest.c | 32 |
2 files changed, 37 insertions, 8 deletions
diff --git a/regress/sys/dev/audio/autest.1 b/regress/sys/dev/audio/autest.1 index ba895d60eb9..129872cd54e 100644 --- a/regress/sys/dev/audio/autest.1 +++ b/regress/sys/dev/audio/autest.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: autest.1,v 1.1 2003/02/01 17:58:18 jason Exp $ +.\" $OpenBSD: autest.1,v 1.2 2003/02/01 18:09:27 jason Exp $ .\" .\" Copyright (c) 2002 Jason L. Wright (jason@thought.net) .\" All rights reserved. @@ -37,11 +37,18 @@ .Nd test audio encoding output .Sh SYNOPSIS .Nm autest +.Op Fl f Ar device .Sh DESCRIPTION The .Nm -utility opens -.Ar /dev/sound +utility opens the +.Xr audio 4 +device specified with the +.Fl f +flag +or +.Pa /dev/sound +if not specified, and iterates through all of the encodings supported by the device playing a 440Hz tone in the proper format. The tone should sound almost identical in each of the formats. diff --git a/regress/sys/dev/audio/autest.c b/regress/sys/dev/audio/autest.c index d3e1f4e1af3..1d8c8792c7e 100644 --- a/regress/sys/dev/audio/autest.c +++ b/regress/sys/dev/audio/autest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autest.c,v 1.1 2003/02/01 17:58:18 jason Exp $ */ +/* $OpenBSD: autest.c,v 1.2 2003/02/01 18:09:27 jason Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -45,7 +45,7 @@ #include "adpcm.h" #include "law.h" -int main(void); +int main(int, char **); void check_encoding(int, audio_encoding_t *); void check_encoding_mono(int, audio_encoding_t *); void check_encoding_stereo(int, audio_encoding_t *); @@ -62,16 +62,38 @@ void audio_wait(int); #define PLAYSECS 2 +#define DEFAULT_DEV "/dev/sound" + int -main() +main(int argc, char **argv) { - int fd, i; + audio_info_t ainfo; + char *fname = NULL; + int fd, i, c; + + while ((c = getopt(argc, argv, "f:")) != -1) { + switch (c) { + case 'f': + fname = optarg; + break; + case '?': + default: + fprintf(stderr, "%s [-f device]\n", argv[0]); + return (1); + } + } + + if (fname == NULL) + fname = DEFAULT_DEV; - fd = open("/dev/sound", O_RDWR, 0); + fd = open(fname, O_RDWR, 0); if (fd == -1) err(1, "open"); + if (ioctl(fd, AUDIO_GETINFO, &ainfo) == -1) + err(1, "%s: audio_getinfo", fname); + for (i = 0; ; i++) { audio_encoding_t enc; |