diff --git a/source/backend/plugin/CarlaPlugin.cpp b/source/backend/plugin/CarlaPlugin.cpp index 26c4c4f29..539883332 100644 --- a/source/backend/plugin/CarlaPlugin.cpp +++ b/source/backend/plugin/CarlaPlugin.cpp @@ -1819,7 +1819,7 @@ bool CarlaPlugin::waitForOscGuiShow() uint i=0, oscUiTimeout = kData->engine->getOptions().oscUiTimeout; // wait for UI 'update' call - for (; i < oscUiTimeout; i++) + for (; i < oscUiTimeout/100; ++i) { if (kData->osc.data.target != nullptr) { diff --git a/source/backend/plugin/CarlaPlugin.pro b/source/backend/plugin/CarlaPlugin.pro index 3a515f138..acc9b312c 100644 --- a/source/backend/plugin/CarlaPlugin.pro +++ b/source/backend/plugin/CarlaPlugin.pro @@ -9,10 +9,10 @@ VERSION = 1.0 QT = core gui xml CONFIG = debug -CONFIG += link_pkgconfig moc qt shared warn_on +CONFIG += link_pkgconfig qt shared warn_on DEFINES = DEBUG -DEFINES += QTCREATOR_TEST MOC_PARSING +DEFINES += QTCREATOR_TEST # Shared DEFINES += WANT_NATIVE diff --git a/source/backend/plugin/CarlaPluginThread.cpp b/source/backend/plugin/CarlaPluginThread.cpp index 3922c8203..4f5294423 100644 --- a/source/backend/plugin/CarlaPluginThread.cpp +++ b/source/backend/plugin/CarlaPluginThread.cpp @@ -80,9 +80,26 @@ void CarlaPluginThread::run() { fProcess = new QProcess(nullptr); fProcess->setProcessChannelMode(QProcess::ForwardedChannels); -#ifndef BUILD_BRIDGE - //fProcess->setProcessEnvironment(kEngine->getOptionsAsProcessEnvironment()); -#endif + } + else if (fProcess->state() == QProcess::Running) + { + carla_stderr("CarlaPluginThread::run() - already running, giving up..."); + + switch (fMode) + { + case PLUGIN_THREAD_NULL: + break; + + case PLUGIN_THREAD_DSSI_GUI: + case PLUGIN_THREAD_LV2_GUI: + case PLUGIN_THREAD_VST_GUI: + fProcess->terminate(); + kEngine->callback(CarlaBackend::CALLBACK_SHOW_GUI, kPlugin->id(), -1, 0, 0.0f, nullptr); + return; + + case PLUGIN_THREAD_BRIDGE: + break; + } } QString name(kPlugin->name()); @@ -151,20 +168,31 @@ void CarlaPluginThread::run() { // Kill kEngine->callback(CarlaBackend::CALLBACK_SHOW_GUI, kPlugin->id(), -1, 0, 0.0f, nullptr); - carla_stderr("CarlaPluginThread::run() - GUI crashed"); + carla_stderr("CarlaPluginThread::run() - GUI crashed while running"); } } else { - carla_debug("CarlaPluginThread::run() - GUI timeout"); - kEngine->callback(CarlaBackend::CALLBACK_SHOW_GUI, kPlugin->id(), 0, 0, 0.0f, nullptr); + fProcess->close(); + CARLA_ASSERT(fProcess->state() == QProcess::NotRunning); + + if (fProcess->exitCode() != 0 || fProcess->exitStatus() == QProcess::CrashExit) + { + kEngine->callback(CarlaBackend::CALLBACK_SHOW_GUI, kPlugin->id(), -1, 0, 0.0f, nullptr); + carla_stderr("CarlaPluginThread::run() - GUI crashed while opening"); + } + else + { + kEngine->callback(CarlaBackend::CALLBACK_SHOW_GUI, kPlugin->id(), 0, 0, 0.0f, nullptr); + carla_debug("CarlaPluginThread::run() - GUI timeout"); + } } break; case PLUGIN_THREAD_BRIDGE: fProcess->waitForFinished(-1); - if (fProcess->exitCode() != 0) + if (fProcess->exitCode() != 0 || fProcess->exitStatus() == QProcess::CrashExit) { carla_stderr("CarlaPluginThread::run() - bridge crashed"); diff --git a/source/backend/plugin/Lv2Plugin.cpp b/source/backend/plugin/Lv2Plugin.cpp index e660327b4..406587770 100644 --- a/source/backend/plugin/Lv2Plugin.cpp +++ b/source/backend/plugin/Lv2Plugin.cpp @@ -515,11 +515,15 @@ public: uint32_t midiInCount() const override { + CARLA_ASSERT(fRdfDescriptor != nullptr); + uint32_t i, count = 0; - for (i=0; i < fEventsIn.count; ++i) + for (i=0; i < fRdfDescriptor->PortCount; ++i) { - if (fEventsIn.data[i].type & CARLA_EVENT_TYPE_MIDI) + const LV2_Property portTypes(fRdfDescriptor->Ports[i].Types); + + if (LV2_IS_PORT_INPUT(portTypes) && LV2_PORT_SUPPORTS_MIDI_EVENT(portTypes)) count += 1; } @@ -528,11 +532,15 @@ public: uint32_t midiOutCount() const override { + CARLA_ASSERT(fRdfDescriptor != nullptr); + uint32_t i, count = 0; - for (i=0; i < fEventsOut.count; ++i) + for (i=0; i < fRdfDescriptor->PortCount; ++i) { - if (fEventsOut.data[i].type & CARLA_EVENT_TYPE_MIDI) + const LV2_Property portTypes(fRdfDescriptor->Ports[i].Types); + + if (LV2_IS_PORT_OUTPUT(portTypes) && LV2_PORT_SUPPORTS_MIDI_EVENT(portTypes)) count += 1; } @@ -565,11 +573,15 @@ public: unsigned int availableOptions() override { + CARLA_ASSERT(fRdfDescriptor != nullptr); + unsigned int options = 0x0; - options |= PLUGIN_OPTION_FIXED_BUFFER; options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES; + if (! needsFixedBuffer()) + options |= PLUGIN_OPTION_FIXED_BUFFER; + if (kData->engine->getProccessMode() != PROCESS_MODE_CONTINUOUS_RACK) { if (fOptions & PLUGIN_OPTION_FORCE_STEREO) @@ -578,7 +590,7 @@ public: options |= PLUGIN_OPTION_FORCE_STEREO; } - //if (fDescriptor->midiIns > 0) + if (midiInCount() > 0) { options |= PLUGIN_OPTION_SEND_CONTROL_CHANGES; options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE; @@ -3309,6 +3321,21 @@ protected: // ------------------------------------------------------------------- + bool needsFixedBuffer() + { + CARLA_ASSERT(fRdfDescriptor != nullptr); + + for (uint32_t i=0; i < fRdfDescriptor->FeatureCount; ++i) + { + if (std::strcmp(fRdfDescriptor->Features[i].URI, LV2_BUF_SIZE__fixedBlockLength) == 0) + return true; + } + + return false; + } + + // ------------------------------------------------------------------- + const char* getUiBridgePath(const LV2_Property type) { const EngineOptions& options(kData->engine->getOptions()); @@ -3716,13 +3743,15 @@ public: // set default options fOptions = 0x0; - fOptions |= PLUGIN_OPTION_FIXED_BUFFER; fOptions |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES; + if (needsFixedBuffer()) + fOptions |= PLUGIN_OPTION_FIXED_BUFFER; + if (kData->engine->getOptions().forceStereo) fOptions |= PLUGIN_OPTION_FORCE_STEREO; - //if (fDescriptor->midiIns > 0) + if (midiInCount() > 0) { fOptions |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE; fOptions |= PLUGIN_OPTION_SEND_NOTE_AFTERTOUCH; @@ -3734,6 +3763,10 @@ public: kData->idStr = "LV2/"; kData->idStr += uri; fOptions = kData->loadSettings(fOptions, availableOptions()); + + // ignore settings, we need this anyway + if (needsFixedBuffer()) + fOptions |= PLUGIN_OPTION_FIXED_BUFFER; } // --------------------------------------------------------------- diff --git a/source/bridges/Makefile b/source/bridges/Makefile index aff662402..ab30956c8 100644 --- a/source/bridges/Makefile +++ b/source/bridges/Makefile @@ -12,8 +12,8 @@ HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true) HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true) ifeq ($(HAVE_QT5),true) -QT_UI_FLAGS = $(shell pkg-config --cflags QtWidgets) -QT_UI_LIBS = $(shell pkg-config --libs QtWidgets) +QT_UI_FLAGS = $(shell pkg-config --cflags Qt5Gui Qt5Widgets) +QT_UI_LIBS = $(shell pkg-config --libs Qt5Gui Qt5Widgets) else QT_UI_FLAGS = $(shell pkg-config --cflags QtGui) QT_UI_LIBS = $(shell pkg-config --libs QtGui) @@ -23,8 +23,16 @@ endif BUILD_CXX_FLAGS += -DBUILD_BRIDGE BUILD_CXX_FLAGS += -I. -I../backend -I../includes -I../utils -BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo QtCore) -LINK_FLAGS += $(shell pkg-config --libs liblo QtCore) +BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo) +LINK_FLAGS += $(shell pkg-config --libs liblo) + +ifeq ($(HAVE_QT5),true) +BUILD_CXX_FLAGS += $(shell pkg-config --cflags Qt5Core) +LINK_FLAGS += $(shell pkg-config --libs Qt5Core) +else +BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtCore) +LINK_FLAGS += $(shell pkg-config --libs QtCore) +endif # -------------------------------------------------------------- # Plugin bridges @@ -33,10 +41,15 @@ BUILD_PLUGIN_FLAGS = $(BUILD_CXX_FLAGS) BUILD_PLUGIN_FLAGS += -DBUILD_BRIDGE_PLUGIN -DBRIDGE_PLUGIN BUILD_PLUGIN_FLAGS += -DWANT_LADSPA -DWANT_DSSI -DWANT_LV2 -DWANT_VST BUILD_PLUGIN_FLAGS += -I../backend/engine -I../backend/plugin -I../libs -I../theme -BUILD_PLUGIN_FLAGS += $(QT_UI_FLAGS) $(shell pkg-config --cflags QtXml) +LINK_PLUGIN_FLAGS = $(LINK_FLAGS) -lpthread -LINK_PLUGIN_FLAGS = $(LINK_FLAGS) -LINK_PLUGIN_FLAGS += $(QT_UI_LIBS) $(shell pkg-config --libs QtXml) -lpthread +ifeq ($(HAVE_QT5),true) +BUILD_PLUGIN_FLAGS += $(shell pkg-config --cflags Qt5Gui Qt5Widgets Qt5Xml) +LINK_PLUGIN_FLAGS += $(shell pkg-config --libs Qt5Gui Qt5Widgets Qt5Xml) +else +BUILD_PLUGIN_FLAGS += $(shell pkg-config --cflags QtGui QtXml) +LINK_PLUGIN_FLAGS += $(shell pkg-config --libs QtGui QtXml) +endif # -------------------------------------------------------------- # Plugin bridges (POSIX) @@ -69,7 +82,7 @@ NATIVE_LINK_FLAGS += $(shell pkg-config --libs fluidsynth) endif ifeq ($(HAVE_LINUXSAMPLER),true) -NATIVE_BUILD_FLAGS += -DWANT_LINUXSAMPLER -DIS_CPP11=1 +NATIVE_BUILD_FLAGS += -DWANT_LINUXSAMPLER NATIVE_BUILD_FLAGS += $(shell pkg-config --cflags linuxsampler) NATIVE_LINK_FLAGS += $(shell pkg-config --libs linuxsampler) endif @@ -115,8 +128,8 @@ LINK_UI_LV2_GTK3_FLAGS = $(LINK_UI_FLAGS) $(shell pkg-config --libs gtk+-3.0) BUILD_UI_LV2_QT4_FLAGS = $(BUILD_UI_LV2_FLAGS) -DBRIDGE_QT4 -DBRIDGE_LV2_QT4 $(shell pkg-config --cflags QtGui) LINK_UI_LV2_QT4_FLAGS = $(LINK_UI_FLAGS) $(shell pkg-config --libs QtGui) -BUILD_UI_LV2_QT5_FLAGS = $(BUILD_UI_LV2_FLAGS) -DBRIDGE_QT5 -DBRIDGE_LV2_QT5 $(shell pkg-config --cflags QtWidgets) -LINK_UI_LV2_QT5_FLAGS = $(LINK_UI_FLAGS) $(shell pkg-config --libs QtWidgets) +BUILD_UI_LV2_QT5_FLAGS = $(BUILD_UI_LV2_FLAGS) -DBRIDGE_QT5 -DBRIDGE_LV2_QT5 $(shell pkg-config --cflags Qt5Gui Qt5Widgets) +LINK_UI_LV2_QT5_FLAGS = $(LINK_UI_FLAGS) $(shell pkg-config --libs Qt5Gui Qt5Widgets) BUILD_UI_LV2_COCOA_FLAGS = $(BUILD_UI_VST_FLAGS) -DBRIDGE_COCOA -DBRIDGE_LV2_COCOA $(QT_UI_FLAGS) LINK_UI_LV2_COCOA_FLAGS = $(LINK_FLAGS) $(QT_UI_LIBS)