Hey Sean,

Unfortunately I spent much of my pre-college youth doing win32 
development -- so I'm used to these crappy APIs.

I have a few ideas:

1:
midiOutLongMsg's last parameter is the size of the MIDIHR structure, not 
the length of the sysex message.

midiOutLongMsg(outhandle, &header, length);

the third parameter should probably be sizeof(header)

2:
The MIDIHDR structure needs to be prepared before you use it. You do 
this with 'midiOutPrepareHeader'.

"Before the buffer is passed to midiOutLongMsg, it must be prepared by 
using the midiOutPrepareHeader function. The MIDI output device driver 
determines whether the data is sent synchronously or asynchronously."

So call this after the memset() and setting lpData, dwBufferLength, and 
dwBytesRecorded:

midiOutPrepareHeader(outhandle, &header, sizeof(header));

3: (this may not be an issue)
The MIDIHDR object is declared in the stack (i.e. as a local variable). 
As the quote says above, we have no control over whether the call is 
asynchronous or synchronous. The midiOutLongMsg call probably sticks the 
MIDIHDR pointer in a queue somewhere deep in the MIDI subsystem. This 
means that once sendSysexMsg returns, then the data pointed to by that 
queue may be junk, and it might even cause Mixxx to crash.

Hints of this are in the midiOutPrepareHeader function: "After the 
header has been prepared, do not modify the buffer. To free the buffer, 
use the *midiOutUnprepareHeader* 
<http://msdn.microsoft.com/en-us/library/ms711641%28VS.85%29.aspx> 
function."

If this is a problem:
- We need to keep a pool of MIDIHDR's that are queued and free to be queued.
- We need to find out how to learn when the MIDI subsystem is done with 
a buffer (I'm guessing it involves the MidiOutProc callback).

It's possible that they make a copy of the buffer once you call 
midiOutLongMsg, in which case we're fine -- but we should unprepare our 
MIDIHDR's just the same.

Anyway -- that's all that stuck out. There may be more things that need 
fixing.

Cheers,
RJ


Sean M. Pappalardo wrote:
> Hello again.
>
> Turns out Mixxx gets confused when more than one MIDI device is plugged
> in so by removing my extra device, MIDI send (short messages) now works
> fine. However there's still a problem with sending System Exclusive
> messages, in midiobjectwin.cpp, line 168. The return value of
> midiOutLongMsg is 11 which means "The specified pointer or structure is
> invalid." So probably due to my complete lack of Windows programming
> knowledge, I must've screwed up the construction of the MIDIHDR data object.
>
> Could someone with Windows programming experience take a quick look at
> that function?
>
> Thanks!
>
> Sincerely,
> Sean M. Pappalardo
>
> <<--------------------------------------------------------------------------------->>
> This E-Mail message has been scanned for viruses
> and cleared by >>SmartMail<< from Smarter Technology, Inc.
> <<--------------------------------------------------------------------------------->>
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Mixxx-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mixxx-devel
>   


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Mixxx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mixxx-devel

Reply via email to