Browse Source

Stop using VLAs on code that will be used in OBS

Signed-off-by: falkTX <falktx@falktx.com>
pull/1775/head
falkTX 1 year ago
parent
commit
b93cb19975
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
18 changed files with 293 additions and 156 deletions
  1. +69
    -44
      source/backend/engine/CarlaEngineBridge.cpp
  2. +23
    -12
      source/backend/engine/CarlaEngineGraph.cpp
  3. +8
    -1
      source/backend/plugin/CarlaPlugin.cpp
  4. +14
    -5
      source/backend/plugin/CarlaPluginBridge.cpp
  5. +4
    -1
      source/backend/plugin/CarlaPluginCLAP.cpp
  6. +10
    -8
      source/backend/plugin/CarlaPluginFluidSynth.cpp
  7. +9
    -1
      source/backend/plugin/CarlaPluginInternal.cpp
  8. +1
    -0
      source/backend/plugin/CarlaPluginInternal.hpp
  9. +3
    -2
      source/backend/plugin/CarlaPluginJack.cpp
  10. +4
    -1
      source/backend/plugin/CarlaPluginJuce.cpp
  11. +6
    -3
      source/backend/plugin/CarlaPluginLADSPADSSI.cpp
  12. +83
    -52
      source/backend/plugin/CarlaPluginLV2.cpp
  13. +13
    -10
      source/backend/plugin/CarlaPluginNative.cpp
  14. +1
    -1
      source/backend/plugin/CarlaPluginSFZero.cpp
  15. +5
    -2
      source/backend/plugin/CarlaPluginVST2.cpp
  16. +6
    -3
      source/backend/plugin/CarlaPluginVST3.cpp
  17. +29
    -8
      source/discovery/carla-discovery.cpp
  18. +5
    -2
      source/utils/CarlaPipeUtils.cpp

+ 69
- 44
source/backend/engine/CarlaEngineBridge.cpp View File

@@ -93,6 +93,41 @@ private:

// -------------------------------------------------------------------

struct BridgeTextReader {
char* text;

BridgeTextReader(BridgeNonRtClientControl& nonRtClientCtrl)
: text(nullptr)
{
const uint32_t size = nonRtClientCtrl.readUInt();
CARLA_SAFE_ASSERT_RETURN(size != 0,);

text = new char[size + 1];
nonRtClientCtrl.readCustomData(text, size);
text[size] = '\0';
}

BridgeTextReader(BridgeNonRtClientControl& nonRtClientCtrl, const uint32_t size)
: text(nullptr)
{
text = new char[size + 1];

if (size != 0)
nonRtClientCtrl.readCustomData(text, size);

text[size] = '\0';
}

~BridgeTextReader() noexcept
{
delete[] text;
}

CARLA_DECLARE_NON_COPYABLE(BridgeTextReader)
};

// -------------------------------------------------------------------

class CarlaEngineBridge : public CarlaEngine,
private CarlaThread,
private LatencyChangedCallback
@@ -884,16 +919,10 @@ public:

case kPluginBridgeNonRtClientSetCustomData: {
// type
const uint32_t typeSize = fShmNonRtClientControl.readUInt();
char typeStr[typeSize+1];
carla_zeroChars(typeStr, typeSize+1);
fShmNonRtClientControl.readCustomData(typeStr, typeSize);
const BridgeTextReader type(fShmNonRtClientControl);

// key
const uint32_t keySize = fShmNonRtClientControl.readUInt();
char keyStr[keySize+1];
carla_zeroChars(keyStr, keySize+1);
fShmNonRtClientControl.readCustomData(keyStr, keySize);
const BridgeTextReader key(fShmNonRtClientControl);

// value
const uint32_t valueSize = fShmNonRtClientControl.readUInt();
@@ -902,15 +931,12 @@ public:
{
if (valueSize > 16384)
{
const uint32_t bigValueFilePathSize = fShmNonRtClientControl.readUInt();
char bigValueFilePathTry[bigValueFilePathSize+1];
carla_zeroChars(bigValueFilePathTry, bigValueFilePathSize+1);
fShmNonRtClientControl.readCustomData(bigValueFilePathTry, bigValueFilePathSize);
const BridgeTextReader bigValueFilePathTry(fShmNonRtClientControl, valueSize);

CARLA_SAFE_ASSERT_BREAK(bigValueFilePathTry[0] != '\0');
CARLA_SAFE_ASSERT_BREAK(bigValueFilePathTry.text[0] != '\0');
if (! plugin->isEnabled()) break;

String bigValueFilePath(bigValueFilePathTry);
String bigValueFilePath(bigValueFilePathTry.text);

#ifdef CARLA_OS_WIN
// check if running under Wine
@@ -921,41 +947,37 @@ public:
File bigValueFile(bigValueFilePath);
CARLA_SAFE_ASSERT_BREAK(bigValueFile.existsAsFile());

plugin->setCustomData(typeStr, keyStr, bigValueFile.loadFileAsString().toRawUTF8(), true);
plugin->setCustomData(type.text, key.text, bigValueFile.loadFileAsString().toRawUTF8(), true);

bigValueFile.deleteFile();
}
else
{
char valueStr[valueSize+1];
carla_zeroChars(valueStr, valueSize+1);
fShmNonRtClientControl.readCustomData(valueStr, valueSize);
const BridgeTextReader value(fShmNonRtClientControl, valueSize);

if (plugin->isEnabled())
plugin->setCustomData(typeStr, keyStr, valueStr, true);
plugin->setCustomData(type.text, key.text, value.text, true);
}
}
else
{
if (plugin->isEnabled())
plugin->setCustomData(typeStr, keyStr, "", true);
plugin->setCustomData(type.text, key.text, "", true);
}

break;
}

