From 33a599c08e1d6be6abccee59b873302795b62621 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Fri, 28 Aug 2009 06:30:18 +0000 Subject: top device before closing it. It's necessary to ensure that if we are using another instance of aucat as device, the server closes the connection before we open a new one. --- usr.bin/aucat/safile.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'usr.bin') diff --git a/usr.bin/aucat/safile.c b/usr.bin/aucat/safile.c index a8cd4b8dd23..41438d9e240 100644 --- a/usr.bin/aucat/safile.c +++ b/usr.bin/aucat/safile.c @@ -1,4 +1,4 @@ -/* $OpenBSD: safile.c,v 1.14 2009/07/25 10:52:19 ratchov Exp $ */ +/* $OpenBSD: safile.c,v 1.15 2009/08/28 06:30:17 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -34,6 +34,7 @@ struct safile { struct file file; struct sio_hdl *hdl; + int started; #ifdef DEBUG struct timeval itv, otv; #endif @@ -150,6 +151,7 @@ safile_new(struct fileops *ops, char *path, if (f == NULL) goto bad_close; f->hdl = hdl; + f->started = 0; sio_onmove(f->hdl, safile_cb, f); return f; bad_close: @@ -167,6 +169,7 @@ safile_start(struct file *file) file_close(file); return; } + f->started = 1; DPRINTF("safile_start: play/rec started\n"); } @@ -180,6 +183,7 @@ safile_stop(struct file *file) file_close(file); return; } + f->started = 0; DPRINTF("safile_stop: play/rec stopped\n"); } @@ -281,5 +285,9 @@ safile_revents(struct file *file, struct pollfd *pfd) void safile_close(struct file *file) { + struct safile *f = (struct safile *)file; + + if (f->started) + safile_stop(&f->file); return sio_close(((struct safile *)file)->hdl); } -- cgit v1.2.3