@@ -728,22 +728,32 @@ CMidiPort::SendMidiMessage(UINT32 midiMessage)
728
728
byte status = midiMessage & 0x000000FF ;
729
729
// byte* messagePointer = (byte*)(&midiMessage);
730
730
731
- if (MIDI_MESSAGE_IS_ONE_BYTE (status))
731
+ // if it's a valid status byte, then figure
732
+ // out the actual size of the message. If it's
733
+ // not a valid status byte, then we just drop it
734
+ if (MIDI_BYTE_IS_STATUS_BYTE (status))
732
735
{
733
- messageSize = 1 ;
734
- }
735
- else if (MIDI_MESSAGE_IS_TWO_BYTES (status))
736
- {
737
- messageSize = 2 ;
736
+ if (MIDI_MESSAGE_IS_ONE_BYTE (status))
737
+ {
738
+ messageSize = 1 ;
739
+ }
740
+ else if (MIDI_MESSAGE_IS_TWO_BYTES (status))
741
+ {
742
+ messageSize = 2 ;
743
+ }
744
+ else if (MIDI_MESSAGE_IS_THREE_BYTES (status))
745
+ {
746
+ messageSize = 3 ;
747
+ }
748
+
749
+ // send the message to the transport
750
+ // pass a timestamp of 0 to bypass scheduler
751
+ RETURN_IF_FAILED (m_MidisrvTransport->SendMidiMessage (&midiMessage, messageSize, 0 ));
738
752
}
739
- else if ( MIDI_MESSAGE_IS_THREE_BYTES (status))
753
+ else
740
754
{
741
- messageSize = 3 ;
755
+ return E_INVALIDARG ;
742
756
}
743
-
744
- // send the message to the transport
745
- // pass a timestamp of 0 to bypass scheduler
746
- RETURN_IF_FAILED (m_MidisrvTransport->SendMidiMessage (&midiMessage, messageSize, 0 ));
747
757
}
748
758
749
759
return S_OK;
@@ -789,7 +799,8 @@ CMidiPort::SendLongMessage(LPMIDIHDR buffer)
789
799
// TODO: based on the buffer length, this message may require chunking into smaller
790
800
// pieces to ensure it fits into the cross process queue.
791
801
//
792
- RETURN_IF_FAILED (m_MidisrvTransport->SendMidiMessage (buffer->lpData , buffer->dwBytesRecorded , 0 ));
802
+ // RETURN_IF_FAILED(m_MidisrvTransport->SendMidiMessage(buffer->lpData, buffer->dwBytesRecorded, 0));
803
+ RETURN_IF_FAILED (m_MidisrvTransport->SendMidiMessage (buffer->lpData , buffer->dwBufferLength , 0 ));
793
804
}
794
805
795
806
// mark the buffer as completed
0 commit comments