case kPluginBridgeNonRtClientSetChunkDataFile: {
const uint32_t size(fShmNonRtClientControl.readUInt());
const uint32_t size = fShmNonRtClientControl.readUInt();
CARLA_SAFE_ASSERT_BREAK(size > 0);

char chunkFilePathTry[size+1];
carla_zeroChars(chunkFilePathTry, size+1);
fShmNonRtClientControl.readCustomData(chunkFilePathTry, size);
const BridgeTextReader chunkFilePathTry(fShmNonRtClientControl, size);

CARLA_SAFE_ASSERT_BREAK(chunkFilePathTry[0] != '\0');
CARLA_SAFE_ASSERT_BREAK(chunkFilePathTry.text[0] != '\0');
if (! plugin->isEnabled()) break;

String chunkFilePath(chunkFilePathTry);
String chunkFilePath(chunkFilePathTry.text);

#ifdef CARLA_OS_WIN
// check if running under Wine
@@ -1006,14 +1028,9 @@ public:
}

case kPluginBridgeNonRtClientSetWindowTitle: {
const uint32_t size = fShmNonRtClientControl.readUInt();
CARLA_SAFE_ASSERT_BREAK(size > 0);

char title[size+1];
carla_zeroChars(title, size+1);
fShmNonRtClientControl.readCustomData(title, size);
const BridgeTextReader title(fShmNonRtClientControl);

plugin->setCustomUITitle(title);
plugin->setCustomUITitle(title.text);
break;
}

@@ -1414,10 +1431,18 @@ protected:
CARLA_SAFE_ASSERT_BREAK(size > 0);

// FIXME variable-size stack
uint8_t data[size];
uint8_t data[4];

{
uint8_t i=0;
for (; i<size && i<4; ++i)
data[i] = fShmRtClientControl.readByte();
for (; i<size; ++i)
fShmRtClientControl.readByte();
}

for (uint8_t i=0; i<size; ++i)
data[i] = fShmRtClientControl.readByte();
if (size > 4)
continue;

