Browse Source

Small optimization to bridges midi out

tags/1.9.8
falkTX 7 years ago
parent
commit
c35f761240
3 changed files with 9 additions and 8 deletions
  1. +5
    -5
      source/backend/engine/CarlaEngineBridge.cpp
  2. +3
    -3
      source/libjack/libjack.cpp
  3. +1
    -0
      source/utils/CarlaBridgeDefines.hpp

+ 5
- 5
source/backend/engine/CarlaEngineBridge.cpp View File

@@ -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<size; ++j)
*midiData++ = data[j];

curMidiDataPos += 6U /* time, port and size */ + size;
curMidiDataPos += kBridgeBaseMidiOutHeaderSize + size;
}
else if (event.type == kEngineEventTypeMidi)
{
const EngineMidiEvent& _midiEvent(event.midi);

if (curMidiDataPos + 6U /* time, port and size */ + _midiEvent.size >= 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;
}
}



+ 3
- 3
source/libjack/libjack.cpp View File

@@ -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<fServer.numMidiOuts; ++i)
@@ -757,7 +757,7 @@ bool CarlaJackAppClient::handleRtData()
{
jack_midi_event_t& jmevent(midiPortBuf.events[j]);

if (curMidiDataPos + 6U /* time, port and size */ + jmevent.size >= 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;
}
}
}


+ 1
- 0
source/utils/CarlaBridgeDefines.hpp View File

@@ -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 {


Loading…
Cancel
Save