From 59cd6d019677c2a28978a8a93f39f93d8bc7a56c Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 28 Feb 2013 07:37:34 +0000 Subject: [PATCH] Misc fixes, useful for DSSIs --- source/backend/engine/CarlaEngine.cpp | 43 ++++++++++++++++++++++++++- source/backend/plugin/CarlaPlugin.cpp | 25 +++++++++------- source/backend/plugin/DssiPlugin.cpp | 1 + source/bridges/CarlaBridgePlugin.cpp | 38 +++-------------------- 4 files changed, 62 insertions(+), 45 deletions(-) diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index a1cd72447..009a4ccd8 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -20,7 +20,9 @@ #include "CarlaStateUtils.hpp" #include "CarlaMIDI.h" +#include #include +#include #include CARLA_BACKEND_START_NAMESPACE @@ -391,6 +393,40 @@ void doPluginRemove(CarlaEngineProtectedData* const kData, const bool unlock) kData->nextAction.mutex.unlock(); } +const char* findDSSIGUI(const char* const filename, const char* const label) +{ + QString guiFilename; + guiFilename.clear(); + + QString pluginDir(filename); + pluginDir.resize(pluginDir.lastIndexOf(".")); + + QString shortName = QFileInfo(pluginDir).baseName(); + + QString checkLabel = QString(label); + QString checkSName = shortName; + + if (! checkLabel.endsWith("_")) checkLabel += "_"; + if (! checkSName.endsWith("_")) checkSName += "_"; + + QStringList guiFiles = QDir(pluginDir).entryList(); + + foreach (const QString& gui, guiFiles) + { + if (gui.startsWith(checkLabel) || gui.startsWith(checkSName)) + { + QFileInfo finalname(pluginDir + QDir::separator() + gui); + guiFilename = finalname.absoluteFilePath(); + break; + } + } + + if (guiFilename.isEmpty()) + return nullptr; + + return carla_strdup(guiFilename.toUtf8().constData()); +} + // ----------------------------------------------------------------------- // Static values and calls @@ -993,8 +1029,13 @@ bool CarlaEngine::loadProject(const char* const filename) { const SaveState& saveState = getSaveStateDictFromXML(node); + const void* extraStuff = nullptr; + + if (std::strcmp(saveState.type, "DSSI") == 0) + extraStuff = findDSSIGUI(saveState.binary, saveState.label); + // TODO - proper find&load plugins - if (addPlugin(getPluginTypeFromString(saveState.type), saveState.binary, saveState.name, saveState.label, nullptr)) + if (addPlugin(getPluginTypeFromString(saveState.type), saveState.binary, saveState.name, saveState.label, extraStuff)) { if (CarlaPlugin* plugin = getPlugin(kData->curPluginCount-1)) plugin->loadSaveState(saveState); diff --git a/source/backend/plugin/CarlaPlugin.cpp b/source/backend/plugin/CarlaPlugin.cpp index e2055c0ce..21cb5412d 100644 --- a/source/backend/plugin/CarlaPlugin.cpp +++ b/source/backend/plugin/CarlaPlugin.cpp @@ -597,7 +597,7 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) // Part 3 - set midi program if (saveState.currentMidiBank >= 0 && saveState.currentMidiProgram) - setMidiProgramById(saveState.currentMidiBank, currentMidiProgram(), true, true, true); + setMidiProgramById(saveState.currentMidiBank, saveState.currentMidiProgram, true, true, true); // --------------------------------------------------------------------- // Part 4a - get plugin parameter symbols @@ -1508,17 +1508,22 @@ void CarlaPlugin::updateOscData(const lo_address& source, const char* const url) osc_send_sample_rate(&kData->osc.data, kData->engine->getSampleRate()); -#if 0 - for (size_t i=0; i < kData->custom.count(); i++) + for (size_t i=0, count=kData->custom.count(); i < count; i++) { - // TODO - //if (m_type == PLUGIN_LV2) - //osc_send_lv2_transfer_event(&osc.data, getCustomDataTypeString(custom[i].type), /*custom[i].key,*/ custom[i].value); - //else - if (custom[i].type == CUSTOM_DATA_STRING) - osc_send_configure(&osc.data, custom[i].key, custom[i].value); - } + CustomData* const cData(kData->custom.getAt(i)); + + assert(cData->type != nullptr); + assert(cData->key != nullptr); + assert(cData->value != nullptr); + +#ifdef WANT_LV2 + if (type() == PLUGIN_LV2) + osc_send_lv2_transfer_event(&kData->osc.data, 0, cData->type, cData->value); + else #endif + if (std::strcmp(cData->type, CUSTOM_DATA_STRING) == 0) + osc_send_configure(&kData->osc.data, cData->key, cData->value); + } if (kData->prog.current >= 0) osc_send_program(&kData->osc.data, kData->prog.current); diff --git a/source/backend/plugin/DssiPlugin.cpp b/source/backend/plugin/DssiPlugin.cpp index 7db3b0a4d..87a416658 100644 --- a/source/backend/plugin/DssiPlugin.cpp +++ b/source/backend/plugin/DssiPlugin.cpp @@ -247,6 +247,7 @@ public: void setCustomData(const char* const type, const char* const key, const char* const value, const bool sendGui) { + carla_debug("DssiPlugin::setCustomData(%s, %s, %s, %s)", type, key, value, bool2str(sendGui)); CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); CARLA_ASSERT(type != nullptr); diff --git a/source/bridges/CarlaBridgePlugin.cpp b/source/bridges/CarlaBridgePlugin.cpp index 51c844f13..18dd2fc38 100644 --- a/source/bridges/CarlaBridgePlugin.cpp +++ b/source/bridges/CarlaBridgePlugin.cpp @@ -101,39 +101,9 @@ void initSignalHandler() extern CarlaBackend::CarlaEngine* carla_get_standalone_engine(); -const char* findDSSIGUI(const char* const filename, const char* const label) -{ - QString guiFilename; - guiFilename.clear(); - - QString pluginDir(filename); - pluginDir.resize(pluginDir.lastIndexOf(".")); - - QString shortName = QFileInfo(pluginDir).baseName(); - - QString checkLabel = QString(label); - QString checkSName = shortName; - - if (! checkLabel.endsWith("_")) checkLabel += "_"; - if (! checkSName.endsWith("_")) checkSName += "_"; - - QStringList guiFiles = QDir(pluginDir).entryList(); - - foreach (const QString& gui, guiFiles) - { - if (gui.startsWith(checkLabel) || gui.startsWith(checkSName)) - { - QFileInfo finalname(pluginDir + QDir::separator() + gui); - guiFilename = finalname.absoluteFilePath(); - break; - } - } - - if (guiFilename.isEmpty()) - return nullptr; - - return carla_strdup(guiFilename.toUtf8().constData()); -} +CARLA_BACKEND_START_NAMESPACE +extern const char* findDSSIGUI(const char* const filename, const char* const label); +CARLA_BACKEND_END_NAMESPACE CARLA_BRIDGE_START_NAMESPACE @@ -537,7 +507,7 @@ int main(int argc, char* argv[]) const void* extraStuff = nullptr; if (itype == CarlaBackend::PLUGIN_DSSI) - extraStuff = findDSSIGUI(filename, label); + extraStuff = CarlaBackend::findDSSIGUI(filename, label); // Init plugin int ret;