Browse Source

Move a bit more stuff around

tags/1.9.4
falkTX 11 years ago
parent
commit
40c7a02c08
23 changed files with 741 additions and 572 deletions
  1. +10
    -9
      source/backend/CarlaEngine.hpp
  2. +8
    -0
      source/backend/CarlaPlugin.hpp
  3. +13
    -13
      source/backend/engine/CarlaEngine.cpp
  4. +17
    -16
      source/backend/engine/CarlaEngineInternal.cpp
  5. +42
    -16
      source/backend/engine/CarlaEngineInternal.hpp
  6. +3
    -3
      source/backend/engine/CarlaEngineJack.cpp
  7. +1
    -1
      source/backend/engine/CarlaEngineJuce.cpp
  8. +6
    -6
      source/backend/engine/CarlaEngineNative.cpp
  9. +2
    -2
      source/backend/engine/CarlaEngineRtAudio.cpp
  10. +3
    -1
      source/backend/plugin/AuPlugin.cpp
  11. +1
    -0
      source/backend/plugin/BridgePlugin.cpp
  12. +1
    -0
      source/backend/plugin/CarlaPlugin.cpp
  13. +553
    -2
      source/backend/plugin/CarlaPluginInternal.cpp
  14. +72
    -503
      source/backend/plugin/CarlaPluginInternal.hpp
  15. +1
    -0
      source/backend/plugin/CsoundPlugin.cpp
  16. +1
    -0
      source/backend/plugin/DssiPlugin.cpp
  17. +1
    -0
      source/backend/plugin/FluidSynthPlugin.cpp
  18. +1
    -0
      source/backend/plugin/JucePlugin.cpp
  19. +1
    -0
      source/backend/plugin/LadspaPlugin.cpp
  20. +1
    -0
      source/backend/plugin/LinuxSamplerPlugin.cpp
  21. +1
    -0
      source/backend/plugin/Lv2Plugin.cpp
  22. +1
    -0
      source/backend/plugin/NativePlugin.cpp
  23. +1
    -0
      source/backend/plugin/VstPlugin.cpp

+ 10
- 9
source/backend/CarlaEngine.hpp View File

@@ -24,12 +24,16 @@
struct CarlaOscData; struct CarlaOscData;
#endif #endif


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

CARLA_BACKEND_START_NAMESPACE CARLA_BACKEND_START_NAMESPACE


#if 0 #if 0
} /* Fix editor indentation */ } /* Fix editor indentation */
#endif #endif


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

/*! /*!
* @defgroup CarlaEngineAPI Carla Engine API * @defgroup CarlaEngineAPI Carla Engine API
* *
@@ -159,6 +163,8 @@ enum EngineControlEventType {
kEngineControlEventTypeAllNotesOff = 5 kEngineControlEventTypeAllNotesOff = 5
}; };


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

/*! /*!
* Engine control event. * Engine control event.
*/ */
@@ -194,8 +200,6 @@ struct EngineMidiEvent {
* Engine event. * Engine event.
*/ */
struct EngineEvent { struct EngineEvent {
static const ushort kMaxInternalCount = 512; //!< Maximum pre-allocated events for rack and bridge modes

EngineEventType type; //!< Event Type; either Control or MIDI EngineEventType type; //!< Event Type; either Control or MIDI
uint32_t time; //!< Time offset in frames uint32_t time; //!< Time offset in frames
uint8_t channel; //!< Channel, used for MIDI-related events uint8_t channel; //!< Channel, used for MIDI-related events
@@ -214,6 +218,8 @@ struct EngineEvent {
void fillFromMidiData(const uint8_t size, const uint8_t* const data) noexcept; void fillFromMidiData(const uint8_t size, const uint8_t* const data) noexcept;
}; };


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

/*! /*!
* Engine options. * Engine options.
*/ */
@@ -1042,11 +1048,6 @@ protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Patchbay stuff // Patchbay stuff


/*!
* Called from patchbayRefresh() after all rack ports are in place.
*/
void handleRackConnectionsRefresh();

/*! /*!
* Virtual functions for handling MIDI ports in the rack patchbay. * Virtual functions for handling MIDI ports in the rack patchbay.
*/ */
@@ -1054,8 +1055,6 @@ protected:
virtual bool connectRackMidiOutPort(const int) { return false; } virtual bool connectRackMidiOutPort(const int) { return false; }
virtual bool disconnectRackMidiInPort(const int) { return false; } virtual bool disconnectRackMidiInPort(const int) { return false; }
virtual bool disconnectRackMidiOutPort(const int) { return false; } virtual bool disconnectRackMidiOutPort(const int) { return false; }
virtual uint getMidiConnectionsCount(const bool) { return 0; }
virtual uint getMidiConnectionPortId(const uint) { return 0; }


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


@@ -1162,6 +1161,8 @@ public:


/**@}*/ /**@}*/


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

CARLA_BACKEND_END_NAMESPACE CARLA_BACKEND_END_NAMESPACE


#endif // CARLA_ENGINE_HPP_INCLUDED #endif // CARLA_ENGINE_HPP_INCLUDED

+ 8
- 0
source/backend/CarlaPlugin.hpp View File

@@ -20,17 +20,23 @@


#include "CarlaBackend.h" #include "CarlaBackend.h"


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

typedef void* lo_address; typedef void* lo_address;
typedef struct _NativePluginDescriptor NativePluginDescriptor; typedef struct _NativePluginDescriptor NativePluginDescriptor;
struct LADSPA_RDF_Descriptor; struct LADSPA_RDF_Descriptor;


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

CARLA_BACKEND_START_NAMESPACE CARLA_BACKEND_START_NAMESPACE


#if 0 #if 0
} /* Fix editor indentation */ } /* Fix editor indentation */
#endif #endif


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

/*! /*!
* @defgroup CarlaPluginAPI Carla Plugin API * @defgroup CarlaPluginAPI Carla Plugin API
* *
@@ -899,6 +905,8 @@ protected:


/**@}*/ /**@}*/


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

CARLA_BACKEND_END_NAMESPACE CARLA_BACKEND_END_NAMESPACE


#endif // CARLA_PLUGIN_HPP_INCLUDED #endif // CARLA_PLUGIN_HPP_INCLUDED

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

@@ -32,9 +32,9 @@
#include "CarlaEngineUtils.hpp" #include "CarlaEngineUtils.hpp"
#include "CarlaStateUtils.hpp" #include "CarlaStateUtils.hpp"


#include <cmath>
#ifdef HAVE_JUCE
#ifndef HAVE_JUCE
# include <cmath>
#else
# include "juce_audio_basics.h" # include "juce_audio_basics.h"
using juce::FloatVectorOperations; using juce::FloatVectorOperations;
#endif #endif
@@ -145,7 +145,7 @@ CarlaEngineEventPort::CarlaEngineEventPort(const CarlaEngine& engine, const bool
carla_debug("CarlaEngineEventPort::CarlaEngineEventPort(%s)", bool2str(isInput)); carla_debug("CarlaEngineEventPort::CarlaEngineEventPort(%s)", bool2str(isInput));


if (fProcessMode == ENGINE_PROCESS_MODE_PATCHBAY) if (fProcessMode == ENGINE_PROCESS_MODE_PATCHBAY)
fBuffer = new EngineEvent[EngineEvent::kMaxInternalCount];
fBuffer = new EngineEvent[kMaxEngineEventInternalCount];
} }


CarlaEngineEventPort::~CarlaEngineEventPort() CarlaEngineEventPort::~CarlaEngineEventPort()
@@ -166,7 +166,7 @@ void CarlaEngineEventPort::initBuffer()
if (fProcessMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || fProcessMode == ENGINE_PROCESS_MODE_BRIDGE) if (fProcessMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || fProcessMode == ENGINE_PROCESS_MODE_BRIDGE)
fBuffer = fEngine.getInternalEventBuffer(fIsInput); fBuffer = fEngine.getInternalEventBuffer(fIsInput);
else if (fProcessMode == ENGINE_PROCESS_MODE_PATCHBAY && ! fIsInput) else if (fProcessMode == ENGINE_PROCESS_MODE_PATCHBAY && ! fIsInput)
carla_zeroStruct<EngineEvent>(fBuffer, EngineEvent::kMaxInternalCount);
carla_zeroStruct<EngineEvent>(fBuffer, kMaxEngineEventInternalCount);
} }


