From 04e87de45947f5d0a9ecd1be3f4f475d5339ddb4 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 5 Oct 2013 16:46:25 +0100 Subject: [PATCH] Misc cleanup --- source/backend/plugin/CarlaPlugin.cpp | 22 ++++++------- source/backend/plugin/CarlaPluginInternal.hpp | 32 ++++++++----------- source/carla-patchbay | 5 +++ 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/source/backend/plugin/CarlaPlugin.cpp b/source/backend/plugin/CarlaPlugin.cpp index 771ab7788..f6889aa8c 100644 --- a/source/backend/plugin/CarlaPlugin.cpp +++ b/source/backend/plugin/CarlaPlugin.cpp @@ -41,17 +41,16 @@ struct ParamSymbol { uint32_t index; const char* symbol; - ParamSymbol(uint32_t index_, const char* symbol_) - : index(index_), - symbol(carla_strdup(symbol_)) {} + ParamSymbol(uint32_t i, const char* s) + : index(i), + symbol(carla_strdup(s)) {} - void free() + ~ParamSymbol() { - if (symbol != nullptr) - { - delete[] symbol; - symbol = nullptr; - } + CARLA_SAFE_ASSERT_RETURN(symbol != nullptr,) + + delete[] symbol; + symbol = nullptr; } #ifdef CARLA_PROPER_CPP11_SUPPORT @@ -109,6 +108,8 @@ const char* CarlaPluginProtectedData::libError(const char* const filename) // ------------------------------------------------------------------- // Settings functions, defined in CarlaPluginInternal.hpp +// FIXME - this doesn't work!! + void CarlaPluginProtectedData::saveSetting(const unsigned int option, const bool yesNo) { PropertiesFile::Options opts; @@ -226,7 +227,7 @@ CarlaPlugin::CarlaPlugin(CarlaEngine* const engine, const unsigned int id) fIconName("plugin"), pData(new CarlaPluginProtectedData(engine, this)) { - CARLA_ASSERT(engine != nullptr); + CARLA_SAFE_ASSERT_RETURN(engine != nullptr,); CARLA_ASSERT(id < engine->getMaxPluginNumber()); CARLA_ASSERT(id == engine->getCurrentPluginCount()); carla_debug("CarlaPlugin::CarlaPlugin(%p, %i)", engine, id); @@ -776,7 +777,6 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) for (NonRtList::Itenerator it = paramSymbols.begin(); it.valid(); it.next()) { ParamSymbol* const paramSymbol(*it); - paramSymbol->free(); delete paramSymbol; } diff --git a/source/backend/plugin/CarlaPluginInternal.hpp b/source/backend/plugin/CarlaPluginInternal.hpp index 0508b4faf..a613e1a4a 100644 --- a/source/backend/plugin/CarlaPluginInternal.hpp +++ b/source/backend/plugin/CarlaPluginInternal.hpp @@ -658,10 +658,10 @@ struct CarlaPluginProtectedData { if (client != nullptr) { - CARLA_ASSERT(! client->isActive()); - if (client->isActive()) client->deactivate(); + else + carla_assert("client->isActive()", __FILE__, __LINE__); clearBuffers(); @@ -673,27 +673,29 @@ struct CarlaPluginProtectedData { { CustomData& cData(*it); - CARLA_ASSERT(cData.type != nullptr); - CARLA_ASSERT(cData.key != nullptr); - CARLA_ASSERT(cData.value != nullptr); - if (cData.type != nullptr) { delete[] cData.type; cData.type = nullptr; } + else + carla_assert("cData.type != nullptr", __FILE__, __LINE__); if (cData.key != nullptr) { delete[] cData.key; cData.key = nullptr; } + else + carla_assert("cData.key != nullptr", __FILE__, __LINE__); if (cData.value != nullptr) { delete[] cData.value; cData.value = nullptr; } + else + carla_assert("cData.value != nullptr", __FILE__, __LINE__); } prog.clear(); @@ -719,13 +721,10 @@ struct CarlaPluginProtectedData { for (uint32_t i=0; i < audioIn.count; ++i) { - CARLA_ASSERT(latencyBuffers[i] != nullptr); + CARLA_SAFE_ASSERT_CONTINUE(latencyBuffers[i] != nullptr); - if (latencyBuffers[i] != nullptr) - { - delete[] latencyBuffers[i]; - latencyBuffers[i] = nullptr; - } + delete[] latencyBuffers[i]; + latencyBuffers[i] = nullptr; } delete[] latencyBuffers; @@ -751,13 +750,10 @@ struct CarlaPluginProtectedData { for (uint32_t i=0; i < audioIn.count; ++i) { - CARLA_ASSERT(latencyBuffers[i] != nullptr); + CARLA_SAFE_ASSERT_CONTINUE(latencyBuffers[i] != nullptr); - if (latencyBuffers[i] != nullptr) - { - delete[] latencyBuffers[i]; - latencyBuffers[i] = nullptr; - } + delete[] latencyBuffers[i]; + latencyBuffers[i] = nullptr; } delete[] latencyBuffers; diff --git a/source/carla-patchbay b/source/carla-patchbay index 6799c6779..2c3d7a5b8 100755 --- a/source/carla-patchbay +++ b/source/carla-patchbay @@ -72,6 +72,11 @@ if __name__ == '__main__': # ------------------------------------------------------------- # Init host backend + Carla.isControl = False + Carla.isLocal = True + Carla.isPlugin = False + Carla.processMode = PROCESS_MODE_MULTIPLE_CLIENTS + initHost(appName, libPrefix) # -------------------------------------------------------------