mirror of https://github.com/ericonr/sndio.git
sndiod: Remove redundant slot->tstate variable.
It was used to determine whether the slot obeys MMC and is ready to start. The stop->opt->mmc flag indicates if it obeys MMC and the slot->pstate == SLOT_READY indicates if it's ready. So slot->tstate can be safely removed.
This commit is contained in:
parent
84ec0ebd8c
commit
ed64776ceb
40
sndiod/dev.c
40
sndiod/dev.c
|
@ -132,9 +132,6 @@ slot_log(struct slot *s)
|
||||||
static char *pstates[] = {
|
static char *pstates[] = {
|
||||||
"ini", "sta", "rdy", "run", "stp", "mid"
|
"ini", "sta", "rdy", "run", "stp", "mid"
|
||||||
};
|
};
|
||||||
static char *tstates[] = {
|
|
||||||
"off", "sta", "run", "stp"
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
log_puts(s->name);
|
log_puts(s->name);
|
||||||
log_putu(s->unit);
|
log_putu(s->unit);
|
||||||
|
@ -145,8 +142,6 @@ slot_log(struct slot *s)
|
||||||
if (s->ops) {
|
if (s->ops) {
|
||||||
log_puts(",pst=");
|
log_puts(",pst=");
|
||||||
log_puts(pstates[s->pstate]);
|
log_puts(pstates[s->pstate]);
|
||||||
log_puts(",mmc=");
|
|
||||||
log_puts(tstates[s->tstate]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1000,7 +995,6 @@ dev_new(char *path, struct aparams *par,
|
||||||
d->slot[i].unit = i;
|
d->slot[i].unit = i;
|
||||||
d->slot[i].ops = NULL;
|
d->slot[i].ops = NULL;
|
||||||
d->slot[i].vol = MIDI_MAXCTL;
|
d->slot[i].vol = MIDI_MAXCTL;
|
||||||
d->slot[i].tstate = MMC_OFF;
|
|
||||||
d->slot[i].serial = d->serial++;
|
d->slot[i].serial = d->serial++;
|
||||||
strlcpy(d->slot[i].name, "prog", SLOT_NAMEMAX);
|
strlcpy(d->slot[i].name, "prog", SLOT_NAMEMAX);
|
||||||
}
|
}
|
||||||
|
@ -1315,9 +1309,9 @@ dev_sync_attach(struct dev *d)
|
||||||
}
|
}
|
||||||
for (i = 0; i < DEV_NSLOT; i++) {
|
for (i = 0; i < DEV_NSLOT; i++) {
|
||||||
s = d->slot + i;
|
s = d->slot + i;
|
||||||
if (!s->ops || s->tstate == MMC_OFF)
|
if (!s->ops || !s->opt->mmc)
|
||||||
continue;
|
continue;
|
||||||
if (s->tstate != MMC_START || s->pstate != SLOT_READY) {
|
if (s->pstate != SLOT_READY) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (log_level >= 3) {
|
if (log_level >= 3) {
|
||||||
slot_log(s);
|
slot_log(s);
|
||||||
|
@ -1331,18 +1325,9 @@ dev_sync_attach(struct dev *d)
|
||||||
return;
|
return;
|
||||||
for (i = 0; i < DEV_NSLOT; i++) {
|
for (i = 0; i < DEV_NSLOT; i++) {
|
||||||
s = d->slot + i;
|
s = d->slot + i;
|
||||||
if (!s->ops)
|
if (!s->ops || !s->opt->mmc)
|
||||||
continue;
|
continue;
|
||||||
if (s->tstate == MMC_START) {
|
slot_attach(s);
|
||||||
#ifdef DEBUG
|
|
||||||
if (log_level >= 3) {
|
|
||||||
slot_log(s);
|
|
||||||
log_puts(": started\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
s->tstate = MMC_RUN;
|
|
||||||
slot_attach(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
d->tstate = MMC_RUN;
|
d->tstate = MMC_RUN;
|
||||||
dev_midi_full(d);
|
dev_midi_full(d);
|
||||||
|
@ -1672,13 +1657,7 @@ found:
|
||||||
s->mix.nch = s->opt->pmax - s->opt->pmin + 1;
|
s->mix.nch = s->opt->pmax - s->opt->pmin + 1;
|
||||||
if (s->mode & MODE_RECMASK)
|
if (s->mode & MODE_RECMASK)
|
||||||
s->sub.nch = s->opt->rmax - s->opt->rmin + 1;
|
s->sub.nch = s->opt->rmax - s->opt->rmin + 1;
|
||||||
if (s->opt->mmc) {
|
s->xrun = s->opt->mmc ? XRUN_SYNC : XRUN_IGNORE;
|
||||||
s->xrun = XRUN_SYNC;
|
|
||||||
s->tstate = MMC_STOP;
|
|
||||||
} else {
|
|
||||||
s->xrun = XRUN_IGNORE;
|
|
||||||
s->tstate = MMC_OFF;
|
|
||||||
}
|
|
||||||
s->appbufsz = d->bufsz;
|
s->appbufsz = d->bufsz;
|
||||||
s->round = d->round;
|
s->round = d->round;
|
||||||
s->rate = d->rate;
|
s->rate = d->rate;
|
||||||
|
@ -1821,12 +1800,10 @@ slot_ready(struct slot *s)
|
||||||
*/
|
*/
|
||||||
if (s->dev->pstate == DEV_CFG)
|
if (s->dev->pstate == DEV_CFG)
|
||||||
return;
|
return;
|
||||||
if (s->tstate == MMC_OFF)
|
if (!s->opt->mmc)
|
||||||
slot_attach(s);
|
slot_attach(s);
|
||||||
else {
|
else
|
||||||
s->tstate = MMC_START;
|
|
||||||
dev_sync_attach(s->dev);
|
dev_sync_attach(s->dev);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1923,9 +1900,6 @@ slot_stop(struct slot *s)
|
||||||
slot_ready(s);
|
slot_ready(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->tstate != MMC_OFF)
|
|
||||||
s->tstate = MMC_STOP;
|
|
||||||
|
|
||||||
if (s->pstate == SLOT_RUN) {
|
if (s->pstate == SLOT_RUN) {
|
||||||
if (s->mode & MODE_PLAY) {
|
if (s->mode & MODE_PLAY) {
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -89,7 +89,6 @@ struct slot {
|
||||||
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; /* current (midi) volume */
|
unsigned int vol; /* current (midi) volume */
|
||||||
unsigned int tstate; /* mmc state */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct opt {
|
struct opt {
|
||||||
|
@ -190,7 +189,6 @@ struct dev {
|
||||||
/*
|
/*
|
||||||
* MIDI machine control (MMC)
|
* MIDI machine control (MMC)
|
||||||
*/
|
*/
|
||||||
#define MMC_OFF 0 /* ignore MMC messages */
|
|
||||||
#define MMC_STOP 1 /* stopped, can't start */
|
#define MMC_STOP 1 /* stopped, can't start */
|
||||||
#define MMC_START 2 /* attempting to start */
|
#define MMC_START 2 /* attempting to start */
|
||||||
#define MMC_RUN 3 /* started */
|
#define MMC_RUN 3 /* started */
|
||||||
|
|
Loading…
Reference in New Issue