summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2009-10-10 09:54:05 +0000
committerratchov <ratchov@openbsd.org>2009-10-10 09:54:05 +0000
commit77eb785ff9c286ee99ba052ea2282f3e7d7503f4 (patch)
tree87e8cb70639ee05c84d828011dcd5dfcfe5c5daf
parentSupport for individual session idle time locking. May be enabled by turning off (diff)
downloadwireguard-openbsd-77eb785ff9c286ee99ba052ea2282f3e7d7503f4.tar.xz
wireguard-openbsd-77eb785ff9c286ee99ba052ea2282f3e7d7503f4.zip
We don't need independent file reader and writer anymore. So,
destroy reader when writer terminates and destroy writer when reader terminates. This simplifies a lot the way we drain audio devices and will help simplifying other parts.
-rw-r--r--usr.bin/aucat/aproc.c14
-rw-r--r--usr.bin/aucat/dev.c97
2 files changed, 62 insertions, 49 deletions
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c
index f9274299f6c..44e5529b163 100644
--- a/usr.bin/aucat/aproc.c
+++ b/usr.bin/aucat/aproc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aproc.c,v 1.36 2009/10/09 16:49:48 ratchov Exp $ */
+/* $OpenBSD: aproc.c,v 1.37 2009/10/10 09:54:05 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -201,8 +201,10 @@ rpipe_done(struct aproc *p)
if (f == NULL)
return;
- f->rproc = NULL;
- if (f->wproc == NULL)
+ if (f->wproc) {
+ f->rproc = NULL;
+ aproc_del(f->wproc);
+ } else
file_del(f);
p->u.io.file = NULL;
}
@@ -250,8 +252,10 @@ wpipe_done(struct aproc *p)
if (f == NULL)
return;
- f->wproc = NULL;
- if (f->rproc == NULL)
+ if (f->rproc) {
+ f->wproc = NULL;
+ aproc_del(f->rproc);
+ } else
file_del(f);
p->u.io.file = NULL;
}
diff --git a/usr.bin/aucat/dev.c b/usr.bin/aucat/dev.c
index 133014e7b47..b34886dbca5 100644
--- a/usr.bin/aucat/dev.c
+++ b/usr.bin/aucat/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.31 2009/10/09 16:49:48 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.32 2009/10/10 09:54:06 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -289,68 +289,77 @@ dev_done(void)
{
struct file *f;
- dev_midi->refs--;
- aproc_del(dev_midi);
- dev_midi = NULL;
-
+ 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;
+ }
if (dev_mix) {
- dev_mix->refs--;
- dev_mix->u.mix.flags |= MIX_AUTOQUIT;
- dev_mix = NULL;
/*
- * Generate EOF on all inputs (but not the device), and
- * put the mixer in ``autoquit'' state, so once buffers
- * are drained the mixer will terminate and shutdown the
- * write-end of the device.
+ * Put the mixer in ``autoquit'' state and generate
+ * EOF on all inputs connected it. Once buffers are
+ * drained the mixer will terminate and shutdown the
+ * device.
*
* NOTE: since file_eof() can destroy the file and
* reorder the file_list, we have to restart the loop
* after each call to file_eof().
*/
- restart:
+ dev_mix->u.mix.flags |= MIX_AUTOQUIT;
+ restart_mix:
LIST_FOREACH(f, &file_list, entry) {
- if (f->rproc != NULL && f->rproc != dev_rec) {
+ if (f->rproc != NULL &&
+ aproc_depend(dev_mix, f->rproc)) {
file_eof(f);
- goto restart;
+ goto restart_mix;
}
}
-
+ } else if (dev_sub) {
/*
- * Wait for play chain to terminate.
- */
- if (dev_play) {
- while (!LIST_EMPTY(&dev_play->ibuflist)) {
- if (!file_poll())
- break;
+ * Same as above, but since there's no mixer,
+ * we generate EOF on the record-end of the
+ * device.
+ */
+ restart_sub:
+ LIST_FOREACH(f, &file_list, entry) {
+ if (f->rproc != NULL &&
+ aproc_depend(dev_sub, f->rproc)) {
+ file_eof(f);
+ goto restart_sub;
}
- dev_play->refs--;
- aproc_del(dev_play);
- dev_play = NULL;
}
}
+ if (dev_mix) {
+ dev_mix->refs--;
+ if (dev_mix->zomb)
+ aproc_del(dev_mix);
+ dev_mix = NULL;
+ }
+ if (dev_play) {
+ dev_play->refs--;
+ if (dev_play->zomb)
+ aproc_del(dev_play);
+ dev_play = NULL;
+ }
if (dev_sub) {
dev_sub->refs--;
- dev_sub->u.sub.flags |= SUB_AUTOQUIT;
+ if (dev_sub->zomb)
+ aproc_del(dev_sub);
dev_sub = NULL;
- /*
- * Same as above, but for the record chain: generate eof
- * on the read-end of the device and wait record buffers
- * to disappear. We must stop the device first, because
- * play-end will underrun (and xrun correction code will
- * insert silence on the record-end of the device).
- */
- if (dev_rec) {
- dev_stop();
- if (dev_rec->u.io.file)
- file_eof(dev_rec->u.io.file);
- while (!LIST_EMPTY(&dev_rec->obuflist)) {
- if (!file_poll())
- break;
- }
- dev_rec->refs--;
+ }
+ if (dev_rec) {
+ dev_rec->refs--;
+ if (dev_rec->zomb)
aproc_del(dev_rec);
- dev_rec = NULL;
- }
+ dev_rec = NULL;
+ }
+ for (;;) {
+ if (!file_poll())
+ break;
}
}