-/* $OpenBSD: midi.c,v 1.37 2015/05/12 18:32:49 ratchov Exp $ */
+/* $OpenBSD: midi.c,v 1.38 2015/05/12 18:39:30 ratchov Exp $ */
/*
* Copyright (c) 2003, 2004 Alexandre Ratchov
struct midi_softc *sc = (struct midi_softc *)addr;
struct midi_buffer *mb = &sc->inbuf;
- if (sc->isdying || !sc->isopen || !(sc->flags & FREAD))
+ if (sc->isdying || !(sc->flags & FREAD))
return;
if (MIDIBUF_ISFULL(mb))
struct midi_buffer *mb;
MUTEX_ASSERT_LOCKED(&audio_lock);
- if (sc->isopen && !sc->isdying) {
+ if (!(sc->flags & FWRITE) && !sc->isdying) {
mb = &sc->outbuf;
if (mb->used > 0) {
#ifdef MIDI_DEBUG
return ENXIO;
if (sc->isdying)
return EIO;
- if (sc->isopen)
+ if (sc->flags)
return EBUSY;
MIDIBUF_INIT(&sc->inbuf);
sc->rchan = sc->wchan = 0;
sc->async = 0;
sc->flags = flags;
-
err = sc->hw_if->open(sc->hw_hdl, flags, midi_iintr, midi_ointr, sc);
- if (err)
+ if (err) {
+ sc->flags = 0;
return err;
- sc->isopen = 1;
+ }
return 0;
}
*/
tsleep(&sc->wchan, PWAIT, "mid_cl", hz * MIDI_MAXWRITE / MIDI_RATE);
sc->hw_if->close(sc->hw_hdl);
- sc->isopen = 0;
+ sc->flags = 0;
return 0;
}
sc->isdying = 0;
sc->hw_if->getinfo(sc->hw_hdl, &mi);
sc->props = mi.props;
- sc->isopen = 0;
+ sc->flags = 0;
timeout_set(&sc->timeo, midi_timeout, sc);
printf(": <%s>\n", mi.name);
}
-/* $OpenBSD: midivar.h,v 1.7 2013/03/15 09:10:52 ratchov Exp $ */
+/* $OpenBSD: midivar.h,v 1.8 2015/05/12 18:39:30 ratchov Exp $ */
/*
* Copyright (c) 2003, 2004 Alexandre Ratchov
struct device dev;
struct midi_hw_if *hw_if;
void *hw_hdl;
- int isopen;
int isbusy; /* concerns only the output */
int isdying;
int flags; /* open flags */