uint32_t CarlaEngineEventPort::getEventCount() const noexcept uint32_t CarlaEngineEventPort::getEventCount() const noexcept
@@ -177,7 +177,7 @@ uint32_t CarlaEngineEventPort::getEventCount() const noexcept


uint32_t i=0; uint32_t i=0;


for (; i < EngineEvent::kMaxInternalCount; ++i)
for (; i < kMaxEngineEventInternalCount; ++i)
{ {
if (fBuffer[i].type == kEngineEventTypeNull) if (fBuffer[i].type == kEngineEventTypeNull)
break; break;
@@ -191,7 +191,7 @@ const EngineEvent& CarlaEngineEventPort::getEvent(const uint32_t index) noexcept
CARLA_SAFE_ASSERT_RETURN(fIsInput, kFallbackEngineEvent); CARLA_SAFE_ASSERT_RETURN(fIsInput, kFallbackEngineEvent);
CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, kFallbackEngineEvent); CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, kFallbackEngineEvent);
CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, kFallbackEngineEvent); CARLA_SAFE_ASSERT_RETURN(fProcessMode != ENGINE_PROCESS_MODE_SINGLE_CLIENT && fProcessMode != ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS, kFallbackEngineEvent);
CARLA_SAFE_ASSERT_RETURN(index < EngineEvent::kMaxInternalCount, kFallbackEngineEvent);
CARLA_SAFE_ASSERT_RETURN(index < kMaxEngineEventInternalCount, kFallbackEngineEvent);


return fBuffer[index]; return fBuffer[index];
} }
@@ -216,7 +216,7 @@ bool CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t


const float fixedValue(carla_fixValue<float>(0.0f, 1.0f, value)); const float fixedValue(carla_fixValue<float>(0.0f, 1.0f, value));


for (uint32_t i=0; i < EngineEvent::kMaxInternalCount; ++i)
for (uint32_t i=0; i < kMaxEngineEventInternalCount; ++i)
{ {
if (fBuffer[i].type != kEngineEventTypeNull) if (fBuffer[i].type != kEngineEventTypeNull)
continue; continue;
@@ -252,7 +252,7 @@ bool CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t cha
CARLA_SAFE_ASSERT_RETURN(size > 0 && size <= EngineMidiEvent::kDataSize, false); CARLA_SAFE_ASSERT_RETURN(size > 0 && size <= EngineMidiEvent::kDataSize, false);
CARLA_SAFE_ASSERT_RETURN(data != nullptr, false); CARLA_SAFE_ASSERT_RETURN(data != nullptr, false);


for (uint32_t i=0; i < EngineEvent::kMaxInternalCount; ++i)
for (uint32_t i=0; i < kMaxEngineEventInternalCount; ++i)
{ {
if (fBuffer[i].type != kEngineEventTypeNull) if (fBuffer[i].type != kEngineEventTypeNull)
continue; continue;
@@ -586,8 +586,8 @@ bool CarlaEngine::init(const char* const clientName)


case ENGINE_PROCESS_MODE_CONTINUOUS_RACK: case ENGINE_PROCESS_MODE_CONTINUOUS_RACK:
pData->maxPluginNumber = MAX_RACK_PLUGINS; pData->maxPluginNumber = MAX_RACK_PLUGINS;
pData->bufEvents.in = new EngineEvent[EngineEvent::kMaxInternalCount];
pData->bufEvents.out = new EngineEvent[EngineEvent::kMaxInternalCount];
pData->bufEvents.in = new EngineEvent[kMaxEngineEventInternalCount];
pData->bufEvents.out = new EngineEvent[kMaxEngineEventInternalCount];
break; break;


case ENGINE_PROCESS_MODE_PATCHBAY: case ENGINE_PROCESS_MODE_PATCHBAY:
@@ -596,8 +596,8 @@ bool CarlaEngine::init(const char* const clientName)


case ENGINE_PROCESS_MODE_BRIDGE: case ENGINE_PROCESS_MODE_BRIDGE:
pData->maxPluginNumber = 1; pData->maxPluginNumber = 1;
pData->bufEvents.in = new EngineEvent[EngineEvent::kMaxInternalCount];
pData->bufEvents.out = new EngineEvent[EngineEvent::kMaxInternalCount];
pData->bufEvents.in = new EngineEvent[kMaxEngineEventInternalCount];
pData->bufEvents.out = new EngineEvent[kMaxEngineEventInternalCount];
break; break;
} }




+ 17
- 16
source/backend/engine/CarlaEngineInternal.cpp View File

@@ -17,7 +17,6 @@


#include "CarlaEngineInternal.hpp" #include "CarlaEngineInternal.hpp"
#include "CarlaPlugin.hpp" #include "CarlaPlugin.hpp"

#include "CarlaMIDI.h" #include "CarlaMIDI.h"


#ifndef HAVE_JUCE #ifndef HAVE_JUCE
@@ -377,7 +376,7 @@ void EnginePatchbayBuffers::resize(const uint32_t /*bufferSize*/)
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// InternalAudio // InternalAudio


InternalAudio::InternalAudio() noexcept
EngineInternalAudio::EngineInternalAudio() noexcept
: isReady(false), : isReady(false),
usePatchbay(false), usePatchbay(false),
inCount(0), inCount(0),
@@ -386,17 +385,19 @@ InternalAudio::InternalAudio() noexcept
rack = nullptr; rack = nullptr;
} }


InternalAudio::~InternalAudio() noexcept
EngineInternalAudio::~EngineInternalAudio() noexcept
{ {
CARLA_ASSERT(! isReady); CARLA_ASSERT(! isReady);
CARLA_ASSERT(rack == nullptr); CARLA_ASSERT(rack == nullptr);
} }


void InternalAudio::initPatchbay() noexcept
void EngineInternalAudio::initPatchbay() noexcept
{ {
if (usePatchbay) if (usePatchbay)
{ {
CARLA_SAFE_ASSERT_RETURN(patchbay != nullptr,); CARLA_SAFE_ASSERT_RETURN(patchbay != nullptr,);

// TODO
} }
else else
{ {
@@ -407,7 +408,7 @@ void InternalAudio::initPatchbay() noexcept
} }
} }


void InternalAudio::clear()
void EngineInternalAudio::clear()
{ {
isReady = false; isReady = false;
inCount = 0; inCount = 0;
@@ -427,7 +428,7 @@ void InternalAudio::clear()
} }
} }


