Browse Source

Change the way plugins are deleted, ensure they are not being used

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.2.0-RC1
falkTX 4 years ago
parent
commit
3ab47c9481
33 changed files with 531 additions and 386 deletions
  1. +8
    -4
      source/backend/CarlaEngine.hpp
  2. +24
    -13
      source/backend/CarlaPlugin.hpp
  3. +57
    -53
      source/backend/CarlaStandalone.cpp
  4. +49
    -42
      source/backend/engine/CarlaEngine.cpp
  5. +9
    -6
      source/backend/engine/CarlaEngineBridge.cpp
  6. +19
    -3
      source/backend/engine/CarlaEngineClient.cpp
  7. +10
    -4
      source/backend/engine/CarlaEngineClient.hpp
  8. +18
    -18
      source/backend/engine/CarlaEngineGraph.cpp
  9. +6
    -6
      source/backend/engine/CarlaEngineGraph.hpp
  10. +43
    -8
      source/backend/engine/CarlaEngineInternal.cpp
  11. +16
    -5
      source/backend/engine/CarlaEngineInternal.hpp
  12. +63
    -27
      source/backend/engine/CarlaEngineJack.cpp
  13. +52
    -47
      source/backend/engine/CarlaEngineNative.cpp
  14. +1
    -1
      source/backend/engine/CarlaEngineOsc.cpp
  15. +16
    -11
      source/backend/engine/CarlaEngineOsc.hpp
  16. +2
    -2
      source/backend/engine/CarlaEngineOscHandlers.cpp
  17. +13
    -13
      source/backend/engine/CarlaEngineOscSend.cpp
  18. +2
    -2
      source/backend/engine/CarlaEnginePorts.hpp
  19. +2
    -2
      source/backend/engine/CarlaEngineThread.cpp
  20. +10
    -1
      source/backend/plugin/CarlaPlugin.cpp
  21. +4
    -3
      source/backend/plugin/CarlaPluginAU.cpp
  22. +11
    -10
      source/backend/plugin/CarlaPluginBridge.cpp
  23. +7
    -9
      source/backend/plugin/CarlaPluginFluidSynth.cpp
  24. +1
    -1
      source/backend/plugin/CarlaPluginInternal.cpp
  25. +8
    -10
      source/backend/plugin/CarlaPluginJack.cpp
  26. +10
    -10
      source/backend/plugin/CarlaPluginJuce.cpp
  27. +17
    -20
      source/backend/plugin/CarlaPluginLADSPADSSI.cpp
  28. +14
    -15
      source/backend/plugin/CarlaPluginLV2.cpp
  29. +14
    -15
      source/backend/plugin/CarlaPluginNative.cpp
  30. +8
    -10
      source/backend/plugin/CarlaPluginSFZero.cpp
  31. +9
    -10
      source/backend/plugin/CarlaPluginVST2.cpp
  32. +4
    -3
      source/backend/plugin/CarlaPluginVST3.cpp
  33. +4
    -2
      source/bridges-plugin/CarlaBridgeSingleLV2.cpp

+ 8
- 4
source/backend/CarlaEngine.hpp View File

@@ -20,6 +20,8 @@

#include "CarlaBackend.h"

#include <memory>

namespace water {
class MemoryOutputStream;
class XmlDocument;
@@ -27,6 +29,8 @@ class XmlDocument;

CARLA_BACKEND_START_NAMESPACE

typedef std::shared_ptr<CarlaPlugin> CarlaPluginPtr;

// -----------------------------------------------------------------------

/*!
@@ -704,7 +708,7 @@ public:
* Deactivate this client.
* Client must be activated before calling this function.
*/
virtual void deactivate() noexcept;
virtual void deactivate(bool willClose) noexcept;

/*!
* Check if the client is activated.
@@ -925,7 +929,7 @@ public:
* Add new engine client.
* @note This function must only be called within a plugin class.
*/
virtual CarlaEngineClient* addClient(CarlaPlugin* plugin);
virtual CarlaEngineClient* addClient(CarlaPluginPtr plugin);

/*!
* Get the current CPU load estimated by the engine.
@@ -1024,12 +1028,12 @@ public:
/*!
* Get plugin with id @a id.
*/
CarlaPlugin* getPlugin(uint id) const noexcept;
CarlaPluginPtr getPlugin(uint id) const noexcept;

/*!
* Get plugin with id @a id, faster unchecked version.
*/
CarlaPlugin* getPluginUnchecked(uint id) const noexcept;
CarlaPluginPtr getPluginUnchecked(uint id) const noexcept;

/*!
* Get a unique plugin name within the engine.


+ 24
- 13
source/backend/CarlaPlugin.hpp View File

@@ -1,6 +1,6 @@
/*
* Carla Plugin Host
* Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2020 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,6 +20,8 @@

#include "CarlaBackend.h"

#include <memory>

// -----------------------------------------------------------------------
// Avoid including extra libs here

@@ -35,6 +37,8 @@ CARLA_BACKEND_START_NAMESPACE
} /* Fix editor indentation */
#endif

typedef std::shared_ptr<CarlaPlugin> CarlaPluginPtr;

// -----------------------------------------------------------------------

/*!
@@ -943,21 +947,22 @@ public:
const uint options; // see PluginOptions
};

static CarlaPlugin* newNative(const Initializer& init);
static CarlaPlugin* newBridge(const Initializer& init, BinaryType btype, PluginType ptype, const char* bridgeBinary);
static CarlaPluginPtr newNative(const Initializer& init);
static CarlaPluginPtr newBridge(const Initializer& init,
BinaryType btype, PluginType ptype, const char* bridgeBinary);

static CarlaPlugin* newLADSPA(const Initializer& init, const LADSPA_RDF_Descriptor* rdfDescriptor);
static CarlaPlugin* newDSSI(const Initializer& init);
static CarlaPlugin* newLV2(const Initializer& init);
static CarlaPlugin* newVST2(const Initializer& init);
static CarlaPlugin* newVST3(const Initializer& init);
static CarlaPlugin* newAU(const Initializer& init);
static CarlaPluginPtr newLADSPA(const Initializer& init, const LADSPA_RDF_Descriptor* rdfDescriptor);
static CarlaPluginPtr newDSSI(const Initializer& init);
static CarlaPluginPtr newLV2(const Initializer& init);
static CarlaPluginPtr newVST2(const Initializer& init);
static CarlaPluginPtr newVST3(const Initializer& init);
static CarlaPluginPtr newAU(const Initializer& init);

static CarlaPlugin* newJuce(const Initializer& init, const char* format);
static CarlaPlugin* newFluidSynth(const Initializer& init, PluginType ptype, bool use16Outs);
static CarlaPlugin* newSFZero(const Initializer& init);
static CarlaPluginPtr newJuce(const Initializer& init, const char* format);
static CarlaPluginPtr newFluidSynth(const Initializer& init, PluginType ptype, bool use16Outs);
static CarlaPluginPtr newSFZero(const Initializer& init);

static CarlaPlugin* newJackApp(const Initializer& init);
static CarlaPluginPtr newJackApp(const Initializer& init);
#endif

// -------------------------------------------------------------------
@@ -980,6 +985,11 @@ public:
virtual void restoreLV2State() noexcept;

protected:
/*!
* Allow engine to signal that plugin will be deleted soon.
*/
virtual void prepareForDeletion() noexcept;

/*!
* Give plugin bridges a change to update their custom data sets.
*/
@@ -1025,6 +1035,7 @@ protected:
CARLA_DECLARE_NON_COPY_CLASS(ScopedSingleProcessLocker)
};

friend class CarlaEngine;
friend class CarlaEngineBridge;
CARLA_DECLARE_NON_COPY_CLASS(CarlaPlugin)
};


+ 57
- 53
source/backend/CarlaStandalone.cpp View File

@@ -58,6 +58,10 @@ static void carla_juce_cleanup();

// --------------------------------------------------------------------------------------------------------------------

using CarlaBackend::CarlaPluginPtr;

// --------------------------------------------------------------------------------------------------------------------

uint carla_get_engine_driver_count()
{
carla_debug("carla_get_engine_driver_count()");
@@ -1166,7 +1170,7 @@ bool carla_load_plugin_state(CarlaHostHandle handle, uint pluginId, const char*
CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(handle->engine != nullptr
&& handle->engine->isRunning(), "Engine is not running", false);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(plugin != nullptr, "could not find requested plugin", false);

carla_debug("carla_load_plugin_state(%p, %i, \"%s\")", handle, pluginId, filename);
@@ -1179,7 +1183,7 @@ bool carla_save_plugin_state(CarlaHostHandle handle, uint pluginId, const char*
CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false);
CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(handle->engine != nullptr, "Engine is not initialized", false);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(plugin != nullptr, "could not find requested plugin", false);

carla_debug("carla_save_plugin_state(%p, %i, \"%s\")", handle, pluginId, filename);
@@ -1192,7 +1196,7 @@ bool carla_export_plugin_lv2(CarlaHostHandle handle, uint pluginId, const char*
CARLA_SAFE_ASSERT_RETURN(lv2path != nullptr && lv2path[0] != '\0', false);
CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(handle->engine != nullptr, "Engine is not initialized", false);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(plugin != nullptr, "could not find requested plugin", false);

carla_debug("carla_export_plugin_lv2(%p, %i, \"%s\")", handle, pluginId, lv2path);
@@ -1238,7 +1242,7 @@ const CarlaPluginInfo* carla_get_plugin_info(CarlaHostHandle handle, uint plugin

CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, &retInfo);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retInfo);

carla_debug("carla_get_plugin_info(%p, %i)", handle, pluginId);
@@ -1281,7 +1285,7 @@ const CarlaPortCountInfo* carla_get_audio_port_count_info(CarlaHostHandle handle

CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, &retInfo);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retInfo);

carla_debug("carla_get_audio_port_count_info(%p, %i)", handle, pluginId);
@@ -1298,7 +1302,7 @@ const CarlaPortCountInfo* carla_get_midi_port_count_info(CarlaHostHandle handle,

CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, &retInfo);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retInfo);

carla_debug("carla_get_midi_port_count_info(%p, %i)", handle, pluginId);
@@ -1315,7 +1319,7 @@ const CarlaPortCountInfo* carla_get_parameter_count_info(CarlaHostHandle handle,

CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, &retInfo);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retInfo);

carla_debug("carla_get_parameter_count_info(%p, %i)", handle, pluginId);
@@ -1364,7 +1368,7 @@ const CarlaParameterInfo* carla_get_parameter_info(CarlaHostHandle handle, uint

CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, &retInfo);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retInfo);

carla_debug("carla_get_parameter_info(%p, %i, %i)", handle, pluginId, parameterId);
@@ -1434,7 +1438,7 @@ const CarlaScalePointInfo* carla_get_parameter_scalepoint_info(CarlaHostHandle h

CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, &retInfo);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retInfo);

carla_debug("carla_get_parameter_scalepoint_info(%p, %i, %i, %i)", handle, pluginId, parameterId, scalePointId);
@@ -1470,7 +1474,7 @@ const ParameterData* carla_get_parameter_data(CarlaHostHandle handle, uint plugi

CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, &retParamData);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retParamData);

carla_debug("carla_get_parameter_data(%p, %i, %i)", handle, pluginId, parameterId);
@@ -1502,7 +1506,7 @@ const ParameterRanges* carla_get_parameter_ranges(CarlaHostHandle handle, uint p

CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, &retParamRanges);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retParamRanges);

carla_debug("carla_get_parameter_ranges(%p, %i, %i)", handle, pluginId, parameterId);
@@ -1534,7 +1538,7 @@ const MidiProgramData* carla_get_midi_program_data(CarlaHostHandle handle, uint

CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, &retMidiProgData);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retMidiProgData);

carla_debug("carla_get_midi_program_data(%p, %i, %i)", handle, pluginId, midiProgramId);
@@ -1582,7 +1586,7 @@ const CustomData* carla_get_custom_data(CarlaHostHandle handle, uint pluginId, u

CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, &retCustomData);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, &retCustomData);

carla_debug("carla_get_custom_data(%p, %i, %i)", handle, pluginId, customDataId);
@@ -1604,7 +1608,7 @@ const char* carla_get_custom_data_value(CarlaHostHandle handle, uint pluginId, c
CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0', gNullCharPtr);
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, gNullCharPtr);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, gNullCharPtr);

carla_debug("carla_get_custom_data_value(%p, %i, %s, %s)", handle, pluginId, type, key);
@@ -1636,7 +1640,7 @@ const char* carla_get_chunk_data(CarlaHostHandle handle, uint pluginId)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, gNullCharPtr);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, gNullCharPtr);

carla_debug("carla_get_chunk_data(%p, %i)", handle, pluginId);
@@ -1658,7 +1662,7 @@ uint32_t carla_get_parameter_count(CarlaHostHandle handle, uint pluginId)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, 0);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0);

carla_debug("carla_get_parameter_count(%p, %i)", handle, pluginId);
@@ -1669,7 +1673,7 @@ uint32_t carla_get_program_count(CarlaHostHandle handle, uint pluginId)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, 0);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0);

carla_debug("carla_get_program_count(%p, %i)", handle, pluginId);
@@ -1680,7 +1684,7 @@ uint32_t carla_get_midi_program_count(CarlaHostHandle handle, uint pluginId)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, 0);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0);

carla_debug("carla_get_midi_program_count(%p, %i)", handle, pluginId);
@@ -1691,7 +1695,7 @@ uint32_t carla_get_custom_data_count(CarlaHostHandle handle, uint pluginId)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, 0);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0);

carla_debug("carla_get_custom_data_count(%p, %i)", handle, pluginId);
@@ -1704,7 +1708,7 @@ const char* carla_get_parameter_text(CarlaHostHandle handle, uint pluginId, uint
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, gNullCharPtr);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, gNullCharPtr);

carla_debug("carla_get_parameter_text(%p, %i, %i)", handle, pluginId, parameterId);
@@ -1723,7 +1727,7 @@ const char* carla_get_program_name(CarlaHostHandle handle, uint pluginId, uint32
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, nullptr);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, gNullCharPtr);

carla_debug("carla_get_program_name(%p, %i, %i)", handle, pluginId, programId);
@@ -1742,7 +1746,7 @@ const char* carla_get_midi_program_name(CarlaHostHandle handle, uint pluginId, u
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, gNullCharPtr);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, gNullCharPtr);

carla_debug("carla_get_midi_program_name(%p, %i, %i)", handle, pluginId, midiProgramId);
@@ -1761,7 +1765,7 @@ const char* carla_get_real_plugin_name(CarlaHostHandle handle, uint pluginId)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, gNullCharPtr);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, gNullCharPtr);

carla_debug("carla_get_real_plugin_name(%p, %i)", handle, pluginId);
@@ -1780,7 +1784,7 @@ int32_t carla_get_current_program_index(CarlaHostHandle handle, uint pluginId)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, -1);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, -1);

