Write MIDI data from the sequencer to the device in a more sane way.
This commit is contained in:
parent
2da237ca1f
commit
4e7c07c2b4
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: midi.c,v 1.4 1998/08/17 21:16:11 augustss Exp $ */
|
/* $NetBSD: midi.c,v 1.5 1998/08/24 17:59:25 augustss Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||||
@ -582,6 +582,45 @@ midiwrite(dev, uio, ioflag)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This write routine is only called from sequencer code and expect
|
||||||
|
* a write that is smaller than the MIDI buffer.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
midi_writebytes(unit, buf, cc)
|
||||||
|
int unit;
|
||||||
|
u_char *buf;
|
||||||
|
int cc;
|
||||||
|
{
|
||||||
|
struct midi_softc *sc = midi_cd.cd_devs[unit];
|
||||||
|
struct midi_buffer *mb = &sc->outbuf;
|
||||||
|
int n, s;
|
||||||
|
|
||||||
|
DPRINTFN(2, ("midi_writebytes: %p, unit=%d, cc=%d\n", sc, unit, cc));
|
||||||
|
|
||||||
|
s = splaudio();
|
||||||
|
if (mb->used + cc >= mb->usedhigh) {
|
||||||
|
splx(s);
|
||||||
|
return (EWOULDBLOCK);
|
||||||
|
}
|
||||||
|
n = mb->end - mb->inp;
|
||||||
|
if (cc < n)
|
||||||
|
n = cc;
|
||||||
|
memcpy(mb->inp, buf, cc);
|
||||||
|
mb->inp += n;
|
||||||
|
if (mb->inp >= mb->end) {
|
||||||
|
mb->inp = mb->start;
|
||||||
|
cc -= n;
|
||||||
|
if (cc > 0) {
|
||||||
|
memcpy(mb->inp, buf + n, cc);
|
||||||
|
mb->inp += cc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mb->used += cc;
|
||||||
|
splx(s);
|
||||||
|
return (midi_start_output(sc, 0));
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
midiioctl(dev, cmd, addr, flag, p)
|
midiioctl(dev, cmd, addr, flag, p)
|
||||||
dev_t dev;
|
dev_t dev;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: midi_if.h,v 1.1 1998/08/17 21:16:12 augustss Exp $ */
|
/* $NetBSD: midi_if.h,v 1.2 1998/08/24 17:59:26 augustss Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||||
@ -63,5 +63,6 @@ void midi_attach_mi __P((struct midi_hw_if *, void *, struct device *));
|
|||||||
|
|
||||||
int midi_unit_count __P((void));
|
int midi_unit_count __P((void));
|
||||||
void midi_getinfo __P((dev_t, struct midi_info *));
|
void midi_getinfo __P((dev_t, struct midi_info *));
|
||||||
|
int midi_writebytes __P((int, u_char *, int));
|
||||||
|
|
||||||
#endif /* _SYS_DEV_MIDI_IF_H_ */
|
#endif /* _SYS_DEV_MIDI_IF_H_ */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: sequencer.c,v 1.9 1998/08/20 10:59:09 augustss Exp $ */
|
/* $NetBSD: sequencer.c,v 1.10 1998/08/24 17:59:27 augustss Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||||
@ -1133,28 +1133,15 @@ midiseq_out(md, buf, cc, chk)
|
|||||||
u_int cc;
|
u_int cc;
|
||||||
int chk;
|
int chk;
|
||||||
{
|
{
|
||||||
struct uio uio;
|
|
||||||
struct iovec iovec;
|
|
||||||
|
|
||||||
DPRINTFN(5, ("midiseq_out: m=%p, unit=%d, buf[0]=0x%02x, cc=%d\n",
|
DPRINTFN(5, ("midiseq_out: m=%p, unit=%d, buf[0]=0x%02x, cc=%d\n",
|
||||||
md->msc, md->unit, buf[0], cc));
|
md->msc, md->unit, buf[0], cc));
|
||||||
#if 1
|
|
||||||
/* The MIDI "status" byte does not have to be repeated. */
|
/* The MIDI "status" byte does not have to be repeated. */
|
||||||
if (chk && md->last_cmd == buf[0])
|
if (chk && md->last_cmd == buf[0])
|
||||||
buf++, cc--;
|
buf++, cc--;
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
md->last_cmd = buf[0];
|
md->last_cmd = buf[0];
|
||||||
iovec.iov_base = (char *)buf;
|
return midi_writebytes(md->unit, buf, cc);
|
||||||
iovec.iov_len = cc;
|
|
||||||
uio.uio_iov = &iovec;
|
|
||||||
uio.uio_iovcnt = 1;
|
|
||||||
uio.uio_offset = 0;
|
|
||||||
uio.uio_resid = cc;
|
|
||||||
uio.uio_segflg = UIO_SYSSPACE;
|
|
||||||
uio.uio_rw = UIO_WRITE;
|
|
||||||
uio.uio_procp = 0; /* process not needed for UIO_SYSSPACE */
|
|
||||||
return midiwrite(makedev(0, md->unit), &uio, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -1379,10 +1366,10 @@ midiclose(dev, flags, ifmt, p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
midiwrite(dev, uio, ioflag)
|
midi_writebytes(unit, buf, cc)
|
||||||
dev_t dev;
|
int unit;
|
||||||
struct uio *uio;
|
u_char *buf;
|
||||||
int ioflag;
|
int cc;
|
||||||
{
|
{
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user