Roger,
Just to make sure we're on the same page, here's what the revised code
would look like with the prepare/unprepare stuff in place
m->hdr->dwBufferLength = m->sysex_byte_count;
/* DEBUG CODE: */
{ int i; int len = m->hdr->dwBufferLength;
/* added */
if (m->hdr->dwFlags & MHDR_PREPARED)
midiOutUnprepareHeader(m->handle.out, m->hdr, sizeof(MIDIHDR));
/* ----- */
char *newmsg = (char *) malloc(len);
for (i = 0; i < len; i++) newmsg[i] = m->hdr->lpData[i];
m->hdr->lpData = newmsg;
/* added */
m->hdr->dwFlags=0;
midiOutPrepareHeader(m->handle.out, m->hdr, sizeof(MIDIHDR));
/* ----- */
}
m->error = midiOutLongMsg(m->handle.out, m->hdr, sizeof(MIDIHDR));
if (m->error) rslt = pmHostError;
-Ben Allison
Roger Dannenberg wrote:
Yes, I call unprepare when buffers are returned, but in most of these
tests, I'm using the buffer for the first time when the failure
occurs. I'm checking that midiOutPrepareHeader sets the dwFlags field
like it's supposed to. (Keep those ideas coming -- there must be
something I haven' thought of. I've asked the Midi Ox developer about
some internal details of their code, and I've checked rtMidi -- which
uses malloc() for every sysex send -- and I'd be interested to see any
other source that successfully sends sysex messages.) -Roger
----- in reply to ------
Roger,
Did you unprepare (midiOutUnprepareHeader) first? If the MIDIHDR that
was
passed in was already prepared, you'll need to do this. The MIDIHDR data
structure stores a bool to indicate whether or not it's already been
prepared. If it's been prepared already, midiOutPrepareHeader exits
immediately without doing anything (or at least the documentation
suggests
so).
-Ben Allison
_______________________________________________
media_api mailing list
[email protected]
http://www.create.ucsb.edu/mailman/listinfo/media_api