upon connection copy the maxweight parameter from the opt structure

This commit is contained in:
Alexandre Ratchov 2012-09-04 16:54:45 +02:00
parent 41b3188fd4
commit 526f2d2b92
3 changed files with 9 additions and 10 deletions

View File

@ -865,13 +865,13 @@ void
dev_onmove(struct dev *d, int delta) dev_onmove(struct dev *d, int delta)
{ {
long long pos; long long pos;
struct slot *s; struct slot *s, *snext;
/* /*
* XXX: - what about the start signal * s->ops->onmove() may remove the slot
* - can s->ops->onmove() reorder the list?
*/ */
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; pos = (long long)delta * s->round + s->delta_rem;
s->delta_rem = pos % d->round; s->delta_rem = pos % d->round;
s->delta += pos / (int)d->round; s->delta += pos / (int)d->round;
@ -1592,8 +1592,6 @@ slot_setvol(struct slot *s, unsigned int vol)
if (s->ops == NULL) if (s->ops == NULL)
return; return;
s->mix.vol = MIDI_TO_ADATA(s->vol); s->mix.vol = MIDI_TO_ADATA(s->vol);
dev_mix_setmaster(s->dev);
dev_midi_vol(s->dev, s);
} }
void void
@ -1812,8 +1810,6 @@ slot_start(struct slot *s)
abuf_init(&s->sub.buf, bufsz, abuf_init(&s->sub.buf, bufsz,
s->par.bps * (s->sub.slot_cmax - s->sub.slot_cmin + 1)); 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); s->mix.weight = MIDI_TO_ADATA(MIDI_MAXCTL);
#ifdef DEBUG #ifdef DEBUG
if (log_level >= 3) { if (log_level >= 3) {

View File

@ -94,7 +94,7 @@ struct slot {
char name[SLOT_NAMEMAX]; /* name matching [a-z]+ */ char name[SLOT_NAMEMAX]; /* name matching [a-z]+ */
unsigned int unit; /* instance of name */ unsigned int unit; /* instance of name */
unsigned int serial; /* global unique number */ 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 tstate; /* mmc state */
unsigned int midichan; /* for volume messages */ unsigned int midichan; /* for volume messages */
}; };
@ -208,12 +208,13 @@ void dev_onmove(struct dev *, int);
void dev_cycle(struct dev *); void dev_cycle(struct dev *);
/* /*
* midi call-backs * midi & midi call-backs
*/ */
void dev_mmcstart(struct dev *); void dev_mmcstart(struct dev *);
void dev_mmcstop(struct dev *); void dev_mmcstop(struct dev *);
void dev_mmcloc(struct dev *, unsigned int); void dev_mmcloc(struct dev *, unsigned int);
void dev_master(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 * sio_open(3) like interface for clients

View File

@ -933,6 +933,7 @@ sock_hello(struct sock *f)
s->xrun = XRUN_IGNORE; s->xrun = XRUN_IGNORE;
s->tstate = MMC_OFF; s->tstate = MMC_OFF;
} }
s->mix.maxweight = f->opt->maxweight;
s->dup = f->opt->dup; s->dup = f->opt->dup;
/* XXX: must convert to slot rate */ /* XXX: must convert to slot rate */
f->pstate = SOCK_INIT; f->pstate = SOCK_INIT;
@ -1212,6 +1213,7 @@ sock_execmsg(struct sock *f)
f->rtodo = sizeof(struct amsg); f->rtodo = sizeof(struct amsg);
f->rstate = SOCK_RMSG; f->rstate = SOCK_RMSG;
f->lastvol = ctl; /* dont trigger feedback message */ f->lastvol = ctl; /* dont trigger feedback message */
dev_midi_vol(s->dev, s);
slot_setvol(s, ctl); slot_setvol(s, ctl);
break; break;
case AMSG_AUTH: case AMSG_AUTH: