diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2008-12-29 17:59:09 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2008-12-29 17:59:09 +0000 |
commit | 6c4053031259f10fa0060a0e39acee631e2ec026 (patch) | |
tree | 66ba65b8cf26b209e036989b3a86d0acfa0675be /usr.bin/aucat/aucat.c | |
parent | 82b6a7781a258d770c4104783c04017b0acc5eeb (diff) |
make the code "more correct": add reference counters to aproc
structures so we can keep a pointer to the device. Beside some
simplifications, this allows to easily handle the situation
where the audio device desappears. No change in the behaviour.
Diffstat (limited to 'usr.bin/aucat/aucat.c')
-rw-r--r-- | usr.bin/aucat/aucat.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c index 7c45e3bb4c4..4cabe127593 100644 --- a/usr.bin/aucat/aucat.c +++ b/usr.bin/aucat/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.49 2008/12/26 13:29:31 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.50 2008/12/29 17:59:08 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -527,14 +527,15 @@ main(int argc, char **argv) */ for (;;) { if (quit_flag) { - if (l_flag) - filelist_unlisten(); break; } - if (!file_poll()) { - fprintf(stderr, "Terminated, device disappeared?\n"); - exit(1); + if ((!dev_rec || dev_rec->u.io.file == NULL) && + (!dev_play || dev_play->u.io.file == NULL)) { + fprintf(stderr, "device desappeared, terminating\n"); + break; } + if (!file_poll()) + break; if ((!dev_mix || dev_mix->u.mix.idle > 2 * dev_bufsz) && (!dev_sub || dev_sub->u.sub.idle > 2 * dev_bufsz)) { if (!l_flag) @@ -555,6 +556,8 @@ main(int argc, char **argv) } } } + if (l_flag) + filelist_unlisten(); if (suspend) { DPRINTF("resuming to drain\n"); suspend = 0; |