|
@@ -1007,62 +1007,29 @@ void MidiOutCore :: sendMessage( std::vector<unsigned char> *message )
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
MIDITimeStamp timeStamp = AudioGetCurrentHostTime();
|
|
MIDITimeStamp timeStamp = AudioGetCurrentHostTime();
|
|
CoreMidiData *data = static_cast<CoreMidiData *> (apiData_);
|
|
CoreMidiData *data = static_cast<CoreMidiData *> (apiData_);
|
|
OSStatus result;
|
|
OSStatus result;
|
|
|
|
|
|
-
|
|
+ if ( message->at(0) != 0xF0 && nBytes > 3 ) {
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if ( message->at(0) == 0xF0 && nBytes > 1022 ) {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- MIDISysexSendRequest *newRequest = (MIDISysexSendRequest *) malloc(sizeof(struct MIDISysexSendRequest) + nBytes);
|
|
|
|
- char * sysexBuffer = ((char *) newRequest) + sizeof(struct MIDISysexSendRequest);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- for ( unsigned int i=0; i<nBytes; ++i ) sysexBuffer[i] = message->at(i);
|
|
|
|
-
|
|
|
|
- newRequest->destination = data->destinationId;
|
|
|
|
- newRequest->data = (Byte *)sysexBuffer;
|
|
|
|
- newRequest->bytesToSend = nBytes;
|
|
|
|
- newRequest->complete = 0;
|
|
|
|
- newRequest->completionProc = sysexCompletionProc;
|
|
|
|
- newRequest->completionRefCon = newRequest;
|
|
|
|
-
|
|
|
|
- result = MIDISendSysex(newRequest);
|
|
|
|
- if ( result != noErr ) {
|
|
|
|
- free( newRequest );
|
|
|
|
- errorString_ = "MidiOutCore::sendMessage: error sending MIDI to virtual destinations.";
|
|
|
|
- error( RtMidiError::WARNING, errorString_ );
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- else if ( message->at(0) != 0xF0 && nBytes > 3 ) {
|
|
|
|
errorString_ = "MidiOutCore::sendMessage: message format problem ... not sysex but > 3 bytes?";
|
|
errorString_ = "MidiOutCore::sendMessage: message format problem ... not sysex but > 3 bytes?";
|
|
error( RtMidiError::WARNING, errorString_ );
|
|
error( RtMidiError::WARNING, errorString_ );
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
- MIDIPacketList packetList;
|
|
+ Byte buffer[nBytes+(sizeof(MIDIPacketList))];
|
|
- MIDIPacket *packet = MIDIPacketListInit( &packetList );
|
|
+ ByteCount listSize = sizeof(buffer);
|
|
- packet = MIDIPacketListAdd( &packetList, sizeof(packetList), packet, timeStamp, nBytes, (const Byte *) &message->at( 0 ) );
|
|
+ MIDIPacketList *packetList = (MIDIPacketList*)buffer;
|
|
|
|
+ MIDIPacket *packet = MIDIPacketListInit( packetList );
|
|
|
|
+
|
|
|
|
+ ByteCount remainingBytes = nBytes;
|
|
|
|
+ while (remainingBytes) {
|
|
|
|
+ ByteCount bytesForPacket = remainingBytes > 65535 ? 65535 : remainingBytes;
|
|
|
|
+ const Byte* dataStartPtr = (const Byte *) &message->at( nBytes - remainingBytes );
|
|
|
|
+ packet = MIDIPacketListAdd( packetList, listSize, packet, timeStamp, bytesForPacket, dataStartPtr);
|
|
|
|
+ remainingBytes -= bytesForPacket;
|
|
|
|
+ }
|
|
|
|
+
|
|
if ( !packet ) {
|
|
if ( !packet ) {
|
|
errorString_ = "MidiOutCore::sendMessage: could not allocate packet list";
|
|
errorString_ = "MidiOutCore::sendMessage: could not allocate packet list";
|
|
error( RtMidiError::DRIVER_ERROR, errorString_ );
|
|
error( RtMidiError::DRIVER_ERROR, errorString_ );
|
|
@@ -1071,7 +1038,7 @@ void MidiOutCore :: sendMessage( std::vector<unsigned char> *message )
|
|
|
|
|
|
|
|
|
|
if ( data->endpoint ) {
|
|
if ( data->endpoint ) {
|
|
- result = MIDIReceived( data->endpoint, &packetList );
|
|
+ result = MIDIReceived( data->endpoint, packetList );
|
|
if ( result != noErr ) {
|
|
if ( result != noErr ) {
|
|
errorString_ = "MidiOutCore::sendMessage: error sending MIDI to virtual destinations.";
|
|
errorString_ = "MidiOutCore::sendMessage: error sending MIDI to virtual destinations.";
|
|
error( RtMidiError::WARNING, errorString_ );
|
|
error( RtMidiError::WARNING, errorString_ );
|
|
@@ -1080,7 +1047,7 @@ void MidiOutCore :: sendMessage( std::vector<unsigned char> *message )
|
|
|
|
|
|
|
|
|
|
if ( connected_ ) {
|
|
if ( connected_ ) {
|
|
- result = MIDISend( data->port, data->destinationId, &packetList );
|
|
+ result = MIDISend( data->port, data->destinationId, packetList );
|
|
if ( result != noErr ) {
|
|
if ( result != noErr ) {
|
|
errorString_ = "MidiOutCore::sendMessage: error sending MIDI message to port.";
|
|
errorString_ = "MidiOutCore::sendMessage: error sending MIDI message to port.";
|
|
error( RtMidiError::WARNING, errorString_ );
|
|
error( RtMidiError::WARNING, errorString_ );
|