summaryrefslogtreecommitdiff
path: root/usr.bin/sndiod/dev.c
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2021-01-29 10:55:20 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2021-01-29 10:55:20 +0000
commitebee9ba15ca054b636c68ec99cc04e2c8c8005b2 (patch)
tree5498c7e3b4a4e20ce49cf85c65db37f14adb0153 /usr.bin/sndiod/dev.c
parentb7efc18a83d715d559d725a45a95538ce2534343 (diff)
Move the control client state out of the device structure
No behavior change. Later this will ease changing the controlled device by "just" swapping pointers.
Diffstat (limited to 'usr.bin/sndiod/dev.c')
-rw-r--r--usr.bin/sndiod/dev.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c
index a221558f512..83e577f7fa1 100644
--- a/usr.bin/sndiod/dev.c
+++ b/usr.bin/sndiod/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.84 2021/01/29 10:51:24 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.85 2021/01/29 10:55:19 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -109,6 +109,7 @@ struct slotops zomb_slotops = {
struct dev *dev_list = NULL;
unsigned int dev_sndnum = 0;
+struct ctlslot ctlslot_array[DEV_NCTLSLOT];
struct slot slot_array[DEV_NSLOT];
unsigned int slot_serial; /* for slot allocation */
@@ -1033,7 +1034,6 @@ dev_new(char *path, struct aparams *par,
unsigned int rate, unsigned int hold, unsigned int autovol)
{
struct dev *d;
- unsigned int i;
if (dev_sndnum == DEV_NMAX) {
if (log_level >= 1)
@@ -1066,12 +1066,6 @@ dev_new(char *path, struct aparams *par,
d->autovol = autovol;
d->refcnt = 0;
d->pstate = DEV_CFG;
- for (i = 0; i < DEV_NCTLSLOT; i++) {
- d->ctlslot[i].ops = NULL;
- d->ctlslot[i].dev = d;
- d->ctlslot[i].mask = 0;
- d->ctlslot[i].mode = 0;
- }
d->slot_list = NULL;
d->master = MIDI_MAXCTL;
d->mtc.origin = 0;
@@ -1285,7 +1279,9 @@ dev_abort(struct dev *d)
}
d->slot_list = NULL;
- for (c = d->ctlslot, i = DEV_NCTLSLOT; i > 0; i--, c++) {
+ for (c = ctlslot_array, i = DEV_NCTLSLOT; i > 0; i--, c++) {
+ if (c->dev != d)
+ continue;
if (c->ops)
c->ops->exit(c->arg);
c->ops = NULL;
@@ -2320,7 +2316,7 @@ ctlslot_new(struct dev *d, struct ctlops *ops, void *arg)
for (;;) {
if (i == DEV_NCTLSLOT)
return NULL;
- s = d->ctlslot + i;
+ s = ctlslot_array + i;
if (s->ops == NULL)
break;
i++;
@@ -2425,7 +2421,7 @@ dev_addctl(struct dev *d, char *gstr, int type, int addr,
c->refs_mask = 0;
for (i = 0; i < DEV_NCTLSLOT; i++) {
c->refs_mask |= CTL_DEVMASK;
- if (d->ctlslot[i].ops != NULL)
+ if (ctlslot_array[i].ops != NULL)
c->refs_mask |= 1 << i;
}
for (pc = &d->ctl_list; *pc != NULL; pc = &(*pc)->next)
@@ -2511,8 +2507,8 @@ dev_ctlsync(struct dev *d)
"output", -1, "level", NULL, -1, 127, d->master);
}
- for (s = d->ctlslot, i = DEV_NCTLSLOT; i > 0; i--, s++) {
- if (s->ops)
+ for (s = ctlslot_array, i = DEV_NCTLSLOT; i > 0; i--, s++) {
+ if (s->dev == d && s->ops)
s->ops->sync(s->arg);
}
}