if (EngineEvent* const event = getNextFreeInputEvent())
{
@@ -1458,15 +1483,15 @@ protected:
{
const BridgeTimeInfo& bridgeTimeInfo(fShmRtClientControl.data->timeInfo);

const uint32_t audioInCount(plugin->getAudioInCount());
const uint32_t audioOutCount(plugin->getAudioOutCount());
const uint32_t cvInCount(plugin->getCVInCount());
const uint32_t cvOutCount(plugin->getCVOutCount());
const uint32_t audioInCount = plugin->getAudioInCount();
const uint32_t audioOutCount = plugin->getAudioOutCount();
const uint32_t cvInCount = plugin->getCVInCount();
const uint32_t cvOutCount = plugin->getCVOutCount();

const float* audioIn[audioInCount];
/* */ float* audioOut[audioOutCount];
const float* cvIn[cvInCount];
/* */ float* cvOut[cvOutCount];
const float* audioIn[64];
/* */ float* audioOut[64];
const float* cvIn[32];
/* */ float* cvOut[32];

float* fdata = fShmAudioPool.data;



+ 23
- 12
source/backend/engine/CarlaEngineGraph.cpp View File

@@ -31,6 +31,9 @@ using water::MidiBuffer;
using water::String;
using water::StringArray;

#define MAX_GRAPH_AUDIO_IO 64U
#define MAX_GRAPH_CV_IO 32U

CARLA_BACKEND_START_NAMESPACE

// -----------------------------------------------------------------------
@@ -990,6 +993,10 @@ void RackGraph::process(CarlaEngine::ProtectedData* const data, const float* inB
// initialize event outputs (zero)
carla_zeroStructs(data->events.out, kMaxEngineEventInternalCount);

const float* inBuf[MAX_GRAPH_AUDIO_IO];
float* outBuf[MAX_GRAPH_AUDIO_IO];
float* cvBuf[MAX_GRAPH_CV_IO];

uint32_t oldAudioInCount = 0;
uint32_t oldAudioOutCount = 0;
uint32_t oldMidiOutCount = 0;
@@ -1041,15 +1048,16 @@ void RackGraph::process(CarlaEngine::ProtectedData* const data, const float* inB
const uint32_t numOutBufs = std::max(oldAudioOutCount, 2U);
const uint32_t numCvBufs = std::max(plugin->getCVInCount(), plugin->getCVOutCount());

const float* inBuf[numInBufs];
CARLA_SAFE_ASSERT_RETURN(numInBufs <= MAX_GRAPH_AUDIO_IO, plugin->unlock());
CARLA_SAFE_ASSERT_RETURN(numOutBufs <= MAX_GRAPH_AUDIO_IO, plugin->unlock());
CARLA_SAFE_ASSERT_RETURN(numCvBufs <= MAX_GRAPH_CV_IO, plugin->unlock());

inBuf[0] = inBuf0;
inBuf[1] = inBuf1;

float* outBuf[numOutBufs];
outBuf[0] = outBufReal[0];
outBuf[1] = outBufReal[1];

float* cvBuf[numCvBufs];
for (uint32_t j=0; j<numCvBufs; ++j)
cvBuf[j] = dummyBuf;

@@ -1585,9 +1593,12 @@ public:
if (plugin->getAudioInCount() == 0)
audio.clear();

float* audioBuffers[numAudioChan];
float* cvOutBuffers[numCVOutChan];
const float* cvInBuffers[numCVInChan];
float* audioBuffers[MAX_GRAPH_AUDIO_IO];
float* cvOutBuffers[MAX_GRAPH_CV_IO];
const float* cvInBuffers[MAX_GRAPH_CV_IO];
CARLA_SAFE_ASSERT_RETURN(numAudioChan <= MAX_GRAPH_AUDIO_IO, plugin->unlock());
CARLA_SAFE_ASSERT_RETURN(numCVOutChan <= MAX_GRAPH_CV_IO, plugin->unlock());
CARLA_SAFE_ASSERT_RETURN(numCVInChan <= MAX_GRAPH_CV_IO, plugin->unlock());

for (uint32_t i=0; i<numAudioChan; ++i)
audioBuffers[i] = audio.getWritePointer(i);
@@ -1614,8 +1625,8 @@ public:
else
{
// processing CV only, skip audiopeaks
float* cvOutBuffers[numCVOutChan];
const float* cvInBuffers[numCVInChan];
float* cvOutBuffers[MAX_GRAPH_CV_IO];
const float* cvInBuffers[MAX_GRAPH_CV_IO];

for (uint32_t i=0; i<numCVOutChan; ++i)
cvOutBuffers[i] = cvOut.getWritePointer(i);
@@ -1757,10 +1768,10 @@ PatchbayGraph::PatchbayGraph(CarlaEngine* const engine,
cvInBuffer(),
cvOutBuffer(),
midiBuffer(),
numAudioIns(carla_fixedValue(0U, 64U, audioIns)),
numAudioOuts(carla_fixedValue(0U, 64U, audioOuts)),
numCVIns(carla_fixedValue(0U, 32U, cvIns)),
numCVOuts(carla_fixedValue(0U, 32U, cvOuts)),
numAudioIns(carla_fixedValue(0U, MAX_GRAPH_AUDIO_IO, audioIns)),
numAudioOuts(carla_fixedValue(0U, MAX_GRAPH_AUDIO_IO, audioOuts)),
numCVIns(carla_fixedValue(0U, MAX_GRAPH_CV_IO, cvIns)),
numCVOuts(carla_fixedValue(0U, MAX_GRAPH_CV_IO, cvOuts)),
retCon(),
usingExternalHost(false),
usingExternalOSC(false),


+ 8
- 1
source/backend/plugin/CarlaPlugin.cpp View File

@@ -2081,8 +2081,15 @@ void CarlaPlugin::deactivate() noexcept
CARLA_SAFE_ASSERT(pData->active);
}

void CarlaPlugin::bufferSizeChanged(const uint32_t)
void CarlaPlugin::bufferSizeChanged(const uint32_t newBufferSize)
{
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
delete[] pData->postProc.extraBuffer;
pData->postProc.extraBuffer = new float[newBufferSize];
#else
// unused
(void)newBufferSize;
#endif
}

void CarlaPlugin::sampleRateChanged(const double)


+ 14
- 5
source/backend/plugin/CarlaPluginBridge.cpp View File

@@ -1790,12 +1790,18 @@ public:
break;

// store midi data advancing as needed
uint8_t data[size];
uint8_t data[4];

for (uint8_t j=0; j<size; ++j)
data[j] = *midiData++;
{
uint8_t j=0;
for (; j<size && j<4; ++j)
data[j] = *midiData++;
for (; j<size; ++j)
data[j] = *midiData++;
}

pData->event.portOut->writeMidiEvent(time, size, data);
if (size <= 4)
pData->event.portOut->writeMidiEvent(time, size, data);

read += kBridgeBaseMidiOutHeaderSize + size;
}
@@ -1915,7 +1921,8 @@ public:
const bool isMono = (pData->audioIn.count == 1);

bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1];
float bufValue;
float* const oldBufLeft = pData->postProc.extraBuffer;

for (uint32_t i=0; i < pData->audioOut.count; ++i)
{
@@ -2033,6 +2040,8 @@ public:
fProcWaitTime = 1000;

waitForClient("buffersize", 1000);

CarlaPlugin::bufferSizeChanged(newBufferSize);
}

void sampleRateChanged(const double newSampleRate) override


+ 4
- 1
source/backend/plugin/CarlaPluginCLAP.cpp View File

@@ -2443,7 +2443,8 @@ public:
const bool isMono = (pData->audioIn.count == 1);

bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1];
float bufValue;
float* const oldBufLeft = pData->postProc.extraBuffer;

for (uint32_t i=0; i < pData->audioOut.count; ++i)
{
@@ -2594,6 +2595,8 @@ public:

if (pData->active)
activate();

CarlaPlugin::bufferSizeChanged(newBufferSize);
}
#endif



+ 10
- 8
source/backend/plugin/CarlaPluginFluidSynth.cpp View File

@@ -1541,7 +1541,7 @@ public:
const bool doVolume = (pData->hints & PLUGIN_CAN_VOLUME) != 0 && carla_isNotEqual(pData->postProc.volume, 1.0f);
const bool doBalance = (pData->hints & PLUGIN_CAN_BALANCE) != 0 && ! (carla_isEqual(pData->postProc.balanceLeft, -1.0f) && carla_isEqual(pData->postProc.balanceRight, 1.0f));

float oldBufLeft[doBalance ? frames : 1];
float* const oldBufLeft = pData->postProc.extraBuffer;

for (uint32_t i=0; i < pData->audioOut.count; ++i)
{
@@ -1604,15 +1604,17 @@ public:

void bufferSizeChanged(const uint32_t newBufferSize) override
{
if (! kUse16Outs)
return;

for (uint32_t i=0; i < pData->audioOut.count; ++i)
if (kUse16Outs)
{
if (fAudio16Buffers[i] != nullptr)
delete[] fAudio16Buffers[i];
fAudio16Buffers[i] = new float[newBufferSize];
for (uint32_t i=0; i < pData->audioOut.count; ++i)
{
if (fAudio16Buffers[i] != nullptr)
delete[] fAudio16Buffers[i];
fAudio16Buffers[i] = new float[newBufferSize];
}
}

CarlaPlugin::bufferSizeChanged(newBufferSize);
}

void sampleRateChanged(const double newSampleRate) override


+ 9
- 1
source/backend/plugin/CarlaPluginInternal.cpp View File

@@ -709,7 +709,8 @@ CarlaPlugin::ProtectedData::PostProc::PostProc() noexcept
volume(1.0f),
balanceLeft(-1.0f),
balanceRight(1.0f),
panning(0.0f) {}
panning(0.0f),
extraBuffer(nullptr) {}
#endif

// -----------------------------------------------------------------------
@@ -866,6 +867,13 @@ void CarlaPlugin::ProtectedData::clearBuffers() noexcept
#ifndef BUILD_BRIDGE
latency.clearBuffers();
#endif
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
if (postProc.extraBuffer != nullptr)
{
delete[] postProc.extraBuffer;
postProc.extraBuffer = nullptr;
}
#endif
}

// -----------------------------------------------------------------------


+ 1
- 0
source/backend/plugin/CarlaPluginInternal.hpp View File

@@ -392,6 +392,7 @@ struct CarlaPlugin::ProtectedData {
float balanceLeft;
float balanceRight;
float panning;
float* extraBuffer;

PostProc() noexcept;



+ 3
- 2
source/backend/plugin/CarlaPluginJack.cpp View File

@@ -1014,7 +1014,7 @@ public:
} CARLA_SAFE_EXCEPTION("deactivate - waitForClient");
}

void process(const float* const* const audioIn, float** const audioOut,
void process(const float* const* const audioIn, float** const audioOut,
const float* const*, float**, const uint32_t frames) override
{
// --------------------------------------------------------------------------------------------------------
@@ -1402,7 +1402,8 @@ public:
const bool isMono = (pData->audioIn.count == 1);

bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1];
float bufValue;
float* const oldBufLeft = pData->postProc.extraBuffer;

for (uint32_t i=0; i < pData->audioOut.count; ++i)
{


+ 4
- 1
source/backend/plugin/CarlaPluginJuce.cpp View File

@@ -1417,7 +1417,8 @@ public:
const bool isMono = (pData->audioIn.count == 1);

bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1];
float bufValue;
float* const oldBufLeft = pData->postProc.extraBuffer;

for (uint32_t i=0; i < pData->audioOut.count; ++i)
{
@@ -1518,6 +1519,8 @@ public:
deactivate();
activate();
}

CarlaPlugin::bufferSizeChanged(newBufferSize);
}

void sampleRateChanged(const double newSampleRate) override


+ 6
- 3
source/backend/plugin/CarlaPluginLADSPADSSI.cpp View File

@@ -1318,8 +1318,8 @@ public:
const LADSPA_Handle handle(fHandles.getFirst(nullptr));
CARLA_SAFE_ASSERT_RETURN(handle != nullptr,);

float tmpIn [(aIns > 0) ? aIns : 1][2];
float tmpOut[(aOuts > 0) ? aOuts : 1][2];
float tmpIn[64][2];
float tmpOut[64][2];

for (uint32_t j=0; j < aIns; ++j)
{
@@ -2069,7 +2069,8 @@ public:
const bool isMono = (pData->audioIn.count == 1);

bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1];
float bufValue;
float* const oldBufLeft = pData->postProc.extraBuffer;

for (uint32_t i=0; i < pData->audioOut.count; ++i)
{
@@ -2224,6 +2225,8 @@ public:
reconnectAudioPorts();

carla_debug("CarlaPluginLADSPADSSI::bufferSizeChanged(%i) - end", newBufferSize);

CarlaPlugin::bufferSizeChanged(newBufferSize);
}

void sampleRateChanged(const double newSampleRate) override


+ 83
- 52
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -272,15 +272,23 @@ struct Lv2EventData {
CARLA_DECLARE_NON_COPYABLE(Lv2EventData)
};

union LV2EventIters {
LV2_Atom_Buffer_Iterator atom;
LV2_Event_Iterator event;
LV2_MIDIState midiState;
};

struct CarlaPluginLV2EventData {
uint32_t count;
Lv2EventData* data;
LV2EventIters* iters;
Lv2EventData* ctrl; // default port, either this->data[x] or pData->portIn/Out
uint32_t ctrlIndex;

CarlaPluginLV2EventData() noexcept
: count(0),
data(nullptr),
iters(nullptr),
ctrl(nullptr),
ctrlIndex(0) {}

@@ -288,6 +296,7 @@ struct CarlaPluginLV2EventData {
{
CARLA_SAFE_ASSERT_INT(count == 0, count);
CARLA_SAFE_ASSERT(data == nullptr);
CARLA_SAFE_ASSERT(iters == nullptr);
CARLA_SAFE_ASSERT(ctrl == nullptr);
CARLA_SAFE_ASSERT_INT(ctrlIndex == 0, ctrlIndex);
}
@@ -297,10 +306,12 @@ struct CarlaPluginLV2EventData {
CARLA_SAFE_ASSERT_INT(count == 0, count);
CARLA_SAFE_ASSERT_INT(ctrlIndex == 0, ctrlIndex);
CARLA_SAFE_ASSERT_RETURN(data == nullptr,);
CARLA_SAFE_ASSERT_RETURN(iters == nullptr,);
CARLA_SAFE_ASSERT_RETURN(ctrl == nullptr,);
CARLA_SAFE_ASSERT_RETURN(newCount > 0,);

data = new Lv2EventData[newCount];
iters = new LV2EventIters[newCount];
count = newCount;

ctrl = nullptr;
@@ -325,6 +336,12 @@ struct CarlaPluginLV2EventData {
data = nullptr;
}

if (iters != nullptr)
{
delete[] iters;
iters = nullptr;
}

count = 0;

ctrl = nullptr;
@@ -3361,13 +3378,14 @@ public:
// we need to pre-run the plugin so it can update its latency control-port
const uint32_t bufferSize = static_cast<uint32_t>(fLv2Options.nominalBufferSize);

float tmpIn [( aIns+cvIns > 0) ? aIns+cvIns : 1][bufferSize];
float tmpOut[(aOuts+cvOuts > 0) ? aOuts+cvOuts : 1][bufferSize];
float* tmpIn[96];
float* tmpOut[96];

{
uint32_t i=0;
for (; i < aIns; ++i)
{
tmpIn[i] = new float[bufferSize];
carla_zeroFloats(tmpIn[i], bufferSize);

try {
@@ -3377,6 +3395,7 @@ public:

for (uint32_t j=0; j < cvIns; ++i, ++j)
{
tmpIn[i] = new float[bufferSize];
carla_zeroFloats(tmpIn[i], bufferSize);

try {
@@ -3389,6 +3408,7 @@ public:
uint32_t i=0;
for (; i < aOuts; ++i)
{
tmpOut[i] = new float[bufferSize];
carla_zeroFloats(tmpOut[i], bufferSize);

try {
@@ -3398,6 +3418,7 @@ public:

for (uint32_t j=0; j < cvOuts; ++i, ++j)
{
tmpIn[i] = new float[bufferSize];
carla_zeroFloats(tmpOut[i], bufferSize);

try {
@@ -3432,6 +3453,12 @@ public:
pData->latency.recreateBuffers(std::max(aIns, aOuts), latency);
#endif
}

for (uint32_t i=0; i < aIns + cvIns; ++i)
delete[] tmpIn[i];

for (uint32_t i=0; i < aOuts + cvOuts; ++i)
delete[] tmpOut[i];
}

void reloadPrograms(const bool doInit) override
@@ -3611,29 +3638,26 @@ public:
// --------------------------------------------------------------------------------------------------------
// Event itenerators from different APIs (input)

LV2_Atom_Buffer_Iterator evInAtomIters[fEventsIn.count];
LV2_Event_Iterator evInEventIters[fEventsIn.count];
LV2_MIDIState evInMidiStates[fEventsIn.count];

for (uint32_t i=0; i < fEventsIn.count; ++i)
{
if (fEventsIn.data[i].type & CARLA_EVENT_DATA_ATOM)
{
lv2_atom_buffer_reset(fEventsIn.data[i].atom, true);
lv2_atom_buffer_begin(&evInAtomIters[i], fEventsIn.data[i].atom);
lv2_atom_buffer_begin(&fEventsIn.iters[i].atom, fEventsIn.data[i].atom);
}
else if (fEventsIn.data[i].type & CARLA_EVENT_DATA_EVENT)
{
lv2_event_buffer_reset(fEventsIn.data[i].event, LV2_EVENT_AUDIO_STAMP, fEventsIn.data[i].event->data);
lv2_event_begin(&evInEventIters[i], fEventsIn.data[i].event);
lv2_event_begin(&fEventsIn.iters[i].event, fEventsIn.data[i].event);
}
else if (fEventsIn.data[i].type & CARLA_EVENT_DATA_MIDI_LL)
{
fEventsIn.data[i].midi.event_count = 0;
fEventsIn.data[i].midi.size = 0;
evInMidiStates[i].midi = &fEventsIn.data[i].midi;
evInMidiStates[i].frame_count = frames;
evInMidiStates[i].position = 0;
LV2_MIDIState& midiState(fEventsIn.iters[i].midiState);
midiState.midi = &fEventsIn.data[i].midi;
midiState.frame_count = frames;
midiState.position = 0;
}
}

@@ -3673,25 +3697,25 @@ public:
midiData[1] = MIDI_CONTROL_ALL_NOTES_OFF;

if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[j], 0, 0, kUridMidiEvent, 3, midiData);
lv2_atom_buffer_write(&fEventsIn.iters[j].atom, 0, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[j], 0, 0, kUridMidiEvent, 3, midiData);
lv2_event_write(&fEventsIn.iters[j].event, 0, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[j], 0.0, 3, midiData);
lv2midi_put_event(&fEventsIn.iters[j].midiState, 0.0, 3, midiData);

midiData[0] = uint8_t(MIDI_STATUS_CONTROL_CHANGE | (i & MIDI_CHANNEL_BIT));
midiData[1] = MIDI_CONTROL_ALL_SOUND_OFF;

if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[j], 0, 0, kUridMidiEvent, 3, midiData);
lv2_atom_buffer_write(&fEventsIn.iters[j].atom, 0, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[j], 0, 0, kUridMidiEvent, 3, midiData);
lv2_event_write(&fEventsIn.iters[j].event, 0, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[j], 0.0, 3, midiData);
lv2midi_put_event(&fEventsIn.iters[j].midiState, 0.0, 3, midiData);
}
}
else if (pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS)
@@ -3702,13 +3726,13 @@ public:
midiData[1] = k;

if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[j], 0, 0, kUridMidiEvent, 3, midiData);
lv2_atom_buffer_write(&fEventsIn.iters[j].atom, 0, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[j], 0, 0, kUridMidiEvent, 3, midiData);
lv2_event_write(&fEventsIn.iters[j].event, 0, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[j], 0.0, 3, midiData);
lv2midi_put_event(&fEventsIn.iters[j].midiState, 0.0, 3, midiData);
}
}
}
@@ -3875,10 +3899,10 @@ public:
CARLA_SAFE_ASSERT_BREAK(atom->size < 256);

// send only deprecated blank object for now
lv2_atom_buffer_write(&evInAtomIters[i], 0, 0, kUridAtomBlank, atom->size, LV2_ATOM_BODY_CONST(atom));
lv2_atom_buffer_write(&fEventsIn.iters[i].atom, 0, 0, kUridAtomBlank, atom->size, LV2_ATOM_BODY_CONST(atom));

// for atom:object
//lv2_atom_buffer_write(&evInAtomIters[i], 0, 0, atom->type, atom->size, LV2_ATOM_BODY_CONST(atom));
//lv2_atom_buffer_write(&fEventsIn.iters[i].atom, 0, 0, atom->type, atom->size, LV2_ATOM_BODY_CONST(atom));
}

pData->postRtEvents.trySplice();
@@ -3906,7 +3930,7 @@ public:
{
j = (portIndex < fEventsIn.count) ? portIndex : fEventsIn.ctrlIndex;

if (! lv2_atom_buffer_write(&evInAtomIters[j], 0, 0, atom->type, atom->size, LV2_ATOM_BODY_CONST(atom)))
if (! lv2_atom_buffer_write(&fEventsIn.iters[j].atom, 0, 0, atom->type, atom->size, LV2_ATOM_BODY_CONST(atom)))
{
carla_stderr2("Event input buffer full, at least 1 message lost");
continue;
@@ -3944,13 +3968,13 @@ public:
midiEvent[2] = note.velo;

if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[j], 0, 0, kUridMidiEvent, 3, midiEvent);
lv2_atom_buffer_write(&fEventsIn.iters[j].atom, 0, 0, kUridMidiEvent, 3, midiEvent);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[j], 0, 0, kUridMidiEvent, 3, midiEvent);
lv2_event_write(&fEventsIn.iters[j].event, 0, 0, kUridMidiEvent, 3, midiEvent);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[j], 0.0, 3, midiEvent);
lv2midi_put_event(&fEventsIn.iters[j].midiState, 0.0, 3, midiEvent);
}