void InternalAudio::create(const uint32_t bufferSize)
void EngineInternalAudio::create(const uint32_t bufferSize)
{ {
if (usePatchbay) if (usePatchbay)
{ {
@@ -443,7 +444,7 @@ void InternalAudio::create(const uint32_t bufferSize)
isReady = true; isReady = true;
} }


void InternalAudio::resize(const uint32_t bufferSize)
void EngineInternalAudio::resize(const uint32_t bufferSize)
{ {
if (usePatchbay) if (usePatchbay)
{ {
@@ -460,11 +461,11 @@ void InternalAudio::resize(const uint32_t bufferSize)
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// InternalEvents // InternalEvents


InternalEvents::InternalEvents() noexcept
EngineInternalEvents::EngineInternalEvents() noexcept
: in(nullptr), : in(nullptr),
out(nullptr) {} out(nullptr) {}


InternalEvents::~InternalEvents() noexcept
EngineInternalEvents::~EngineInternalEvents() noexcept
{ {
CARLA_ASSERT(in == nullptr); CARLA_ASSERT(in == nullptr);
CARLA_ASSERT(out == nullptr); CARLA_ASSERT(out == nullptr);
@@ -473,24 +474,24 @@ InternalEvents::~InternalEvents() noexcept
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// InternalTime // InternalTime


InternalTime::InternalTime() noexcept
EngineInternalTime::EngineInternalTime() noexcept
: playing(false), : playing(false),
frame(0) {} frame(0) {}


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// NextAction // NextAction


NextAction::NextAction() noexcept
EngineNextAction::EngineNextAction() noexcept
: opcode(kEnginePostActionNull), : opcode(kEnginePostActionNull),
pluginId(0), pluginId(0),
value(0) {} value(0) {}


NextAction::~NextAction() noexcept
EngineNextAction::~EngineNextAction() noexcept
{ {
CARLA_ASSERT(opcode == kEnginePostActionNull); CARLA_ASSERT(opcode == kEnginePostActionNull);
} }


void NextAction::ready() noexcept
void EngineNextAction::ready() noexcept
{ {
mutex.lock(); mutex.lock();
mutex.unlock(); mutex.unlock();
@@ -635,7 +636,7 @@ void CarlaEngineProtectedData::processRack(float* inBufReal[2], float* outBuf[2]
FLOAT_CLEAR(outBuf[1], frames); FLOAT_CLEAR(outBuf[1], frames);


// initialize event outputs (zero) // initialize event outputs (zero)
carla_zeroStruct<EngineEvent>(bufEvents.out, EngineEvent::kMaxInternalCount);
carla_zeroStruct<EngineEvent>(bufEvents.out, kMaxEngineEventInternalCount);


bool processed = false; bool processed = false;


@@ -672,10 +673,10 @@ void CarlaEngineProtectedData::processRack(float* inBufReal[2], float* outBuf[2]
else else
{ {
// initialize event inputs from previous outputs // initialize event inputs from previous outputs
carla_copyStruct<EngineEvent>(bufEvents.in, bufEvents.out, EngineEvent::kMaxInternalCount);
carla_copyStruct<EngineEvent>(bufEvents.in, bufEvents.out, kMaxEngineEventInternalCount);


// initialize event outputs (zero) // initialize event outputs (zero)
carla_zeroStruct<EngineEvent>(bufEvents.out, EngineEvent::kMaxInternalCount);
carla_zeroStruct<EngineEvent>(bufEvents.out, kMaxEngineEventInternalCount);
} }
} }




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

@@ -52,6 +52,11 @@ CARLA_BACKEND_START_NAMESPACE
} // Fix editor indentation } // Fix editor indentation
#endif #endif


// -----------------------------------------------------------------------
// Maximum pre-allocated events for rack and bridge modes

const unsigned short kMaxEngineEventInternalCount = 512;

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Rack Patchbay stuff // Rack Patchbay stuff


@@ -104,6 +109,8 @@ struct EngineRackBuffers {
~EngineRackBuffers(); ~EngineRackBuffers();
void clear(); void clear();
void resize(const uint32_t bufferSize); void resize(const uint32_t bufferSize);

CARLA_DECLARE_NON_COPY_STRUCT(EngineRackBuffers)
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -115,12 +122,14 @@ struct EnginePatchbayBuffers {
~EnginePatchbayBuffers(); ~EnginePatchbayBuffers();
void clear(); void clear();
void resize(const uint32_t bufferSize); void resize(const uint32_t bufferSize);

CARLA_DECLARE_NON_COPY_STRUCT(EnginePatchbayBuffers)
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// InternalAudio // InternalAudio


struct InternalAudio {
struct EngineInternalAudio {
bool isReady; bool isReady;
bool usePatchbay; bool usePatchbay;


@@ -132,34 +141,39 @@ struct InternalAudio {
EnginePatchbayBuffers* patchbay; EnginePatchbayBuffers* patchbay;
}; };


InternalAudio() noexcept;
~InternalAudio() noexcept;
EngineInternalAudio() noexcept;
~EngineInternalAudio() noexcept;
void initPatchbay() noexcept; void initPatchbay() noexcept;
void clear(); void clear();
void create(const uint32_t bufferSize); void create(const uint32_t bufferSize);
void resize(const uint32_t bufferSize); void resize(const uint32_t bufferSize);

CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalAudio)
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// InternalEvents // InternalEvents


struct InternalEvents {
struct EngineInternalEvents {
EngineEvent* in; EngineEvent* in;
EngineEvent* out; EngineEvent* out;


InternalEvents() noexcept;
~InternalEvents() noexcept;
void allocateEvents();
EngineInternalEvents() noexcept;
~EngineInternalEvents() noexcept;

CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalEvents)
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// InternalTime // InternalTime


struct InternalTime {
struct EngineInternalTime {
bool playing; bool playing;
uint64_t frame; uint64_t frame;


InternalTime() noexcept;
EngineInternalTime() noexcept;

CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalTime)
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -172,15 +186,17 @@ enum EnginePostAction {
kEnginePostActionSwitchPlugins kEnginePostActionSwitchPlugins
}; };


struct NextAction {
struct EngineNextAction {
EnginePostAction opcode; EnginePostAction opcode;
unsigned int pluginId; unsigned int pluginId;
unsigned int value; unsigned int value;
CarlaMutex mutex; CarlaMutex mutex;


NextAction() noexcept;
~NextAction() noexcept;
EngineNextAction() noexcept;
~EngineNextAction() noexcept;
void ready() noexcept; void ready() noexcept;

CARLA_DECLARE_NON_COPY_STRUCT(EngineNextAction)
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -223,19 +239,25 @@ struct CarlaEngineProtectedData {
EnginePluginData* plugins; EnginePluginData* plugins;


#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
InternalAudio bufAudio;
EngineInternalAudio bufAudio;
#endif #endif
InternalEvents bufEvents;
InternalTime time;
NextAction nextAction;
EngineInternalEvents bufEvents;
EngineInternalTime time;
EngineNextAction nextAction;

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


CarlaEngineProtectedData(CarlaEngine* const engine); CarlaEngineProtectedData(CarlaEngine* const engine);
~CarlaEngineProtectedData() noexcept; ~CarlaEngineProtectedData() noexcept;


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

void doPluginRemove() noexcept; void doPluginRemove() noexcept;
void doPluginsSwitch() noexcept; void doPluginsSwitch() noexcept;
void doNextPluginAction(const bool unlock) noexcept; void doNextPluginAction(const bool unlock) noexcept;


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

#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
// the base, where plugins run // the base, where plugins run
void processRack(float* inBufReal[2], float* outBuf[2], const uint32_t nframes, const bool isOffline); void processRack(float* inBufReal[2], float* outBuf[2], const uint32_t nframes, const bool isOffline);
@@ -244,6 +266,8 @@ struct CarlaEngineProtectedData {
void processRackFull(float** const inBuf, const uint32_t inCount, float** const outBuf, const uint32_t outCount, const uint32_t nframes, const bool isOffline); void processRackFull(float** const inBuf, const uint32_t inCount, float** const outBuf, const uint32_t outCount, const uint32_t nframes, const bool isOffline);
#endif #endif


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

class ScopedActionLock class ScopedActionLock
{ {
public: public:
@@ -257,6 +281,8 @@ struct CarlaEngineProtectedData {
CARLA_DECLARE_NON_COPY_CLASS(ScopedActionLock) CARLA_DECLARE_NON_COPY_CLASS(ScopedActionLock)
}; };


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

#ifdef CARLA_PROPER_CPP11_SUPPORT #ifdef CARLA_PROPER_CPP11_SUPPORT
CarlaEngineProtectedData() = delete; CarlaEngineProtectedData() = delete;
CARLA_DECLARE_NON_COPY_STRUCT(CarlaEngineProtectedData) CARLA_DECLARE_NON_COPY_STRUCT(CarlaEngineProtectedData)


+ 3
- 3
source/backend/engine/CarlaEngineJack.cpp View File

@@ -1122,7 +1122,7 @@ protected:
float* outBuf[2] = { audioOut1, audioOut2 }; float* outBuf[2] = { audioOut1, audioOut2 };


// initialize input events // initialize input events
carla_zeroStruct<EngineEvent>(pData->bufEvents.in, EngineEvent::kMaxInternalCount);
carla_zeroStruct<EngineEvent>(pData->bufEvents.in, kMaxEngineEventInternalCount);
{ {
uint32_t engineEventIndex = 0; uint32_t engineEventIndex = 0;


@@ -1141,7 +1141,7 @@ protected:
engineEvent.time = jackEvent.time; engineEvent.time = jackEvent.time;
engineEvent.fillFromMidiData(static_cast<uint8_t>(jackEvent.size), jackEvent.buffer); engineEvent.fillFromMidiData(static_cast<uint8_t>(jackEvent.size), jackEvent.buffer);


if (engineEventIndex >= EngineEvent::kMaxInternalCount)
if (engineEventIndex >= kMaxEngineEventInternalCount)
break; break;
} }
} }
@@ -1153,7 +1153,7 @@ protected:
{ {
jackbridge_midi_clear_buffer(eventOut); jackbridge_midi_clear_buffer(eventOut);


for (unsigned short i=0; i < EngineEvent::kMaxInternalCount; ++i)
for (unsigned short i=0; i < kMaxEngineEventInternalCount; ++i)
{ {
const EngineEvent& engineEvent(pData->bufEvents.out[i]); const EngineEvent& engineEvent(pData->bufEvents.out[i]);




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

@@ -439,7 +439,7 @@ protected:
return runPendingRtEvents(); return runPendingRtEvents();


// initialize input events // initialize input events
carla_zeroStruct<EngineEvent>(pData->bufEvents.in, EngineEvent::kMaxInternalCount);
carla_zeroStruct<EngineEvent>(pData->bufEvents.in, kMaxEngineEventInternalCount);


// TODO - get events from juce // TODO - get events from juce




+ 6
- 6
source/backend/engine/CarlaEngineNative.cpp View File

@@ -1059,8 +1059,8 @@ protected:
// --------------------------------------------------------------- // ---------------------------------------------------------------
// initialize events // initialize events


carla_zeroStruct<EngineEvent>(pData->bufEvents.in, EngineEvent::kMaxInternalCount);
carla_zeroStruct<EngineEvent>(pData->bufEvents.out, EngineEvent::kMaxInternalCount);
carla_zeroStruct<EngineEvent>(pData->bufEvents.in, kMaxEngineEventInternalCount);
carla_zeroStruct<EngineEvent>(pData->bufEvents.out, kMaxEngineEventInternalCount);


// --------------------------------------------------------------- // ---------------------------------------------------------------
// events input (before processing) // events input (before processing)
@@ -1068,7 +1068,7 @@ protected:
{ {
uint32_t engineEventIndex = 0; uint32_t engineEventIndex = 0;


for (uint32_t i=0; i < midiEventCount && engineEventIndex < EngineEvent::kMaxInternalCount; ++i)
for (uint32_t i=0; i < midiEventCount && engineEventIndex < kMaxEngineEventInternalCount; ++i)
{ {
const NativeMidiEvent& midiEvent(midiEvents[i]); const NativeMidiEvent& midiEvent(midiEvents[i]);
EngineEvent& engineEvent(pData->bufEvents.in[engineEventIndex++]); EngineEvent& engineEvent(pData->bufEvents.in[engineEventIndex++]);
@@ -1076,7 +1076,7 @@ protected:
engineEvent.time = midiEvent.time; engineEvent.time = midiEvent.time;
engineEvent.fillFromMidiData(midiEvent.size, midiEvent.data); engineEvent.fillFromMidiData(midiEvent.size, midiEvent.data);


if (engineEventIndex >= EngineEvent::kMaxInternalCount)
if (engineEventIndex >= kMaxEngineEventInternalCount)
break; break;
} }
} }
@@ -1112,12 +1112,12 @@ protected:
// --------------------------------------------------------------- // ---------------------------------------------------------------
// events output (after processing) // events output (after processing)


carla_zeroStruct<EngineEvent>(pData->bufEvents.in, EngineEvent::kMaxInternalCount);
carla_zeroStruct<EngineEvent>(pData->bufEvents.in, kMaxEngineEventInternalCount);


{ {
NativeMidiEvent midiEvent; NativeMidiEvent midiEvent;


for (uint32_t i=0; i < EngineEvent::kMaxInternalCount; ++i)
for (uint32_t i=0; i < kMaxEngineEventInternalCount; ++i)
{ {
const EngineEvent& engineEvent(pData->bufEvents.out[i]); const EngineEvent& engineEvent(pData->bufEvents.out[i]);




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

@@ -643,7 +643,7 @@ protected:
FLOAT_CLEAR(fAudioBufOut[i], nframes); FLOAT_CLEAR(fAudioBufOut[i], nframes);


// initialize input events // initialize input events
carla_zeroStruct<EngineEvent>(pData->bufEvents.in, EngineEvent::kMaxInternalCount);
carla_zeroStruct<EngineEvent>(pData->bufEvents.in, kMaxEngineEventInternalCount);


if (fMidiInEvents.mutex.tryLock()) if (fMidiInEvents.mutex.tryLock())
{ {
@@ -669,7 +669,7 @@ protected:


engineEvent.fillFromMidiData(midiEvent.size, midiEvent.data); engineEvent.fillFromMidiData(midiEvent.size, midiEvent.data);


if (engineEventIndex >= EngineEvent::kMaxInternalCount)
if (engineEventIndex >= kMaxEngineEventInternalCount)
break; break;
} }




+ 3
- 1
source/backend/plugin/AuPlugin.cpp View File

@@ -15,7 +15,9 @@
* For a full copy of the GNU General Public License see the doc/GPL.txt file. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/ */


#include "CarlaPluginInternal.hpp"
#include "CarlaPlugin.hpp"
#include "CarlaEngine.hpp"
#include "CarlaUtils.hpp"


CARLA_BACKEND_START_NAMESPACE CARLA_BACKEND_START_NAMESPACE




+ 1
- 0
source/backend/plugin/BridgePlugin.cpp View File

@@ -16,6 +16,7 @@
*/ */


#include "CarlaPluginInternal.hpp" #include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"


#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE




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

@@ -16,6 +16,7 @@
*/ */


#include "CarlaPluginInternal.hpp" #include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"


#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QTextStream> #include <QtCore/QTextStream>


+ 553
- 2
source/backend/plugin/CarlaPluginInternal.cpp View File

@@ -16,17 +16,566 @@
*/ */


#include "CarlaPluginInternal.hpp" #include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"


#include "CarlaLibCounter.hpp" #include "CarlaLibCounter.hpp"


#include <QtCore/QSettings> #include <QtCore/QSettings>


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

CARLA_BACKEND_START_NAMESPACE CARLA_BACKEND_START_NAMESPACE


#if 0 #if 0
} // Fix editor indentation } // Fix editor indentation
#endif #endif


// -------------------------------------------------------------------
// Fallback data

static const MidiProgramData kMidiProgramDataNull = { 0, 0, nullptr };

// -----------------------------------------------------------------------
// PluginAudioPort

PluginAudioPort::PluginAudioPort() noexcept
: rindex(0),
port(nullptr) {}

PluginAudioPort::~PluginAudioPort()
{
CARLA_ASSERT(port == nullptr);
}

// -----------------------------------------------------------------------
// PluginAudioData

PluginAudioData::PluginAudioData() noexcept
: count(0),
ports(nullptr) {}

PluginAudioData::~PluginAudioData()
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT(ports == nullptr);
}

void PluginAudioData::createNew(const uint32_t newCount)
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT(ports == nullptr);
CARLA_ASSERT_INT(newCount > 0, newCount);

if (ports != nullptr || newCount == 0)
return;

ports = new PluginAudioPort[newCount];
count = newCount;
}

void PluginAudioData::clear()
{
if (ports != nullptr)
{
for (uint32_t i=0; i < count; ++i)
{
if (ports[i].port != nullptr)
{
delete ports[i].port;
ports[i].port = nullptr;
}
}

delete[] ports;
ports = nullptr;
}

count = 0;
}

void PluginAudioData::initBuffers()
{
for (uint32_t i=0; i < count; ++i)
{
if (ports[i].port != nullptr)
ports[i].port->initBuffer();
}
}

// -----------------------------------------------------------------------
// PluginCVPort

PluginCVPort::PluginCVPort() noexcept
: rindex(0),
param(0),
port(nullptr) {}

PluginCVPort::~PluginCVPort()
{
CARLA_ASSERT(port == nullptr);
}

// -----------------------------------------------------------------------
// PluginCVData

PluginCVData::PluginCVData() noexcept
: count(0),
ports(nullptr) {}

PluginCVData::~PluginCVData()
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT(ports == nullptr);
}

void PluginCVData::createNew(const uint32_t newCount)
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT(ports == nullptr);
CARLA_ASSERT_INT(newCount > 0, newCount);

if (ports != nullptr || newCount == 0)
return;

ports = new PluginCVPort[newCount];
count = newCount;
}

void PluginCVData::clear()
{
if (ports != nullptr)
{
for (uint32_t i=0; i < count; ++i)
{
if (ports[i].port != nullptr)
{
delete ports[i].port;
ports[i].port = nullptr;
}
}

delete[] ports;
ports = nullptr;
}

count = 0;
}

void PluginCVData::initBuffers()
{
for (uint32_t i=0; i < count; ++i)
{
if (ports[i].port != nullptr)
ports[i].port->initBuffer();
}
}

// -----------------------------------------------------------------------
// PluginEventData

PluginEventData::PluginEventData() noexcept
: portIn(nullptr),
portOut(nullptr) {}

PluginEventData::~PluginEventData()
{
CARLA_ASSERT(portIn == nullptr);
CARLA_ASSERT(portOut == nullptr);
}

void PluginEventData::clear()
{
if (portIn != nullptr)
{
delete portIn;
portIn = nullptr;
}

if (portOut != nullptr)
{
delete portOut;
portOut = nullptr;
}
}

void PluginEventData::initBuffers()
{
if (portIn != nullptr)
portIn->initBuffer();

if (portOut != nullptr)
portOut->initBuffer();
}

// -----------------------------------------------------------------------
// PluginParameterData

PluginParameterData::PluginParameterData() noexcept
: count(0),
data(nullptr),
ranges(nullptr),
special(nullptr) {}

PluginParameterData::~PluginParameterData()
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT(data == nullptr);
CARLA_ASSERT(ranges == nullptr);
CARLA_ASSERT(special == nullptr);
}

void PluginParameterData::createNew(const uint32_t newCount, const bool withSpecial)
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT(data == nullptr);
CARLA_ASSERT(ranges == nullptr);
CARLA_ASSERT(special == nullptr);
CARLA_ASSERT_INT(newCount > 0, newCount);

if (data != nullptr || ranges != nullptr || newCount == 0)
return;

data = new ParameterData[newCount];
ranges = new ParameterRanges[newCount];
count = newCount;

if (withSpecial)
special = new SpecialParameterType[newCount];
}

void PluginParameterData::clear()
{
if (data != nullptr)
{
delete[] data;
data = nullptr;
}

if (ranges != nullptr)
{
delete[] ranges;
ranges = nullptr;
}

if (special != nullptr)
{
delete[] special;
special = nullptr;
}

count = 0;
}

float PluginParameterData::getFixedValue(const uint32_t parameterId, const float& value) const
{
CARLA_SAFE_ASSERT_RETURN(parameterId < count, 0.0f);
return ranges[parameterId].getFixedValue(value);
}

// -----------------------------------------------------------------------
// PluginProgramData

PluginProgramData::PluginProgramData() noexcept
: count(0),
current(-1),
names(nullptr) {}

PluginProgramData::~PluginProgramData()
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT_INT(current == -1, current);
CARLA_ASSERT(names == nullptr);
}

void PluginProgramData::createNew(const uint32_t newCount)
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT_INT(current == -1, current);
CARLA_ASSERT(names == nullptr);
CARLA_ASSERT_INT(newCount > 0, newCount);

if (names != nullptr || newCount == 0)
return;

names = new ProgramName[newCount];
count = newCount;

for (uint32_t i=0; i < newCount; ++i)
names[i] = nullptr;
}

void PluginProgramData::clear()
{
if (names != nullptr)
{
for (uint32_t i=0; i < count; ++i)
{
if (names[i] != nullptr)
{
delete[] names[i];
names[i] = nullptr;
}
}

delete[] names;
names = nullptr;
}

count = 0;
current = -1;
}

// -----------------------------------------------------------------------
// PluginMidiProgramData

PluginMidiProgramData::PluginMidiProgramData() noexcept
: count(0),
current(-1),
data(nullptr) {}

PluginMidiProgramData::~PluginMidiProgramData()
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT_INT(current == -1, current);
CARLA_ASSERT(data == nullptr);
}

void PluginMidiProgramData::createNew(const uint32_t newCount)
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT_INT(current == -1, current);
CARLA_ASSERT(data == nullptr);
CARLA_ASSERT_INT(newCount > 0, newCount);

if (data != nullptr || newCount == 0)
return;

data = new MidiProgramData[newCount];
count = newCount;

for (uint32_t i=0; i < count; ++i)
{
data[i].bank = 0;
data[i].program = 0;
data[i].name = nullptr;
}
}

void PluginMidiProgramData::clear()
{
if (data != nullptr)
{
for (uint32_t i=0; i < count; ++i)
{
if (data[i].name != nullptr)
{
delete[] data[i].name;
data[i].name = nullptr;
}
}

delete[] data;
data = nullptr;
}

count = 0;
current = -1;
}

const MidiProgramData& PluginMidiProgramData::getCurrent() const noexcept
{
CARLA_SAFE_ASSERT_RETURN(current >= 0 && current < static_cast<int32_t>(count), kMidiProgramDataNull);
return data[current];
}

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

CarlaPluginProtectedData::ExternalNotes::ExternalNotes()
: dataPool(32, 152),
data(dataPool) {}

CarlaPluginProtectedData::ExternalNotes::~ExternalNotes()
{
mutex.lock();
data.clear();
mutex.unlock();
}

void CarlaPluginProtectedData::ExternalNotes::append(const ExternalMidiNote& note)
{
mutex.lock();
data.append_sleepy(note);
mutex.unlock();
}

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

CarlaPluginProtectedData::PostRtEvents::PostRtEvents()
: dataPool(128, 128),
data(dataPool),
dataPendingRT(dataPool) {}

CarlaPluginProtectedData::PostRtEvents::~PostRtEvents()
{
clear();
}

void CarlaPluginProtectedData::PostRtEvents::appendRT(const PluginPostRtEvent& event)
{
dataPendingRT.append(event);
}

void CarlaPluginProtectedData::PostRtEvents::trySplice()
{
if (mutex.tryLock())
{
dataPendingRT.spliceAppend(data);
mutex.unlock();
}
}

void CarlaPluginProtectedData::PostRtEvents::clear()
{
mutex.lock();
data.clear();
dataPendingRT.clear();
mutex.unlock();
}

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

#ifndef BUILD_BRIDGE
CarlaPluginProtectedData::PostProc::PostProc() noexcept
: dryWet(1.0f),
volume(1.0f),
balanceLeft(-1.0f),
balanceRight(1.0f),
panning(0.0f) {}
#endif

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

CarlaPluginProtectedData::OSC::OSC(CarlaEngine* const engine, CarlaPlugin* const plugin)
: thread(engine, plugin) {}

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

CarlaPluginProtectedData::CarlaPluginProtectedData(CarlaEngine* const eng, const unsigned int idx, CarlaPlugin* const self)
: engine(eng),
client(nullptr),
id(idx),
hints(0x0),
options(0x0),
active(false),
enabled(false),
needsReset(false),
lib(nullptr),
uiLib(nullptr),
ctrlChannel(0),
extraHints(0x0),
patchbayClientId(0),
latency(0),
latencyBuffers(nullptr),
name(nullptr),
filename(nullptr),
iconName(nullptr),
identifier(nullptr),
osc(eng, self) {}

CarlaPluginProtectedData::~CarlaPluginProtectedData()
{
CARLA_SAFE_ASSERT(! needsReset);

if (name != nullptr)
{
delete[] name;
name = nullptr;
}

if (filename != nullptr)
{
delete[] filename;
filename = nullptr;
}

if (iconName != nullptr)
{
delete[] iconName;
iconName = nullptr;
}

if (identifier != nullptr)
{
delete[] identifier;
identifier = nullptr;
}

{
// mutex MUST have been locked before
const bool lockMaster(masterMutex.tryLock());
const bool lockSingle(singleMutex.tryLock());
CARLA_SAFE_ASSERT(! lockMaster);
CARLA_SAFE_ASSERT(! lockSingle);
}

if (client != nullptr)
{
if (client->isActive())
{
// must not happen
carla_safe_assert("client->isActive()", __FILE__, __LINE__);
client->deactivate();
}

clearBuffers();

delete client;
client = nullptr;
}

for (LinkedList<CustomData>::Itenerator it = custom.begin(); it.valid(); it.next())
{
CustomData& cData(it.getValue());

if (cData.type != nullptr)
{
delete[] cData.type;
cData.type = nullptr;
}
else
carla_safe_assert("cData.type != nullptr", __FILE__, __LINE__);

if (cData.key != nullptr)
{
delete[] cData.key;
cData.key = nullptr;
}
else
carla_safe_assert("cData.key != nullptr", __FILE__, __LINE__);

if (cData.value != nullptr)
{
delete[] cData.value;
cData.value = nullptr;
}
else
carla_safe_assert("cData.value != nullptr", __FILE__, __LINE__);
}

prog.clear();
midiprog.clear();
custom.clear();

// MUST have been locked before
masterMutex.unlock();
singleMutex.unlock();

if (lib != nullptr)
libClose();

CARLA_ASSERT(uiLib == nullptr);
}

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Buffer functions // Buffer functions


@@ -150,7 +699,7 @@ void* CarlaPluginProtectedData::uiLibSymbol(const char* const symbol)
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Settings functions // Settings functions


void CarlaPluginProtectedData::saveSetting(const unsigned int option, const bool yesNo)
void CarlaPluginProtectedData::saveSetting(const uint option, const bool yesNo)
{ {
CARLA_SAFE_ASSERT_RETURN(identifier != nullptr && identifier[0] != '\0',); CARLA_SAFE_ASSERT_RETURN(identifier != nullptr && identifier[0] != '\0',);


@@ -193,7 +742,7 @@ void CarlaPluginProtectedData::saveSetting(const unsigned int option, const bool
settings.endGroup(); settings.endGroup();
} }


unsigned int CarlaPluginProtectedData::loadSettings(const unsigned int options, const unsigned int availOptions)
uint CarlaPluginProtectedData::loadSettings(const uint options, const uint availOptions)
{ {
CARLA_SAFE_ASSERT_RETURN(identifier != nullptr && identifier[0] != '\0', 0x0); CARLA_SAFE_ASSERT_RETURN(identifier != nullptr && identifier[0] != '\0', 0x0);


@@ -231,4 +780,6 @@ unsigned int CarlaPluginProtectedData::loadSettings(const unsigned int options,
return newOptions; return newOptions;
} }


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

CARLA_BACKEND_END_NAMESPACE CARLA_BACKEND_END_NAMESPACE

+ 72
- 503
source/backend/plugin/CarlaPluginInternal.hpp View File

@@ -20,21 +20,20 @@


#include "CarlaPlugin.hpp" #include "CarlaPlugin.hpp"
#include "CarlaPluginThread.hpp" #include "CarlaPluginThread.hpp"
#include "CarlaEngine.hpp"


#include "CarlaBackendUtils.hpp"
#include "CarlaOscUtils.hpp" #include "CarlaOscUtils.hpp"
#include "CarlaStateUtils.hpp" #include "CarlaStateUtils.hpp"

#include "CarlaMutex.hpp" #include "CarlaMutex.hpp"
#include "RtLinkedList.hpp" #include "RtLinkedList.hpp"


#include <cmath>

#ifdef HAVE_JUCE #ifdef HAVE_JUCE
# include "juce_audio_basics.h" # include "juce_audio_basics.h"
using juce::FloatVectorOperations; using juce::FloatVectorOperations;
#endif #endif


#include <cmath>

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


#define CARLA_PROCESS_CONTINUE_CHECK if (! pData->enabled) { pData->engine->callback(ENGINE_CALLBACK_DEBUG, pData->id, 0, 0, 0.0f, "Processing while plugin is disabled!!"); return; } #define CARLA_PROCESS_CONTINUE_CHECK if (! pData->enabled) { pData->engine->callback(ENGINE_CALLBACK_DEBUG, pData->id, 0, 0, 0.0f, "Processing while plugin is disabled!!"); return; }
@@ -52,6 +51,8 @@ using juce::FloatVectorOperations;
# define FLOAT_CLEAR(buf, frames) carla_zeroFloat(buf, frames) # define FLOAT_CLEAR(buf, frames) carla_zeroFloat(buf, frames)
#endif #endif


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

CARLA_BACKEND_START_NAMESPACE CARLA_BACKEND_START_NAMESPACE


#if 0 #if 0
@@ -59,9 +60,21 @@ CARLA_BACKEND_START_NAMESPACE
#endif #endif


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Forward declarations of CarlaEngine classes

class CarlaEngineAudioPort;
class CarlaEngineCVPort;
class CarlaEngineEventPort;
class CarlaEngineClient;

// -----------------------------------------------------------------------
// Maximum pre-allocated events for some plugin types


const unsigned short kPluginMaxMidiEvents = 512; const unsigned short kPluginMaxMidiEvents = 512;


// -----------------------------------------------------------------------
// Extra plugin hints, hidden from backend

const unsigned int PLUGIN_EXTRA_HINT_HAS_MIDI_IN = 0x01; const unsigned int PLUGIN_EXTRA_HINT_HAS_MIDI_IN = 0x01;
const unsigned int PLUGIN_EXTRA_HINT_HAS_MIDI_OUT = 0x02; const unsigned int PLUGIN_EXTRA_HINT_HAS_MIDI_OUT = 0x02;
const unsigned int PLUGIN_EXTRA_HINT_CAN_RUN_RACK = 0x04; const unsigned int PLUGIN_EXTRA_HINT_CAN_RUN_RACK = 0x04;
@@ -96,6 +109,8 @@ struct PluginPostRtEvent {
float value3; float value3;
}; };


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

struct ExternalMidiNote { struct ExternalMidiNote {
int8_t channel; // invalid if -1 int8_t channel; // invalid if -1
uint8_t note; // 0 to 127 uint8_t note; // 0 to 127
@@ -108,14 +123,8 @@ struct PluginAudioPort {
uint32_t rindex; uint32_t rindex;
CarlaEngineAudioPort* port; CarlaEngineAudioPort* port;


PluginAudioPort() noexcept
: rindex(0),
port(nullptr) {}

~PluginAudioPort()
{
CARLA_ASSERT(port == nullptr);
}
PluginAudioPort() noexcept;
~PluginAudioPort();


CARLA_DECLARE_NON_COPY_STRUCT(PluginAudioPort) CARLA_DECLARE_NON_COPY_STRUCT(PluginAudioPort)
}; };
@@ -124,57 +133,11 @@ struct PluginAudioData {
uint32_t count; uint32_t count;
PluginAudioPort* ports; PluginAudioPort* ports;


PluginAudioData() noexcept
: count(0),
ports(nullptr) {}

~PluginAudioData()
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT(ports == nullptr);
}

void createNew(const uint32_t newCount)
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT(ports == nullptr);
CARLA_ASSERT_INT(newCount > 0, newCount);

if (ports != nullptr || newCount == 0)
return;

ports = new PluginAudioPort[newCount];
count = newCount;
}

void clear()
{
if (ports != nullptr)
{
for (uint32_t i=0; i < count; ++i)
{
if (ports[i].port != nullptr)
{
delete ports[i].port;
ports[i].port = nullptr;
}
}

delete[] ports;
ports = nullptr;
}

count = 0;
}

void initBuffers()
{
for (uint32_t i=0; i < count; ++i)
{
if (ports[i].port != nullptr)
ports[i].port->initBuffer();
}
}
PluginAudioData() noexcept;
~PluginAudioData();
void createNew(const uint32_t newCount);
void clear();
void initBuffers();


CARLA_DECLARE_NON_COPY_STRUCT(PluginAudioData) CARLA_DECLARE_NON_COPY_STRUCT(PluginAudioData)
}; };
@@ -186,15 +149,8 @@ struct PluginCVPort {
uint32_t param; uint32_t param;
CarlaEngineCVPort* port; CarlaEngineCVPort* port;


PluginCVPort() noexcept
: rindex(0),
param(0),
port(nullptr) {}

~PluginCVPort()
{
CARLA_ASSERT(port == nullptr);
}
PluginCVPort() noexcept;
~PluginCVPort();


CARLA_DECLARE_NON_COPY_STRUCT(PluginCVPort) CARLA_DECLARE_NON_COPY_STRUCT(PluginCVPort)
}; };
@@ -203,57 +159,11 @@ struct PluginCVData {
uint32_t count; uint32_t count;
PluginCVPort* ports; PluginCVPort* ports;


PluginCVData() noexcept
: count(0),
ports(nullptr) {}

~PluginCVData()
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT(ports == nullptr);
}

void createNew(const uint32_t newCount)
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT(ports == nullptr);
CARLA_ASSERT_INT(newCount > 0, newCount);

if (ports != nullptr || newCount == 0)
return;

ports = new PluginCVPort[newCount];
count = newCount;
}

void clear()
{
if (ports != nullptr)
{
for (uint32_t i=0; i < count; ++i)
{
if (ports[i].port != nullptr)
{
delete ports[i].port;
ports[i].port = nullptr;
}
}

delete[] ports;
ports = nullptr;
}

count = 0;
}

void initBuffers()
{
for (uint32_t i=0; i < count; ++i)
{
if (ports[i].port != nullptr)
ports[i].port->initBuffer();
}
}
PluginCVData() noexcept;
~PluginCVData();
void createNew(const uint32_t newCount);
void clear();
void initBuffers();


CARLA_DECLARE_NON_COPY_STRUCT(PluginCVData) CARLA_DECLARE_NON_COPY_STRUCT(PluginCVData)
}; };
@@ -264,39 +174,10 @@ struct PluginEventData {
CarlaEngineEventPort* portIn; CarlaEngineEventPort* portIn;
CarlaEngineEventPort* portOut; CarlaEngineEventPort* portOut;


PluginEventData() noexcept
: portIn(nullptr),
portOut(nullptr) {}

~PluginEventData()
{
CARLA_ASSERT(portIn == nullptr);
CARLA_ASSERT(portOut == nullptr);
}

void clear()
{
if (portIn != nullptr)
{
delete portIn;
portIn = nullptr;
}

if (portOut != nullptr)
{
delete portOut;
portOut = nullptr;
}
}

void initBuffers()
{
if (portIn != nullptr)
portIn->initBuffer();

if (portOut != nullptr)
portOut->initBuffer();
}
PluginEventData() noexcept;
~PluginEventData();
void clear();
void initBuffers();


CARLA_DECLARE_NON_COPY_STRUCT(PluginEventData) CARLA_DECLARE_NON_COPY_STRUCT(PluginEventData)
}; };
@@ -317,67 +198,11 @@ struct PluginParameterData {
ParameterRanges* ranges; ParameterRanges* ranges;
SpecialParameterType* special; SpecialParameterType* special;


PluginParameterData() noexcept
: count(0),
data(nullptr),
ranges(nullptr),
special(nullptr) {}

~PluginParameterData()
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT(data == nullptr);
CARLA_ASSERT(ranges == nullptr);
CARLA_ASSERT(special == nullptr);
}

void createNew(const uint32_t newCount, const bool withSpecial)
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT(data == nullptr);
CARLA_ASSERT(ranges == nullptr);
CARLA_ASSERT(special == nullptr);
CARLA_ASSERT_INT(newCount > 0, newCount);

if (data != nullptr || ranges != nullptr || newCount == 0)
return;

data = new ParameterData[newCount];
ranges = new ParameterRanges[newCount];
count = newCount;

if (withSpecial)
special = new SpecialParameterType[newCount];
}

void clear()
{
if (data != nullptr)
{
delete[] data;
data = nullptr;
}

if (ranges != nullptr)
{
delete[] ranges;
ranges = nullptr;
}

if (special != nullptr)
{
delete[] special;
special = nullptr;
}

count = 0;
}

float getFixedValue(const uint32_t parameterId, const float& value) const
{
CARLA_SAFE_ASSERT_RETURN(parameterId < count, 0.0f);
return ranges[parameterId].getFixedValue(value);
}
PluginParameterData() noexcept;
~PluginParameterData();
void createNew(const uint32_t newCount, const bool withSpecial);
void clear();
float getFixedValue(const uint32_t parameterId, const float& value) const;


CARLA_DECLARE_NON_COPY_STRUCT(PluginParameterData) CARLA_DECLARE_NON_COPY_STRUCT(PluginParameterData)
}; };
@@ -391,55 +216,10 @@ struct PluginProgramData {
int32_t current; int32_t current;
ProgramName* names; ProgramName* names;


PluginProgramData() noexcept
: count(0),
current(-1),
names(nullptr) {}

~PluginProgramData()
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT_INT(current == -1, current);
CARLA_ASSERT(names == nullptr);
}

void createNew(const uint32_t newCount)
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT_INT(current == -1, current);
CARLA_ASSERT(names == nullptr);
CARLA_ASSERT_INT(newCount > 0, newCount);

if (names != nullptr || newCount == 0)
return;

names = new ProgramName[newCount];
count = newCount;

for (uint32_t i=0; i < newCount; ++i)
names[i] = nullptr;
}

void clear()
{
if (names != nullptr)
{
for (uint32_t i=0; i < count; ++i)
{
if (names[i] != nullptr)
{
delete[] names[i];
names[i] = nullptr;
}
}

delete[] names;
names = nullptr;
}

count = 0;
current = -1;
}
PluginProgramData() noexcept;
~PluginProgramData();
void createNew(const uint32_t newCount);
void clear();


CARLA_DECLARE_NON_COPY_STRUCT(PluginProgramData) CARLA_DECLARE_NON_COPY_STRUCT(PluginProgramData)
}; };
@@ -451,65 +231,11 @@ struct PluginMidiProgramData {
int32_t current; int32_t current;
MidiProgramData* data; MidiProgramData* data;


PluginMidiProgramData() noexcept
: count(0),
current(-1),
data(nullptr) {}

~PluginMidiProgramData()
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT_INT(current == -1, current);
CARLA_ASSERT(data == nullptr);
}