carla_debug("carla_get_current_program_index(%p, %i)", handle, pluginId);
@@ -1791,7 +1795,7 @@ int32_t carla_get_current_midi_program_index(CarlaHostHandle handle, uint plugin
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, -1);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, -1);

carla_debug("carla_get_current_midi_program_index(%p, %i)", handle, pluginId);
@@ -1804,7 +1808,7 @@ float carla_get_default_parameter_value(CarlaHostHandle handle, uint pluginId, u
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, 0.0f);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0.0f);

carla_debug("carla_get_default_parameter_value(%p, %i, %i)", handle, pluginId, parameterId);
@@ -1817,7 +1821,7 @@ float carla_get_current_parameter_value(CarlaHostHandle handle, uint pluginId, u
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr, 0.0f);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0.0f);
CARLA_SAFE_ASSERT_RETURN(parameterId < plugin->getParameterCount(), 0.0f);

@@ -1833,7 +1837,7 @@ float carla_get_internal_parameter_value(CarlaHostHandle handle, uint pluginId,
#endif
CARLA_SAFE_ASSERT_RETURN(parameterId != CB::PARAMETER_NULL && parameterId > CB::PARAMETER_MAX, 0.0f);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, 0.0f);

carla_debug("carla_get_internal_parameter_value(%p, %i, %i)", handle, pluginId, parameterId);
@@ -1869,11 +1873,11 @@ CARLA_BACKEND_START_NAMESPACE

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
// defined in CarlaPluginInternal.cpp
const void* carla_render_inline_display_internal(CarlaPlugin* plugin, uint32_t width, uint32_t height);
const void* carla_render_inline_display_internal(const CarlaPluginPtr& plugin, uint32_t width, uint32_t height);
#endif

// defined in CarlaPluginLV2.cpp
const void* carla_render_inline_display_lv2(CarlaPlugin* plugin, uint32_t width, uint32_t height);
const void* carla_render_inline_display_lv2(const CarlaPluginPtr& plugin, uint32_t width, uint32_t height);

CARLA_BACKEND_END_NAMESPACE

@@ -1883,7 +1887,7 @@ const CarlaInlineDisplayImageSurface* carla_render_inline_display(CarlaHostHandl
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr && handle->engine->isRunning(), nullptr);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr, nullptr);