pData->extNotes.data.clear();
@@ -4015,18 +4039,18 @@ public:
if (fEventsIn.data[j].type & CARLA_EVENT_DATA_ATOM)
{
lv2_atom_buffer_reset(fEventsIn.data[j].atom, true);
lv2_atom_buffer_begin(&evInAtomIters[j], fEventsIn.data[j].atom);
lv2_atom_buffer_begin(&fEventsIn.iters[j].atom, fEventsIn.data[j].atom);
}
else if (fEventsIn.data[j].type & CARLA_EVENT_DATA_EVENT)
{
lv2_event_buffer_reset(fEventsIn.data[j].event, LV2_EVENT_AUDIO_STAMP, fEventsIn.data[j].event->data);
lv2_event_begin(&evInEventIters[j], fEventsIn.data[j].event);
lv2_event_begin(&fEventsIn.iters[j].event, fEventsIn.data[j].event);
}
else if (fEventsIn.data[j].type & CARLA_EVENT_DATA_MIDI_LL)
{
fEventsIn.data[j].midi.event_count = 0;
fEventsIn.data[j].midi.size = 0;
evInMidiStates[j].position = eventTime;
fEventsIn.iters[j].midiState.position = eventTime;
}
}

@@ -4156,13 +4180,13 @@ public:
const uint32_t mtime(isSampleAccurate ? startTime : eventTime);

