summaryrefslogtreecommitdiff
path: root/usr.bin/aucat
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2010-06-04 07:07:34 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2010-06-04 07:07:34 +0000
commite1efc32c5109f8b8660ab489edce65a5e670df3a (patch)
tree3791cb6018c0ce60e29789986d18a0c5af665e0a /usr.bin/aucat
parentc709908b2fffc550f82c645b98bd9416e84e6c95 (diff)
when attaching files to play or record to the device, check that
the device supports play or record modes respectively. spotted by jakemsr
Diffstat (limited to 'usr.bin/aucat')
-rw-r--r--usr.bin/aucat/wav.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/usr.bin/aucat/wav.c b/usr.bin/aucat/wav.c
index fa1dc4e99d6..cb28bb290a4 100644
--- a/usr.bin/aucat/wav.c
+++ b/usr.bin/aucat/wav.c
@@ -692,6 +692,14 @@ wav_new_in(struct fileops *ops,
close(fd);
return NULL;
}
+ if (!(dev->mode & MODE_PLAY)) {
+#ifdef DEBUG
+ dbg_puts(name);
+ dbg_puts(": device can't play\n");
+#endif
+ close(fd);
+ dev_unref(dev);
+ }
f->dev = dev;
if (hdr == HDR_WAV) {
if (!wav_readhdr(f->pipe.fd, par, &f->startpos, &f->rbytes, &f->map)) {
@@ -772,6 +780,14 @@ wav_new_out(struct fileops *ops,
close(fd);
return NULL;
}
+ if (!(dev->mode & MODE_RECMASK)) {
+#ifdef DEBUG
+ dbg_puts(name);
+ dbg_puts(": device can't record\n");
+#endif
+ close(fd);
+ dev_unref(dev);
+ }
f->dev = dev;
if (hdr == HDR_WAV) {
par->le = 1;