Signed-off-by: falkTX <falktx@falktx.com>tags/v2.5.0
| @@ -85,13 +85,23 @@ endif | |||
| # --------------------------------------------------------------------------------------------------------------------- | |||
| # Set PKG_CONFIG (can be overridden by environment variable) | |||
| ifeq ($(WINDOWS),true) | |||
| ifeq ($(WASM),true) | |||
| # Skip on wasm by default | |||
| PKG_CONFIG ?= false | |||
| else ifeq ($(WINDOWS),true) | |||
| # Build statically on Windows by default | |||
| PKG_CONFIG ?= pkg-config --static | |||
| else | |||
| PKG_CONFIG ?= pkg-config | |||
| endif | |||
| # --------------------------------------------------------------------------------------------------------------------- | |||
| # Set cross compiling flag | |||
| ifeq ($(WASM),true) | |||
| CROSS_COMPILING = true | |||
| endif | |||
| # --------------------------------------------------------------------------------------------------------------------- | |||
| # Set LINUX_OR_MACOS | |||
| @@ -21,6 +21,10 @@ | |||
| # error This file should not be compiled if building alternative-arch bridges | |||
| #endif | |||
| #ifdef CARLA_OS_WASM | |||
| # define CARLA_ENGINE_WITHOUT_UI | |||
| #endif | |||
| #include "CarlaEngineInit.hpp" | |||
| #include "CarlaEngineInternal.hpp" | |||
| #include "CarlaPlugin.hpp" | |||
| @@ -61,6 +65,7 @@ static const uint16_t kUiHeight = 712; | |||
| // ----------------------------------------------------------------------- | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| class CarlaEngineNative; | |||
| class CarlaEngineNativeUI : public CarlaExternalUI | |||
| @@ -89,6 +94,7 @@ private: | |||
| CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineNativeUI) | |||
| }; | |||
| #endif | |||
| // ----------------------------------------------------------------------- | |||
| @@ -112,8 +118,10 @@ public: | |||
| fIsActive(false), | |||
| fIsRunning(false), | |||
| fUsesEmbed(false), | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| fUiServer(this), | |||
| fLastScaleFactor(1.0f), | |||
| #endif | |||
| fLastProjectFolder(), | |||
| fPluginDeleterMutex(), | |||
| fOptionsForced(false) | |||
| @@ -280,8 +288,10 @@ public: | |||
| { | |||
| CarlaEngine::callback(sendHost, sendOsc, action, pluginId, value1, value2, value3, valuef, valueStr); | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| if (sendHost) | |||
| uiServerCallback(action, pluginId, value1, value2, value3, valuef, valueStr); | |||
| #endif | |||
| switch (action) | |||
| { | |||
| @@ -298,11 +308,13 @@ public: | |||
| { | |||
| fParameters[rindex] = valuef; | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| if (fUsesEmbed || fUiServer.isPipeRunning()) | |||
| { | |||
| pHost->ui_parameter_changed(pHost->handle, rindex, valuef); | |||
| } | |||
| else | |||
| #endif | |||
| { | |||
| static uint last_pluginId = pluginId; | |||
| static int last_value1 = value1; | |||
| @@ -390,6 +402,7 @@ protected: | |||
| if (pData->bufferSize == newBufferSize) | |||
| return; | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| { | |||
| const CarlaMutexLocker cml(fUiServer.getPipeLock()); | |||
| @@ -404,6 +417,7 @@ protected: | |||
| fUiServer.flushMessages(); | |||
| } | |||
| } | |||
| #endif | |||
| pData->bufferSize = newBufferSize; | |||
| CarlaEngine::bufferSizeChanged(newBufferSize); | |||
| @@ -414,6 +428,7 @@ protected: | |||
| if (carla_isEqual(pData->sampleRate, newSampleRate)) | |||
| return; | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| { | |||
| const CarlaMutexLocker cml(fUiServer.getPipeLock()); | |||
| @@ -431,11 +446,13 @@ protected: | |||
| fUiServer.flushMessages(); | |||
| } | |||
| } | |||
| #endif | |||
| pData->sampleRate = newSampleRate; | |||
| CarlaEngine::sampleRateChanged(newSampleRate); | |||
| } | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| // ------------------------------------------------------------------- | |||
| void uiServerSendPluginInfo(const CarlaPluginPtr& plugin) | |||
| @@ -911,6 +928,7 @@ protected: | |||
| CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),); | |||
| fUiServer.flushMessages(); | |||
| } | |||
| #endif | |||
| // ------------------------------------------------------------------- | |||
| // Plugin parameter calls | |||
| @@ -1217,6 +1235,7 @@ protected: | |||
| // ------------------------------------------------------------------- | |||
| // Plugin UI calls | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| void uiShow(const bool show) | |||
| { | |||
| if (show) | |||
| @@ -1468,6 +1487,7 @@ protected: | |||
| } | |||
| } | |||
| } | |||
| #endif | |||
| // ------------------------------------------------------------------- | |||
| // Plugin state calls | |||
| @@ -1591,6 +1611,7 @@ public: | |||
| handlePtr->setParameterValue(index, value); | |||
| } | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| static void _ui_show(NativePluginHandle handle, bool show) | |||
| { | |||
| handlePtr->uiShow(show); | |||
| @@ -1605,6 +1626,7 @@ public: | |||
| { | |||
| handlePtr->uiSetParameterValue(index, value); | |||
| } | |||
| #endif | |||
| static void _activate(NativePluginHandle handle) | |||
| { | |||
| @@ -1717,10 +1739,12 @@ private: | |||
| const bool kIsPatchbay; // rack if false | |||
| const bool kHasMidiOut; | |||
| bool fIsActive, fIsRunning, fUsesEmbed; | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| CarlaEngineNativeUI fUiServer; | |||
| float fLastScaleFactor; | |||
| #endif | |||
| float fParameters[kNumInParams+kNumOutParams]; | |||
| float fLastScaleFactor; | |||
| CarlaString fLastProjectFolder; | |||
| CarlaMutex fPluginDeleterMutex; | |||
| @@ -1779,6 +1803,7 @@ private: | |||
| // ----------------------------------------------------------------------- | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept | |||
| { | |||
| if (CarlaExternalUI::msgReceived(msg)) | |||
| @@ -2359,6 +2384,7 @@ void CarlaEngineNativeUI::_updateParamValues(const CarlaPluginPtr& plugin, | |||
| } | |||
| } | |||
| } | |||
| #endif | |||
| // ----------------------------------------------------------------------- | |||
| @@ -2391,9 +2417,13 @@ static const NativePluginDescriptor carlaRackDesc = { | |||
| CarlaEngineNative::_set_parameter_value, | |||
| /* _set_midi_program */ nullptr, | |||
| /* _set_custom_data */ nullptr, | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| CarlaEngineNative::_ui_show, | |||
| CarlaEngineNative::_ui_idle, | |||
| CarlaEngineNative::_ui_set_parameter_value, | |||
| #else | |||
| nullptr, nullptr, nullptr, | |||
| #endif | |||
| /* _ui_set_midi_program */ nullptr, | |||
| /* _ui_set_custom_data */ nullptr, | |||
| CarlaEngineNative::_activate, | |||
| @@ -2440,9 +2470,13 @@ static const NativePluginDescriptor carlaRackNoMidiOutDesc = { | |||
| CarlaEngineNative::_set_parameter_value, | |||
| /* _set_midi_program */ nullptr, | |||
| /* _set_custom_data */ nullptr, | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| CarlaEngineNative::_ui_show, | |||
| CarlaEngineNative::_ui_idle, | |||
| CarlaEngineNative::_ui_set_parameter_value, | |||
| #else | |||
| nullptr, nullptr, nullptr, | |||
| #endif | |||
| /* _ui_set_midi_program */ nullptr, | |||
| /* _ui_set_custom_data */ nullptr, | |||
| CarlaEngineNative::_activate, | |||
| @@ -2489,9 +2523,13 @@ static const NativePluginDescriptor carlaPatchbayDesc = { | |||
| CarlaEngineNative::_set_parameter_value, | |||
| /* _set_midi_program */ nullptr, | |||
| /* _set_custom_data */ nullptr, | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| CarlaEngineNative::_ui_show, | |||
| CarlaEngineNative::_ui_idle, | |||
| CarlaEngineNative::_ui_set_parameter_value, | |||
| #else | |||
| nullptr, nullptr, nullptr, | |||
| #endif | |||
| /* _ui_set_midi_program */ nullptr, | |||
| /* _ui_set_custom_data */ nullptr, | |||
| CarlaEngineNative::_activate, | |||
| @@ -2538,9 +2576,13 @@ static const NativePluginDescriptor carlaPatchbay3sDesc = { | |||
| CarlaEngineNative::_set_parameter_value, | |||
| /* _set_midi_program */ nullptr, | |||
| /* _set_custom_data */ nullptr, | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| CarlaEngineNative::_ui_show, | |||
| CarlaEngineNative::_ui_idle, | |||
| CarlaEngineNative::_ui_set_parameter_value, | |||
| #else | |||
| nullptr, nullptr, nullptr, | |||
| #endif | |||
| /* _ui_set_midi_program */ nullptr, | |||
| /* _ui_set_custom_data */ nullptr, | |||
| CarlaEngineNative::_activate, | |||
| @@ -2587,9 +2629,13 @@ static const NativePluginDescriptor carlaPatchbay16Desc = { | |||
| CarlaEngineNative::_set_parameter_value, | |||
| /* _set_midi_program */ nullptr, | |||
| /* _set_custom_data */ nullptr, | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| CarlaEngineNative::_ui_show, | |||
| CarlaEngineNative::_ui_idle, | |||
| CarlaEngineNative::_ui_set_parameter_value, | |||
| #else | |||
| nullptr, nullptr, nullptr, | |||
| #endif | |||
| /* _ui_set_midi_program */ nullptr, | |||
| /* _ui_set_custom_data */ nullptr, | |||
| CarlaEngineNative::_activate, | |||
| @@ -2636,9 +2682,13 @@ static const NativePluginDescriptor carlaPatchbay32Desc = { | |||
| CarlaEngineNative::_set_parameter_value, | |||
| /* _set_midi_program */ nullptr, | |||
| /* _set_custom_data */ nullptr, | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| CarlaEngineNative::_ui_show, | |||
| CarlaEngineNative::_ui_idle, | |||
| CarlaEngineNative::_ui_set_parameter_value, | |||
| #else | |||
| nullptr, nullptr, nullptr, | |||
| #endif | |||
| /* _ui_set_midi_program */ nullptr, | |||
| /* _ui_set_custom_data */ nullptr, | |||
| CarlaEngineNative::_activate, | |||
| @@ -2685,9 +2735,13 @@ static const NativePluginDescriptor carlaPatchbay64Desc = { | |||
| CarlaEngineNative::_set_parameter_value, | |||
| /* _set_midi_program */ nullptr, | |||
| /* _set_custom_data */ nullptr, | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| CarlaEngineNative::_ui_show, | |||
| CarlaEngineNative::_ui_idle, | |||
| CarlaEngineNative::_ui_set_parameter_value, | |||
| #else | |||
| nullptr, nullptr, nullptr, | |||
| #endif | |||
| /* _ui_set_midi_program */ nullptr, | |||
| /* _ui_set_custom_data */ nullptr, | |||
| CarlaEngineNative::_activate, | |||
| @@ -2735,9 +2789,13 @@ static const NativePluginDescriptor carlaPatchbayCVDesc = { | |||
| CarlaEngineNative::_set_parameter_value, | |||
| /* _set_midi_program */ nullptr, | |||
| /* _set_custom_data */ nullptr, | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| CarlaEngineNative::_ui_show, | |||
| CarlaEngineNative::_ui_idle, | |||
| CarlaEngineNative::_ui_set_parameter_value, | |||
| #else | |||
| nullptr, nullptr, nullptr, | |||
| #endif | |||
| /* _ui_set_midi_program */ nullptr, | |||
| /* _ui_set_custom_data */ nullptr, | |||
| CarlaEngineNative::_activate, | |||
| @@ -2785,9 +2843,13 @@ static const NativePluginDescriptor carlaPatchbayCV8Desc = { | |||
| CarlaEngineNative::_set_parameter_value, | |||
| /* _set_midi_program */ nullptr, | |||
| /* _set_custom_data */ nullptr, | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| CarlaEngineNative::_ui_show, | |||
| CarlaEngineNative::_ui_idle, | |||
| CarlaEngineNative::_ui_set_parameter_value, | |||
| #else | |||
| nullptr, nullptr, nullptr, | |||
| #endif | |||
| /* _ui_set_midi_program */ nullptr, | |||
| /* _ui_set_custom_data */ nullptr, | |||
| CarlaEngineNative::_activate, | |||
| @@ -2835,9 +2897,13 @@ static const NativePluginDescriptor carlaPatchbayCV32Desc = { | |||
| CarlaEngineNative::_set_parameter_value, | |||
| /* _set_midi_program */ nullptr, | |||
| /* _set_custom_data */ nullptr, | |||
| #ifndef CARLA_ENGINE_WITHOUT_UI | |||
| CarlaEngineNative::_ui_show, | |||
| CarlaEngineNative::_ui_idle, | |||
| CarlaEngineNative::_ui_set_parameter_value, | |||
| #else | |||
| nullptr, nullptr, nullptr, | |||
| #endif | |||
| /* _ui_set_midi_program */ nullptr, | |||
| /* _ui_set_custom_data */ nullptr, | |||
| CarlaEngineNative::_activate, | |||
| @@ -49,6 +49,10 @@ extern "C" { | |||
| # endif | |||
| #endif | |||
| #ifdef CARLA_OS_WASM | |||
| # define LV2_UIS_ONLY_INPROCESS | |||
| #endif | |||
| #include <string> | |||
| #include <vector> | |||
| @@ -485,6 +489,7 @@ struct CarlaPluginLV2Options { | |||
| CARLA_DECLARE_NON_COPYABLE(CarlaPluginLV2Options); | |||
| }; | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| class CarlaPluginLV2; | |||
| @@ -576,6 +581,7 @@ private: | |||
| }; | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| #endif | |||
| static void initAtomForge(LV2_Atom_Forge& atomForge) noexcept | |||
| { | |||
| @@ -648,7 +654,9 @@ public: | |||
| fEventsIn(), | |||
| fEventsOut(), | |||
| fLv2Options(), | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| fPipeServer(engine, this), | |||
| #endif | |||
| fCustomURIDs(kUridCount, std::string("urn:null")), | |||
| fFirstActive(true), | |||
| fLastStateChunk(nullptr), | |||
| @@ -675,11 +683,13 @@ public: | |||
| { | |||
| showCustomUI(false); | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| if (fUI.type == UI::TYPE_BRIDGE) | |||
| { | |||
| fPipeServer.stopPipeServer(pData->engine->getOptions().uiBridgesTimeout); | |||
| } | |||
| else | |||
| #endif | |||
| { | |||
| if (fFeatures[kFeatureIdUiDataAccess] != nullptr && fFeatures[kFeatureIdUiDataAccess]->data != nullptr) | |||
| delete (LV2_Extension_Data_Feature*)fFeatures[kFeatureIdUiDataAccess]->data; | |||
| @@ -1466,8 +1476,10 @@ public: | |||
| if (fFeatures[kFeatureIdExternalUi] != nullptr && fFeatures[kFeatureIdExternalUi]->data != nullptr) | |||
| ((LV2_External_UI_Host*)fFeatures[kFeatureIdExternalUi]->data)->plugin_human_id = fLv2Options.windowTitle; | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| if (fPipeServer.isPipeRunning()) | |||
| fPipeServer.writeUiTitleMessage(fLv2Options.windowTitle); | |||
| #endif | |||
| #ifndef LV2_UIS_ONLY_BRIDGES | |||
| if (fUI.window != nullptr) | |||
| @@ -1786,6 +1798,7 @@ public: | |||
| pData->transientTryCounter = 0; | |||
| #endif | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| if (fUI.type == UI::TYPE_BRIDGE) | |||
| { | |||
| if (yesNo) | |||
| @@ -1916,6 +1929,7 @@ public: | |||
| } | |||
| return; | |||
| } | |||
| #endif | |||
| // take some precautions | |||
| CARLA_SAFE_ASSERT_RETURN(fUI.descriptor != nullptr,); | |||
| @@ -2188,12 +2202,14 @@ public: | |||
| for (; tmpRingBuffer.get(atom, portIndex);) | |||
| { | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| if (fUI.type == UI::TYPE_BRIDGE) | |||
| { | |||
| if (fPipeServer.isPipeRunning()) | |||
| fPipeServer.writeLv2AtomMessage(portIndex, atom); | |||
| } | |||
| else | |||
| #endif | |||
| { | |||
| if (hasPortEvent && ! fNeedsUiClose) | |||
| fUI.descriptor->port_event(fUI.handle, portIndex, lv2_atom_total_size(atom), kUridAtomTransferEvent, atom); | |||
| @@ -2203,6 +2219,7 @@ public: | |||
| } | |||
| } | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| if (fPipeServer.isPipeRunning()) | |||
| { | |||
| fPipeServer.idlePipe(); | |||
| @@ -2231,6 +2248,7 @@ public: | |||
| { | |||
| // TODO - detect if ui-bridge crashed | |||
| } | |||
| #endif | |||
| if (fNeedsUiClose) | |||
| { | |||
| @@ -4943,12 +4961,14 @@ public: | |||
| CARLA_SAFE_ASSERT_RETURN(index < pData->param.count,); | |||
| CARLA_SAFE_ASSERT_RETURN(pData->param.data[index].rindex >= 0,); | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| if (fUI.type == UI::TYPE_BRIDGE) | |||
| { | |||
| if (! fPipeServer.isPipeRunning()) | |||
| return; | |||
| } | |||
| else | |||
| #endif | |||
| { | |||
| if (fUI.handle == nullptr) | |||
| return; | |||
| @@ -4970,11 +4990,14 @@ public: | |||
| const char* const uri = fRdfDescriptor->Parameters[rindex].URI; | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| if (fUI.type == UI::TYPE_BRIDGE) | |||
| { | |||
| fPipeServer.writeLv2ParameterMessage(uri, value); | |||
| } | |||
| else if (fEventsIn.ctrl != nullptr) | |||
| else | |||
| #endif | |||
| if (fEventsIn.ctrl != nullptr) | |||
| { | |||
| uint8_t atomBuf[256]; | |||
| LV2_Atom_Forge atomForge; | |||
| @@ -5028,11 +5051,13 @@ public: | |||
| } | |||
| else | |||
| { | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| if (fUI.type == UI::TYPE_BRIDGE) | |||
| { | |||
| fPipeServer.writeControlMessage(static_cast<uint32_t>(pData->param.data[index].rindex), value); | |||
| } | |||
| else | |||
| #endif | |||
| { | |||
| fUI.descriptor->port_event(fUI.handle, | |||
| static_cast<uint32_t>(pData->param.data[index].rindex), | |||
| @@ -5046,12 +5071,14 @@ public: | |||
| CARLA_SAFE_ASSERT_RETURN(fUI.type != UI::TYPE_NULL || fFilePathURI.isNotEmpty(),); | |||
| CARLA_SAFE_ASSERT_RETURN(index < pData->midiprog.count,); | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| if (fUI.type == UI::TYPE_BRIDGE) | |||
| { | |||
| if (fPipeServer.isPipeRunning()) | |||
| fPipeServer.writeMidiProgramMessage(pData->midiprog.data[index].bank, pData->midiprog.data[index].program); | |||
| } | |||
| else | |||
| #endif | |||
| { | |||
| if (fExt.uiprograms != nullptr && fExt.uiprograms->select_program != nullptr && ! fNeedsUiClose) | |||
| fExt.uiprograms->select_program(fUI.handle, pData->midiprog.data[index].bank, pData->midiprog.data[index].program); | |||
| @@ -5666,8 +5693,10 @@ public: | |||
| fCustomURIDs.push_back(uri); | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| if (fUI.type == UI::TYPE_BRIDGE && fPipeServer.isPipeRunning()) | |||
| fPipeServer.writeLv2UridMessage(urid, uri); | |||
| #endif | |||
| return urid; | |||
| } | |||
| @@ -6353,10 +6382,12 @@ public: | |||
| return fDescriptor; | |||
| } | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| uintptr_t getUiBridgeProcessId() const noexcept override | |||
| { | |||
| return fPipeServer.isPipeRunning() ? fPipeServer.getPID() : 0; | |||
| } | |||
| #endif | |||
| // ------------------------------------------------------------------- | |||
| @@ -7044,8 +7075,9 @@ public: | |||
| // --------------------------------------------------------------- | |||
| // initialize ui according to type | |||
| const LV2_Property uiType(fUI.rdfDescriptor->Type); | |||
| const LV2_Property uiType = fUI.rdfDescriptor->Type; | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| if ( | |||
| (iFinal == eQt4 || | |||
| iFinal == eQt5 || | |||
| @@ -7095,6 +7127,7 @@ public: | |||
| return; | |||
| } | |||
| } | |||
| #endif | |||
| #ifdef LV2_UIS_ONLY_BRIDGES | |||
| carla_stderr2("Failed to get an UI working, canBridge:%s", bool2str(isUiBridgeable(static_cast<uint32_t>(iFinal)))); | |||
| @@ -7435,7 +7468,9 @@ private: | |||
| CarlaPluginLV2EventData fEventsIn; | |||
| CarlaPluginLV2EventData fEventsOut; | |||
| CarlaPluginLV2Options fLv2Options; | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| CarlaPipeServerLV2 fPipeServer; | |||
| #endif | |||
| std::vector<std::string> fCustomURIDs; | |||
| @@ -7476,7 +7511,9 @@ private: | |||
| struct UI { | |||
| enum Type { | |||
| TYPE_NULL = 0, | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| TYPE_BRIDGE, | |||
| #endif | |||
| TYPE_EMBED, | |||
| TYPE_EXTERNAL | |||
| }; | |||
| @@ -8124,6 +8161,7 @@ private: | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| #ifndef LV2_UIS_ONLY_INPROCESS | |||
| bool CarlaPipeServerLV2::msgReceived(const char* const msg) noexcept | |||
| { | |||
| if (std::strcmp(msg, "exiting") == 0) | |||
| @@ -8254,6 +8292,7 @@ bool CarlaPipeServerLV2::msgReceived(const char* const msg) noexcept | |||
| return false; | |||
| } | |||
| #endif | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| @@ -2565,6 +2565,7 @@ public: | |||
| sCurrentUniqueId = static_cast<intptr_t>(uniqueId); | |||
| sLastCarlaPluginVST2 = this; | |||
| #if !(defined(CARLA_OS_WASM) || defined(CARLA_OS_WIN)) | |||
| bool wasTriggered, wasThrown = false; | |||
| { | |||
| const ScopedAbortCatcher sac; | |||
| @@ -2587,6 +2588,7 @@ public: | |||
| fEffect = vstFn(carla_vst_audioMasterCallback); | |||
| } CARLA_SAFE_EXCEPTION_RETURN("VST init 2nd attempt", false); | |||
| } | |||
| #endif | |||
| sLastCarlaPluginVST2 = nullptr; | |||
| sCurrentUniqueId = 0; | |||
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * Carla Native Plugin API (C++) | |||
| * Copyright (C) 2012-2020 Filipe Coelho <falktx@falktx.com> | |||
| * Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * This program is free software; you can redistribute it and/or | |||
| * modify it under the terms of the GNU General Public License as | |||
| @@ -30,13 +30,17 @@ | |||
| // ----------------------------------------------------------------------- | |||
| // Native Plugin and External UI class | |||
| class NativePluginAndUiClass : public NativePluginClass, | |||
| public CarlaExternalUI | |||
| class NativePluginAndUiClass : public NativePluginClass | |||
| #ifndef CARLA_OS_WASM | |||
| , public CarlaExternalUI | |||
| #endif | |||
| { | |||
| public: | |||
| NativePluginAndUiClass(const NativeHostDescriptor* const host, const char* const pathToExternalUI) | |||
| : NativePluginClass(host), | |||
| #ifndef CARLA_OS_WASM | |||
| CarlaExternalUI(), | |||
| #endif | |||
| fExtUiPath(getResourceDir()) | |||
| { | |||
| fExtUiPath += CARLA_OS_SEP_STR; | |||
| @@ -51,6 +55,7 @@ public: | |||
| return fExtUiPath; | |||
| } | |||
| #ifndef CARLA_OS_WASM | |||
| protected: | |||
| // ------------------------------------------------------------------- | |||
| // Plugin UI calls | |||
| @@ -212,6 +217,7 @@ protected: | |||
| return false; | |||
| } | |||
| #endif | |||
| private: | |||
| CarlaString fExtUiPath; | |||
| @@ -306,6 +306,7 @@ protected: | |||
| fLastFrame = fTimeInfo.frame; | |||
| } | |||
| #ifndef CARLA_OS_WASM | |||
| // ------------------------------------------------------------------- | |||
| // Plugin UI calls | |||
| @@ -355,6 +356,7 @@ protected: | |||
| flushMessages(); | |||
| } | |||
| } | |||
| #endif | |||
| // ------------------------------------------------------------------- | |||
| // Plugin state calls | |||
| @@ -368,8 +370,10 @@ protected: | |||
| { | |||
| fMidiOut.setState(data); | |||
| #ifndef CARLA_OS_WASM | |||
| if (isPipeRunning()) | |||
| _sendEventsToUI(); | |||
| #endif | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| @@ -397,6 +401,7 @@ protected: | |||
| NativePluginAndUiClass::writeMidiEvent(&midiEvent); | |||
| } | |||
| #ifndef CARLA_OS_WASM | |||
| // ------------------------------------------------------------------- | |||
| // Pipe Server calls | |||
| @@ -481,6 +486,7 @@ protected: | |||
| return false; | |||
| } | |||
| #endif | |||
| // ------------------------------------------------------------------- | |||
| @@ -502,6 +508,7 @@ private: | |||
| float fParameters[kParameterCount]; | |||
| #ifndef CARLA_OS_WASM | |||
| void _sendEventsToUI() const noexcept | |||
| { | |||
| char strBuf[0xff+1]; | |||
| @@ -540,6 +547,7 @@ private: | |||
| } | |||
| } | |||
| } | |||
| #endif | |||
| PluginClassEND(MidiPatternPlugin) | |||
| CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MidiPatternPlugin) | |||
| @@ -168,6 +168,7 @@ protected: | |||
| writeMidiEvent(&midiEvents[i]); | |||
| } | |||
| #ifndef CARLA_OS_WASM | |||
| // ------------------------------------------------------------------- | |||
| // Pipe Server calls | |||
| @@ -242,6 +243,7 @@ protected: | |||
| return false; | |||
| } | |||
| #endif | |||
| private: | |||
| float params[kParamCount]; | |||
| @@ -143,6 +143,25 @@ SYMBOLS_LV2 += -Wl,-exported_symbol,_lv2ui_descriptor | |||
| SYMBOLS_LV2_UI = -Wl,-exported_symbol,_lv2ui_descriptor | |||
| endif | |||
| SYMBOLS_VST = -Wl,-exported_symbol,_VSTPluginMain | |||
| else ifeq ($(WASM),true) | |||
| SYMBOLS_NATIVE = -sSIDE_MODULE=2 -sEXPORTED_FUNCTIONS="[ | |||
| SYMBOLS_NATIVE += 'carla_get_native_rack_plugin', | |||
| SYMBOLS_NATIVE += 'carla_get_native_patchbay_plugin', | |||
| SYMBOLS_NATIVE += 'carla_get_native_patchbay16_plugin', | |||
| SYMBOLS_NATIVE += 'carla_get_native_patchbay32_plugin', | |||
| SYMBOLS_NATIVE += 'carla_get_native_patchbay64_plugin', | |||
| SYMBOLS_NATIVE += 'carla_get_native_patchbay_cv_plugin', | |||
| SYMBOLS_NATIVE += 'carla_create_native_plugin_host_handle', | |||
| SYMBOLS_NATIVE += 'carla_host_handle_free', | |||
| SYMBOLS_NATIVE += 'carla_get_native_plugin_engine' | |||
| SYMBOLS_NATIVE += ]" | |||
| ifeq ($(HAVE_PYQT),true) | |||
| SYMBOLS_LV2 = -sSIDE_MODULE=2 -sEXPORTED_FUNCTIONS="['lv2_descriptor','lv2ui_descriptor']" | |||
| SYMBOLS_LV2_UI = -sSIDE_MODULE=2 -sEXPORTED_FUNCTIONS="['lv2ui_descriptor']" | |||
| else | |||
| SYMBOLS_LV2 = -sSIDE_MODULE=2 -sEXPORTED_FUNCTIONS="['lv2_descriptor']" | |||
| endif | |||
| SYMBOLS_VST = -sSIDE_MODULE=2 -sEXPORTED_FUNCTIONS="['VSTPluginMain']" | |||
| else ifeq ($(WINDOWS),true) | |||
| SYMBOLS_NATIVE = symbols/carla-native-plugin.def | |||
| SYMBOLS_VST = symbols/carla-vst.def | |||
| @@ -112,7 +112,7 @@ const AEffect* VSTPluginMain(audioMasterCallback audioMaster) | |||
| return VSTPluginMainInit(effect); | |||
| } | |||
| #if ! (defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN)) | |||
| #if ! (defined(CARLA_OS_MAC) || defined(CARLA_OS_WASM) || defined(CARLA_OS_WIN)) | |||
| CARLA_PLUGIN_EXPORT __cdecl | |||
| const AEffect* VSTPluginMain_asm(audioMasterCallback audioMaster) asm ("main"); | |||
| @@ -130,12 +130,10 @@ $(BINDIR)/carla-host-plugin: carla-host-plugin.c | |||
| # --------------------------------------------------------------------------------------------------------------------- | |||
| # $(CWD)/../build/plugin/Release/carla-host-plugin.cpp.o \ | |||
| .PHONY: carla-engine-sdl$(APP_EXT) | |||
| carla-engine-sdl$(APP_EXT): $(OBJDIR)/carla-engine-sdl.c.o | |||
| $(CC) $< \ | |||
| $(CWD)/../build/backend/Release/CarlaStandalone.cpp.o \ | |||
| carla-engine-sdl$(APP_EXT): $(OBJDIR)/carla-engine-sdl.c.o $(OBJDIR)/carla-engine-sdl-extra.cpp.o | |||
| $(CC) $^ \ | |||
| $(CWD)/../build/plugin/Release/carla-host-plugin.cpp.o \ | |||
| $(MODULEDIR)/carla_engine.a \ | |||
| $(MODULEDIR)/carla_plugin.a \ | |||
| $(MODULEDIR)/lilv.a \ | |||
| @@ -0,0 +1,25 @@ | |||
| /* | |||
| * Carla Host Plugin SDL test | |||
| * Copyright (C) 2022 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * This program is free software; you can redistribute it and/or | |||
| * modify it under the terms of the GNU General Public License as | |||
| * published by the Free Software Foundation; either version 2 of | |||
| * the License, or any later version. | |||
| * | |||
| * This program is distributed in the hope that it will be useful, | |||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| * GNU General Public License for more details. | |||
| * | |||
| * For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
| */ | |||
| #define CARLA_PLUGIN_UI_CLASS_PREFIX Standalone | |||
| #include "CarlaPluginUI.cpp" | |||
| // #include "CarlaDssiUtils.cpp" | |||
| // #include "CarlaMacUtils.cpp" | |||
| // #include "CarlaPatchbayUtils.cpp" | |||
| // #include "CarlaPipeUtils.cpp" | |||
| #include "CarlaProcessUtils.cpp" | |||
| #include "CarlaStateUtils.cpp" | |||
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * Carla process utils | |||
| * Copyright (C) 2019-2020 Filipe Coelho <falktx@falktx.com> | |||
| * Copyright (C) 2019-2022 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * This program is free software; you can redistribute it and/or | |||
| * modify it under the terms of the GNU General Public License as | |||
| @@ -20,27 +20,23 @@ | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| // process utility classes | |||
| #if !(defined(CARLA_OS_WASM) || defined(CARLA_OS_WIN)) | |||
| ScopedAbortCatcher::ScopedAbortCatcher() | |||
| { | |||
| s_triggered = false; | |||
| #ifndef CARLA_OS_WIN | |||
| s_oldsig = ::setjmp(s_env) == 0 | |||
| ? std::signal(SIGABRT, sig_handler) | |||
| : nullptr; | |||
| #endif | |||
| } | |||
| ScopedAbortCatcher::~ScopedAbortCatcher() | |||
| { | |||
| #ifndef CARLA_OS_WIN | |||
| if (s_oldsig != nullptr && ! s_triggered) | |||
| std::signal(SIGABRT, s_oldsig); | |||
| #endif | |||
| } | |||
| bool ScopedAbortCatcher::s_triggered = false; | |||
| #ifndef CARLA_OS_WIN | |||
| jmp_buf ScopedAbortCatcher::s_env; | |||
| sig_t ScopedAbortCatcher::s_oldsig; | |||
| @@ -58,7 +54,7 @@ void ScopedAbortCatcher::sig_handler(const int signum) | |||
| CarlaSignalRestorer::CarlaSignalRestorer() | |||
| { | |||
| #ifndef CARLA_OS_WIN | |||
| #if !(defined(CARLA_OS_WASM) || defined(CARLA_OS_WIN)) | |||
| carla_zeroStructs(sigs, 16); | |||
| for (int i=0; i < 16; ++i) | |||
| @@ -68,7 +64,7 @@ CarlaSignalRestorer::CarlaSignalRestorer() | |||
| CarlaSignalRestorer::~CarlaSignalRestorer() | |||
| { | |||
| #ifndef CARLA_OS_WIN | |||
| #if !(defined(CARLA_OS_WASM) || defined(CARLA_OS_WIN)) | |||
| for (int i=0; i < 16; ++i) | |||
| ::sigaction(i+1, &sigs[i], nullptr); | |||
| #endif | |||
| @@ -95,6 +95,7 @@ void carla_terminateProcessOnParentExit(const bool kill) noexcept | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| // process utility classes | |||
| #if !(defined(CARLA_OS_WASM) || defined(CARLA_OS_WIN)) | |||
| /* | |||
| * Catches SIGABRT for a function scope. | |||
| */ | |||
| @@ -110,15 +111,14 @@ public: | |||
| private: | |||
| static bool s_triggered; | |||
| #ifndef CARLA_OS_WIN | |||
| static jmp_buf s_env; | |||
| static sig_t s_oldsig; | |||
| static void sig_handler(const int signum); | |||
| #endif | |||
| CARLA_DECLARE_NON_COPYABLE(ScopedAbortCatcher) | |||
| CARLA_PREVENT_HEAP_ALLOCATION | |||
| }; | |||
| #endif | |||
| /* | |||
| * Store and restore all signal handlers for a function scope. | |||
| @@ -129,7 +129,7 @@ public: | |||
| ~CarlaSignalRestorer(); | |||
| private: | |||
| #ifndef CARLA_OS_WIN | |||
| #if !(defined(CARLA_OS_WASM) || defined(CARLA_OS_WIN)) | |||
| struct ::sigaction sigs[16]; | |||
| #endif | |||