if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], mtime, 0, kUridMidiEvent, 3, midiData);
lv2_atom_buffer_write(&fEventsIn.iters[fEventsIn.ctrlIndex].atom, mtime, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], mtime, 0, kUridMidiEvent, 3, midiData);
lv2_event_write(&fEventsIn.iters[fEventsIn.ctrlIndex].event, mtime, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], mtime, 3, midiData);
lv2midi_put_event(&fEventsIn.iters[fEventsIn.ctrlIndex].midiState, mtime, 3, midiData);
}

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
@@ -4188,13 +4212,13 @@ public:
const uint32_t mtime(isSampleAccurate ? startTime : eventTime);

if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], mtime, 0, kUridMidiEvent, 3, midiData);
lv2_atom_buffer_write(&fEventsIn.iters[fEventsIn.ctrlIndex].atom, mtime, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], mtime, 0, kUridMidiEvent, 3, midiData);
lv2_event_write(&fEventsIn.iters[fEventsIn.ctrlIndex].event, mtime, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], mtime, 3, midiData);
lv2midi_put_event(&fEventsIn.iters[fEventsIn.ctrlIndex].midiState, mtime, 3, midiData);
}
break;

@@ -4224,13 +4248,13 @@ public:
const uint32_t mtime(isSampleAccurate ? startTime : eventTime);

