Skip to content

Commit

Permalink
Reverted OS-X sendMessage function for sysex messages > 1024 bytes, a…
Browse files Browse the repository at this point in the history
…s the MIDIReceived() function does not work for such.
  • Loading branch information
garyscavone committed Jul 15, 2014
1 parent ce21fe6 commit 770b572
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions RtMidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,10 +991,10 @@ void MidiOutCore :: openVirtualPort( std::string portName )

// Not necessary if we don't treat sysex messages any differently than
// normal messages ... see below.
//static void sysexCompletionProc( MIDISysexSendRequest *sreq )
//{
// free( sreq );
//}
static void sysexCompletionProc( MIDISysexSendRequest *sreq )
{
free( sreq );
}

void MidiOutCore :: sendMessage( std::vector<unsigned char> *message )
{
Expand All @@ -1013,12 +1013,16 @@ void MidiOutCore :: sendMessage( std::vector<unsigned char> *message )
CoreMidiData *data = static_cast<CoreMidiData *> (apiData_);
OSStatus result;

/*
// I don't think this code is necessary. We can send sysex
// messages through the normal mechanism. In addition, this avoids
// the problem of virtual ports not receiving sysex messages.
///*
// It would be nice if the following "special-case" code for sysex
// messages longer than 1024 bytes wasn't necessary. In fact, we
// can send sysex messages through the normal messaging mechanism.
// However, that does not work for messages greater than 1024
// bytes. From a previous note, there may be a problem of virtual
// ports not receiving sysex messages when using this section of
// code.

if ( message->at(0) == 0xF0 ) {
if ( message->at(0) == 0xF0 && nBytes > 1022 ) {

// Apple's fantastic API requires us to free the allocated data in
// the completion callback but trashes the pointer and size before
Expand Down Expand Up @@ -1049,12 +1053,12 @@ void MidiOutCore :: sendMessage( std::vector<unsigned char> *message )
}
return;
}
else if ( nBytes > 3 ) {
else if ( message->at(0) != 0xF0 && nBytes > 3 ) {
errorString_ = "MidiOutCore::sendMessage: message format problem ... not sysex but > 3 bytes?";
error( RtMidiError::WARNING, errorString_ );
return;
}
*/
//*/

MIDIPacketList packetList;
MIDIPacket *packet = MIDIPacketListInit( &packetList );
Expand Down

0 comments on commit 770b572

Please sign in to comment.