void createNew(const uint32_t newCount)
{
CARLA_ASSERT_INT(count == 0, count);
CARLA_ASSERT_INT(current == -1, current);
CARLA_ASSERT(data == nullptr);
CARLA_ASSERT_INT(newCount > 0, newCount);

if (data != nullptr || newCount == 0)
return;

data = new MidiProgramData[newCount];
count = newCount;

for (uint32_t i=0; i < count; ++i)
{
data[i].bank = 0;
data[i].program = 0;
data[i].name = nullptr;
}
}

void clear()
{
if (data != nullptr)
{
for (uint32_t i=0; i < count; ++i)
{
if (data[i].name != nullptr)
{
delete[] data[i].name;
data[i].name = nullptr;
}
}

delete[] data;
data = nullptr;
}

count = 0;
current = -1;
}

const MidiProgramData& getCurrent() const
{
CARLA_ASSERT_INT2(current >= 0 && current < static_cast<int32_t>(count), current, count);
return data[current];
}
PluginMidiProgramData() noexcept;
~PluginMidiProgramData();
void createNew(const uint32_t newCount);
void clear();
const MidiProgramData& getCurrent() const noexcept;


CARLA_DECLARE_NON_COPY_STRUCT(PluginMidiProgramData) CARLA_DECLARE_NON_COPY_STRUCT(PluginMidiProgramData)
}; };
@@ -565,23 +291,9 @@ struct CarlaPluginProtectedData {
RtLinkedList<ExternalMidiNote>::Pool dataPool; RtLinkedList<ExternalMidiNote>::Pool dataPool;
RtLinkedList<ExternalMidiNote> data; RtLinkedList<ExternalMidiNote> data;


ExternalNotes()
: dataPool(32, 152),
data(dataPool) {}

~ExternalNotes()
{
mutex.lock();
data.clear();
mutex.unlock();
}

void append(const ExternalMidiNote& note)
{
mutex.lock();
data.append_sleepy(note);
mutex.unlock();
}
ExternalNotes();
~ExternalNotes();
void append(const ExternalMidiNote& note);


CARLA_DECLARE_NON_COPY_STRUCT(ExternalNotes) CARLA_DECLARE_NON_COPY_STRUCT(ExternalNotes)


@@ -593,37 +305,11 @@ struct CarlaPluginProtectedData {
RtLinkedList<PluginPostRtEvent> data; RtLinkedList<PluginPostRtEvent> data;
RtLinkedList<PluginPostRtEvent> dataPendingRT; RtLinkedList<PluginPostRtEvent> dataPendingRT;


PostRtEvents()
: dataPool(128, 128),
data(dataPool),
dataPendingRT(dataPool) {}

~PostRtEvents()
{
clear();
}

void appendRT(const PluginPostRtEvent& event)
{
dataPendingRT.append(event);
}

void trySplice()
{
if (mutex.tryLock())
{
dataPendingRT.spliceAppend(data);
mutex.unlock();
}
}

void clear()
{
mutex.lock();
data.clear();
dataPendingRT.clear();
mutex.unlock();
}
PostRtEvents();
~PostRtEvents();
void appendRT(const PluginPostRtEvent& event);
void trySplice();
void clear();


CARLA_DECLARE_NON_COPY_STRUCT(PostRtEvents) CARLA_DECLARE_NON_COPY_STRUCT(PostRtEvents)


@@ -637,12 +323,7 @@ struct CarlaPluginProtectedData {
float balanceRight; float balanceRight;
float panning; float panning;


PostProc() noexcept
: dryWet(1.0f),
volume(1.0f),
balanceLeft(-1.0f),
balanceRight(1.0f),
panning(0.0f) {}
PostProc() noexcept;


CARLA_DECLARE_NON_COPY_STRUCT(PostProc) CARLA_DECLARE_NON_COPY_STRUCT(PostProc)


@@ -653,8 +334,7 @@ struct CarlaPluginProtectedData {
CarlaOscData data; CarlaOscData data;
CarlaPluginThread thread; CarlaPluginThread thread;


OSC(CarlaEngine* const engine, CarlaPlugin* const plugin)
: thread(engine, plugin) {}
OSC(CarlaEngine* const engine, CarlaPlugin* const plugin);


#ifdef CARLA_PROPER_CPP11_SUPPORT #ifdef CARLA_PROPER_CPP11_SUPPORT
OSC() = delete; OSC() = delete;
@@ -662,126 +342,8 @@ struct CarlaPluginProtectedData {
#endif #endif
} osc; } osc;


CarlaPluginProtectedData(CarlaEngine* const eng, const unsigned int idx, CarlaPlugin* const self)
: engine(eng),
client(nullptr),
id(idx),
hints(0x0),
options(0x0),
active(false),
enabled(false),
needsReset(false),
lib(nullptr),
uiLib(nullptr),
ctrlChannel(0),
extraHints(0x0),
patchbayClientId(0),
latency(0),
latencyBuffers(nullptr),
name(nullptr),
filename(nullptr),
iconName(nullptr),
identifier(nullptr),
osc(eng, self) {}

#ifdef CARLA_PROPER_CPP11_SUPPORT
CarlaPluginProtectedData() = delete;
CARLA_DECLARE_NON_COPY_STRUCT(CarlaPluginProtectedData)
#endif

~CarlaPluginProtectedData()
{
CARLA_SAFE_ASSERT(! needsReset);

if (name != nullptr)
{
delete[] name;
name = nullptr;
}

if (filename != nullptr)
{
delete[] filename;
filename = nullptr;
}

if (iconName != nullptr)
{
delete[] iconName;
iconName = nullptr;
}

if (identifier != nullptr)
{
delete[] identifier;
identifier = nullptr;
}

{
// mutex MUST have been locked before
const bool lockMaster(masterMutex.tryLock());
const bool lockSingle(singleMutex.tryLock());
CARLA_SAFE_ASSERT(! lockMaster);
CARLA_SAFE_ASSERT(! lockSingle);
}

if (client != nullptr)
{
if (client->isActive())
{
// must not happen
carla_safe_assert("client->isActive()", __FILE__, __LINE__);
client->deactivate();
}

clearBuffers();

delete client;
client = nullptr;
}

for (LinkedList<CustomData>::Itenerator it = custom.begin(); it.valid(); it.next())
{
CustomData& cData(it.getValue());

if (cData.type != nullptr)
{
delete[] cData.type;
cData.type = nullptr;
}
else
carla_safe_assert("cData.type != nullptr", __FILE__, __LINE__);

if (cData.key != nullptr)
{
delete[] cData.key;
cData.key = nullptr;
}
else
carla_safe_assert("cData.key != nullptr", __FILE__, __LINE__);

if (cData.value != nullptr)
{
delete[] cData.value;
cData.value = nullptr;
}
else
carla_safe_assert("cData.value != nullptr", __FILE__, __LINE__);
}

prog.clear();
midiprog.clear();
custom.clear();

// MUST have been locked before
masterMutex.unlock();
singleMutex.unlock();

if (lib != nullptr)
libClose();

CARLA_ASSERT(uiLib == nullptr);
}
CarlaPluginProtectedData(CarlaEngine* const eng, const unsigned int idx, CarlaPlugin* const self);
~CarlaPluginProtectedData();


// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Buffer functions // Buffer functions
@@ -811,8 +373,15 @@ struct CarlaPluginProtectedData {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Settings functions, see CarlaPlugin.cpp // Settings functions, see CarlaPlugin.cpp


void saveSetting(const unsigned int option, const bool yesNo);
unsigned int loadSettings(const unsigned int options, const unsigned int availOptions);
void saveSetting(const uint option, const bool yesNo);
uint loadSettings(const uint options, const uint availOptions);

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

#ifdef CARLA_PROPER_CPP11_SUPPORT
CarlaPluginProtectedData() = delete;
CARLA_DECLARE_NON_COPY_STRUCT(CarlaPluginProtectedData)
#endif
}; };


CARLA_BACKEND_END_NAMESPACE CARLA_BACKEND_END_NAMESPACE


+ 1
- 0
source/backend/plugin/CsoundPlugin.cpp View File

@@ -16,6 +16,7 @@
*/ */


#include "CarlaPluginInternal.hpp" #include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"


//#define WANT_CSOUND 1 //#define WANT_CSOUND 1
#ifdef WANT_CSOUND #ifdef WANT_CSOUND


+ 1
- 0
source/backend/plugin/DssiPlugin.cpp View File

@@ -16,6 +16,7 @@
*/ */


#include "CarlaPluginInternal.hpp" #include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"


#ifdef WANT_DSSI #ifdef WANT_DSSI




+ 1
- 0
source/backend/plugin/FluidSynthPlugin.cpp View File

@@ -16,6 +16,7 @@
*/ */


#include "CarlaPluginInternal.hpp" #include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"


#ifdef WANT_FLUIDSYNTH #ifdef WANT_FLUIDSYNTH




+ 1
- 0
source/backend/plugin/JucePlugin.cpp View File

@@ -16,6 +16,7 @@
*/ */


#include "CarlaPluginInternal.hpp" #include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"


#ifdef HAVE_JUCE #ifdef HAVE_JUCE




+ 1
- 0
source/backend/plugin/LadspaPlugin.cpp View File

@@ -16,6 +16,7 @@
*/ */


#include "CarlaPluginInternal.hpp" #include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"


#ifdef WANT_LADSPA #ifdef WANT_LADSPA




+ 1
- 0
source/backend/plugin/LinuxSamplerPlugin.cpp View File

@@ -22,6 +22,7 @@
* - use CARLA_SAFE_ASSERT_RETURN with err * - use CARLA_SAFE_ASSERT_RETURN with err
*/ */
#include "CarlaPluginInternal.hpp" #include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"


#ifdef WANT_LINUXSAMPLER #ifdef WANT_LINUXSAMPLER




+ 1
- 0
source/backend/plugin/Lv2Plugin.cpp View File

@@ -16,6 +16,7 @@
*/ */


#include "CarlaPluginInternal.hpp" #include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"


#ifdef WANT_LV2 #ifdef WANT_LV2




+ 1
- 0
source/backend/plugin/NativePlugin.cpp View File

@@ -16,6 +16,7 @@
*/ */


#include "CarlaPluginInternal.hpp" #include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"


#ifdef WANT_NATIVE #ifdef WANT_NATIVE




+ 1
- 0
source/backend/plugin/VstPlugin.cpp View File

@@ -16,6 +16,7 @@
*/ */


#include "CarlaPluginInternal.hpp" #include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"


#ifdef WANT_VST #ifdef WANT_VST




Loading…
Cancel
Save