if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], mtime, 0, kUridMidiEvent, 2, midiData);
lv2_atom_buffer_write(&fEventsIn.iters[fEventsIn.ctrlIndex].atom, mtime, 0, kUridMidiEvent, 2, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], mtime, 0, kUridMidiEvent, 2, midiData);
lv2_event_write(&fEventsIn.iters[fEventsIn.ctrlIndex].event, mtime, 0, kUridMidiEvent, 2, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], mtime, 2, midiData);
lv2midi_put_event(&fEventsIn.iters[fEventsIn.ctrlIndex].midiState, mtime, 2, midiData);
}
break;

@@ -4245,13 +4269,13 @@ public:
midiData[2] = 0;

if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], mtime, 0, kUridMidiEvent, 3, midiData);
lv2_atom_buffer_write(&fEventsIn.iters[fEventsIn.ctrlIndex].atom, mtime, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], mtime, 0, kUridMidiEvent, 3, midiData);
lv2_event_write(&fEventsIn.iters[fEventsIn.ctrlIndex].event, mtime, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], mtime, 3, midiData);
lv2midi_put_event(&fEventsIn.iters[fEventsIn.ctrlIndex].midiState, mtime, 3, midiData);
}
break;

@@ -4274,13 +4298,13 @@ public:
midiData[2] = 0;

if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[fEventsIn.ctrlIndex], mtime, 0, kUridMidiEvent, 3, midiData);
lv2_atom_buffer_write(&fEventsIn.iters[fEventsIn.ctrlIndex].atom, mtime, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[fEventsIn.ctrlIndex], mtime, 0, kUridMidiEvent, 3, midiData);
lv2_event_write(&fEventsIn.iters[fEventsIn.ctrlIndex].event, mtime, 0, kUridMidiEvent, 3, midiData);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[fEventsIn.ctrlIndex], mtime, 3, midiData);
lv2midi_put_event(&fEventsIn.iters[fEventsIn.ctrlIndex].midiState, mtime, 3, midiData);
}
break;
} // switch (ctrlEvent.type)
@@ -4290,7 +4314,7 @@ public:
case kEngineEventTypeMidi: {
const EngineMidiEvent& midiEvent(event.midi);

const uint8_t* const midiData(midiEvent.size > EngineMidiEvent::kDataSize ? midiEvent.dataExt : midiEvent.data);
const uint8_t* const midiData = midiEvent.size > EngineMidiEvent::kDataSize ? midiEvent.dataExt : midiEvent.data;

uint8_t status = uint8_t(MIDI_GET_STATUS_FROM_DATA(midiData));

@@ -4313,18 +4337,22 @@ public:
const uint32_t mtime = isSampleAccurate ? startTime : eventTime;

// put back channel in data
uint8_t midiData2[midiEvent.size];
midiData2[0] = uint8_t(status | (event.channel & MIDI_CHANNEL_BIT));
std::memcpy(midiData2+1, midiData+1, static_cast<std::size_t>(midiEvent.size-1));
uint8_t midiData2[4]; // FIXME
if (midiEvent.size > 4)
continue;
{
midiData2[0] = uint8_t(status | (event.channel & MIDI_CHANNEL_BIT));
std::memcpy(midiData2+1, midiData+1, static_cast<std::size_t>(midiEvent.size-1));
}

if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM)
lv2_atom_buffer_write(&evInAtomIters[j], mtime, 0, kUridMidiEvent, midiEvent.size, midiData2);
lv2_atom_buffer_write(&fEventsIn.iters[j].atom, mtime, 0, kUridMidiEvent, midiEvent.size, midiData2);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_EVENT)
lv2_event_write(&evInEventIters[j], mtime, 0, kUridMidiEvent, midiEvent.size, midiData2);
lv2_event_write(&fEventsIn.iters[j].event, mtime, 0, kUridMidiEvent, midiEvent.size, midiData2);

