From 526f2d2b92d86e5b2ed6369cdefcc9cfabac497d Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Tue, 4 Sep 2012 16:54:45 +0200 Subject: [PATCH] upon connection copy the maxweight parameter from the opt structure --- sndiod/dev.c | 12 ++++-------- sndiod/dev.h | 5 +++-- sndiod/sock.c | 2 ++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/sndiod/dev.c b/sndiod/dev.c index bb3d521..c8dcc12 100644 --- a/sndiod/dev.c +++ b/sndiod/dev.c @@ -865,13 +865,13 @@ void dev_onmove(struct dev *d, int delta) { long long pos; - struct slot *s; + struct slot *s, *snext; /* - * XXX: - what about the start signal - * - can s->ops->onmove() reorder the list? + * s->ops->onmove() may remove the slot */ - for (s = d->slot_list; s != NULL; s = s->next) { + for (s = d->slot_list; s != NULL; s = snext) { + snext = s->next; pos = (long long)delta * s->round + s->delta_rem; s->delta_rem = pos % d->round; s->delta += pos / (int)d->round; @@ -1592,8 +1592,6 @@ slot_setvol(struct slot *s, unsigned int vol) if (s->ops == NULL) return; s->mix.vol = MIDI_TO_ADATA(s->vol); - dev_mix_setmaster(s->dev); - dev_midi_vol(s->dev, s); } void @@ -1812,8 +1810,6 @@ slot_start(struct slot *s) abuf_init(&s->sub.buf, bufsz, s->par.bps * (s->sub.slot_cmax - s->sub.slot_cmin + 1)); } - /* XXX: maxweight should be set by the socket layer */ - s->mix.maxweight = MIDI_TO_ADATA(MIDI_MAXCTL); s->mix.weight = MIDI_TO_ADATA(MIDI_MAXCTL); #ifdef DEBUG if (log_level >= 3) { diff --git a/sndiod/dev.h b/sndiod/dev.h index 99cd6a1..83d2bae 100644 --- a/sndiod/dev.h +++ b/sndiod/dev.h @@ -94,7 +94,7 @@ struct slot { char name[SLOT_NAMEMAX]; /* name matching [a-z]+ */ unsigned int unit; /* instance of name */ unsigned int serial; /* global unique number */ - unsigned int vol; /* saved midi volume */ + unsigned int vol; /* current (midi) volume */ unsigned int tstate; /* mmc state */ unsigned int midichan; /* for volume messages */ }; @@ -208,12 +208,13 @@ void dev_onmove(struct dev *, int); void dev_cycle(struct dev *); /* - * midi call-backs + * midi & midi call-backs */ void dev_mmcstart(struct dev *); void dev_mmcstop(struct dev *); void dev_mmcloc(struct dev *, unsigned int); void dev_master(struct dev *, unsigned int); +void dev_midi_vol(struct dev *, struct slot *); /* * sio_open(3) like interface for clients diff --git a/sndiod/sock.c b/sndiod/sock.c index 5c52f3a..6df501e 100644 --- a/sndiod/sock.c +++ b/sndiod/sock.c @@ -933,6 +933,7 @@ sock_hello(struct sock *f) s->xrun = XRUN_IGNORE; s->tstate = MMC_OFF; } + s->mix.maxweight = f->opt->maxweight; s->dup = f->opt->dup; /* XXX: must convert to slot rate */ f->pstate = SOCK_INIT; @@ -1212,6 +1213,7 @@ sock_execmsg(struct sock *f) f->rtodo = sizeof(struct amsg); f->rstate = SOCK_RMSG; f->lastvol = ctl; /* dont trigger feedback message */ + dev_midi_vol(s->dev, s); slot_setvol(s, ctl); break; case AMSG_AUTH: