diff --git a/source/backend/engine/CarlaEngineBridge.cpp b/source/backend/engine/CarlaEngineBridge.cpp index cd0c12b4f..02031cc2f 100644 --- a/source/backend/engine/CarlaEngineBridge.cpp +++ b/source/backend/engine/CarlaEngineBridge.cpp @@ -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 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; diff --git a/source/backend/engine/CarlaEngineGraph.cpp b/source/backend/engine/CarlaEngineGraph.cpp index d92154d4a..0f2bb96a5 100644 --- a/source/backend/engine/CarlaEngineGraph.cpp +++ b/source/backend/engine/CarlaEngineGraph.cpp @@ -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; jgetAudioInCount() == 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; iactive); } -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) diff --git a/source/backend/plugin/CarlaPluginBridge.cpp b/source/backend/plugin/CarlaPluginBridge.cpp index 1299c60fa..ae8eada79 100644 --- a/source/backend/plugin/CarlaPluginBridge.cpp +++ b/source/backend/plugin/CarlaPluginBridge.cpp @@ -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; jevent.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 diff --git a/source/backend/plugin/CarlaPluginCLAP.cpp b/source/backend/plugin/CarlaPluginCLAP.cpp index c8c2142e2..0c52c1f9d 100644 --- a/source/backend/plugin/CarlaPluginCLAP.cpp +++ b/source/backend/plugin/CarlaPluginCLAP.cpp @@ -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 diff --git a/source/backend/plugin/CarlaPluginFluidSynth.cpp b/source/backend/plugin/CarlaPluginFluidSynth.cpp index 37339530f..cfcf00710 100644 --- a/source/backend/plugin/CarlaPluginFluidSynth.cpp +++ b/source/backend/plugin/CarlaPluginFluidSynth.cpp @@ -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 diff --git a/source/backend/plugin/CarlaPluginInternal.cpp b/source/backend/plugin/CarlaPluginInternal.cpp index 017004a21..3f7bbd2e9 100644 --- a/source/backend/plugin/CarlaPluginInternal.cpp +++ b/source/backend/plugin/CarlaPluginInternal.cpp @@ -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 } // ----------------------------------------------------------------------- diff --git a/source/backend/plugin/CarlaPluginInternal.hpp b/source/backend/plugin/CarlaPluginInternal.hpp index 3be242d02..5d8c2e00b 100644 --- a/source/backend/plugin/CarlaPluginInternal.hpp +++ b/source/backend/plugin/CarlaPluginInternal.hpp @@ -392,6 +392,7 @@ struct CarlaPlugin::ProtectedData { float balanceLeft; float balanceRight; float panning; + float* extraBuffer; PostProc() noexcept; diff --git a/source/backend/plugin/CarlaPluginJack.cpp b/source/backend/plugin/CarlaPluginJack.cpp index b4e5b2627..d7f14c3d7 100644 --- a/source/backend/plugin/CarlaPluginJack.cpp +++ b/source/backend/plugin/CarlaPluginJack.cpp @@ -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) { diff --git a/source/backend/plugin/CarlaPluginJuce.cpp b/source/backend/plugin/CarlaPluginJuce.cpp index a0f255263..91c16d8ba 100644 --- a/source/backend/plugin/CarlaPluginJuce.cpp +++ b/source/backend/plugin/CarlaPluginJuce.cpp @@ -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 diff --git a/source/backend/plugin/CarlaPluginLADSPADSSI.cpp b/source/backend/plugin/CarlaPluginLADSPADSSI.cpp index b24224fec..5a74dcb05 100644 --- a/source/backend/plugin/CarlaPluginLADSPADSSI.cpp +++ b/source/backend/plugin/CarlaPluginLADSPADSSI.cpp @@ -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 diff --git a/source/backend/plugin/CarlaPluginLV2.cpp b/source/backend/plugin/CarlaPluginLV2.cpp index 28b08f110..62f3efa43 100644 --- a/source/backend/plugin/CarlaPluginLV2.cpp +++ b/source/backend/plugin/CarlaPluginLV2.cpp @@ -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(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(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(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 diff --git a/source/backend/plugin/CarlaPluginNative.cpp b/source/backend/plugin/CarlaPluginNative.cpp index ba10e7af5..5537461b9 100644 --- a/source/backend/plugin/CarlaPluginNative.cpp +++ b/source/backend/plugin/CarlaPluginNative.cpp @@ -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(newBufferSize), nullptr, 0.0f); + fCurBufferSize = newBufferSize; - if (fHandle2 != nullptr) - fDescriptor->dispatcher(fHandle2, NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED, 0, static_cast(newBufferSize), nullptr, 0.0f); + if (fDescriptor != nullptr && fDescriptor->dispatcher != nullptr) + { + fDescriptor->dispatcher(fHandle, NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED, 0, static_cast(newBufferSize), nullptr, 0.0f); + + if (fHandle2 != nullptr) + fDescriptor->dispatcher(fHandle2, NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED, 0, static_cast(newBufferSize), nullptr, 0.0f); + } } + + CarlaPlugin::bufferSizeChanged(newBufferSize); } void sampleRateChanged(const double newSampleRate) override diff --git a/source/backend/plugin/CarlaPluginSFZero.cpp b/source/backend/plugin/CarlaPluginSFZero.cpp index 05b4666ac..ff5509a0e 100644 --- a/source/backend/plugin/CarlaPluginSFZero.cpp +++ b/source/backend/plugin/CarlaPluginSFZero.cpp @@ -595,7 +595,7 @@ public: #if 0 if (doBalance) { - float oldBufLeft[frames]; + float* const oldBufLeft = pData->postProc.extraBuffer; // there was a loop here { diff --git a/source/backend/plugin/CarlaPluginVST2.cpp b/source/backend/plugin/CarlaPluginVST2.cpp index 0cfa53d9b..818ae1be1 100644 --- a/source/backend/plugin/CarlaPluginVST2.cpp +++ b/source/backend/plugin/CarlaPluginVST2.cpp @@ -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(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 diff --git a/source/backend/plugin/CarlaPluginVST3.cpp b/source/backend/plugin/CarlaPluginVST3.cpp index 42a0824ec..07be45309 100644 --- a/source/backend/plugin/CarlaPluginVST3.cpp +++ b/source/backend/plugin/CarlaPluginVST3.cpp @@ -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 diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index 569d6805f..64eca858f 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -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) { diff --git a/source/utils/CarlaPipeUtils.cpp b/source/utils/CarlaPipeUtils.cpp index 93cdcdbfb..30ba1d154 100644 --- a/source/utils/CarlaPipeUtils.cpp +++ b/source/utils/CarlaPipeUtils.cpp @@ -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(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