diff --git a/source/backend/engine/CarlaEngineBridge.cpp b/source/backend/engine/CarlaEngineBridge.cpp index be3a87ac7..7ae1b3886 100644 --- a/source/backend/engine/CarlaEngineBridge.cpp +++ b/source/backend/engine/CarlaEngineBridge.cpp @@ -1186,7 +1186,7 @@ protected: } uint8_t* midiData(fShmRtClientControl.data->midiOut); - carla_zeroBytes(midiData, kBridgeRtClientDataMidiOutSize); + carla_zeroBytes(midiData, kBridgeBaseMidiOutHeaderSize); std::size_t curMidiDataPos = 0; if (pData->events.in[0].type != kEngineEventTypeNull) @@ -1208,7 +1208,7 @@ protected: event.ctrl.convertToMidiData(event.channel, size, data); CARLA_SAFE_ASSERT_CONTINUE(size > 0 && size <= 3); - if (curMidiDataPos + 6U /* time, port and size */ + size >= kBridgeRtClientDataMidiOutSize) + if (curMidiDataPos + kBridgeBaseMidiOutHeaderSize + size >= kBridgeRtClientDataMidiOutSize) break; // set time @@ -1225,13 +1225,13 @@ protected: for (uint8_t j=0; j= kBridgeRtClientDataMidiOutSize) + if (curMidiDataPos + kBridgeBaseMidiOutHeaderSize + _midiEvent.size >= kBridgeRtClientDataMidiOutSize) break; const uint8_t* const _midiData(_midiEvent.dataExt != nullptr ? _midiEvent.dataExt : _midiEvent.data); @@ -1252,7 +1252,7 @@ protected: for (uint8_t j=1; j<_midiEvent.size; ++j) *midiData++ = _midiData[j]; - curMidiDataPos += 6U /* time, port and size */ + _midiEvent.size; + curMidiDataPos += kBridgeBaseMidiOutHeaderSize + _midiEvent.size; } } diff --git a/source/libjack/libjack.cpp b/source/libjack/libjack.cpp index 20c32ffc9..4bfe50036 100644 --- a/source/libjack/libjack.cpp +++ b/source/libjack/libjack.cpp @@ -746,7 +746,7 @@ bool CarlaJackAppClient::handleRtData() if (fServer.numMidiOuts > 0) { uint8_t* midiData(fShmRtClientControl.data->midiOut); - carla_zeroBytes(midiData, kBridgeRtClientDataMidiOutSize); + carla_zeroBytes(midiData, kBridgeBaseMidiOutHeaderSize); std::size_t curMidiDataPos = 0; for (uint8_t i=0; i= kBridgeRtClientDataMidiOutSize) + if (curMidiDataPos + kBridgeBaseMidiOutHeaderSize + jmevent.size >= kBridgeRtClientDataMidiOutSize) break; // set time @@ -774,7 +774,7 @@ bool CarlaJackAppClient::handleRtData() std::memcpy(midiData, jmevent.buffer, jmevent.size); midiData += jmevent.size; - curMidiDataPos += 6U /* time, port and size */ + jmevent.size; + curMidiDataPos += kBridgeBaseMidiOutHeaderSize + jmevent.size; } } } diff --git a/source/utils/CarlaBridgeDefines.hpp b/source/utils/CarlaBridgeDefines.hpp index ecfe971a5..93fd1f416 100644 --- a/source/utils/CarlaBridgeDefines.hpp +++ b/source/utils/CarlaBridgeDefines.hpp @@ -139,6 +139,7 @@ struct BridgeTimeInfo { // ------------------------------------------------------------------------------------------------------------------- static const std::size_t kBridgeRtClientDataMidiOutSize = 511*4; +static const std::size_t kBridgeBaseMidiOutHeaderSize = 6U /* time, port and size */; // Server => Client RT struct BridgeRtClientData {