diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2018-06-26 07:44:36 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2018-06-26 07:44:36 +0000 |
commit | 7dec49586050077bae184abd77b1d30b58d5d219 (patch) | |
tree | dc4ea2859d50cc7d369a8af3694110c08a2583ba | |
parent | bc67eecd064c7edd117a3f2ec9917c2d911d5c34 (diff) |
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.
-rw-r--r-- | usr.bin/sndiod/dev.c | 42 | ||||
-rw-r--r-- | usr.bin/sndiod/dev.h | 4 |
2 files changed, 9 insertions, 37 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c index 0cf0fe686d5..a22ebecb14f 100644 --- a/usr.bin/sndiod/dev.c +++ b/usr.bin/sndiod/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.45 2018/06/26 07:43:19 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.46 2018/06/26 07:44:35 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -131,9 +131,6 @@ slot_log(struct slot *s) static char *pstates[] = { "ini", "sta", "rdy", "run", "stp", "mid" }; - static char *tstates[] = { - "off", "sta", "run", "stp" - }; #endif log_puts(s->name); log_putu(s->unit); @@ -144,8 +141,6 @@ slot_log(struct slot *s) if (s->ops) { log_puts(",pst="); log_puts(pstates[s->pstate]); - log_puts(",mmc="); - log_puts(tstates[s->tstate]); } } #endif @@ -999,7 +994,6 @@ dev_new(char *path, struct aparams *par, d->slot[i].unit = i; d->slot[i].ops = NULL; d->slot[i].vol = MIDI_MAXCTL; - d->slot[i].tstate = MMC_OFF; d->slot[i].serial = d->serial++; strlcpy(d->slot[i].name, "prog", SLOT_NAMEMAX); } @@ -1314,9 +1308,9 @@ dev_sync_attach(struct dev *d) } for (i = 0; i < DEV_NSLOT; i++) { s = d->slot + i; - if (!s->ops || s->tstate == MMC_OFF) + if (!s->ops || !s->opt->mmc) continue; - if (s->tstate != MMC_START || s->pstate != SLOT_READY) { + if (s->pstate != SLOT_READY) { #ifdef DEBUG if (log_level >= 3) { slot_log(s); @@ -1330,18 +1324,9 @@ dev_sync_attach(struct dev *d) return; for (i = 0; i < DEV_NSLOT; i++) { s = d->slot + i; - if (!s->ops) + if (!s->ops || !s->opt->mmc) continue; - if (s->tstate == MMC_START) { -#ifdef DEBUG - if (log_level >= 3) { - slot_log(s); - log_puts(": started\n"); - } -#endif - s->tstate = MMC_RUN; - slot_attach(s); - } + slot_attach(s); } d->tstate = MMC_RUN; dev_midi_full(d); @@ -1671,13 +1656,7 @@ found: s->mix.nch = s->opt->pmax - s->opt->pmin + 1; if (s->mode & MODE_RECMASK) s->sub.nch = s->opt->rmax - s->opt->rmin + 1; - if (s->opt->mmc) { - s->xrun = XRUN_SYNC; - s->tstate = MMC_STOP; - } else { - s->xrun = XRUN_IGNORE; - s->tstate = MMC_OFF; - } + s->xrun = s->opt->mmc ? XRUN_SYNC : XRUN_IGNORE; s->appbufsz = d->bufsz; s->round = d->round; s->rate = d->rate; @@ -1820,12 +1799,10 @@ slot_ready(struct slot *s) */ if (s->dev->pstate == DEV_CFG) return; - if (s->tstate == MMC_OFF) + if (!s->opt->mmc) slot_attach(s); - else { - s->tstate = MMC_START; + else dev_sync_attach(s->dev); - } } /* @@ -1922,9 +1899,6 @@ slot_stop(struct slot *s) slot_ready(s); } - if (s->tstate != MMC_OFF) - s->tstate = MMC_STOP; - if (s->pstate == SLOT_RUN) { if (s->mode & MODE_PLAY) { /* diff --git a/usr.bin/sndiod/dev.h b/usr.bin/sndiod/dev.h index 685eb2928fb..00753906b74 100644 --- a/usr.bin/sndiod/dev.h +++ b/usr.bin/sndiod/dev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.h,v 1.19 2018/06/26 07:36:27 ratchov Exp $ */ +/* $OpenBSD: dev.h,v 1.20 2018/06/26 07:44:35 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -89,7 +89,6 @@ struct slot { unsigned int unit; /* instance of name */ unsigned int serial; /* global unique number */ unsigned int vol; /* current (midi) volume */ - unsigned int tstate; /* mmc state */ }; struct opt { @@ -190,7 +189,6 @@ struct dev { /* * MIDI machine control (MMC) */ -#define MMC_OFF 0 /* ignore MMC messages */ #define MMC_STOP 1 /* stopped, can't start */ #define MMC_START 2 /* attempting to start */ #define MMC_RUN 3 /* started */ |