diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2020-03-08 14:52:21 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2020-03-08 14:52:21 +0000 |
commit | 95cc480f4e7a9f6397099466adfd5e8861c09c7f (patch) | |
tree | 30dd376ce7a5a5d5912272aef07dbd5989fbca66 /usr.bin/sndiod | |
parent | d23afde3cbfe041c3fee0dbc74495c005932d75c (diff) |
Don't forget to notify clients when controls list is ready.
This is needed because when devices are swapped, clients need to know
when to rebuild their user interface.
Diffstat (limited to 'usr.bin/sndiod')
-rw-r--r-- | usr.bin/sndiod/dev.c | 14 | ||||
-rw-r--r-- | usr.bin/sndiod/dev.h | 4 | ||||
-rw-r--r-- | usr.bin/sndiod/dev_sioctl.c | 7 | ||||
-rw-r--r-- | usr.bin/sndiod/sock.c | 19 |
4 files changed, 36 insertions, 8 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c index 6a5ed2c6165..0fbfb911e6b 100644 --- a/usr.bin/sndiod/dev.c +++ b/usr.bin/sndiod/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.64 2020/02/26 13:53:58 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.65 2020/03/08 14:52:20 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -2333,6 +2333,18 @@ dev_rmctl(struct dev *d, int addr) xfree(c); } +void +dev_ctlsync(struct dev *d) +{ + struct ctlslot *s; + int i; + + for (s = d->ctlslot, i = DEV_NCTLSLOT; i > 0; i--, s++) { + if (s->ops) + s->ops->sync(s->arg); + } +} + int dev_setctl(struct dev *d, int addr, int val) { diff --git a/usr.bin/sndiod/dev.h b/usr.bin/sndiod/dev.h index d095fb9f632..d74476ba6dc 100644 --- a/usr.bin/sndiod/dev.h +++ b/usr.bin/sndiod/dev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.h,v 1.23 2020/02/26 13:53:58 ratchov Exp $ */ +/* $OpenBSD: dev.h,v 1.24 2020/03/08 14:52:20 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -43,6 +43,7 @@ struct slotops struct ctlops { void (*exit)(void *); /* delete client */ + void (*sync)(void *); /* description ready */ }; struct slot { @@ -313,5 +314,6 @@ struct ctl *dev_addctl(struct dev *, char *, int, int, char *, int, char *, char *, int, int, int); void dev_rmctl(struct dev *, int); int dev_makeunit(struct dev *, char *); +void dev_ctlsync(struct dev *); #endif /* !defined(DEV_H) */ diff --git a/usr.bin/sndiod/dev_sioctl.c b/usr.bin/sndiod/dev_sioctl.c index 4270135efd0..e0c56db97cb 100644 --- a/usr.bin/sndiod/dev_sioctl.c +++ b/usr.bin/sndiod/dev_sioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_sioctl.c,v 1.1 2020/02/26 13:53:58 ratchov Exp $ */ +/* $OpenBSD: dev_sioctl.c,v 1.2 2020/03/08 14:52:20 ratchov Exp $ */ /* * Copyright (c) 2014-2020 Alexandre Ratchov <alex@caoua.org> * @@ -55,8 +55,11 @@ dev_sioctl_ondesc(void *arg, struct sioctl_desc *desc, int val) struct dev *d = arg; int addr; - if (desc == NULL) + if (desc == NULL) { + dev_ctlsync(d); return; + } + addr = CTLADDR_END + desc->addr; dev_rmctl(d, addr); diff --git a/usr.bin/sndiod/sock.c b/usr.bin/sndiod/sock.c index be192acb830..b4a3abe92d2 100644 --- a/usr.bin/sndiod/sock.c +++ b/usr.bin/sndiod/sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sock.c,v 1.32 2020/02/26 13:53:58 ratchov Exp $ */ +/* $OpenBSD: sock.c,v 1.33 2020/03/08 14:52:20 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -44,6 +44,7 @@ void sock_slot_onvol(void *); void sock_midi_imsg(void *, unsigned char *, int); void sock_midi_omsg(void *, unsigned char *, int); void sock_midi_fill(void *, int); +void sock_ctl_sync(void *); struct sock *sock_new(int); void sock_exit(void *); int sock_fdwrite(struct sock *, void *, int); @@ -91,7 +92,8 @@ struct midiops sock_midiops = { }; struct ctlops sock_ctlops = { - sock_exit + sock_exit, + sock_ctl_sync }; struct sock *sock_list = NULL; @@ -281,6 +283,15 @@ sock_midi_fill(void *arg, int count) f->fillpending += count; } +void +sock_ctl_sync(void *arg) +{ + struct sock *f = arg; + + if (f->ctlops & SOCK_CTLDESC) + f->ctlsyncpending = 1; +} + struct sock * sock_new(int fd) { @@ -1236,9 +1247,9 @@ sock_execmsg(struct sock *f) c->desc_mask |= ctl; c = c->next; } + f->ctlops |= SOCK_CTLDESC; + f->ctlsyncpending = 1; } - f->ctlops |= SOCK_CTLDESC; - f->ctlsyncpending = 1; } else f->ctlops &= ~SOCK_CTLDESC; if (m->u.ctlsub.val) { |