else if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
lv2midi_put_event(&evInMidiStates[j], mtime, midiEvent.size, midiData2);
lv2midi_put_event(&fEventsIn.iters[j].midiState, mtime, midiEvent.size, midiData2);

if (status == MIDI_STATUS_NOTE_ON)
{
@@ -4632,7 +4660,8 @@ public:
const bool isMono = (pData->audioIn.count == 1);

bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1];
float bufValue;
float* const oldBufLeft = pData->postProc.extraBuffer;

for (uint32_t i=0; i < pData->audioOut.count; ++i)
{
@@ -4851,6 +4880,8 @@ public:
}

carla_debug("CarlaPluginLV2::bufferSizeChanged(%i) - end", newBufferSize);

CarlaPlugin::bufferSizeChanged(newBufferSize);
}

void sampleRateChanged(const double newSampleRate) override


+ 13
- 10
source/backend/plugin/CarlaPluginNative.cpp View File

@@ -2383,7 +2383,8 @@ public:
const bool doBalance = (pData->hints & PLUGIN_CAN_BALANCE) != 0 && ! (carla_isEqual(pData->postProc.balanceLeft, -1.0f) && carla_isEqual(pData->postProc.balanceRight, 1.0f));

bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1];
float bufValue;
float* const oldBufLeft = pData->postProc.extraBuffer;

for (; i < pData->audioOut.count; ++i)
{
@@ -2492,18 +2493,20 @@ public:
fAudioAndCvOutBuffers[i] = new float[newBufferSize];
}

if (fCurBufferSize == newBufferSize)
return;

fCurBufferSize = newBufferSize;

if (fDescriptor != nullptr && fDescriptor->dispatcher != nullptr)
if (fCurBufferSize != newBufferSize)
{
fDescriptor->dispatcher(fHandle, NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED, 0, static_cast<intptr_t>(newBufferSize), nullptr, 0.0f);
fCurBufferSize = newBufferSize;

if (fHandle2 != nullptr)
fDescriptor->dispatcher(fHandle2, NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED, 0, static_cast<intptr_t>(newBufferSize), nullptr, 0.0f);
if (fDescriptor != nullptr && fDescriptor->dispatcher != nullptr)
{
fDescriptor->dispatcher(fHandle, NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED, 0, static_cast<intptr_t>(newBufferSize), nullptr, 0.0f);

if (fHandle2 != nullptr)
fDescriptor->dispatcher(fHandle2, NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED, 0, static_cast<intptr_t>(newBufferSize), nullptr, 0.0f);
}
}

CarlaPlugin::bufferSizeChanged(newBufferSize);
}

void sampleRateChanged(const double newSampleRate) override


+ 1
- 1
source/backend/plugin/CarlaPluginSFZero.cpp View File

@@ -595,7 +595,7 @@ public:
#if 0
if (doBalance)
{
float oldBufLeft[frames];
float* const oldBufLeft = pData->postProc.extraBuffer;

// there was a loop here
{


+ 5
- 2
source/backend/plugin/CarlaPluginVST2.cpp View File

@@ -1746,7 +1746,7 @@ public:
// --------------------------------------------------------------------------------------------------------
// Set audio buffers

float* vstInBuffer[pData->audioIn.count];
float* vstInBuffer[64]; // pData->audioIn.count

for (uint32_t i=0; i < pData->audioIn.count; ++i)
vstInBuffer[i] = const_cast<float*>(inBuffer[i]+timeOffset);
@@ -1799,7 +1799,8 @@ public:
const bool isMono = (pData->audioIn.count == 1);

bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1];
float bufValue;
float* const oldBufLeft = pData->postProc.extraBuffer;

for (uint32_t i=0; i < pData->audioOut.count; ++i)
{
@@ -1892,6 +1893,8 @@ public:

if (pData->active)
activate();

CarlaPlugin::bufferSizeChanged(newBufferSize);
}

void sampleRateChanged(const double newSampleRate) override


+ 6
- 3
source/backend/plugin/CarlaPluginVST3.cpp View File

@@ -1738,8 +1738,8 @@ public:
// --------------------------------------------------------------------------------------------------------
// Set audio buffers

float* bufferAudioIn[std::max(1u, pData->audioIn.count + pData->cvIn.count)];
float* bufferAudioOut[std::max(1u, pData->audioOut.count + pData->cvOut.count)];
float* bufferAudioIn[96]; // std::max(1u, pData->audioIn.count + pData->cvIn.count)
float* bufferAudioOut[96]; // std::max(1u, pData->audioOut.count + pData->cvOut.count)

{
uint32_t i=0;
@@ -1810,7 +1810,8 @@ public:
const bool isMono = (pData->audioIn.count == 1);

bool isPair;
float bufValue, oldBufLeft[doBalance ? frames : 1];
float bufValue;
float* const oldBufLeft = pData->postProc.extraBuffer;

uint32_t i=0;

@@ -1906,6 +1907,8 @@ public:

if (pData->active)
activate();

CarlaPlugin::bufferSizeChanged(newBufferSize);
}

void sampleRateChanged(const double newSampleRate) override


+ 29
- 8
source/discovery/carla-discovery.cpp View File

@@ -77,6 +77,9 @@
# pragma GCC diagnostic pop
#endif

#define MAX_DISCOVERY_AUDIO_IO 64
#define MAX_DISCOVERY_CV_IO 32

#define DISCOVERY_OUT(x, y) std::cout << "\ncarla-discovery::" << x << "::" << y << std::endl;

using water::File;
@@ -286,6 +289,9 @@ static void do_ladspa_check(lib_t& libHandle, const char* const filename, const
}
}

