summaryrefslogtreecommitdiff
path: root/usr.bin/aucat/opt.c
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2010-06-04 06:15:29 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2010-06-04 06:15:29 +0000
commit2f26a15fe85a93502fda187db3aa3d3b3af985bb (patch)
treef0058377c8c72be142aaa0d4fe60b0492a2b8bb4 /usr.bin/aucat/opt.c
parentf0d36a131a1ee4ee7ed9a0c5937c9dab18f7090c (diff)
Allow the audio device to be opened only while it's actually used.
This is necessary for uaudio devices, for instance to start aucat before the device is plugged. Or to unplug a device whithout having to restart aucat when another device is plugged. This is controlled with the new -a option. Allow multiple audio devices to be used concurently, i.e. multiple ``-f devname'' options to be used; -f options must follow per-device options, which is what we do for other options.
Diffstat (limited to 'usr.bin/aucat/opt.c')
-rw-r--r--usr.bin/aucat/opt.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/usr.bin/aucat/opt.c b/usr.bin/aucat/opt.c
index ef36daf4ff8..6ab06ce677c 100644
--- a/usr.bin/aucat/opt.c
+++ b/usr.bin/aucat/opt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: opt.c,v 1.8 2010/04/21 06:13:07 ratchov Exp $ */
+/* $OpenBSD: opt.c,v 1.9 2010/06/04 06:15:28 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -27,7 +27,7 @@
struct optlist opt_list = SLIST_HEAD_INITIALIZER(&opt_list);
void
-opt_new(char *name, struct aparams *wpar, struct aparams *rpar,
+opt_new(char *name, struct dev *d, struct aparams *wpar, struct aparams *rpar,
int maxweight, int mmc, int join, unsigned mode)
{
struct opt *o;
@@ -48,6 +48,12 @@ opt_new(char *name, struct aparams *wpar, struct aparams *rpar,
exit(1);
}
}
+ SLIST_FOREACH(o, &opt_list, entry) {
+ if (strcmp(name, o->name) == 0) {
+ fprintf(stderr, "%s: already defined\n", name);
+ exit(1);
+ }
+ }
o = malloc(sizeof(struct opt));
if (o == NULL) {
perror("opt_new: malloc");
@@ -62,6 +68,7 @@ opt_new(char *name, struct aparams *wpar, struct aparams *rpar,
o->mmc = mmc;
o->join = join;
o->mode = mode;
+ o->dev = d;
#ifdef DEBUG
if (debug_level >= 2) {
dbg_puts(o->name);