carla_debug("carla_render_inline_display(%p, %i, %i, %i)", handle, pluginId, width, height);
@@ -1910,7 +1914,7 @@ void carla_set_active(CarlaHostHandle handle, uint pluginId, bool onOff)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_active(%p, %i, %s)", handle, pluginId, bool2str(onOff));
@@ -1922,7 +1926,7 @@ void carla_set_drywet(CarlaHostHandle handle, uint pluginId, float value)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_drywet(%p, %i, %f)", handle, pluginId, static_cast<double>(value));
@@ -1933,7 +1937,7 @@ void carla_set_volume(CarlaHostHandle handle, uint pluginId, float value)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_volume(%p, %i, %f)", handle, pluginId, static_cast<double>(value));
@@ -1944,7 +1948,7 @@ void carla_set_balance_left(CarlaHostHandle handle, uint pluginId, float value)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_balance_left(%p, %i, %f)", handle, pluginId, static_cast<double>(value));
@@ -1955,7 +1959,7 @@ void carla_set_balance_right(CarlaHostHandle handle, uint pluginId, float value)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_balance_right(%p, %i, %f)", handle, pluginId, static_cast<double>(value));
@@ -1966,7 +1970,7 @@ void carla_set_panning(CarlaHostHandle handle, uint pluginId, float value)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_panning(%p, %i, %f)", handle, pluginId, static_cast<double>(value));
@@ -1978,7 +1982,7 @@ void carla_set_ctrl_channel(CarlaHostHandle handle, uint pluginId, int8_t channe
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);
CARLA_SAFE_ASSERT_RETURN(channel >= -1 && channel < MAX_MIDI_CHANNELS,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_ctrl_channel(%p, %i, %i)", handle, pluginId, channel);
@@ -1990,7 +1994,7 @@ void carla_set_option(CarlaHostHandle handle, uint pluginId, uint option, bool y
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_option(%p, %i, %i, %s)", handle, pluginId, option, bool2str(yesNo));
@@ -2003,7 +2007,7 @@ void carla_set_parameter_value(CarlaHostHandle handle, uint pluginId, uint32_t p
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_parameter_value(%p, %i, %i, %f)", handle, pluginId, parameterId, static_cast<double>(value));
@@ -2019,7 +2023,7 @@ void carla_set_parameter_midi_channel(CarlaHostHandle handle, uint pluginId, uin
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);
CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_parameter_midi_channel(%p, %i, %i, %i)", handle, pluginId, parameterId, channel);
@@ -2033,7 +2037,7 @@ void carla_set_parameter_mapped_control_index(CarlaHostHandle handle, uint plugi
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);
CARLA_SAFE_ASSERT_RETURN(index >= CB::CONTROL_INDEX_NONE && index <= CB::CONTROL_INDEX_MAX_ALLOWED,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_parameter_mapped_control_index(%p, %i, %i, %i)", handle, pluginId, parameterId, index);
@@ -2046,7 +2050,7 @@ void carla_set_parameter_mapped_range(CarlaHostHandle handle, uint pluginId, uin
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_parameter_mapped_range(%p, %i, %i, %f, %f)",
@@ -2071,7 +2075,7 @@ void carla_set_program(CarlaHostHandle handle, uint pluginId, uint32_t programId
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_program(%p, %i, %i)", handle, pluginId, programId);
@@ -2084,7 +2088,7 @@ void carla_set_midi_program(CarlaHostHandle handle, uint pluginId, uint32_t midi
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_midi_program(%p, %i, %i)", handle, pluginId, midiProgramId);
@@ -2102,7 +2106,7 @@ void carla_set_custom_data(CarlaHostHandle handle, uint pluginId, const char* ty
CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(value != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_custom_data(%p, %i, \"%s\", \"%s\", \"%s\")", handle, pluginId, type, key, value);
@@ -2114,7 +2118,7 @@ void carla_set_chunk_data(CarlaHostHandle handle, uint pluginId, const char* chu
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);
CARLA_SAFE_ASSERT_RETURN(chunkData != nullptr && chunkData[0] != '\0',);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_set_chunk_data(%p, %i, \"%s\")", handle, pluginId, chunkData);
@@ -2134,7 +2138,7 @@ void carla_prepare_for_save(CarlaHostHandle handle, uint pluginId)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_prepare_for_save(%p, %i)", handle, pluginId);
@@ -2145,7 +2149,7 @@ void carla_reset_parameters(CarlaHostHandle handle, uint pluginId)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_reset_parameters(%p, %i)", handle, pluginId);
@@ -2156,7 +2160,7 @@ void carla_randomize_parameters(CarlaHostHandle handle, uint pluginId)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_randomize_parameters(%p, %i)", handle, pluginId);
@@ -2168,7 +2172,7 @@ void carla_send_midi_note(CarlaHostHandle handle, uint pluginId, uint8_t channel
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr && handle->engine->isRunning(),);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_send_midi_note(%p, %i, %i, %i, %i)", handle, pluginId, channel, note, velocity);
@@ -2181,7 +2185,7 @@ void carla_set_custom_ui_title_format(CarlaHostHandle handle, uint pluginId, con
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);
CARLA_SAFE_ASSERT_RETURN(format != nullptr && format[0] != '\0',);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_randomize_parameters(%p, %i, %s)", handle, pluginId, format);
@@ -2192,7 +2196,7 @@ void carla_show_custom_ui(CarlaHostHandle handle, uint pluginId, bool yesNo)
{
CARLA_SAFE_ASSERT_RETURN(handle->engine != nullptr,);

CarlaPlugin* const plugin = handle->engine->getPlugin(pluginId);
const CarlaPluginPtr plugin = handle->engine->getPlugin(pluginId);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

carla_debug("carla_show_custom_ui(%p, %i, %s)", handle, pluginId, bool2str(yesNo));


+ 49
- 42
source/backend/engine/CarlaEngine.cpp View File

@@ -364,7 +364,7 @@ void CarlaEngine::idle() noexcept

for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin != nullptr && plugin->isEnabled())
{
@@ -382,9 +382,11 @@ void CarlaEngine::idle() noexcept
#if defined(HAVE_LIBLO) && !defined(BUILD_BRIDGE)
pData->osc.idle();
#endif

pData->deletePluginsAsNeeded();
}

CarlaEngineClient* CarlaEngine::addClient(CarlaPlugin* const plugin)
CarlaEngineClient* CarlaEngine::addClient(CarlaPluginPtr plugin)
{
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
return new CarlaEngineClientForStandalone(*this, pData->graph, plugin);
@@ -464,7 +466,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
uint id;

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
CarlaPlugin* oldPlugin = nullptr;
CarlaPluginPtr oldPlugin;

if (pData->nextPluginId < pData->curPluginCount)
{
@@ -501,7 +503,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
options
};

CarlaPlugin* plugin = nullptr;
CarlaPluginPtr plugin;
CarlaString bridgeBinary(pData->options.binaryDir);

if (bridgeBinary.isNotEmpty())
@@ -670,7 +672,6 @@ bool CarlaEngine::addPlugin(const BinaryType btype,

if (! canRun)
{
delete plugin;
return false;
}

@@ -692,7 +693,8 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
const float oldDryWet = oldPlugin->getInternalParameterValue(PARAMETER_DRYWET);
const float oldVolume = oldPlugin->getInternalParameterValue(PARAMETER_VOLUME);

delete oldPlugin;
oldPlugin->prepareForDeletion();
pData->pluginsToDelete.push_back(oldPlugin);

if (plugin->getHints() & PLUGIN_CAN_DRYWET)
plugin->setDryWet(oldDryWet, true, true);
@@ -741,12 +743,14 @@ bool CarlaEngine::removePlugin(const uint id)
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
CARLA_SAFE_ASSERT_RETURN_ERR(pData->plugins != nullptr, "Invalid engine internal data");
CARLA_SAFE_ASSERT_RETURN_ERR(pData->curPluginCount != 0, "Invalid engine internal data");
#else
CARLA_SAFE_ASSERT_RETURN_ERR(id == 0, "Invalid engine internal data");
#endif
CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data");
CARLA_SAFE_ASSERT_RETURN_ERR(id < pData->curPluginCount, "Invalid plugin Id");
carla_debug("CarlaEngine::removePlugin(%i)", id);

CarlaPlugin* const plugin(pData->plugins[id].plugin);
CarlaPluginPtr plugin = pData->plugins[id].plugin;

CARLA_SAFE_ASSERT_RETURN_ERR(plugin != nullptr, "Could not find plugin to remove");
CARLA_SAFE_ASSERT_RETURN_ERR(plugin->getId() == id, "Invalid engine internal data");
@@ -769,10 +773,12 @@ bool CarlaEngine::removePlugin(const uint id)
*/
#else
pData->curPluginCount = 0;
carla_zeroStructs(pData->plugins, 1);
pData->plugins[0].plugin = nullptr;
carla_zeroStruct(pData->plugins[0].peaks);
#endif

delete plugin;
plugin->prepareForDeletion();
pData->pluginsToDelete.push_back(plugin);

callback(true, true, ENGINE_CALLBACK_PLUGIN_REMOVED, id, 0, 0, 0, 0.0f, nullptr);
return true;
@@ -793,7 +799,7 @@ bool CarlaEngine::removeAllPlugins()

const ScopedThreadStopper sts(this);

const uint curPluginCount(pData->curPluginCount);
const uint curPluginCount = pData->curPluginCount;

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
if (pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY)
@@ -809,13 +815,11 @@ bool CarlaEngine::removeAllPlugins()
const uint id = curPluginCount - i - 1;
EnginePluginData& pluginData(pData->plugins[id]);

if (pluginData.plugin != nullptr)
{
delete pluginData.plugin;
pluginData.plugin = nullptr;
}
pluginData.plugin->prepareForDeletion();
pData->pluginsToDelete.push_back(pluginData.plugin);

carla_zeroFloats(pluginData.peaks, 4);
pluginData.plugin = nullptr;
carla_zeroStruct(pluginData.peaks);

callback(true, true, ENGINE_CALLBACK_PLUGIN_REMOVED, id, 0, 0, 0, 0.0f, nullptr);
callback(true, false, ENGINE_CALLBACK_IDLE, 0, 0, 0, 0, 0.0f, nullptr);
@@ -835,7 +839,7 @@ bool CarlaEngine::renamePlugin(const uint id, const char* const newName)
CARLA_SAFE_ASSERT_RETURN_ERR(newName != nullptr && newName[0] != '\0', "Invalid plugin name");
carla_debug("CarlaEngine::renamePlugin(%i, \"%s\")", id, newName);

CarlaPlugin* const plugin(pData->plugins[id].plugin);
CarlaPluginPtr plugin = pData->plugins[id].plugin;
CARLA_SAFE_ASSERT_RETURN_ERR(plugin != nullptr, "Could not find plugin to rename");
CARLA_SAFE_ASSERT_RETURN_ERR(plugin->getId() == id, "Invalid engine internal data");

@@ -862,7 +866,7 @@ bool CarlaEngine::clonePlugin(const uint id)
CARLA_SAFE_ASSERT_RETURN_ERR(id < pData->curPluginCount, "Invalid plugin Id");
carla_debug("CarlaEngine::clonePlugin(%i)", id);

CarlaPlugin* const plugin(pData->plugins[id].plugin);
CarlaPluginPtr plugin = pData->plugins[id].plugin;

CARLA_SAFE_ASSERT_RETURN_ERR(plugin != nullptr, "Could not find plugin to clone");
CARLA_SAFE_ASSERT_RETURN_ERR(plugin->getId() == id, "Invalid engine internal data");
@@ -882,7 +886,7 @@ bool CarlaEngine::clonePlugin(const uint id)

CARLA_SAFE_ASSERT_RETURN_ERR(pluginCountBefore+1 == pData->curPluginCount, "No new plugin found");

if (CarlaPlugin* const newPlugin = pData->plugins[pluginCountBefore].plugin)
if (const CarlaPluginPtr newPlugin = pData->plugins[pluginCountBefore].plugin)
newPlugin->loadStateSave(plugin->getStateSave());

return true;
@@ -905,7 +909,7 @@ bool CarlaEngine::replacePlugin(const uint id) noexcept

CARLA_SAFE_ASSERT_RETURN_ERR(id < pData->curPluginCount, "Invalid plugin Id");

CarlaPlugin* const plugin(pData->plugins[id].plugin);
CarlaPluginPtr plugin = pData->plugins[id].plugin;

CARLA_SAFE_ASSERT_RETURN_ERR(plugin != nullptr, "Could not find plugin to replace");
CARLA_SAFE_ASSERT_RETURN_ERR(plugin->getId() == id, "Invalid engine internal data");
@@ -926,8 +930,8 @@ bool CarlaEngine::switchPlugins(const uint idA, const uint idB) noexcept
CARLA_SAFE_ASSERT_RETURN_ERR(idB < pData->curPluginCount, "Invalid plugin Id");
carla_debug("CarlaEngine::switchPlugins(%i)", idA, idB);

CarlaPlugin* const pluginA(pData->plugins[idA].plugin);
CarlaPlugin* const pluginB(pData->plugins[idB].plugin);
CarlaPluginPtr pluginA = pData->plugins[idA].plugin;
CarlaPluginPtr pluginB = pData->plugins[idB].plugin;

CARLA_SAFE_ASSERT_RETURN_ERR(pluginA != nullptr, "Could not find plugin to switch");
CARLA_SAFE_ASSERT_RETURN_ERR(pluginA != nullptr, "Could not find plugin to switch");
@@ -958,7 +962,7 @@ void CarlaEngine::touchPluginParameter(const uint, const uint32_t, const bool) n
{
}

CarlaPlugin* CarlaEngine::getPlugin(const uint id) const noexcept
CarlaPluginPtr CarlaEngine::getPlugin(const uint id) const noexcept
{
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
CARLA_SAFE_ASSERT_RETURN_ERRN(pData->plugins != nullptr, "Invalid engine internal data");
@@ -970,7 +974,7 @@ CarlaPlugin* CarlaEngine::getPlugin(const uint id) const noexcept
return pData->plugins[id].plugin;
}

CarlaPlugin* CarlaEngine::getPluginUnchecked(const uint id) const noexcept
CarlaPluginPtr CarlaEngine::getPluginUnchecked(const uint id) const noexcept
{
return pData->plugins[id].plugin;
}
@@ -1150,7 +1154,7 @@ bool CarlaEngine::loadFile(const char* const filename)
{
if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "audiofile", 0, nullptr))
{
if (CarlaPlugin* const plugin = getPlugin(curPluginId))
if (const CarlaPluginPtr plugin = getPlugin(curPluginId))
plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, "file", filename, true);
return true;
}
@@ -1163,7 +1167,7 @@ bool CarlaEngine::loadFile(const char* const filename)
{
if (addPlugin(PLUGIN_INTERNAL, nullptr, baseName, "midifile", 0, nullptr))
{
if (CarlaPlugin* const plugin = getPlugin(curPluginId))
if (const CarlaPluginPtr plugin = getPlugin(curPluginId))
plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, "file", filename, true);
return true;
}
@@ -1185,13 +1189,16 @@ bool CarlaEngine::loadFile(const char* const filename)
else
nicerName += baseName;

//nicerName
if (addPlugin(PLUGIN_INTERNAL, nullptr, nicerName, "zynaddsubfx", 0, nullptr))
{
callback(true, true, ENGINE_CALLBACK_UI_STATE_CHANGED, curPluginId, 0, 0, 0, 0.0f, nullptr);

if (CarlaPlugin* const plugin = getPlugin(curPluginId))
plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, (extension == "xmz") ? "CarlaAlternateFile1" : "CarlaAlternateFile2", filename, true);
if (const CarlaPluginPtr plugin = getPlugin(curPluginId))
{
const char* const ext = (extension == "xmz") ? "CarlaAlternateFile1" : "CarlaAlternateFile2";
plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, ext, filename, true);
}

return true;
}
return false;
@@ -1415,7 +1422,7 @@ void CarlaEngine::callback(const bool sendHost, const bool sendOSC,
{
case ENGINE_CALLBACK_RELOAD_INFO:
{
CarlaPlugin* const plugin = pData->plugins[pluginId].plugin;
CarlaPluginPtr plugin = pData->plugins[pluginId].plugin;
CARLA_SAFE_ASSERT_BREAK(plugin != nullptr);

pData->osc.sendPluginInfo(plugin);
@@ -1424,7 +1431,7 @@ void CarlaEngine::callback(const bool sendHost, const bool sendOSC,

case ENGINE_CALLBACK_RELOAD_PARAMETERS:
{
CarlaPlugin* const plugin = pData->plugins[pluginId].plugin;
CarlaPluginPtr plugin = pData->plugins[pluginId].plugin;
CARLA_SAFE_ASSERT_BREAK(plugin != nullptr);

pData->osc.sendPluginPortCount(plugin);
@@ -1439,7 +1446,7 @@ void CarlaEngine::callback(const bool sendHost, const bool sendOSC,

case ENGINE_CALLBACK_RELOAD_PROGRAMS:
{
CarlaPlugin* const plugin = pData->plugins[pluginId].plugin;
CarlaPluginPtr plugin = pData->plugins[pluginId].plugin;
CARLA_SAFE_ASSERT_BREAK(plugin != nullptr);

pData->osc.sendPluginProgramCount(plugin);
@@ -1461,7 +1468,7 @@ void CarlaEngine::callback(const bool sendHost, const bool sendOSC,
case ENGINE_CALLBACK_PLUGIN_ADDED:
case ENGINE_CALLBACK_RELOAD_ALL:
{
CarlaPlugin* const plugin = pData->plugins[pluginId].plugin;
CarlaPluginPtr plugin = pData->plugins[pluginId].plugin;
CARLA_SAFE_ASSERT_BREAK(plugin != nullptr);

pData->osc.sendPluginInfo(plugin);
@@ -2023,7 +2030,7 @@ void CarlaEngine::bufferSizeChanged(const uint32_t newBufferSize)

for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin != nullptr && plugin->isEnabled())
{
@@ -2052,7 +2059,7 @@ void CarlaEngine::sampleRateChanged(const double newSampleRate)

for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin != nullptr && plugin->isEnabled())
{
@@ -2079,7 +2086,7 @@ void CarlaEngine::offlineModeChanged(const bool isOfflineNow)

for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin != nullptr && plugin->isEnabled())
plugin->offlineModeChanged(isOfflineNow);
@@ -2101,7 +2108,7 @@ void CarlaEngine::saveProjectInternal(water::MemoryOutputStream& outStream) cons
// send initial prepareForSave first, giving time for bridges to act
for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin != nullptr && plugin->isEnabled())
{
@@ -2165,7 +2172,7 @@ void CarlaEngine::saveProjectInternal(water::MemoryOutputStream& outStream) cons

for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin != nullptr && plugin->isEnabled())
{
@@ -2188,7 +2195,7 @@ void CarlaEngine::saveProjectInternal(water::MemoryOutputStream& outStream) cons
// tell bridges we're done saving
for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin != nullptr && plugin->isEnabled() && (plugin->getHints() & PLUGIN_IS_BRIDGE) != 0)
plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, "__CarlaPingOnOff__", "true", false);
@@ -2639,7 +2646,7 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc)
{
const uint pluginId = pData->curPluginCount;

if (CarlaPlugin* const plugin = pData->plugins[pluginId].plugin)
if (const CarlaPluginPtr plugin = pData->plugins[pluginId].plugin)
{
callback(true, true, ENGINE_CALLBACK_IDLE, 0, 0, 0, 0, 0.0f, nullptr);

@@ -2789,7 +2796,7 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc)
const uint pluginId = 0;
#endif

if (CarlaPlugin* const plugin = pData->plugins[pluginId].plugin)
if (const CarlaPluginPtr plugin = pData->plugins[pluginId].plugin)
{
callback(true, true, ENGINE_CALLBACK_IDLE, 0, 0, 0, 0, 0.0f, nullptr);

@@ -2845,7 +2852,7 @@ bool CarlaEngine::loadProjectInternal(water::XmlDocument& xmlDoc)
// tell bridges we're done loading
for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin != nullptr && plugin->isEnabled() && (plugin->getHints() & PLUGIN_IS_BRIDGE) != 0)
plugin->setCustomData(CUSTOM_DATA_TYPE_STRING, "__CarlaPingOnOff__", "true", false);


+ 9
- 6
source/backend/engine/CarlaEngineBridge.cpp View File

@@ -67,7 +67,10 @@ class CarlaEngineBridgeClient : public CarlaEngineClientForSubclassing
{
public:
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
CarlaEngineBridgeClient(const CarlaEngine& engine, EngineInternalGraph& egraph, CarlaPlugin* const plugin, LatencyChangedCallback* const cb)
CarlaEngineBridgeClient(const CarlaEngine& engine,
EngineInternalGraph& egraph,
const CarlaPluginPtr plugin,
LatencyChangedCallback* const cb)
: CarlaEngineClientForSubclassing(engine, egraph, plugin),
fLatencyCallback(cb) {}
#else
@@ -294,7 +297,7 @@ public:
fShmNonRtServerControl.commitWrite();
}

CarlaEngineClient* addClient(CarlaPlugin* const plugin) override
CarlaEngineClient* addClient(const CarlaPluginPtr plugin) override
{
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
return new CarlaEngineBridgeClient(*this, pData->graph, plugin, this);
@@ -308,7 +311,7 @@ public:

void idle() noexcept override
{
CarlaPlugin* const plugin(pData->plugins[0].plugin);
const CarlaPluginPtr plugin = pData->plugins[0].plugin;

if (plugin == nullptr)
{
@@ -702,7 +705,7 @@ public:
break;

case ENGINE_CALLBACK_RELOAD_PARAMETERS:
if (CarlaPlugin* const plugin = pData->plugins[0].plugin)
if (const CarlaPluginPtr plugin = pData->plugins[0].plugin)
{
if (const uint32_t count = std::min(pData->options.maxParameters, plugin->getParameterCount()))
{
@@ -745,7 +748,7 @@ public:

void handleNonRtData()
{
CarlaPlugin* const plugin(pData->plugins[0].plugin);
const CarlaPluginPtr plugin = pData->plugins[0].plugin;
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

for (; fShmNonRtClientControl.isDataAvailableForReading();)
@@ -1135,7 +1138,7 @@ protected:
for (; fShmRtClientControl.isDataAvailableForReading();)
{
const PluginBridgeRtClientOpcode opcode(fShmRtClientControl.readOpcode());
CarlaPlugin* const plugin(pData->plugins[0].plugin);
const CarlaPluginPtr plugin = pData->plugins[0].plugin;

#ifdef DEBUG
if (opcode != kPluginBridgeRtClientProcess && opcode != kPluginBridgeRtClientMidiEvent) {


+ 19
- 3
source/backend/engine/CarlaEngineClient.cpp View File

@@ -87,7 +87,9 @@ static void _getUniquePortName(CarlaString& sname, const CarlaStringList& list)
// Carla Engine Client

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
CarlaEngineClient::ProtectedData::ProtectedData(const CarlaEngine& eng, EngineInternalGraph& eg, CarlaPlugin* const p) noexcept
CarlaEngineClient::ProtectedData::ProtectedData(const CarlaEngine& eng,
EngineInternalGraph& eg,
const CarlaPluginPtr p) noexcept
#else
CarlaEngineClient::ProtectedData::ProtectedData(const CarlaEngine& eng) noexcept
#endif
@@ -106,6 +108,12 @@ CarlaEngineClient::ProtectedData::ProtectedData(const CarlaEngine& eng) noexcept
eventInList(),
eventOutList() {}

CarlaEngineClient::ProtectedData::~ProtectedData()
{
carla_debug("CarlaEngineClient::ProtectedData::~ProtectedData()");
CARLA_SAFE_ASSERT(plugin == nullptr);
}

void CarlaEngineClient::ProtectedData::addAudioPortName(const bool isInput, const char* const name)
{
CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0',);
@@ -178,12 +186,20 @@ void CarlaEngineClient::activate() noexcept
pData->active = true;
}

void CarlaEngineClient::deactivate() noexcept
void CarlaEngineClient::deactivate(const bool willClose) noexcept
{
CARLA_SAFE_ASSERT(pData->active);
carla_debug("CarlaEngineClient::deactivate()");
carla_debug("CarlaEngineClient::deactivate(%s)", bool2str(willClose));

pData->active = false;

if (willClose)
{
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
pData->cvSourcePorts.setGraphAndPlugin(nullptr, nullptr);
#endif
pData->plugin = nullptr;
}
}

bool CarlaEngineClient::isActive() const noexcept


+ 10
- 4
source/backend/engine/CarlaEngineClient.hpp View File

@@ -20,6 +20,7 @@

#include "CarlaEngine.hpp"
#include "CarlaEnginePorts.hpp"
#include "CarlaPlugin.hpp"

#include "CarlaStringList.hpp"

@@ -37,7 +38,7 @@ struct CarlaEngineClient::ProtectedData {
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
CarlaEngineCVSourcePortsForStandalone cvSourcePorts;
EngineInternalGraph& egraph;
CarlaPlugin* const plugin;
CarlaPluginPtr plugin;
#endif

CarlaStringList audioInList;
@@ -48,10 +49,11 @@ struct CarlaEngineClient::ProtectedData {
CarlaStringList eventOutList;

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
ProtectedData(const CarlaEngine& eng, EngineInternalGraph& eg, CarlaPlugin* p) noexcept;
ProtectedData(const CarlaEngine& eng, EngineInternalGraph& eg, CarlaPluginPtr p) noexcept;
#else
ProtectedData(const CarlaEngine& eng) noexcept;
#endif
~ProtectedData();

void addAudioPortName(bool isInput, const char* name);
void addCVPortName(bool isInput, const char* name);
@@ -72,11 +74,14 @@ struct CarlaEngineClient::ProtectedData {
class CarlaEngineClientForStandalone : public CarlaEngineClient
{
public:
CarlaEngineClientForStandalone(const CarlaEngine& engine, EngineInternalGraph& egraph, CarlaPlugin* const plugin)
CarlaEngineClientForStandalone(const CarlaEngine& engine,
EngineInternalGraph& egraph,
const CarlaPluginPtr plugin)
: CarlaEngineClient(new ProtectedData(engine, egraph, plugin)) {}

~CarlaEngineClientForStandalone() noexcept override
{
carla_debug("CarlaEngineClientForStandalone::~CarlaEngineClientForStandalone()");
delete pData;
}

@@ -86,7 +91,7 @@ protected:
return pData->egraph.getPatchbayGraphOrNull();
}

inline CarlaPlugin* getPlugin() const noexcept
inline CarlaPluginPtr getPlugin() const noexcept
{
return pData->plugin;
}
@@ -103,6 +108,7 @@ public:

~CarlaEngineClientForBridge() override
{
carla_debug("CarlaEngineClientForBridge::~CarlaEngineClientForBridge()");
delete pData;
}



+ 18
- 18
source/backend/engine/CarlaEngineGraph.cpp View File

@@ -967,7 +967,7 @@ void RackGraph::process(CarlaEngine::ProtectedData* const data, const float* inB
// process plugins
for (uint i=0; i < data->curPluginCount; ++i)
{
CarlaPlugin* const plugin = data->plugins[i].plugin;
const CarlaPluginPtr plugin = data->plugins[i].plugin;

if (plugin == nullptr || ! plugin->isEnabled() || ! plugin->tryLock(isOffline))
continue;
@@ -1450,7 +1450,7 @@ void removeNodeFromPatchbay(const bool sendHost, const bool sendOSC, CarlaEngine
class CarlaPluginInstance : public AudioProcessor
{
public:
CarlaPluginInstance(CarlaEngine* const engine, CarlaPlugin* const plugin)
CarlaPluginInstance(CarlaEngine* const engine, const CarlaPluginPtr plugin)
: kEngine(engine),
fPlugin(plugin)
{
@@ -1641,7 +1641,7 @@ public:

private:
CarlaEngine* const kEngine;
CarlaPlugin* fPlugin;
CarlaPluginPtr fPlugin;

CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaPluginInstance)
};
@@ -1862,10 +1862,10 @@ void PatchbayGraph::setOffline(const bool offline)
graph.setNonRealtime(offline);
}

void PatchbayGraph::addPlugin(CarlaPlugin* const plugin)
void PatchbayGraph::addPlugin(const CarlaPluginPtr plugin)
{
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
carla_debug("PatchbayGraph::addPlugin(%p)", plugin);
carla_debug("PatchbayGraph::addPlugin(%p)", plugin.get());

CarlaPluginInstance* const instance(new CarlaPluginInstance(kEngine, plugin));
AudioProcessorGraph::Node* const node(graph.addNode(instance));
@@ -1882,7 +1882,7 @@ void PatchbayGraph::addPlugin(CarlaPlugin* const plugin)
addNodeToPatchbay(sendHost, sendOSC, kEngine, node, static_cast<int>(plugin->getId()), instance);
}

void PatchbayGraph::replacePlugin(CarlaPlugin* const oldPlugin, CarlaPlugin* const newPlugin)
void PatchbayGraph::replacePlugin(const CarlaPluginPtr oldPlugin, const CarlaPluginPtr newPlugin)
{
CARLA_SAFE_ASSERT_RETURN(oldPlugin != nullptr,);
CARLA_SAFE_ASSERT_RETURN(newPlugin != nullptr,);
@@ -1914,10 +1914,10 @@ void PatchbayGraph::replacePlugin(CarlaPlugin* const oldPlugin, CarlaPlugin* con
addNodeToPatchbay(sendHost, sendOSC, kEngine, node, static_cast<int>(newPlugin->getId()), instance);
}

void PatchbayGraph::renamePlugin(CarlaPlugin* const plugin, const char* const newName)
void PatchbayGraph::renamePlugin(const CarlaPluginPtr plugin, const char* const newName)
{
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
carla_debug("PatchbayGraph::renamePlugin(%p)", plugin, newName);
carla_debug("PatchbayGraph::renamePlugin(%p)", plugin.get(), newName);

AudioProcessorGraph::Node* const node(graph.getNodeForId(plugin->getPatchbayNodeId()));
CARLA_SAFE_ASSERT_RETURN(node != nullptr,);
@@ -1932,10 +1932,10 @@ void PatchbayGraph::renamePlugin(CarlaPlugin* const plugin, const char* const ne
newName);
}

void PatchbayGraph::reconfigureForCV(CarlaPlugin* const plugin, const uint portIndex, bool added)
void PatchbayGraph::reconfigureForCV(const CarlaPluginPtr plugin, const uint portIndex, bool added)
{
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
carla_debug("PatchbayGraph::reconfigureForCV(%p, %u, %s)", plugin, portIndex, bool2str(added));
carla_debug("PatchbayGraph::reconfigureForCV(%p, %u, %s)", plugin.get(), portIndex, bool2str(added));

AudioProcessorGraph::Node* const node = graph.getNodeForId(plugin->getPatchbayNodeId());
CARLA_SAFE_ASSERT_RETURN(node != nullptr,);
@@ -1986,10 +1986,10 @@ void PatchbayGraph::reconfigureForCV(CarlaPlugin* const plugin, const uint portI
}
}

void PatchbayGraph::removePlugin(CarlaPlugin* const plugin)
void PatchbayGraph::removePlugin(const CarlaPluginPtr plugin)
{
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
carla_debug("PatchbayGraph::removePlugin(%p)", plugin);
carla_debug("PatchbayGraph::removePlugin(%p)", plugin.get());

AudioProcessorGraph::Node* const node(graph.getNodeForId(plugin->getPatchbayNodeId()));
CARLA_SAFE_ASSERT_RETURN(node != nullptr,);
@@ -2005,7 +2005,7 @@ void PatchbayGraph::removePlugin(CarlaPlugin* const plugin)
// Fix plugin Ids properties
for (uint i=plugin->getId()+1, count=kEngine->getCurrentPluginCount(); i<count; ++i)
{
CarlaPlugin* const plugin2(kEngine->getPlugin(i));
const CarlaPluginPtr plugin2 = kEngine->getPlugin(i);
CARLA_SAFE_ASSERT_BREAK(plugin2 != nullptr);

if (AudioProcessorGraph::Node* const node2 = graph.getNodeForId(plugin2->getPatchbayNodeId()))
@@ -2027,7 +2027,7 @@ void PatchbayGraph::removeAllPlugins()

for (uint i=0, count=kEngine->getCurrentPluginCount(); i<count; ++i)
{
CarlaPlugin* const plugin(kEngine->getPlugin(i));
const CarlaPluginPtr plugin = kEngine->getPlugin(i);
CARLA_SAFE_ASSERT_CONTINUE(plugin != nullptr);

AudioProcessorGraph::Node* const node(graph.getNodeForId(plugin->getPatchbayNodeId()));
@@ -2717,25 +2717,25 @@ void EngineInternalGraph::processRack(CarlaEngine::ProtectedData* const data, co
// -----------------------------------------------------------------------
// used for internal patchbay mode

void EngineInternalGraph::addPlugin(CarlaPlugin* const plugin)
void EngineInternalGraph::addPlugin(const CarlaPluginPtr plugin)
{
CARLA_SAFE_ASSERT_RETURN(fPatchbay != nullptr,);
fPatchbay->addPlugin(plugin);
}

void EngineInternalGraph::replacePlugin(CarlaPlugin* const oldPlugin, CarlaPlugin* const newPlugin)
void EngineInternalGraph::replacePlugin(const CarlaPluginPtr oldPlugin, const CarlaPluginPtr newPlugin)
{
CARLA_SAFE_ASSERT_RETURN(fPatchbay != nullptr,);
fPatchbay->replacePlugin(oldPlugin, newPlugin);
}

void EngineInternalGraph::renamePlugin(CarlaPlugin* const plugin, const char* const newName)
void EngineInternalGraph::renamePlugin(const CarlaPluginPtr plugin, const char* const newName)
{
CARLA_SAFE_ASSERT_RETURN(fPatchbay != nullptr,);
fPatchbay->renamePlugin(plugin, newName);
}

void EngineInternalGraph::removePlugin(CarlaPlugin* const plugin)
void EngineInternalGraph::removePlugin(const CarlaPluginPtr plugin)
{
CARLA_SAFE_ASSERT_RETURN(fPatchbay != nullptr,);
fPatchbay->removePlugin(plugin);


+ 6
- 6
source/backend/engine/CarlaEngineGraph.hpp View File

@@ -190,12 +190,12 @@ public:
void setSampleRate(double sampleRate);
void setOffline(bool offline);

void addPlugin(CarlaPlugin* plugin);
void replacePlugin(CarlaPlugin* oldPlugin, CarlaPlugin* newPlugin);
void renamePlugin(CarlaPlugin* plugin, const char* newName);
void reconfigureForCV(CarlaPlugin* const plugin, const uint portIndex, bool added);
void reconfigurePlugin(CarlaPlugin* plugin, bool portsAdded);
void removePlugin(CarlaPlugin* plugin);
void addPlugin(CarlaPluginPtr plugin);
void replacePlugin(CarlaPluginPtr oldPlugin, CarlaPluginPtr newPlugin);
void renamePlugin(CarlaPluginPtr plugin, const char* newName);
void reconfigureForCV(CarlaPluginPtr plugin, const uint portIndex, bool added);
void reconfigurePlugin(CarlaPluginPtr plugin, bool portsAdded);
void removePlugin(CarlaPluginPtr plugin);
void removeAllPlugins();

bool connect(bool external, uint groupA, uint portA, uint groupB, uint portB);


+ 43
- 8
source/backend/engine/CarlaEngineInternal.cpp View File

@@ -404,6 +404,7 @@ CarlaEngine::ProtectedData::ProtectedData(CarlaEngine* const engine) noexcept
xruns(0),
dspLoad(0.0f),
#endif
pluginsToDelete(),
events(),
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
graph(engine),
@@ -416,7 +417,7 @@ CarlaEngine::ProtectedData::ProtectedData(CarlaEngine* const engine) noexcept
#endif
}

CarlaEngine::ProtectedData::~ProtectedData() noexcept
CarlaEngine::ProtectedData::~ProtectedData()
{
CARLA_SAFE_ASSERT(curPluginCount == 0);
CARLA_SAFE_ASSERT(maxPluginNumber == 0);
@@ -425,6 +426,17 @@ CarlaEngine::ProtectedData::~ProtectedData() noexcept
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
CARLA_SAFE_ASSERT(plugins == nullptr);
#endif

if (pluginsToDelete.size() != 0)
{
for (std::vector<CarlaPluginPtr>::iterator it = pluginsToDelete.begin(); it != pluginsToDelete.end(); ++it)
{
carla_stderr2("Plugin not yet deleted, name: '%s', usage count: '%u'",
(*it)->getName(), it->use_count());
}
}

pluginsToDelete.clear();
}

// -----------------------------------------------------------------------
@@ -488,7 +500,6 @@ bool CarlaEngine::ProtectedData::init(const char* const clientName)

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
plugins = new EnginePluginData[maxPluginNumber];
carla_zeroStructs(plugins, maxPluginNumber);
xruns = 0;
dspLoad = 0.0f;
#endif
@@ -521,6 +532,8 @@ void CarlaEngine::ProtectedData::close()
maxPluginNumber = 0;
nextPluginId = 0;

deletePluginsAsNeeded();

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
if (plugins != nullptr)
{
@@ -550,6 +563,29 @@ void CarlaEngine::ProtectedData::initTime(const char* const features)

// -----------------------------------------------------------------------

void CarlaEngine::ProtectedData::deletePluginsAsNeeded()
{
for (bool stop;;)
{
stop = true;

for (std::vector<CarlaPluginPtr>::iterator it = pluginsToDelete.begin(); it != pluginsToDelete.end(); ++it)
{
if (it->use_count() == 1)
{
stop = false;
pluginsToDelete.erase(it);
break;
}
}

if (stop)
break;
}
}

// -----------------------------------------------------------------------

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
void CarlaEngine::ProtectedData::doPluginRemove(const uint pluginId) noexcept
{
@@ -560,17 +596,16 @@ void CarlaEngine::ProtectedData::doPluginRemove(const uint pluginId) noexcept
// move all plugins 1 spot backwards
for (uint i=pluginId; i < curPluginCount; ++i)
{
CarlaPlugin* const plugin(plugins[i+1].plugin);

const CarlaPluginPtr plugin = plugins[i+1].plugin;
CARLA_SAFE_ASSERT_BREAK(plugin != nullptr);

plugin->setId(i);

plugins[i].plugin = plugin;
carla_zeroFloats(plugins[i].peaks, 4);
carla_zeroStruct(plugins[i].peaks);
}

const uint id(curPluginCount);
const uint id = curPluginCount;

// reset last plugin (now removed)
plugins[id].plugin = nullptr;
@@ -584,10 +619,10 @@ void CarlaEngine::ProtectedData::doPluginsSwitch(const uint idA, const uint idB)
CARLA_SAFE_ASSERT_RETURN(idA < curPluginCount,);
CARLA_SAFE_ASSERT_RETURN(idB < curPluginCount,);

CarlaPlugin* const pluginA(plugins[idA].plugin);
const CarlaPluginPtr pluginA = plugins[idA].plugin;
CARLA_SAFE_ASSERT_RETURN(pluginA != nullptr,);

CarlaPlugin* const pluginB(plugins[idB].plugin);
const CarlaPluginPtr pluginB = plugins[idB].plugin;
CARLA_SAFE_ASSERT_RETURN(pluginB != nullptr,);

pluginA->setId(idB);


+ 16
- 5
source/backend/engine/CarlaEngineInternal.hpp View File

@@ -33,6 +33,8 @@
# include "water/memory/Atomic.h"
#endif

#include <vector>

// FIXME only use CARLA_PREVENT_HEAP_ALLOCATION for structs
// maybe separate macro

@@ -96,10 +98,10 @@ public:
void processRack(CarlaEngine::ProtectedData* data, const float* inBuf[2], float* outBuf[2], uint32_t frames);

// used for internal patchbay mode
void addPlugin(CarlaPlugin* plugin);
void replacePlugin(CarlaPlugin* oldPlugin, CarlaPlugin* newPlugin);
void renamePlugin(CarlaPlugin* plugin, const char* newName);
void removePlugin(CarlaPlugin* plugin);
void addPlugin(CarlaPluginPtr plugin);
void replacePlugin(CarlaPluginPtr oldPlugin, CarlaPluginPtr newPlugin);
void renamePlugin(CarlaPluginPtr plugin, const char* newName);
void removePlugin(CarlaPluginPtr plugin);
void removeAllPlugins();

bool isUsingExternalHost() const noexcept;
@@ -208,8 +210,12 @@ struct EngineNextAction {
// EnginePluginData

struct EnginePluginData {
CarlaPlugin* plugin;
CarlaPluginPtr plugin;
float peaks[4];

EnginePluginData()
: plugin(nullptr),
peaks{0.0f, 0.0f, 0.0f, 0.0f} {}
};

// -----------------------------------------------------------------------
@@ -258,6 +264,7 @@ struct CarlaEngine::ProtectedData {
float dspLoad;
#endif
float peaks[4];
std::vector<CarlaPluginPtr> pluginsToDelete;

EngineInternalEvents events;
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
@@ -280,6 +287,10 @@ struct CarlaEngine::ProtectedData {

// -------------------------------------------------------------------

void deletePluginsAsNeeded();

// -------------------------------------------------------------------

void doPluginRemove(uint pluginId) noexcept;
void doPluginsSwitch(uint idA, uint idB) noexcept;
void doNextPluginAction() noexcept;


+ 63
- 27
source/backend/engine/CarlaEngineJack.cpp View File

@@ -745,7 +745,7 @@ public:
return pData->cvs[ioffset].cvPort;
}

void setGraphAndPlugin(PatchbayGraph* const graph, CarlaPlugin* const plugin) noexcept
void setGraphAndPlugin(PatchbayGraph* const graph, CarlaPluginPtr plugin) noexcept
{
pData->graph = graph;
pData->plugin = plugin;
@@ -771,7 +771,7 @@ public:
CarlaEngineJackClient(const CarlaEngine& engine,
EngineInternalGraph& egraph,
CarlaRecursiveMutex& rmutex,
CarlaPlugin* const plugin,
const CarlaPluginPtr plugin,
const CarlaString& mainClientName,
jack_client_t* const jackClient)
: CarlaEngineClientForSubclassing(engine, egraph, plugin),
@@ -794,6 +794,7 @@ public:
fPreRenameConnections(),
fPreRenamePluginId(),
fPreRenamePluginIcon(),
fReservedPluginPtr(),
#endif
fThreadSafeMetadataMutex(rmutex),
fMainClientName(mainClientName)
@@ -913,9 +914,9 @@ public:
#endif
}

void deactivate() noexcept override
void deactivate(const bool willClose) noexcept override
{
carla_debug("CarlaEngineJackClient::deactivate()");
carla_debug("CarlaEngineJackClient::deactivate(%s)", bool2str(willClose));

if (getProcessMode() == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS)
{
@@ -926,7 +927,15 @@ public:
} catch(...) {}
}

CarlaEngineClient::deactivate();
if (willClose)
{
fCVSourcePorts.setGraphAndPlugin(nullptr, nullptr);
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
fReservedPluginPtr = nullptr;
#endif
}

CarlaEngineClient::deactivate(willClose);
}

bool isOk() const noexcept override
@@ -1071,7 +1080,7 @@ public:
}

fJackClient = nullptr;
CarlaEngineClient::deactivate();
CarlaEngineClient::deactivate(true);
}

const char* getJackClientName() const noexcept
@@ -1150,6 +1159,11 @@ public:
fJackClient = newClient;
}

void reservePluginPtr(CarlaPluginPtr* const pluginPtr)
{
fReservedPluginPtr = pluginPtr;
}

void setNewPluginId(const uint id) const
{
// NOTE: no fThreadSafeMetadataMutex lock here, assumed done from caller
@@ -1190,6 +1204,8 @@ private:
CarlaString fPreRenamePluginId;
CarlaString fPreRenamePluginIcon;

CarlaScopedPointer<CarlaPluginPtr> fReservedPluginPtr;

template<typename T>
bool _renamePorts(const LinkedList<T*>& t, const CarlaString& clientNamePrefix)
{
@@ -1885,11 +1901,13 @@ public:
}
#endif

CarlaEngineClient* addClient(CarlaPlugin* const plugin) override
CarlaEngineClient* addClient(CarlaPluginPtr plugin) override
{
jack_client_t* client = nullptr;

#ifndef BUILD_BRIDGE
CarlaPluginPtr* pluginReserve = nullptr;

if (pData->options.processMode == ENGINE_PROCESS_MODE_SINGLE_CLIENT)
{
client = fClient;
@@ -1937,13 +1955,14 @@ public:
}

#ifndef BUILD_BRIDGE
pluginReserve = new CarlaPluginPtr(plugin);
/*
jackbridge_set_buffer_size_callback(fClient, carla_jack_bufsize_callback_plugin, plugin);
jackbridge_set_sample_rate_callback(fClient, carla_jack_srate_callback_plugin, plugin);
jackbridge_set_buffer_size_callback(fClient, carla_jack_bufsize_callback_plugin, pluginReserve);
jackbridge_set_sample_rate_callback(fClient, carla_jack_srate_callback_plugin, pluginReserve);
*/
jackbridge_set_latency_callback(client, carla_jack_latency_callback_plugin, plugin);
jackbridge_set_process_callback(client, carla_jack_process_callback_plugin, plugin);
jackbridge_on_shutdown(client, carla_jack_shutdown_callback_plugin, plugin);
jackbridge_set_latency_callback(client, carla_jack_latency_callback_plugin, pluginReserve);
jackbridge_set_process_callback(client, carla_jack_process_callback_plugin, pluginReserve);
jackbridge_on_shutdown(client, carla_jack_shutdown_callback_plugin, pluginReserve);
#else
fClient = client;
pData->bufferSize = jackbridge_get_buffer_size(client);
@@ -1962,7 +1981,16 @@ public:
}

#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
return new CarlaEngineJackClient(*this, pData->graph, fThreadSafeMetadataMutex, plugin, fClientName, client);
CarlaEngineJackClient* const jclient = new CarlaEngineJackClient(*this,
pData->graph,
fThreadSafeMetadataMutex,
plugin, fClientName, client);
# ifndef BUILD_BRIDGE
if (pluginReserve != nullptr)
jclient->reservePluginPtr(pluginReserve);
# endif
return jclient;

#else
return new CarlaEngineJackClient(*this, fThreadSafeMetadataMutex, fClientName, client);
#endif
@@ -1978,7 +2006,7 @@ public:

for (uint i=id; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin = pData->plugins[i].plugin;
const CarlaPluginPtr plugin = pData->plugins[i].plugin;
CARLA_SAFE_ASSERT_BREAK(plugin != nullptr);

CarlaEngineJackClient* const client = dynamic_cast<CarlaEngineJackClient*>(plugin->getEngineClient());
@@ -1995,10 +2023,10 @@ public:
if (! CarlaEngine::switchPlugins(idA, idB))
return false;

CarlaPlugin* const newPluginA(pData->plugins[idA].plugin);
CarlaPluginPtr newPluginA = pData->plugins[idA].plugin;
CARLA_SAFE_ASSERT_RETURN(newPluginA != nullptr, true);

CarlaPlugin* const newPluginB(pData->plugins[idB].plugin);
CarlaPluginPtr newPluginB = pData->plugins[idB].plugin;
CARLA_SAFE_ASSERT_RETURN(newPluginB != nullptr, true);

CarlaEngineJackClient* const clientA = dynamic_cast<CarlaEngineJackClient*>(newPluginA->getEngineClient());
@@ -2029,7 +2057,7 @@ public:
CARLA_SAFE_ASSERT_RETURN(id < pData->curPluginCount, false);
CARLA_SAFE_ASSERT_RETURN(newName != nullptr && newName[0] != '\0', false);

CarlaPlugin* const plugin(pData->plugins[id].plugin);
CarlaPluginPtr plugin = pData->plugins[id].plugin;
CARLA_SAFE_ASSERT_RETURN_ERR(plugin != nullptr, "Could not find plugin to rename");
CARLA_SAFE_ASSERT_RETURN_ERR(plugin->getId() == id, "Invalid engine internal data");

@@ -2089,9 +2117,11 @@ public:
plugin->setEnabled(false);

// set new client data
jackbridge_set_latency_callback(jackClient, carla_jack_latency_callback_plugin, plugin);
jackbridge_set_process_callback(jackClient, carla_jack_process_callback_plugin, plugin);
jackbridge_on_shutdown(jackClient, carla_jack_shutdown_callback_plugin, plugin);
CarlaPluginPtr* const pluginReserve = new CarlaPluginPtr(plugin);
client->reservePluginPtr(pluginReserve);
jackbridge_set_latency_callback(jackClient, carla_jack_latency_callback_plugin, pluginReserve);
jackbridge_set_process_callback(jackClient, carla_jack_process_callback_plugin, pluginReserve);
jackbridge_on_shutdown(jackClient, carla_jack_shutdown_callback_plugin, pluginReserve);

// NOTE: jack1 locks up here
if (jackbridge_get_version_string() != nullptr)
@@ -2736,7 +2766,7 @@ protected:
CARLA_SAFE_ASSERT_INT2_RETURN(nframes == pData->bufferSize, nframes, pData->bufferSize,);

#ifdef BUILD_BRIDGE
CarlaPlugin* const plugin(pData->plugins[0].plugin);
CarlaPluginPtr plugin = pData->plugins[0].plugin;

if (plugin != nullptr && plugin->isEnabled() && plugin->tryLock(fFreewheel))
{
@@ -2829,7 +2859,7 @@ protected:
{
for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin != nullptr && plugin->isEnabled() && plugin->tryLock(fFreewheel))
{
@@ -2943,8 +2973,11 @@ protected:
// set first byte
mdataTmp[0] = static_cast<uint8_t>(midiEvent.data[0] | (engineEvent.channel & MIDI_CHANNEL_BIT));

// copy rest
carla_copy<uint8_t>(mdataTmp+1, midiEvent.data+1, size-1U);
if (size > 1)
{
// copy rest
carla_copy<uint8_t>(mdataTmp+1, midiEvent.data+1, size-1U);
}

// done
mdataPtr = mdataTmp;
@@ -3339,7 +3372,7 @@ protected:

for (uint i=0; i < pData->curPluginCount; ++i)
{
if (CarlaPlugin* const plugin = pData->plugins[i].plugin)
if (CarlaPluginPtr plugin = pData->plugins[i].plugin)
{
plugin->tryLock(true);

@@ -3794,7 +3827,7 @@ private:

// -------------------------------------------------------------------

void processPlugin(CarlaPlugin* const plugin, const uint32_t nframes)
void processPlugin(CarlaPluginPtr& plugin, const uint32_t nframes)
{
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
CarlaEngineJackClient* const client = (CarlaEngineJackClient*)plugin->getEngineClient();
@@ -4230,7 +4263,10 @@ private:
#ifndef BUILD_BRIDGE
static int JACKBRIDGE_API carla_jack_process_callback_plugin(jack_nframes_t nframes, void* arg) __attribute__((annotate("realtime")))
{
CarlaPlugin* const plugin((CarlaPlugin*)arg);
CarlaPluginPtr* const pluginPtr = static_cast<CarlaPluginPtr*>(arg);
CARLA_SAFE_ASSERT_RETURN(pluginPtr != nullptr, 0);

CarlaPluginPtr plugin = *pluginPtr;
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr && plugin->isEnabled(), 0);

CarlaEngineJack* const engine((CarlaEngineJack*)plugin->getEngine());


+ 52
- 47
source/backend/engine/CarlaEngineNative.cpp View File

@@ -155,8 +155,9 @@ protected:
private:
CarlaEngineNative* const fEngine;

void _updateParamValues(CarlaPlugin* const plugin, const uint32_t pluginId,
const bool sendCallback, const bool sendPluginHost) const noexcept;
void _updateParamValues(const CarlaPluginPtr& plugin,
uint32_t pluginId,
bool sendCallback, bool sendPluginHost) const noexcept;

CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineNativeUI)
};
@@ -446,7 +447,7 @@ protected:

// -------------------------------------------------------------------

void uiServerSendPluginInfo(CarlaPlugin* const plugin)
void uiServerSendPluginInfo(const CarlaPluginPtr& plugin)
{
char tmpBuf[STR_MAX+1];
carla_zeroChars(tmpBuf, STR_MAX+1);
@@ -518,16 +519,18 @@ protected:
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeEmptyMessage(),);
}

std::snprintf(tmpBuf, STR_MAX, "AUDIO_COUNT_%i:%i:%i\n", pluginId, plugin->getAudioInCount(), plugin->getAudioOutCount());
std::snprintf(tmpBuf, STR_MAX, "AUDIO_COUNT_%i:%i:%i\n",
pluginId, plugin->getAudioInCount(), plugin->getAudioOutCount());
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);

std::snprintf(tmpBuf, STR_MAX, "MIDI_COUNT_%i:%i:%i\n", pluginId, plugin->getMidiInCount(), plugin->getMidiOutCount());
std::snprintf(tmpBuf, STR_MAX, "MIDI_COUNT_%i:%i:%i\n",
pluginId, plugin->getMidiInCount(), plugin->getMidiOutCount());
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);

fUiServer.flushMessages();
}

void uiServerSendPluginParameters(CarlaPlugin* const plugin)
void uiServerSendPluginParameters(const CarlaPluginPtr& plugin)
{
char tmpBuf[STR_MAX+1];
carla_zeroChars(tmpBuf, STR_MAX+1);
@@ -617,7 +620,7 @@ protected:
fUiServer.flushMessages();
}

void uiServerSendPluginPrograms(CarlaPlugin* const plugin)
void uiServerSendPluginPrograms(const CarlaPluginPtr& plugin)
{
char tmpBuf[STR_MAX+1];
carla_zeroChars(tmpBuf, STR_MAX+1);
@@ -645,7 +648,8 @@ protected:
fUiServer.flushMessages();

count = plugin->getMidiProgramCount();
std::snprintf(tmpBuf, STR_MAX, "MIDI_PROGRAM_COUNT_%i:%i:%i\n", pluginId, count, plugin->getCurrentMidiProgram());
std::snprintf(tmpBuf, STR_MAX, "MIDI_PROGRAM_COUNT_%i:%i:%i\n",
pluginId, count, plugin->getCurrentMidiProgram());
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);

for (uint32_t i=0; i<count; ++i)
@@ -665,7 +669,7 @@ protected:
fUiServer.flushMessages();
}

void uiServerSendPluginProperties(CarlaPlugin* const plugin)
void uiServerSendPluginProperties(const CarlaPluginPtr& plugin)
{
char tmpBuf[STR_MAX+1];
carla_zeroChars(tmpBuf, STR_MAX+1);
@@ -705,7 +709,7 @@ protected:
if (! fUiServer.isPipeRunning())
return;

CarlaPlugin* plugin;
CarlaPluginPtr plugin;

switch (action)
{
@@ -957,7 +961,7 @@ protected:
carla_zeroChars(strBufGroupName, STR_MAX+1);

uint32_t rindex = index;
if (CarlaPlugin* const plugin = _getPluginForParameterIndex(rindex))
if (const CarlaPluginPtr plugin = _getPluginForParameterIndex(rindex))
{
const ParameterData& paramData(plugin->getParameterData(rindex));
const ParameterRanges& paramRanges(plugin->getParameterRanges(rindex));
@@ -1029,7 +1033,7 @@ protected:
float getParameterValue(const uint32_t index) const
{
uint32_t rindex = index;
if (CarlaPlugin* const plugin = _getPluginForParameterIndex(rindex))
if (const CarlaPluginPtr plugin = _getPluginForParameterIndex(rindex))
return plugin->getParameterValue(rindex);

return fParameters[index];
@@ -1041,7 +1045,7 @@ protected:
void setParameterValue(const uint32_t index, const float value)
{
uint32_t rindex = index;
if (CarlaPlugin* const plugin = _getPluginForParameterIndex(rindex))
if (const CarlaPluginPtr plugin = _getPluginForParameterIndex(rindex))
plugin->setParameterValueRT(rindex, value, false);

fParameters[index] = value;
@@ -1055,7 +1059,7 @@ protected:
#if 0
for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin == nullptr || ! plugin->isEnabled())
continue;
@@ -1072,7 +1076,7 @@ protected:
#if 0
for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin == nullptr || ! plugin->isEnabled())
continue;
@@ -1283,7 +1287,7 @@ protected:

for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin != nullptr && plugin->isEnabled())
{
@@ -1301,7 +1305,7 @@ protected:
// hide all custom uis
for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin != nullptr && plugin->isEnabled())
{
@@ -1320,7 +1324,7 @@ protected:
{
for (uint i=0; i < pData->curPluginCount; ++i)
{
CarlaPlugin* const plugin(pData->plugins[i].plugin);
CarlaPluginPtr plugin = pData->plugins[i].plugin;

if (plugin != nullptr && plugin->isEnabled())
{
@@ -1365,7 +1369,7 @@ protected:
void uiSetParameterValue(const uint32_t index, const float value)
{
uint32_t rindex = index;
if (CarlaPlugin* const plugin = _getPluginForParameterIndex(rindex))
if (const CarlaPluginPtr plugin = _getPluginForParameterIndex(rindex))
{
if (plugin->getHints() & PLUGIN_HAS_CUSTOM_UI)
plugin->uiParameterChange(rindex, value);
@@ -1436,7 +1440,7 @@ protected:
for (uint i=0; i < pData->curPluginCount; ++i)
{
const EnginePluginData& plugData(pData->plugins[i]);
const CarlaPlugin* const plugin(pData->plugins[i].plugin);
const CarlaPluginPtr plugin = pData->plugins[i].plugin;

std::snprintf(tmpBuf, STR_MAX, "PEAKS_%i\n", i);
CARLA_SAFE_ASSERT_RETURN(fUiServer.writeMessage(tmpBuf),);
@@ -1684,12 +1688,12 @@ private:

bool fOptionsForced;

CarlaPlugin* _getPluginForParameterIndex(uint32_t& index) const noexcept
CarlaPluginPtr _getPluginForParameterIndex(uint32_t& index) const noexcept
{
if (pData->curPluginCount == 0 || pData->plugins == nullptr)
return nullptr;

CarlaPlugin* plugin;
CarlaPluginPtr plugin;

for (uint32_t i=0; i<pData->curPluginCount; ++i)
{
@@ -1718,7 +1722,7 @@ private:
if (pData->curPluginCount == 0 || pluginId >= pData->curPluginCount || pData->plugins == nullptr)
return false;

CarlaPlugin* plugin;
CarlaPluginPtr plugin;

for (uint32_t i=0; i<pluginId; ++i)
{
@@ -1978,7 +1982,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename, false), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
{
plugin->loadStateFromFile(filename);
_updateParamValues(plugin, pluginId, false, true);
@@ -1992,7 +1996,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(filename, false), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->saveStateToFile(filename);
}
else if (std::strcmp(msg, "set_option") == 0)
@@ -2004,7 +2008,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(option), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(yesNo), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->setOption(option, yesNo, false);
}
else if (std::strcmp(msg, "set_active") == 0)
@@ -2015,7 +2019,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(onOff), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->setActive(onOff, true, false);
}
else if (std::strcmp(msg, "set_drywet") == 0)
@@ -2026,7 +2030,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->setDryWet(value, true, false);
}
else if (std::strcmp(msg, "set_volume") == 0)
@@ -2037,7 +2041,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->setVolume(value, true, false);
}
else if (std::strcmp(msg, "set_balance_left") == 0)
@@ -2048,7 +2052,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->setBalanceLeft(value, true, false);
}
else if (std::strcmp(msg, "set_balance_right") == 0)
@@ -2059,7 +2063,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->setBalanceRight(value, true, false);
}
else if (std::strcmp(msg, "set_panning") == 0)
@@ -2070,7 +2074,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->setPanning(value, true, false);
}
else if (std::strcmp(msg, "set_ctrl_channel") == 0)
@@ -2082,7 +2086,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(channel), true);
CARLA_SAFE_ASSERT_RETURN(channel >= -1 && channel < MAX_MIDI_CHANNELS, true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->setCtrlChannel(int8_t(channel), true, false);
}
else if (std::strcmp(msg, "set_parameter_value") == 0)
@@ -2094,7 +2098,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(parameterId), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
{
plugin->setParameterValue(parameterId, value, true, true, false);
fEngine->setParameterValueFromUI(pluginId, parameterId, value);
@@ -2109,7 +2113,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(channel), true);
CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->setParameterMidiChannel(parameterId, static_cast<uint8_t>(channel), true, false);
}
else if (std::strcmp(msg, "set_parameter_mapped_control_index") == 0)
@@ -2122,7 +2126,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(ctrl), true);
CARLA_SAFE_ASSERT_RETURN(ctrl >= CONTROL_INDEX_NONE && ctrl <= CONTROL_INDEX_MAX_ALLOWED, true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->setParameterMappedControlIndex(parameterId, static_cast<int16_t>(ctrl), true, false);
}
else if (std::strcmp(msg, "set_parameter_mapped_range") == 0)
@@ -2135,7 +2139,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(minimum), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(maximum), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->setParameterMappedRange(parameterId, minimum, maximum, true, false);
}
else if (std::strcmp(msg, "set_parameter_touch") == 0)
@@ -2158,7 +2162,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(index), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
{
plugin->setProgram(index, true, true, false);
_updateParamValues(plugin, pluginId, true, true);
@@ -2172,7 +2176,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsInt(index), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
{
plugin->setMidiProgram(index, true, true, false);
_updateParamValues(plugin, pluginId, true, true);
@@ -2190,7 +2194,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(key, true), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(value, false), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->setCustomData(type, key, value, true);

delete[] type;
@@ -2204,7 +2208,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(cdata, false), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
{
std::vector<uint8_t> chunk(carla_getChunkFromBase64String(cdata));
#ifdef CARLA_PROPER_CPP11_SUPPORT
@@ -2221,7 +2225,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept

CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->prepareForSave();
}
else if (std::strcmp(msg, "reset_parameters") == 0)
@@ -2230,7 +2234,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept

CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
{
plugin->resetParameters();
_updateParamValues(plugin, pluginId, false, true);
@@ -2242,7 +2246,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept

CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
{
plugin->randomizeParameters();
_updateParamValues(plugin, pluginId, false, true);
@@ -2260,7 +2264,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(note < MAX_MIDI_VALUE, true);
CARLA_SAFE_ASSERT_RETURN(velocity < MAX_MIDI_VALUE, true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->sendMidiSingleNote(static_cast<uint8_t>(channel), static_cast<uint8_t>(note), static_cast<uint8_t>(velocity), true, true, false);
}
else if (std::strcmp(msg, "show_custom_ui") == 0)
@@ -2271,7 +2275,7 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(pluginId), true);
CARLA_SAFE_ASSERT_RETURN(readNextLineAsBool(yesNo), true);

if (CarlaPlugin* const plugin = fEngine->getPlugin(pluginId))
if (const CarlaPluginPtr plugin = fEngine->getPlugin(pluginId))
plugin->showCustomUI(yesNo);
}
else
@@ -2291,7 +2295,8 @@ bool CarlaEngineNativeUI::msgReceived(const char* const msg) noexcept
return true;
}

void CarlaEngineNativeUI::_updateParamValues(CarlaPlugin* const plugin, const uint32_t pluginId,
void CarlaEngineNativeUI::_updateParamValues(const CarlaPluginPtr& plugin,
const uint32_t pluginId,
const bool sendCallback, const bool sendPluginHost) const noexcept
{
float value;


+ 1
- 1
source/backend/engine/CarlaEngineOsc.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla Plugin Host
* Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2020 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


+ 16
- 11
source/backend/engine/CarlaEngineOsc.hpp View File

@@ -1,6 +1,6 @@
/*
* Carla Plugin Host
* Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2020 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
@@ -27,7 +27,10 @@
#include "CarlaOscUtils.hpp"
#include "CarlaString.hpp"

#define CARLA_ENGINE_OSC_HANDLE_ARGS CarlaPlugin* const plugin, const int argc, const lo_arg* const* const argv, const char* const types
#include <memory>

#define CARLA_ENGINE_OSC_HANDLE_ARGS const CarlaPluginPtr& plugin, \
const int argc, const lo_arg* const* const argv, const char* const types

#define CARLA_ENGINE_OSC_CHECK_OSC_TYPES(/* argc, types, */ argcToCompare, typesToCompare) \
/* check argument count */ \
@@ -54,6 +57,8 @@

CARLA_BACKEND_START_NAMESPACE

typedef std::shared_ptr<CarlaPlugin> CarlaPluginPtr;

// -----------------------------------------------------------------------

class CarlaEngineOsc
@@ -96,15 +101,15 @@ public:
void sendCallback(EngineCallbackOpcode action, uint pluginId,
int value1, int value2, int value3,
float valuef, const char* valueStr) const noexcept;
void sendPluginInfo(const CarlaPlugin* plugin) const noexcept;
void sendPluginPortCount(const CarlaPlugin* plugin) const noexcept;
void sendPluginParameterInfo(const CarlaPlugin* plugin, uint32_t index) const noexcept;
void sendPluginDataCount(const CarlaPlugin* plugin) const noexcept;
void sendPluginProgramCount(const CarlaPlugin* plugin) const noexcept;
void sendPluginProgram(const CarlaPlugin* plugin, uint32_t index) const noexcept;
void sendPluginMidiProgram(const CarlaPlugin* plugin, uint32_t index) const noexcept;
void sendPluginCustomData(const CarlaPlugin* plugin, uint32_t index) const noexcept;
void sendPluginInternalParameterValues(const CarlaPlugin* plugin) const noexcept;
void sendPluginInfo(const CarlaPluginPtr& plugin) const noexcept;
void sendPluginPortCount(const CarlaPluginPtr& plugin) const noexcept;
void sendPluginParameterInfo(const CarlaPluginPtr& plugin, uint32_t index) const noexcept;
void sendPluginDataCount(const CarlaPluginPtr& plugin) const noexcept;
void sendPluginProgramCount(const CarlaPluginPtr& plugin) const noexcept;
void sendPluginProgram(const CarlaPluginPtr& plugin, uint32_t index) const noexcept;
void sendPluginMidiProgram(const CarlaPluginPtr& plugin, uint32_t index) const noexcept;
void sendPluginCustomData(const CarlaPluginPtr& plugin, uint32_t index) const noexcept;
void sendPluginInternalParameterValues(const CarlaPluginPtr& plugin) const noexcept;
void sendPing() const noexcept;
void sendResponse(int messageId, const char* error) const noexcept;
void sendExit() const noexcept;


+ 2
- 2
source/backend/engine/CarlaEngineOscHandlers.cpp View File

@@ -122,7 +122,7 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons
}

// Get plugin
CarlaPlugin* const plugin(fEngine->getPluginUnchecked(pluginId));
const CarlaPluginPtr plugin = fEngine->getPluginUnchecked(pluginId);

if (plugin == nullptr || plugin->getId() != pluginId)
{
@@ -239,7 +239,7 @@ int CarlaEngineOsc::handleMsgRegister(const bool isTCP,

for (uint i=0, count=fEngine->getCurrentPluginCount(); i < count; ++i)
{
CarlaPlugin* const plugin(fEngine->getPluginUnchecked(i));
const CarlaPluginPtr plugin = fEngine->getPluginUnchecked(i);
CARLA_SAFE_ASSERT_CONTINUE(plugin != nullptr);

fEngine->callback(false, true, ENGINE_CALLBACK_PLUGIN_ADDED, i, 0, 0, 0, 0.0f, plugin->getName());


+ 13
- 13
source/backend/engine/CarlaEngineOscSend.cpp View File

@@ -47,7 +47,7 @@ void CarlaEngineOsc::sendCallback(const EngineCallbackOpcode action, const uint
valueStr != nullptr ? valueStr : kNullString);
}

void CarlaEngineOsc::sendPluginInfo(const CarlaPlugin* const plugin) const noexcept
void CarlaEngineOsc::sendPluginInfo(const CarlaPluginPtr& plugin) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);
@@ -95,7 +95,7 @@ void CarlaEngineOsc::sendPluginInfo(const CarlaPlugin* const plugin) const noexc
bufRealName, bufLabel, bufMaker, bufCopyright);
}

void CarlaEngineOsc::sendPluginPortCount(const CarlaPlugin* const plugin) const noexcept
void CarlaEngineOsc::sendPluginPortCount(const CarlaPluginPtr& plugin) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);
@@ -124,12 +124,12 @@ void CarlaEngineOsc::sendPluginPortCount(const CarlaPlugin* const plugin) const
static_cast<int32_t>(plugin->getParameterCount()));
}

void CarlaEngineOsc::sendPluginParameterInfo(const CarlaPlugin* const plugin, const uint32_t index) const noexcept
void CarlaEngineOsc::sendPluginParameterInfo(const CarlaPluginPtr& plugin, const uint32_t index) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);
carla_debug("CarlaEngineOsc::sendPluginParameterInfo(%p, %u)", plugin, index);
carla_debug("CarlaEngineOsc::sendPluginParameterInfo(%p, %u)", plugin.get(), index);

char bufName[STR_MAX+1], bufUnit[STR_MAX+1], bufComment[STR_MAX+1], bufGroupName[STR_MAX+1];
carla_zeroChars(bufName, STR_MAX+1);
@@ -190,7 +190,7 @@ void CarlaEngineOsc::sendPluginParameterInfo(const CarlaPlugin* const plugin, co
static_cast<double>(paramRanges.stepLarge));
}

void CarlaEngineOsc::sendPluginDataCount(const CarlaPlugin* const plugin) const noexcept
void CarlaEngineOsc::sendPluginDataCount(const CarlaPluginPtr& plugin) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);
@@ -209,7 +209,7 @@ void CarlaEngineOsc::sendPluginDataCount(const CarlaPlugin* const plugin) const
static_cast<int32_t>(plugin->getCurrentMidiProgram()));
}

void CarlaEngineOsc::sendPluginProgramCount(const CarlaPlugin* const plugin) const noexcept
void CarlaEngineOsc::sendPluginProgramCount(const CarlaPluginPtr& plugin) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);
@@ -225,11 +225,11 @@ void CarlaEngineOsc::sendPluginProgramCount(const CarlaPlugin* const plugin) con
static_cast<int32_t>(plugin->getMidiProgramCount()));
}

void CarlaEngineOsc::sendPluginProgram(const CarlaPlugin* const plugin, const uint32_t index) const noexcept
void CarlaEngineOsc::sendPluginProgram(const CarlaPluginPtr& plugin, const uint32_t index) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);
carla_stdout("CarlaEngineOsc::sendPluginProgram(%p, %u)", plugin, index);
carla_stdout("CarlaEngineOsc::sendPluginProgram(%p, %u)", plugin.get(), index);

char strBuf[STR_MAX+1];
carla_zeroChars(strBuf, STR_MAX+1);
@@ -243,11 +243,11 @@ void CarlaEngineOsc::sendPluginProgram(const CarlaPlugin* const plugin, const ui
static_cast<int32_t>(plugin->getId()), static_cast<int32_t>(index), strBuf);
}

void CarlaEngineOsc::sendPluginMidiProgram(const CarlaPlugin* const plugin, const uint32_t index) const noexcept
void CarlaEngineOsc::sendPluginMidiProgram(const CarlaPluginPtr& plugin, const uint32_t index) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);
carla_stdout("CarlaEngineOsc::sendPluginProgram(%p, %u)", plugin, index);
carla_stdout("CarlaEngineOsc::sendPluginProgram(%p, %u)", plugin.get(), index);

const MidiProgramData& mpdata(plugin->getMidiProgramData(index));
CARLA_SAFE_ASSERT_RETURN(mpdata.name != nullptr,);
@@ -261,11 +261,11 @@ void CarlaEngineOsc::sendPluginMidiProgram(const CarlaPlugin* const plugin, cons
static_cast<int32_t>(mpdata.bank), static_cast<int32_t>(mpdata.program), mpdata.name);
}

void CarlaEngineOsc::sendPluginCustomData(const CarlaPlugin* const plugin, const uint32_t index) const noexcept
void CarlaEngineOsc::sendPluginCustomData(const CarlaPluginPtr& plugin, const uint32_t index) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);
carla_stdout("CarlaEngineOsc::sendPluginCustomData(%p, %u)", plugin, index);
carla_stdout("CarlaEngineOsc::sendPluginCustomData(%p, %u)", plugin.get(), index);

const CustomData& cdata(plugin->getCustomData(index));
CARLA_SAFE_ASSERT_RETURN(cdata.isValid(),);
@@ -279,7 +279,7 @@ void CarlaEngineOsc::sendPluginCustomData(const CarlaPlugin* const plugin, const
cdata.type, cdata.key, cdata.value);
}

void CarlaEngineOsc::sendPluginInternalParameterValues(const CarlaPlugin* const plugin) const noexcept
void CarlaEngineOsc::sendPluginInternalParameterValues(const CarlaPluginPtr& plugin) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);


+ 2
- 2
source/backend/engine/CarlaEnginePorts.hpp View File

@@ -36,7 +36,7 @@ struct CarlaEngineCVSourcePorts::ProtectedData {
CarlaRecursiveMutex rmutex;
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
PatchbayGraph* graph;
CarlaPlugin* plugin;
CarlaPluginPtr plugin;
#endif
water::Array<CarlaEngineEventCV> cvs;

@@ -76,7 +76,7 @@ public:
CarlaEngineCVSourcePortsForStandalone() : CarlaEngineCVSourcePorts() {}
~CarlaEngineCVSourcePortsForStandalone() override {}

inline void setGraphAndPlugin(PatchbayGraph* const graph, CarlaPlugin* const plugin) noexcept
inline void setGraphAndPlugin(PatchbayGraph* const graph, const CarlaPluginPtr plugin) noexcept
{
pData->graph = graph;
pData->plugin = plugin;


+ 2
- 2
source/backend/engine/CarlaEngineThread.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla Plugin Host
* Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2020 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
@@ -73,7 +73,7 @@ void CarlaEngineThread::run() noexcept

for (uint i=0, count = kEngine->getCurrentPluginCount(); i < count; ++i)
{
CarlaPlugin* const plugin(kEngine->getPluginUnchecked(i));
const CarlaPluginPtr plugin = kEngine->getPluginUnchecked(i);

CARLA_SAFE_ASSERT_CONTINUE(plugin != nullptr && plugin->isEnabled());
CARLA_SAFE_ASSERT_UINT2(i == plugin->getId(), i, plugin->getId());


+ 10
- 1
source/backend/plugin/CarlaPlugin.cpp View File

@@ -2547,6 +2547,15 @@ void CarlaPlugin::restoreLV2State() noexcept
carla_stderr2("Warning: restoreLV2State() called for non-implemented type");
}

void CarlaPlugin::prepareForDeletion() noexcept
{
carla_debug("CarlaPlugin::prepareForDeletion");

const CarlaMutexLocker cml(pData->masterMutex);

pData->client->deactivate(true);
}

void CarlaPlugin::waitForBridgeSaveSignal() noexcept
{
}
@@ -2571,7 +2580,7 @@ CarlaPlugin::ScopedDisabler::ScopedDisabler(CarlaPlugin* const plugin) noexcept
plugin->pData->enabled = false;

if (plugin->pData->client->isActive())
plugin->pData->client->deactivate();
plugin->pData->client->deactivate(false);
}
}



+ 4
- 3
source/backend/plugin/CarlaPluginAU.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla AU Plugin
* Copyright (C) 2014 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2014-2020 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
@@ -23,9 +23,10 @@ CARLA_BACKEND_START_NAMESPACE

// -------------------------------------------------------------------------------------------------------------------

CarlaPlugin* CarlaPlugin::newAU(const Initializer& init)
CarlaPluginPtr CarlaPlugin::newAU(const Initializer& init)
{
carla_debug("CarlaPlugin::newAU({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.label, init.uniqueId);
carla_debug("CarlaPlugin::newAU({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "})",
init.engine, init.filename, init.name, init.label, init.uniqueId);

#if defined(CARLA_OS_MAC)
return newJuce(init, "AU");


+ 11
- 10
source/backend/plugin/CarlaPluginBridge.cpp View File

@@ -424,7 +424,7 @@ public:
pData->masterMutex.lock();

if (pData->client != nullptr && pData->client->isActive())
pData->client->deactivate();
pData->client->deactivate(true);

if (pData->active)
{
@@ -2469,7 +2469,8 @@ public:

// -------------------------------------------------------------------

bool init(const char* const filename,
bool init(CarlaPluginPtr plugin,
const char* const filename,
const char* const name,
const char* const label,
const int64_t uniqueId,
@@ -2600,7 +2601,7 @@ public:
pData->name = pData->engine->getUniquePluginName("unknown");
}

pData->client = pData->engine->addClient(this);
pData->client = pData->engine->addClient(plugin);

if (pData->client == nullptr || ! pData->client->isOk())
{
@@ -3047,9 +3048,12 @@ CARLA_BACKEND_END_NAMESPACE

CARLA_BACKEND_START_NAMESPACE

CarlaPlugin* CarlaPlugin::newBridge(const Initializer& init, BinaryType btype, PluginType ptype, const char* bridgeBinary)
CarlaPluginPtr CarlaPlugin::newBridge(const Initializer& init,
BinaryType btype, PluginType ptype, const char* bridgeBinary)
{
carla_debug("CarlaPlugin::newBridge({%p, \"%s\", \"%s\", \"%s\"}, %s, %s, \"%s\")", init.engine, init.filename, init.name, init.label, BinaryType2Str(btype), PluginType2Str(ptype), bridgeBinary);
carla_debug("CarlaPlugin::newBridge({%p, \"%s\", \"%s\", \"%s\"}, %s, %s, \"%s\")",
init.engine, init.filename, init.name, init.label,
BinaryType2Str(btype), PluginType2Str(ptype), bridgeBinary);

if (bridgeBinary == nullptr || bridgeBinary[0] == '\0')
{
@@ -3063,13 +3067,10 @@ CarlaPlugin* CarlaPlugin::newBridge(const Initializer& init, BinaryType btype, P
++bridgeBinary;
#endif

CarlaPluginBridge* const plugin(new CarlaPluginBridge(init.engine, init.id, btype, ptype));
std::shared_ptr<CarlaPluginBridge> plugin(new CarlaPluginBridge(init.engine, init.id, btype, ptype));

if (! plugin->init(init.filename, init.name, init.label, init.uniqueId, init.options, bridgeBinary))
{
delete plugin;
if (! plugin->init(plugin, init.filename, init.name, init.label, init.uniqueId, init.options, bridgeBinary))
return nullptr;
}

return plugin;
}


+ 7
- 9
source/backend/plugin/CarlaPluginFluidSynth.cpp View File

@@ -118,7 +118,7 @@ public:
pData->masterMutex.lock();

if (pData->client != nullptr && pData->client->isActive())
pData->client->deactivate();
pData->client->deactivate(true);

if (pData->active)
{
@@ -1655,7 +1655,8 @@ public:

// -------------------------------------------------------------------

bool init(const char* const filename, const char* const name, const char* const label, const uint options)
bool init(const CarlaPluginPtr plugin,
const char* const filename, const char* const name, const char* const label, const uint options)
{
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

@@ -1723,7 +1724,7 @@ public:
// ---------------------------------------------------------------
// register client

pData->client = pData->engine->addClient(this);
pData->client = pData->engine->addClient(plugin);

if (pData->client == nullptr || ! pData->client->isOk())
{
@@ -1872,7 +1873,7 @@ CARLA_BACKEND_START_NAMESPACE

// -------------------------------------------------------------------------------------------------------------------

CarlaPlugin* CarlaPlugin::newFluidSynth(const Initializer& init, PluginType ptype, bool use16Outs)
CarlaPluginPtr CarlaPlugin::newFluidSynth(const Initializer& init, PluginType ptype, bool use16Outs)
{
carla_debug("CarlaPlugin::newFluidSynth({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "}, %s)",
init.engine, init.filename, init.name, init.label, init.uniqueId, bool2str(use16Outs));
@@ -1899,13 +1900,10 @@ CarlaPlugin* CarlaPlugin::newFluidSynth(const Initializer& init, PluginType ptyp
}
#endif

CarlaPluginFluidSynth* const plugin(new CarlaPluginFluidSynth(init.engine, init.id, use16Outs));
std::shared_ptr<CarlaPluginFluidSynth> plugin(new CarlaPluginFluidSynth(init.engine, init.id, use16Outs));

if (! plugin->init(init.filename, init.name, init.label, init.options))
{
delete plugin;
if (! plugin->init(plugin, init.filename, init.name, init.label, init.options))
return nullptr;
}

return plugin;
#else


+ 1
- 1
source/backend/plugin/CarlaPluginInternal.cpp View File

@@ -722,7 +722,7 @@ CarlaPlugin::ProtectedData::~ProtectedData() noexcept
{
// must not happen
carla_safe_assert("client->isActive()", __FILE__, __LINE__);
client->deactivate();
client->deactivate(true);
}

clearBuffers();


+ 8
- 10
source/backend/plugin/CarlaPluginJack.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla Plugin JACK
* Copyright (C) 2016-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2016-2020 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
@@ -504,7 +504,7 @@ public:
pData->masterMutex.lock();

if (pData->client != nullptr && pData->client->isActive())
pData->client->deactivate();
pData->client->deactivate(true);

if (pData->active)
{
@@ -1514,7 +1514,8 @@ public:

// -------------------------------------------------------------------

bool init(const char* const filename, const char* const name, const char* const label)
bool init(const CarlaPluginPtr plugin,
const char* const filename, const char* const name, const char* const label)
{
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

@@ -1657,7 +1658,7 @@ public:
if (pData->name == nullptr)
pData->name = pData->engine->getUniquePluginName("unknown");

pData->client = pData->engine->addClient(this);
pData->client = pData->engine->addClient(plugin);

if (pData->client == nullptr || ! pData->client->isOk())
{
@@ -1922,18 +1923,15 @@ CARLA_BACKEND_END_NAMESPACE

CARLA_BACKEND_START_NAMESPACE

CarlaPlugin* CarlaPlugin::newJackApp(const Initializer& init)
CarlaPluginPtr CarlaPlugin::newJackApp(const Initializer& init)
{
carla_debug("CarlaPlugin::newJackApp({%p, \"%s\", \"%s\", \"%s\"})", init.engine, init.filename, init.name, init.label);

#ifdef CARLA_OS_LINUX
CarlaPluginJack* const plugin(new CarlaPluginJack(init.engine, init.id));
std::shared_ptr<CarlaPluginJack> plugin(new CarlaPluginJack(init.engine, init.id));

if (! plugin->init(init.filename, init.name, init.label))
{
delete plugin;
if (! plugin->init(plugin, init.filename, init.name, init.label))
return nullptr;
}

return plugin;
#else


+ 10
- 10
source/backend/plugin/CarlaPluginJuce.cpp View File

@@ -89,7 +89,7 @@ public:
pData->masterMutex.lock();

if (pData->client != nullptr && pData->client->isActive())
pData->client->deactivate();
pData->client->deactivate(true);

if (pData->active)
{
@@ -1248,7 +1248,9 @@ protected:
// -------------------------------------------------------------------

public:
bool init(const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, const uint options, const char* const format)
bool init(const CarlaPluginPtr plugin,
const char* const filename, const char* const name, const char* const label,
const int64_t uniqueId, const uint options, const char* const format)
{
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

@@ -1386,7 +1388,7 @@ public:
// ---------------------------------------------------------------
// register client

pData->client = pData->engine->addClient(this);
pData->client = pData->engine->addClient(plugin);

if (pData->client == nullptr || ! pData->client->isOk())
{
@@ -1482,18 +1484,16 @@ CARLA_BACKEND_END_NAMESPACE

CARLA_BACKEND_START_NAMESPACE

CarlaPlugin* CarlaPlugin::newJuce(const Initializer& init, const char* const format)
CarlaPluginPtr CarlaPlugin::newJuce(const Initializer& init, const char* const format)
{
carla_debug("CarlaPlugin::newJuce({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "}, %s)", init.engine, init.filename, init.name, init.label, init.uniqueId, format);
carla_debug("CarlaPlugin::newJuce({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "}, %s)",
init.engine, init.filename, init.name, init.label, init.uniqueId, format);

#ifdef USING_JUCE
CarlaPluginJuce* const plugin(new CarlaPluginJuce(init.engine, init.id));
std::shared_ptr<CarlaPluginJuce> plugin(new CarlaPluginJuce(init.engine, init.id));

if (! plugin->init(init.filename, init.name, init.label, init.uniqueId, init.options, format))
{
delete plugin;
if (! plugin->init(plugin, init.filename, init.name, init.label, init.uniqueId, init.options, format))
return nullptr;
}

return plugin;
#else


+ 17
- 20
source/backend/plugin/CarlaPluginLADSPADSSI.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla Plugin, LADSPA/DSSI implementation
* Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2020 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
@@ -326,7 +326,7 @@ public:
pData->masterMutex.lock();

if (pData->client != nullptr && pData->client->isActive())
pData->client->deactivate();
pData->client->deactivate(true);

if (pData->active)
{
@@ -2657,7 +2657,8 @@ public:

// -------------------------------------------------------------------

bool initLADSPA(const char* const filename, const char* name, const char* const label, const uint options,
bool initLADSPA(const CarlaPluginPtr plugin,
const char* const filename, const char* name, const char* const label, const uint options,
const LADSPA_RDF_Descriptor* const rdfDescriptor)
{
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);
@@ -2740,10 +2741,11 @@ public:
return false;
}

return init2(filename, name, options, rdfDescriptor);
return init2(plugin, filename, name, options, rdfDescriptor);
}

bool initDSSI(const char* const filename, const char* name, const char* const label, const uint options)
bool initDSSI(const CarlaPluginPtr plugin,
const char* const filename, const char* name, const char* const label, const uint options)
{
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

@@ -2845,10 +2847,11 @@ public:
return false;
}

return init2(filename, name, options, nullptr);
return init2(plugin, filename, name, options, nullptr);
}

bool init2(const char* const filename, const char* name, const uint options,
bool init2(const CarlaPluginPtr plugin,
const char* const filename, const char* name, const uint options,
const LADSPA_RDF_Descriptor* const rdfDescriptor)
{
// ---------------------------------------------------------------
@@ -2885,7 +2888,7 @@ public:
// ---------------------------------------------------------------
// register client

pData->client = pData->engine->addClient(this);
pData->client = pData->engine->addClient(plugin);

if (pData->client == nullptr || ! pData->client->isOk())
{
@@ -3126,34 +3129,28 @@ private:

// -------------------------------------------------------------------------------------------------------------------

CarlaPlugin* CarlaPlugin::newLADSPA(const Initializer& init, const LADSPA_RDF_Descriptor* const rdfDescriptor)
CarlaPluginPtr CarlaPlugin::newLADSPA(const Initializer& init, const LADSPA_RDF_Descriptor* const rdfDescriptor)
{
carla_debug("CarlaPlugin::newLADSPA({%p, \"%s\", \"%s\", \"%s\", " P_INT64 ", %x}, %p)",
init.engine, init.filename, init.name, init.label, init.uniqueId, init.options, rdfDescriptor);

CarlaPluginLADSPADSSI* const plugin(new CarlaPluginLADSPADSSI(init.engine, init.id));
std::shared_ptr<CarlaPluginLADSPADSSI> plugin(new CarlaPluginLADSPADSSI(init.engine, init.id));

if (! plugin->initLADSPA(init.filename, init.name, init.label, init.options, rdfDescriptor))
{
delete plugin;
if (! plugin->initLADSPA(plugin, init.filename, init.name, init.label, init.options, rdfDescriptor))
return nullptr;
}

return plugin;
}

CarlaPlugin* CarlaPlugin::newDSSI(const Initializer& init)
CarlaPluginPtr CarlaPlugin::newDSSI(const Initializer& init)
{
carla_debug("CarlaPlugin::newDSSI({%p, \"%s\", \"%s\", \"%s\", " P_INT64 ", %x})",
init.engine, init.filename, init.name, init.label, init.uniqueId, init.options);

CarlaPluginLADSPADSSI* const plugin(new CarlaPluginLADSPADSSI(init.engine, init.id));
std::shared_ptr<CarlaPluginLADSPADSSI> plugin(new CarlaPluginLADSPADSSI(init.engine, init.id));

if (! plugin->initDSSI(init.filename, init.name, init.label, init.options))
{
delete plugin;
if (! plugin->initDSSI(plugin, init.filename, init.name, init.label, init.options))
return nullptr;
}

return plugin;
}


+ 14
- 15
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla LV2 Plugin
* Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2020 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
@@ -683,7 +683,7 @@ public:
pData->masterMutex.lock();

if (pData->client != nullptr && pData->client->isActive())
pData->client->deactivate();
pData->client->deactivate(true);

if (pData->active)
{
@@ -5321,7 +5321,7 @@ public:
fInlineDisplayNeedsRedraw = true;
}

const LV2_Inline_Display_Image_Surface* renderInlineDisplay(const uint32_t width, const uint32_t height)
const LV2_Inline_Display_Image_Surface* renderInlineDisplay(const uint32_t width, const uint32_t height) const
{
CARLA_SAFE_ASSERT_RETURN(fExt.inlineDisplay != nullptr && fExt.inlineDisplay->render != nullptr, nullptr);
CARLA_SAFE_ASSERT_RETURN(width > 0, nullptr);
@@ -5640,7 +5640,8 @@ public:
// -------------------------------------------------------------------

public:
bool init(const char* const name, const char* const uri, const uint options)
bool init(const CarlaPluginPtr plugin,
const char* const name, const char* const uri, const uint options)
{
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

@@ -5828,7 +5829,7 @@ public:
// ---------------------------------------------------------------
// register client

pData->client = pData->engine->addClient(this);
pData->client = pData->engine->addClient(plugin);

if (pData->client == nullptr || ! pData->client->isOk())
{
@@ -7380,27 +7381,25 @@ bool CarlaPipeServerLV2::msgReceived(const char* const msg) noexcept

// -------------------------------------------------------------------------------------------------------------------

CarlaPlugin* CarlaPlugin::newLV2(const Initializer& init)
CarlaPluginPtr CarlaPlugin::newLV2(const Initializer& init)
{
carla_debug("CarlaPlugin::newLV2({%p, \"%s\", \"%s\", " P_INT64 "})", init.engine, init.name, init.label, init.uniqueId);
carla_debug("CarlaPlugin::newLV2({%p, \"%s\", \"%s\", " P_INT64 "})",
init.engine, init.name, init.label, init.uniqueId);

CarlaPluginLV2* const plugin(new CarlaPluginLV2(init.engine, init.id));
std::shared_ptr<CarlaPluginLV2> plugin(new CarlaPluginLV2(init.engine, init.id));

if (! plugin->init(init.name, init.label, init.options))
{
delete plugin;
if (! plugin->init(plugin, init.name, init.label, init.options))
return nullptr;
}

return plugin;
}

// used in CarlaStandalone.cpp
const void* carla_render_inline_display_lv2(CarlaPlugin* plugin, uint32_t width, uint32_t height);
const void* carla_render_inline_display_lv2(const CarlaPluginPtr& plugin, uint32_t width, uint32_t height);

const void* carla_render_inline_display_lv2(CarlaPlugin* plugin, uint32_t width, uint32_t height)
const void* carla_render_inline_display_lv2(const CarlaPluginPtr& plugin, uint32_t width, uint32_t height)
{
CarlaPluginLV2* const lv2Plugin = (CarlaPluginLV2*)plugin;
const std::shared_ptr<CarlaPluginLV2>& lv2Plugin((const std::shared_ptr<CarlaPluginLV2>&)plugin);

return lv2Plugin->renderInlineDisplay(width, height);
}


+ 14
- 15
source/backend/plugin/CarlaPluginNative.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla Native Plugin
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2020 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
@@ -312,7 +312,7 @@ public:
pData->masterMutex.lock();

if (pData->client != nullptr && pData->client->isActive())
pData->client->deactivate();
pData->client->deactivate(true);

CARLA_ASSERT(! fIsProcessing);

@@ -2620,7 +2620,7 @@ public:

// -------------------------------------------------------------------

const NativeInlineDisplayImageSurface* renderInlineDisplay(const uint32_t width, const uint32_t height)
const NativeInlineDisplayImageSurface* renderInlineDisplay(const uint32_t width, const uint32_t height) const
{
CARLA_SAFE_ASSERT_RETURN(fDescriptor->hints & NATIVE_PLUGIN_HAS_INLINE_DISPLAY, nullptr);
CARLA_SAFE_ASSERT_RETURN(fDescriptor->render_inline_display, nullptr);
@@ -2774,7 +2774,8 @@ public:

// -------------------------------------------------------------------

bool init(const char* const name, const char* const label, const uint options)
bool init(const CarlaPluginPtr plugin,
const char* const name, const char* const label, const uint options)
{
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

@@ -2859,7 +2860,7 @@ public:
// ---------------------------------------------------------------
// register client

pData->client = pData->engine->addClient(this);
pData->client = pData->engine->addClient(plugin);

if (pData->client == nullptr || ! pData->client->isOk())
{
@@ -3037,27 +3038,25 @@ private:

// -----------------------------------------------------------------------

CarlaPlugin* CarlaPlugin::newNative(const Initializer& init)
CarlaPluginPtr CarlaPlugin::newNative(const Initializer& init)
{
carla_debug("CarlaPlugin::newNative({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.label, init.uniqueId);
carla_debug("CarlaPlugin::newNative({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "})",
init.engine, init.filename, init.name, init.label, init.uniqueId);

CarlaPluginNative* const plugin(new CarlaPluginNative(init.engine, init.id));
std::shared_ptr<CarlaPluginNative> plugin(new CarlaPluginNative(init.engine, init.id));

if (! plugin->init(init.name, init.label, init.options))
{
delete plugin;
if (! plugin->init(plugin, init.name, init.label, init.options))
return nullptr;
}

return plugin;
}

// used in CarlaStandalone.cpp
const void* carla_render_inline_display_internal(CarlaPlugin* plugin, uint32_t width, uint32_t height);
const void* carla_render_inline_display_internal(const CarlaPluginPtr& plugin, uint32_t width, uint32_t height);

const void* carla_render_inline_display_internal(CarlaPlugin* plugin, uint32_t width, uint32_t height)
const void* carla_render_inline_display_internal(const CarlaPluginPtr& plugin, uint32_t width, uint32_t height)
{
CarlaPluginNative* const nativePlugin = (CarlaPluginNative*)plugin;
const std::shared_ptr<CarlaPluginNative>& nativePlugin((const std::shared_ptr<CarlaPluginNative>&)plugin);

return nativePlugin->renderInlineDisplay(width, height);
}


+ 8
- 10
source/backend/plugin/CarlaPluginSFZero.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla SFZero Plugin
* Copyright (C) 2018-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2018-2020 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
@@ -68,7 +68,7 @@ public:
pData->masterMutex.lock();

if (pData->client != nullptr && pData->client->isActive())
pData->client->deactivate();
pData->client->deactivate(true);

if (pData->active)
{
@@ -662,7 +662,8 @@ public:

// -------------------------------------------------------------------

bool init(const char* const filename, const char* const name, const char* const label, const uint options)
bool init(const CarlaPluginPtr plugin,
const char* const filename, const char* const name, const char* const label, const uint options)
{
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

@@ -729,7 +730,7 @@ public:
// ---------------------------------------------------------------
// register client

pData->client = pData->engine->addClient(this);
pData->client = pData->engine->addClient(plugin);

if (pData->client == nullptr || ! pData->client->isOk())
{
@@ -770,7 +771,7 @@ private:

// -------------------------------------------------------------------------------------------------------------------

CarlaPlugin* CarlaPlugin::newSFZero(const Initializer& init)
CarlaPluginPtr CarlaPlugin::newSFZero(const Initializer& init)
{
carla_debug("CarlaPluginSFZero::newSFZero({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "})",
init.engine, init.filename, init.name, init.label, init.uniqueId);
@@ -784,13 +785,10 @@ CarlaPlugin* CarlaPlugin::newSFZero(const Initializer& init)
return nullptr;
}

CarlaPluginSFZero* const plugin(new CarlaPluginSFZero(init.engine, init.id));
std::shared_ptr<CarlaPluginSFZero> plugin(new CarlaPluginSFZero(init.engine, init.id));

if (! plugin->init(init.filename, init.name, init.label, init.options))
{
delete plugin;
if (! plugin->init(plugin, init.filename, init.name, init.label, init.options))
return nullptr;
}

return plugin;
}


+ 9
- 10
source/backend/plugin/CarlaPluginVST2.cpp View File

@@ -128,7 +128,7 @@ public:
pData->masterMutex.lock();

if (pData->client != nullptr && pData->client->isActive())
pData->client->deactivate();
pData->client->deactivate(true);

CARLA_ASSERT(! fIsProcessing);

@@ -2357,7 +2357,8 @@ protected:
// -------------------------------------------------------------------

public:
bool init(const char* const filename, const char* const name, const int64_t uniqueId, const uint options)
bool init(const CarlaPluginPtr plugin,
const char* const filename, const char* const name, const int64_t uniqueId, const uint options)
{
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

@@ -2564,7 +2565,7 @@ public:
// ---------------------------------------------------------------
// register client

pData->client = pData->engine->addClient(this);
pData->client = pData->engine->addClient(plugin);

if (pData->client == nullptr || ! pData->client->isOk())
{
@@ -2864,22 +2865,20 @@ CARLA_BACKEND_END_NAMESPACE

CARLA_BACKEND_START_NAMESPACE

CarlaPlugin* CarlaPlugin::newVST2(const Initializer& init)
CarlaPluginPtr CarlaPlugin::newVST2(const Initializer& init)
{
carla_debug("CarlaPlugin::newVST2({%p, \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.uniqueId);
carla_debug("CarlaPlugin::newVST2({%p, \"%s\", \"%s\", " P_INT64 "})",
init.engine, init.filename, init.name, init.uniqueId);

#ifdef USE_JUCE_FOR_VST2
if (std::getenv("CARLA_DO_NOT_USE_JUCE_FOR_VST2") == nullptr)
return newJuce(init, "VST2");
#endif

CarlaPluginVST2* const plugin(new CarlaPluginVST2(init.engine, init.id));
std::shared_ptr<CarlaPluginVST2> plugin(new CarlaPluginVST2(init.engine, init.id));

if (! plugin->init(init.filename, init.name, init.uniqueId, init.options))
{
delete plugin;
if (! plugin->init(plugin, init.filename, init.name, init.uniqueId, init.options))
return nullptr;
}

return plugin;
}


+ 4
- 3
source/backend/plugin/CarlaPluginVST3.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla VST3 Plugin
* Copyright (C) 2014 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2014-2020 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
@@ -23,9 +23,10 @@ CARLA_BACKEND_START_NAMESPACE

// -------------------------------------------------------------------------------------------------------------------

CarlaPlugin* CarlaPlugin::newVST3(const Initializer& init)
CarlaPluginPtr CarlaPlugin::newVST3(const Initializer& init)
{
carla_debug("CarlaPlugin::newVST3({%p, \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.uniqueId);
carla_debug("CarlaPlugin::newVST3({%p, \"%s\", \"%s\", " P_INT64 "})",
init.engine, init.filename, init.name, init.uniqueId);

#ifdef USING_JUCE
return newJuce(init, "VST3");


+ 4
- 2
source/bridges-plugin/CarlaBridgeSingleLV2.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla LV2 Single Plugin
* Copyright (C) 2017-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2017-2020 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
@@ -145,6 +145,8 @@ public:
if (fPlugin != nullptr && fIsActive)
fPlugin->setActive(false, false, false);

fPlugin = nullptr;

close();
}

@@ -496,7 +498,7 @@ protected:
// ----------------------------------------------------------------------------------------------------------------

private:
CarlaPlugin* fPlugin;
std::shared_ptr<CarlaPlugin> fPlugin;
CarlaString fUiName;

#ifdef USING_JUCE


Loading…
Cancel
Save