CARLA_SAFE_ASSERT_CONTINUE(audioIns <= MAX_DISCOVERY_AUDIO_IO);
CARLA_SAFE_ASSERT_CONTINUE(audioOuts <= MAX_DISCOVERY_AUDIO_IO);

if (doInit)
{
// -----------------------------------------------------------------------
@@ -310,8 +316,8 @@ static void do_ladspa_check(lib_t& libHandle, const char* const filename, const
continue;
}

LADSPA_Data bufferAudio[kBufferSize][audioTotal];
LADSPA_Data bufferParams[parametersTotal];
LADSPA_Data* bufferParams = new LADSPA_Data[parametersTotal];
LADSPA_Data bufferAudio[kBufferSize][MAX_DISCOVERY_AUDIO_IO];
LADSPA_Data min, max, def;

for (unsigned long j=0, iA=0, iC=0; j < descriptor->PortCount; ++j)
@@ -388,6 +394,8 @@ static void do_ladspa_check(lib_t& libHandle, const char* const filename, const

descriptor->cleanup(handle);

delete[] bufferParams;

// end crash-free plugin test
// -----------------------------------------------------------------------
}
@@ -546,6 +554,9 @@ static void do_dssi_check(lib_t& libHandle, const char* const filename, const bo
}
}

CARLA_SAFE_ASSERT_CONTINUE(audioIns <= MAX_DISCOVERY_AUDIO_IO);
CARLA_SAFE_ASSERT_CONTINUE(audioOuts <= MAX_DISCOVERY_AUDIO_IO);

if (descriptor->run_synth != nullptr)
midiIns = 1;

@@ -584,8 +595,8 @@ static void do_dssi_check(lib_t& libHandle, const char* const filename, const bo
continue;
}

LADSPA_Data bufferAudio[kBufferSize][audioTotal];
LADSPA_Data bufferParams[parametersTotal];
LADSPA_Data* bufferParams = new LADSPA_Data[parametersTotal];
LADSPA_Data bufferAudio[kBufferSize][MAX_DISCOVERY_AUDIO_IO];
LADSPA_Data min, max, def;

for (unsigned long j=0, iA=0, iC=0; j < ldescriptor->PortCount; ++j)
@@ -688,6 +699,8 @@ static void do_dssi_check(lib_t& libHandle, const char* const filename, const bo

ldescriptor->cleanup(handle);

delete[] bufferParams;

// end crash-free plugin test
// -----------------------------------------------------------------------
}
@@ -1196,6 +1209,9 @@ static void do_vst2_check(lib_t& libHandle, const char* const filename, const bo
if (vstPluginCanDo(effect, "sendVstEvents") || vstPluginCanDo(effect, "sendVstMidiEvent"))
midiOuts = 1;

CARLA_SAFE_ASSERT_CONTINUE(audioIns <= MAX_DISCOVERY_AUDIO_IO);
CARLA_SAFE_ASSERT_CONTINUE(audioOuts <= MAX_DISCOVERY_AUDIO_IO);

// -----------------------------------------------------------------------
// start crash-free plugin test

@@ -1216,8 +1232,8 @@ static void do_vst2_check(lib_t& libHandle, const char* const filename, const bo
midiIns = 1;
}

float* bufferAudioIn[std::max(1U, audioIns)];
float* bufferAudioOut[std::max(1U, audioOuts)];
float* bufferAudioIn[MAX_DISCOVERY_AUDIO_IO];
float* bufferAudioOut[MAX_DISCOVERY_AUDIO_IO];

if (audioIns == 0)
{
@@ -1691,6 +1707,11 @@ static void do_vst3_check(lib_t& libHandle, const char* const filename, const bo
++parameterIns;
}

CARLA_SAFE_ASSERT_CONTINUE(audioIns <= MAX_DISCOVERY_AUDIO_IO);
CARLA_SAFE_ASSERT_CONTINUE(audioOuts <= MAX_DISCOVERY_AUDIO_IO);
CARLA_SAFE_ASSERT_CONTINUE(cvIns <= MAX_DISCOVERY_CV_IO);
CARLA_SAFE_ASSERT_CONTINUE(cvOuts <= MAX_DISCOVERY_CV_IO);

if (v3_plugin_view** const view = v3_cpp_obj(controller)->create_view(controller, "view"))
{
if (v3_cpp_obj(view)->is_platform_type_supported(view, V3_VIEW_PLATFORM_TYPE_NATIVE) == V3_TRUE)
@@ -1739,8 +1760,8 @@ static void do_vst3_check(lib_t& libHandle, const char* const filename, const bo
CARLA_SAFE_ASSERT_BREAK(v3_cpp_obj(component)->set_active(component, true) == V3_OK);
CARLA_SAFE_ASSERT_BREAK(v3_cpp_obj(processor)->set_processing(processor, true) == V3_OK);

float* bufferAudioIn[(uint)std::max(1, audioIns + cvIns)];
float* bufferAudioOut[(uint)std::max(1, audioOuts + cvOuts)];
float* bufferAudioIn[MAX_DISCOVERY_AUDIO_IO + MAX_DISCOVERY_CV_IO];
float* bufferAudioOut[MAX_DISCOVERY_AUDIO_IO + MAX_DISCOVERY_CV_IO];

if (audioIns + cvIns == 0)
{


+ 5
- 2
source/utils/CarlaPipeUtils.cpp View File

@@ -908,7 +908,8 @@ bool CarlaPipeCommon::writeAndFixMessage(const char* const msg) const noexcept

const std::size_t size(std::strlen(msg));

char fixedMsg[size+2];
char* const fixedMsg = static_cast<char*>(std::malloc(size+2));
CARLA_SAFE_ASSERT_RETURN(fixedMsg != nullptr, false);

if (size > 0)
{
@@ -938,7 +939,9 @@ bool CarlaPipeCommon::writeAndFixMessage(const char* const msg) const noexcept
fixedMsg[1] = '\0';
}

return _writeMsgBuffer(fixedMsg, size+1);
const bool ret = _writeMsgBuffer(fixedMsg, size+1);
std::free(fixedMsg);
return ret;
}

bool CarlaPipeCommon::writeEmptyMessage() const noexcept


Loading…
Cancel
Save