summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2019-08-29 07:35:25 +0000
committerratchov <ratchov@openbsd.org>2019-08-29 07:35:25 +0000
commitfa6c3c1f2812fcab005041a380abb3f9b79a2d35 (patch)
treedeb83b320d2382837e5802ac5446c81c46183523
parentComment out the registration of smtp-out events. (diff)
downloadwireguard-openbsd-fa6c3c1f2812fcab005041a380abb3f9b79a2d35.tar.xz
wireguard-openbsd-fa6c3c1f2812fcab005041a380abb3f9b79a2d35.zip
Split dev_open() in two parts.
The first part resets audio parameters to the prefered ones, the second part opens the device and allocates the audio buffers. No behavior change.
-rw-r--r--usr.bin/sndiod/dev.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c
index c142228b447..5545e13b717 100644
--- a/usr.bin/sndiod/dev.c
+++ b/usr.bin/sndiod/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.56 2019/08/29 07:10:27 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.57 2019/08/29 07:35:25 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -57,6 +57,7 @@ int dev_getpos(struct dev *);
struct dev *dev_new(char *, struct aparams *, unsigned int, unsigned int,
unsigned int, unsigned int, unsigned int, unsigned int);
void dev_adjpar(struct dev *, int, int, int);
+int dev_open_do(struct dev *);
int dev_open(struct dev *);
void dev_exitall(struct dev *);
void dev_close(struct dev *);
@@ -1029,24 +1030,11 @@ dev_adjpar(struct dev *d, int mode,
* monitor, midi control, and any necessary conversions.
*/
int
-dev_open(struct dev *d)
+dev_open_do(struct dev *d)
{
- d->mode = d->reqmode;
- d->round = d->reqround;
- d->bufsz = d->reqbufsz;
- d->rate = d->reqrate;
- d->pchan = d->reqpchan;
- d->rchan = d->reqrchan;
- d->par = d->reqpar;
- if (d->pchan == 0)
- d->pchan = 2;
- if (d->rchan == 0)
- d->rchan = 2;
if (!dev_sio_open(d)) {
if (log_level >= 1) {
dev_log(d);
- log_puts(": ");
- log_puts(d->path);
log_puts(": failed to open audio device\n");
}
return 0;
@@ -1109,6 +1097,28 @@ dev_open(struct dev *d)
}
/*
+ * Reset parameters and open the device.
+ */
+int
+dev_open(struct dev *d)
+{
+ d->mode = d->reqmode;
+ d->round = d->reqround;
+ d->bufsz = d->reqbufsz;
+ d->rate = d->reqrate;
+ d->pchan = d->reqpchan;
+ d->rchan = d->reqrchan;
+ d->par = d->reqpar;
+ if (d->pchan == 0)
+ d->pchan = 2;
+ if (d->rchan == 0)
+ d->rchan = 2;
+ if (!dev_open_do(d))
+ return 0;
+ return 1;
+}
+
+/*
* Force all slots to exit
*/
void