summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2009-10-10 12:43:10 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2009-10-10 12:43:10 +0000
commit96782ef80dd52562aa753c36cf4d4abe6b426b64 (patch)
tree97c865e3390f009aa3ab7dfcb471585d12f3c753
parentec19e264dc74ff12317c8579e4d892a2ad0acdec (diff)
make dev_done() common to audio and MIDI, and drop dev_thrudone()
-rw-r--r--usr.bin/aucat/aproc.h4
-rw-r--r--usr.bin/aucat/aucat.c8
-rw-r--r--usr.bin/aucat/dev.c50
-rw-r--r--usr.bin/aucat/midi.c10
4 files changed, 32 insertions, 40 deletions
diff --git a/usr.bin/aucat/aproc.h b/usr.bin/aucat/aproc.h
index fd448b69cb6..299192514af 100644
--- a/usr.bin/aucat/aproc.h
+++ b/usr.bin/aucat/aproc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: aproc.h,v 1.24 2009/10/06 18:06:55 ratchov Exp $ */
+/* $OpenBSD: aproc.h,v 1.25 2009/10/10 12:43:09 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -166,6 +166,8 @@ struct aproc {
struct {
struct abuf *owner; /* current input stream */
struct timo timo; /* timout for throtteling */
+#define THRU_AUTOQUIT 1
+ unsigned flags; /* bit mask of above */
} thru;
struct {
#define CTL_NSLOT 8
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c
index 80975cdc04e..792684ad3c2 100644
--- a/usr.bin/aucat/aucat.c
+++ b/usr.bin/aucat/aucat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aucat.c,v 1.70 2009/10/10 11:58:41 ratchov Exp $ */
+/* $OpenBSD: aucat.c,v 1.71 2009/10/10 12:43:09 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -707,6 +707,8 @@ midicat_main(int argc, char **argv)
filelist_init();
dev_thruinit();
+ if (!l_flag)
+ dev_midi->u.thru.flags |= THRU_AUTOQUIT;
if ((!SLIST_EMPTY(&ifiles) || !SLIST_EMPTY(&ofiles)) &&
SLIST_EMPTY(&dfiles)) {
farg_add(&dfiles, &aparams_none, &aparams_none,
@@ -774,8 +776,6 @@ midicat_main(int argc, char **argv)
if (quit_flag) {
break;
}
- if (!l_flag && LIST_EMPTY(&dev_midi->ibuflist))
- break;
if (!file_poll())
break;
}
@@ -784,7 +784,7 @@ midicat_main(int argc, char **argv)
if (rmdir(base) < 0)
warn("rmdir(\"%s\")", base);
}
- dev_thrudone();
+ dev_done();
filelist_done();
unsetsig();
return 0;
diff --git a/usr.bin/aucat/dev.c b/usr.bin/aucat/dev.c
index f03a3474be9..0e21398b0c0 100644
--- a/usr.bin/aucat/dev.c
+++ b/usr.bin/aucat/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.33 2009/10/10 11:58:41 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.34 2009/10/10 12:43:09 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -43,32 +43,6 @@ dev_thruinit(void)
}
/*
- * Terminate the MIDI thru box
- */
-void
-dev_thrudone(void)
-{
- struct file *f;
-
- restart:
- LIST_FOREACH(f, &file_list, entry) {
- if (f->rproc && aproc_depend(dev_midi, f->rproc)) {
- file_eof(f);
- goto restart;
- }
- }
- while (!LIST_EMPTY(&dev_midi->ibuflist)) {
- if (!file_poll())
- break;
- }
- dev_midi->refs--;
- aproc_del(dev_midi);
- dev_midi = NULL;
- while (file_poll())
- ; /* nothing */
-}
-
-/*
* Attach a bi-directional MIDI stream to the MIDI device
*/
void
@@ -264,13 +238,15 @@ dev_done(void)
struct file *f;
if (dev_midi) {
- /*
- * We don't have the necessary bits to drain
- * control MIDI device, so just kill it
- */
- dev_midi->refs--;
- aproc_del(dev_midi);
- dev_midi = NULL;
+ dev_midi->u.mix.flags |= THRU_AUTOQUIT;
+ restart_midi:
+ LIST_FOREACH(f, &file_list, entry) {
+ if (f->rproc &&
+ aproc_depend(dev_midi, f->rproc)) {
+ file_eof(f);
+ goto restart_midi;
+ }
+ }
}
if (dev_mix) {
/*
@@ -331,6 +307,12 @@ dev_done(void)
aproc_del(dev_rec);
dev_rec = NULL;
}
+ if (dev_midi) {
+ dev_midi->refs--;
+ if (dev_midi->zomb)
+ aproc_del(dev_midi);
+ dev_midi = NULL;
+ }
for (;;) {
if (!file_poll())
break;
diff --git a/usr.bin/aucat/midi.c b/usr.bin/aucat/midi.c
index 0e794305a36..2a2f9c8c813 100644
--- a/usr.bin/aucat/midi.c
+++ b/usr.bin/aucat/midi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: midi.c,v 1.10 2009/10/09 16:49:48 ratchov Exp $ */
+/* $OpenBSD: midi.c,v 1.11 2009/10/10 12:43:09 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -225,11 +225,19 @@ thru_out(struct aproc *p, struct abuf *obuf)
void
thru_eof(struct aproc *p, struct abuf *ibuf)
{
+ if (!(p->u.thru.flags & THRU_AUTOQUIT))
+ return;
+ if (LIST_EMPTY(&p->obuflist) || LIST_EMPTY(&p->ibuflist))
+ aproc_del(p);
}
void
thru_hup(struct aproc *p, struct abuf *obuf)
{
+ if (!(p->u.thru.flags & THRU_AUTOQUIT))
+ return;
+ if (LIST_EMPTY(&p->obuflist) || LIST_EMPTY(&p->ibuflist))
+ aproc_del(p);
}
void