@@ -56,13 +56,9 @@ void PluginAudioData::createNew(const uint32_t newCount) | |||||
CARLA_SAFE_ASSERT_RETURN(newCount > 0,); | CARLA_SAFE_ASSERT_RETURN(newCount > 0,); | ||||
ports = new PluginAudioPort[newCount]; | ports = new PluginAudioPort[newCount]; | ||||
count = newCount; | |||||
carla_zeroStruct(ports, newCount); | |||||
for (uint32_t i=0; i < count; ++i) | |||||
{ | |||||
ports[i].rindex = 0; | |||||
ports[i].port = nullptr; | |||||
} | |||||
count = newCount; | |||||
} | } | ||||
void PluginAudioData::clear() noexcept | void PluginAudioData::clear() noexcept | ||||
@@ -114,14 +110,9 @@ void PluginCVData::createNew(const uint32_t newCount) | |||||
CARLA_SAFE_ASSERT_RETURN(newCount > 0,); | CARLA_SAFE_ASSERT_RETURN(newCount > 0,); | ||||
ports = new PluginCVPort[newCount]; | ports = new PluginCVPort[newCount]; | ||||
count = newCount; | |||||
carla_zeroStruct(ports, newCount); | |||||
for (uint32_t i=0; i < count; ++i) | |||||
{ | |||||
ports[i].rindex = 0; | |||||
ports[i].param = 0; | |||||
ports[i].port = nullptr; | |||||
} | |||||
count = newCount; | |||||
} | } | ||||
void PluginCVData::clear() noexcept | void PluginCVData::clear() noexcept | ||||
@@ -215,31 +206,26 @@ void PluginParameterData::createNew(const uint32_t newCount, const bool withSpec | |||||
CARLA_SAFE_ASSERT_RETURN(special == nullptr,); | CARLA_SAFE_ASSERT_RETURN(special == nullptr,); | ||||
CARLA_SAFE_ASSERT_RETURN(newCount > 0,); | CARLA_SAFE_ASSERT_RETURN(newCount > 0,); | ||||
data = new ParameterData[newCount]; | |||||
ranges = new ParameterRanges[newCount]; | |||||
count = newCount; | |||||
if (withSpecial) | |||||
special = new SpecialParameterType[newCount]; | |||||
data = new ParameterData[newCount]; | |||||
carla_zeroStruct(data, newCount); | |||||
for (uint32_t i=0; i < newCount; ++i) | for (uint32_t i=0; i < newCount; ++i) | ||||
{ | { | ||||
data[i].type = PARAMETER_UNKNOWN; | |||||
data[i].hints = 0x0; | |||||
data[i].index = PARAMETER_NULL; | data[i].index = PARAMETER_NULL; | ||||
data[i].rindex = PARAMETER_NULL; | data[i].rindex = PARAMETER_NULL; | ||||
data[i].midiCC = -1; | data[i].midiCC = -1; | ||||
data[i].midiChannel = 0; | |||||
ranges[i].def = 0.0f; | |||||
ranges[i].min = 0.0f; | |||||
ranges[i].max = 0.0f; | |||||
ranges[i].step = 0.0f; | |||||
ranges[i].stepSmall = 0.0f; | |||||
ranges[i].stepLarge = 0.0f; | |||||
if (withSpecial) | |||||
special[i] = PARAMETER_SPECIAL_NULL; | |||||
} | } | ||||
ranges = new ParameterRanges[newCount]; | |||||
carla_zeroStruct(ranges, newCount); | |||||
if (withSpecial) | |||||
{ | |||||
special = new SpecialParameterType[newCount]; | |||||
carla_zeroStruct(special, newCount); | |||||
} | |||||
count = newCount; | |||||
} | } | ||||
void PluginParameterData::clear() noexcept | void PluginParameterData::clear() noexcept | ||||
@@ -293,12 +279,11 @@ void PluginProgramData::createNew(const uint32_t newCount) | |||||
CARLA_SAFE_ASSERT_RETURN(names == nullptr,); | CARLA_SAFE_ASSERT_RETURN(names == nullptr,); | ||||
CARLA_SAFE_ASSERT_RETURN(newCount > 0,); | CARLA_SAFE_ASSERT_RETURN(newCount > 0,); | ||||
names = new ProgramName[newCount]; | |||||
names = new ProgramName[newCount]; | |||||
carla_zeroStruct(names, newCount); | |||||
count = newCount; | count = newCount; | ||||
current = -1; | current = -1; | ||||
for (uint32_t i=0; i < newCount; ++i) | |||||
names[i] = nullptr; | |||||
} | } | ||||
void PluginProgramData::clear() noexcept | void PluginProgramData::clear() noexcept | ||||
@@ -318,7 +303,7 @@ void PluginProgramData::clear() noexcept | |||||
names = nullptr; | names = nullptr; | ||||
} | } | ||||
count = 0; | |||||
count = 0; | |||||
current = -1; | current = -1; | ||||
} | } | ||||
@@ -344,16 +329,11 @@ void PluginMidiProgramData::createNew(const uint32_t newCount) | |||||
CARLA_SAFE_ASSERT_RETURN(data == nullptr,); | CARLA_SAFE_ASSERT_RETURN(data == nullptr,); | ||||
CARLA_SAFE_ASSERT_RETURN(newCount > 0,); | CARLA_SAFE_ASSERT_RETURN(newCount > 0,); | ||||
data = new MidiProgramData[newCount]; | |||||
data = new MidiProgramData[newCount]; | |||||
carla_zeroStruct(data, newCount); | |||||
count = newCount; | count = newCount; | ||||
current = -1; | current = -1; | ||||
for (uint32_t i=0; i < count; ++i) | |||||
{ | |||||
data[i].bank = 0; | |||||
data[i].program = 0; | |||||
data[i].name = nullptr; | |||||
} | |||||
} | } | ||||
void PluginMidiProgramData::clear() noexcept | void PluginMidiProgramData::clear() noexcept | ||||
@@ -373,7 +353,7 @@ void PluginMidiProgramData::clear() noexcept | |||||
data = nullptr; | data = nullptr; | ||||
} | } | ||||
count = 0; | |||||
count = 0; | |||||
current = -1; | current = -1; | ||||
} | } | ||||
@@ -392,9 +372,7 @@ CarlaPlugin::ProtectedData::ExternalNotes::ExternalNotes() noexcept | |||||
CarlaPlugin::ProtectedData::ExternalNotes::~ExternalNotes() noexcept | CarlaPlugin::ProtectedData::ExternalNotes::~ExternalNotes() noexcept | ||||
{ | { | ||||
mutex.lock(); | |||||
data.clear(); | |||||
mutex.unlock(); | |||||
clear(); | |||||
} | } | ||||
void CarlaPlugin::ProtectedData::ExternalNotes::appendNonRT(const ExternalMidiNote& note) noexcept | void CarlaPlugin::ProtectedData::ExternalNotes::appendNonRT(const ExternalMidiNote& note) noexcept | ||||
@@ -404,6 +382,13 @@ void CarlaPlugin::ProtectedData::ExternalNotes::appendNonRT(const ExternalMidiNo | |||||
mutex.unlock(); | mutex.unlock(); | ||||
} | } | ||||
void CarlaPlugin::ProtectedData::ExternalNotes::clear() noexcept | |||||
{ | |||||
mutex.lock(); | |||||
data.clear(); | |||||
mutex.unlock(); | |||||
} | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// ProtectedData::PostRtEvents | // ProtectedData::PostRtEvents | ||||
@@ -24,11 +24,10 @@ | |||||
#include "CarlaOscUtils.hpp" | #include "CarlaOscUtils.hpp" | ||||
#include "CarlaStateUtils.hpp" | #include "CarlaStateUtils.hpp" | ||||
#include "CarlaMIDI.h" | |||||
#include "CarlaMutex.hpp" | #include "CarlaMutex.hpp" | ||||
#include "RtLinkedList.hpp" | #include "RtLinkedList.hpp" | ||||
#include "CarlaMIDI.h" | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
#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; } | ||||
@@ -42,7 +41,7 @@ CARLA_BACKEND_START_NAMESPACE | |||||
#endif | #endif | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Forward declarations of CarlaEngine classes | |||||
// Forward declarations of CarlaEngine port classes | |||||
class CarlaEngineAudioPort; | class CarlaEngineAudioPort; | ||||
class CarlaEngineCVPort; | class CarlaEngineCVPort; | ||||
@@ -124,7 +123,7 @@ struct PluginAudioData { | |||||
struct PluginCVPort { | struct PluginCVPort { | ||||
uint32_t rindex; | uint32_t rindex; | ||||
uint32_t param; | |||||
uint32_t param; // FIXME is this needed? | |||||
CarlaEngineCVPort* port; | CarlaEngineCVPort* port; | ||||
}; | }; | ||||
@@ -158,11 +157,11 @@ struct PluginEventData { | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
enum SpecialParameterType { | enum SpecialParameterType { | ||||
PARAMETER_SPECIAL_NULL = 0, | |||||
PARAMETER_SPECIAL_LATENCY = 1, | |||||
PARAMETER_SPECIAL_SAMPLE_RATE = 2, | |||||
PARAMETER_SPECIAL_LV2_FREEWHEEL = 3, | |||||
PARAMETER_SPECIAL_LV2_TIME = 4 | |||||
PARAMETER_SPECIAL_NULL = 0, | |||||
PARAMETER_SPECIAL_FREEWHEEL = 1, | |||||
PARAMETER_SPECIAL_LATENCY = 2, | |||||
PARAMETER_SPECIAL_SAMPLE_RATE = 3, | |||||
PARAMETER_SPECIAL_TIME = 4 | |||||
}; | }; | ||||
struct PluginParameterData { | struct PluginParameterData { | ||||
@@ -258,11 +257,11 @@ struct CarlaPlugin::ProtectedData { | |||||
PluginMidiProgramData midiprog; | PluginMidiProgramData midiprog; | ||||
LinkedList<CustomData> custom; | LinkedList<CustomData> custom; | ||||
StateSave stateSave; | |||||
CarlaMutex masterMutex; // global master lock | CarlaMutex masterMutex; // global master lock | ||||
CarlaMutex singleMutex; // small lock used only in processSingle() | CarlaMutex singleMutex; // small lock used only in processSingle() | ||||
StateSave stateSave; | |||||
struct ExternalNotes { | struct ExternalNotes { | ||||
CarlaMutex mutex; | CarlaMutex mutex; | ||||
RtLinkedList<ExternalMidiNote>::Pool dataPool; | RtLinkedList<ExternalMidiNote>::Pool dataPool; | ||||
@@ -271,6 +270,7 @@ struct CarlaPlugin::ProtectedData { | |||||
ExternalNotes() noexcept; | ExternalNotes() noexcept; | ||||
~ExternalNotes() noexcept; | ~ExternalNotes() noexcept; | ||||
void appendNonRT(const ExternalMidiNote& note) noexcept; | void appendNonRT(const ExternalMidiNote& note) noexcept; | ||||
void clear() noexcept; | |||||
CARLA_DECLARE_NON_COPY_STRUCT(ExternalNotes) | CARLA_DECLARE_NON_COPY_STRUCT(ExternalNotes) | ||||
@@ -1979,11 +1979,11 @@ public: | |||||
} | } | ||||
else if (LV2_IS_PORT_DESIGNATION_FREEWHEELING(portDesignation)) | else if (LV2_IS_PORT_DESIGNATION_FREEWHEELING(portDesignation)) | ||||
{ | { | ||||
pData->param.special[j] = PARAMETER_SPECIAL_LV2_FREEWHEEL; | |||||
pData->param.special[j] = PARAMETER_SPECIAL_FREEWHEEL; | |||||
} | } | ||||
else if (LV2_IS_PORT_DESIGNATION_TIME(portDesignation)) | else if (LV2_IS_PORT_DESIGNATION_TIME(portDesignation)) | ||||
{ | { | ||||
pData->param.special[j] = PARAMETER_SPECIAL_LV2_TIME; | |||||
pData->param.special[j] = PARAMETER_SPECIAL_TIME; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
@@ -2031,7 +2031,7 @@ public: | |||||
} | } | ||||
else if (LV2_IS_PORT_DESIGNATION_TIME(portDesignation)) | else if (LV2_IS_PORT_DESIGNATION_TIME(portDesignation)) | ||||
{ | { | ||||
pData->param.special[j] = PARAMETER_SPECIAL_LV2_TIME; | |||||
pData->param.special[j] = PARAMETER_SPECIAL_TIME; | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
@@ -2073,7 +2073,7 @@ public: | |||||
pData->param.ranges[j].stepLarge = stepLarge; | pData->param.ranges[j].stepLarge = stepLarge; | ||||
// Start parameters in their default values (except freewheel, which is off by default) | // Start parameters in their default values (except freewheel, which is off by default) | ||||
if (pData->param.data[j].type == PARAMETER_INPUT && pData->param.special[j] == PARAMETER_SPECIAL_LV2_FREEWHEEL) | |||||
if (pData->param.data[j].type == PARAMETER_INPUT && pData->param.special[j] == PARAMETER_SPECIAL_FREEWHEEL) | |||||
fParamBuffers[j] = min; | fParamBuffers[j] = min; | ||||
else | else | ||||
fParamBuffers[j] = def; | fParamBuffers[j] = def; | ||||
@@ -2574,7 +2574,7 @@ public: | |||||
{ | { | ||||
if (pData->param.data[k].type != PARAMETER_INPUT) | if (pData->param.data[k].type != PARAMETER_INPUT) | ||||
continue; | continue; | ||||
if (pData->param.special[k] != PARAMETER_SPECIAL_LV2_TIME) | |||||
if (pData->param.special[k] != PARAMETER_SPECIAL_TIME) | |||||
continue; | continue; | ||||
doPostRt = false; | doPostRt = false; | ||||
@@ -3581,7 +3581,7 @@ public: | |||||
{ | { | ||||
for (uint32_t k=0; k < pData->param.count; ++k) | for (uint32_t k=0; k < pData->param.count; ++k) | ||||
{ | { | ||||
if (pData->param.data[k].type == PARAMETER_INPUT && pData->param.special[k] == PARAMETER_SPECIAL_LV2_FREEWHEEL) | |||||
if (pData->param.data[k].type == PARAMETER_INPUT && pData->param.special[k] == PARAMETER_SPECIAL_FREEWHEEL) | |||||
{ | { | ||||
fParamBuffers[k] = isOffline ? pData->param.ranges[k].max : pData->param.ranges[k].min; | fParamBuffers[k] = isOffline ? pData->param.ranges[k].max : pData->param.ranges[k].min; | ||||
pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 1, fParamBuffers[k]); | pData->postponeRtEvent(kPluginPostRtEventParameterChange, static_cast<int32_t>(k), 1, fParamBuffers[k]); | ||||