Browse Source

General fixing of utils code

tags/1.9.4
falkTX 11 years ago
parent
commit
8b34a54366
18 changed files with 179 additions and 107 deletions
  1. +2
    -2
      source/backend/engine/CarlaEngineRtAudio.cpp
  2. +2
    -2
      source/backend/engine/CarlaEngineThread.cpp
  3. +2
    -2
      source/backend/native/audio-base.hpp
  4. +4
    -4
      source/backend/native/midi-base.hpp
  5. +2
    -2
      source/backend/native/midi-sequencer.cpp
  6. +3
    -3
      source/backend/plugin/CarlaPlugin.cpp
  7. +3
    -3
      source/backend/plugin/CarlaPluginInternal.hpp
  8. +1
    -1
      source/libs/distrho/dgl/Widget.hpp
  9. +1
    -1
      source/libs/distrho/dgl/src/Widget.cpp
  10. +9
    -9
      source/libs/jackbridge/JackBridge.hpp
  11. +1
    -1
      source/libs/lilv/config/lilv_config.h
  12. +1
    -1
      source/libs/lilv/config/sratom_config.h
  13. +2
    -2
      source/tests/RtList.cpp
  14. +4
    -4
      source/utils/CarlaLadspaUtils.hpp
  15. +3
    -3
      source/utils/CarlaLibUtils.hpp
  16. +90
    -26
      source/utils/CarlaLv2Utils.hpp
  17. +10
    -10
      source/utils/CarlaMutex.hpp
  18. +39
    -31
      source/utils/RtList.hpp

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

@@ -1270,8 +1270,8 @@ private:


RtMidiEvents() RtMidiEvents()
: dataPool(512, 512), : dataPool(512, 512),
data(&dataPool),
dataPending(&dataPool) {}
data(dataPool),
dataPending(dataPool) {}


~RtMidiEvents() ~RtMidiEvents()
{ {


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

@@ -58,7 +58,7 @@ void CarlaEngineThread::stopNow()


fStopNow = true; fStopNow = true;


const CarlaMutex::ScopedLocker sl(&fMutex);
const CarlaMutex::ScopedLocker sl(fMutex);


if (isRunning() && ! wait(500)) if (isRunning() && ! wait(500))
terminate(); terminate();
@@ -77,7 +77,7 @@ void CarlaEngineThread::run()


while (kEngine->isRunning() && ! fStopNow) while (kEngine->isRunning() && ! fStopNow)
{ {
const CarlaMutex::ScopedLocker sl(&fMutex);
const CarlaMutex::ScopedLocker sl(fMutex);


#ifdef BUILD_BRIDGE #ifdef BUILD_BRIDGE
oscRegisted = kEngine->isOscBridgeRegistered(); oscRegisted = kEngine->isOscBridgeRegistered();


+ 2
- 2
source/backend/native/audio-base.hpp View File

@@ -160,7 +160,7 @@ public:
if (isRunning() && ! wait(1000)) if (isRunning() && ! wait(1000))
terminate(); terminate();


const CarlaMutex::ScopedLocker sl(&fMutex);
const CarlaMutex::ScopedLocker sl(fMutex);
fPool.reset(); fPool.reset();
} }


@@ -290,7 +290,7 @@ public:
i = j = 0; i = j = 0;


// lock, and put data asap // lock, and put data asap
const CarlaMutex::ScopedLocker sl(&fMutex);
const CarlaMutex::ScopedLocker sl(fMutex);


for (; i < fPool.size && j < rv; ++j) for (; i < fPool.size && j < rv; ++j)
{ {


+ 4
- 4
source/backend/native/midi-base.hpp View File

@@ -197,7 +197,7 @@ public:


void clear() void clear()
{ {
const CarlaMutex::ScopedLocker sl(&fMutex);
const CarlaMutex::ScopedLocker sl(fMutex);
fData.clear(); fData.clear();
} }


@@ -214,7 +214,7 @@ private:
{ {
if (fData.isEmpty()) if (fData.isEmpty())
{ {
const CarlaMutex::ScopedLocker sl(&fMutex);
const CarlaMutex::ScopedLocker sl(fMutex);
fData.append(event); fData.append(event);
return; return;
} }
@@ -226,12 +226,12 @@ private:
if (event->time >= oldEvent->time) if (event->time >= oldEvent->time)
continue; continue;


const CarlaMutex::ScopedLocker sl(&fMutex);
const CarlaMutex::ScopedLocker sl(fMutex);
fData.insertAt(event, it); fData.insertAt(event, it);
return; return;
} }


const CarlaMutex::ScopedLocker sl(&fMutex);
const CarlaMutex::ScopedLocker sl(fMutex);
fData.append(event); fData.append(event);
} }
}; };


+ 2
- 2
source/backend/native/midi-sequencer.cpp View File

@@ -198,8 +198,8 @@ private:


InRtEvents() InRtEvents()
: dataPool(MIN_PREALLOCATED_EVENT_COUNT, MAX_PREALLOCATED_EVENT_COUNT), : dataPool(MIN_PREALLOCATED_EVENT_COUNT, MAX_PREALLOCATED_EVENT_COUNT),
data(&dataPool),
dataPendingRT(&dataPool) {}
data(dataPool),
dataPendingRT(dataPool) {}


~InRtEvents() ~InRtEvents()
{ {


+ 3
- 3
source/backend/plugin/CarlaPlugin.cpp View File

@@ -54,7 +54,7 @@ public:
if (filename == nullptr) if (filename == nullptr)
return nullptr; return nullptr;


const CarlaMutex::ScopedLocker sl(&mutex);
const CarlaMutex::ScopedLocker sl(mutex);


for (NonRtList<Lib>::Itenerator it = libs.begin(); it.valid(); it.next()) for (NonRtList<Lib>::Itenerator it = libs.begin(); it.valid(); it.next())
{ {
@@ -89,7 +89,7 @@ public:
if (libPtr == nullptr) if (libPtr == nullptr)
return false; return false;


const CarlaMutex::ScopedLocker sl(&mutex);
const CarlaMutex::ScopedLocker sl(mutex);


for (NonRtList<Lib>::Itenerator it = libs.begin(); it.valid(); it.next()) for (NonRtList<Lib>::Itenerator it = libs.begin(); it.valid(); it.next())
{ {
@@ -1952,7 +1952,7 @@ void CarlaPlugin::postponeRtEvent(const PluginPostRtEventType type, const int32_


void CarlaPlugin::postRtEventsRun() void CarlaPlugin::postRtEventsRun()
{ {
const CarlaMutex::ScopedLocker sl(&kData->postRtEvents.mutex);
const CarlaMutex::ScopedLocker sl(kData->postRtEvents.mutex);


while (! kData->postRtEvents.data.isEmpty()) while (! kData->postRtEvents.data.isEmpty())
{ {


+ 3
- 3
source/backend/plugin/CarlaPluginInternal.hpp View File

@@ -429,7 +429,7 @@ struct CarlaPluginProtectedData {


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


~ExternalNotes() ~ExternalNotes()
{ {
@@ -457,8 +457,8 @@ struct CarlaPluginProtectedData {


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


~PostRtEvents() ~PostRtEvents()
{ {


+ 1
- 1
source/libs/distrho/dgl/Widget.hpp View File

@@ -38,7 +38,7 @@ public:
Widget(Window* parent); Widget(Window* parent);
virtual ~Widget(); virtual ~Widget();


bool isVisible();
bool isVisible() const;
void setVisible(bool yesNo); void setVisible(bool yesNo);


void show() void show()


+ 1
- 1
source/libs/distrho/dgl/src/Widget.cpp View File

@@ -39,7 +39,7 @@ Widget::~Widget()
fParent->removeWidget(this); fParent->removeWidget(this);
} }


bool Widget::isVisible()
bool Widget::isVisible() const
{ {
return fVisible; return fVisible;
} }


+ 9
- 9
source/libs/jackbridge/JackBridge.hpp View File

@@ -163,17 +163,17 @@ typedef struct _jack_latency_range jack_latency_range_t;
typedef struct _jack_position jack_position_t; typedef struct _jack_position jack_position_t;
typedef struct _jack_midi_event jack_midi_event_t; typedef struct _jack_midi_event jack_midi_event_t;


typedef void (*JackLatencyCallback)(jack_latency_callback_mode_t mode, void *arg);
typedef int (*JackProcessCallback)(jack_nframes_t nframes, void *arg);
typedef int (*JackBufferSizeCallback)(jack_nframes_t nframes, void *arg);
typedef int (*JackSampleRateCallback)(jack_nframes_t nframes, void *arg);
typedef void (*JackPortRegistrationCallback)(jack_port_id_t port, int register_, void *arg);
typedef void (*JackClientRegistrationCallback)(const char* name, int register_, void *arg);
typedef void (*JackLatencyCallback)(jack_latency_callback_mode_t mode, void* arg);
typedef int (*JackProcessCallback)(jack_nframes_t nframes, void* arg);
typedef int (*JackBufferSizeCallback)(jack_nframes_t nframes, void* arg);
typedef int (*JackSampleRateCallback)(jack_nframes_t nframes, void* arg);
typedef void (*JackPortRegistrationCallback)(jack_port_id_t port, int register_, void* arg);
typedef void (*JackClientRegistrationCallback)(const char* name, int register_, void* arg);
typedef void (*JackPortConnectCallback)(jack_port_id_t a, jack_port_id_t b, int connect, void* arg); typedef void (*JackPortConnectCallback)(jack_port_id_t a, jack_port_id_t b, int connect, void* arg);
typedef int (*JackPortRenameCallback)(jack_port_id_t port, const char* old_name, const char* new_name, void *arg);
typedef void (*JackFreewheelCallback)(int starting, void *arg);
typedef int (*JackPortRenameCallback)(jack_port_id_t port, const char* old_name, const char* new_name, void* arg);
typedef void (*JackFreewheelCallback)(int starting, void* arg);
typedef int (*JackXRunCallback)(void* arg); typedef int (*JackXRunCallback)(void* arg);
typedef void (*JackShutdownCallback)(void *arg);
typedef void (*JackShutdownCallback)(void* arg);


#endif // ! JACKBRIDGE_DIRECT #endif // ! JACKBRIDGE_DIRECT




+ 1
- 1
source/libs/lilv/config/lilv_config.h View File

@@ -2,7 +2,7 @@
#ifndef _LILV_CONFIG_H_ #ifndef _LILV_CONFIG_H_
#define _LILV_CONFIG_H_ #define _LILV_CONFIG_H_


#define LILV_VERSION "0.14.4"
#define LILV_VERSION "0.16.0"
#define LILV_NEW_LV2 1 #define LILV_NEW_LV2 1


#define HAVE_LV2 1 #define HAVE_LV2 1


+ 1
- 1
source/libs/lilv/config/sratom_config.h View File

@@ -2,7 +2,7 @@
#ifndef _SRATOM_CONFIG_H_ #ifndef _SRATOM_CONFIG_H_
#define _SRATOM_CONFIG_H_ #define _SRATOM_CONFIG_H_


#define SRATOM_VERSION "0.4.0"
#define SRATOM_VERSION "0.4.2"


#define HAVE_LV2 1 #define HAVE_LV2 1
#define HAVE_SERD 1 #define HAVE_SERD 1


+ 2
- 2
source/tests/RtList.cpp View File

@@ -48,8 +48,8 @@ struct PostRtEvents {


PostRtEvents() PostRtEvents()
: dataPool(MIN_RT_EVENTS, MAX_RT_EVENTS), : dataPool(MIN_RT_EVENTS, MAX_RT_EVENTS),
data(&dataPool),
dataPendingRT(&dataPool) {}
data(dataPool),
dataPendingRT(dataPool) {}


~PostRtEvents() ~PostRtEvents()
{ {


+ 4
- 4
source/utils/CarlaLadspaUtils.hpp View File

@@ -54,8 +54,8 @@ const LADSPA_RDF_Descriptor* ladspa_rdf_dup(const LADSPA_RDF_Descriptor* const o


for (unsigned long i=0; i < newDescriptor->PortCount; ++i) for (unsigned long i=0; i < newDescriptor->PortCount; ++i)
{ {
LADSPA_RDF_Port* const oldPort = &oldDescriptor->Ports[i];
LADSPA_RDF_Port* const newPort = &newDescriptor->Ports[i];
LADSPA_RDF_Port* const oldPort(&oldDescriptor->Ports[i]);
LADSPA_RDF_Port* const newPort(&newDescriptor->Ports[i]);


newPort->Type = oldPort->Type; newPort->Type = oldPort->Type;
newPort->Hints = oldPort->Hints; newPort->Hints = oldPort->Hints;
@@ -72,8 +72,8 @@ const LADSPA_RDF_Descriptor* ladspa_rdf_dup(const LADSPA_RDF_Descriptor* const o


for (unsigned long j=0; j < oldPort->ScalePointCount; ++j) for (unsigned long j=0; j < oldPort->ScalePointCount; ++j)
{ {
LADSPA_RDF_ScalePoint* const oldScalePoint = &oldPort->ScalePoints[j];
LADSPA_RDF_ScalePoint* const newScalePoint = &newPort->ScalePoints[j];
LADSPA_RDF_ScalePoint* const oldScalePoint(&oldPort->ScalePoints[j]);
LADSPA_RDF_ScalePoint* const newScalePoint(&newPort->ScalePoints[j]);


newScalePoint->Value = oldScalePoint->Value; newScalePoint->Value = oldScalePoint->Value;




+ 3
- 3
source/utils/CarlaLibUtils.hpp View File

@@ -77,13 +77,13 @@ const char* lib_error(const char* const filename)


#ifdef CARLA_OS_WIN #ifdef CARLA_OS_WIN
static char libError[2048]; static char libError[2048];
carla_zeroMem(libError, sizeof(char)*2048);
//carla_fill<char>(libError, 2048, '\0');


LPVOID winErrorString; LPVOID winErrorString;
DWORD winErrorCode = GetLastError(); DWORD winErrorCode = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, winErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&winErrorString, 0, nullptr);
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, winErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&winErrorString, 0, nullptr);


snprintf(libError, 2048, "%s: error code %li: %s", filename, winErrorCode, (const char*)winErrorString);
std::snprintf(libError, 2048, "%s: error code %li: %s", filename, winErrorCode, (const char*)winErrorString);
LocalFree(winErrorString); LocalFree(winErrorString);


return libError; return libError;


+ 90
- 26
source/utils/CarlaLv2Utils.hpp View File

@@ -390,10 +390,10 @@ public:
return nullptr; return nullptr;
} }


if (const LilvState* state = lilv_state_new_from_world(this->me, uridMap, uriNode))
if (const LilvState* cState = lilv_state_new_from_world(this->me, uridMap, uriNode))
{ {
lilv_node_free(uriNode); lilv_node_free(uriNode);
return state;
return cState;
} }
else else
{ {
@@ -567,7 +567,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)
const QString replaceId(replaceURI.split(":").last()); const QString replaceId(replaceURI.split(":").last());


bool ok; bool ok;
ulong uniqueId = replaceId.toULong(&ok);
const ulong uniqueId(replaceId.toULong(&ok));


if (ok && uniqueId != 0) if (ok && uniqueId != 0)
rdfDescriptor->UniqueID = uniqueId; rdfDescriptor->UniqueID = uniqueId;
@@ -587,7 +587,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)
for (uint32_t j = 0; j < rdfDescriptor->PortCount; ++j) for (uint32_t j = 0; j < rdfDescriptor->PortCount; ++j)
{ {
Lilv::Port lilvPort(lilvPlugin.get_port_by_index(j)); Lilv::Port lilvPort(lilvPlugin.get_port_by_index(j));
LV2_RDF_Port* const rdfPort = &rdfDescriptor->Ports[j];
LV2_RDF_Port* const rdfPort(&rdfDescriptor->Ports[j]);


// -------------------------------------- // --------------------------------------
// Set Port Information // Set Port Information
@@ -605,23 +605,24 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)
// Input or Output // Input or Output
if (lilvPort.is_a(gLv2World.port_input)) if (lilvPort.is_a(gLv2World.port_input))
rdfPort->Types |= LV2_PORT_INPUT; rdfPort->Types |= LV2_PORT_INPUT;

else if (lilvPort.is_a(gLv2World.port_output)) else if (lilvPort.is_a(gLv2World.port_output))
rdfPort->Types |= LV2_PORT_OUTPUT; rdfPort->Types |= LV2_PORT_OUTPUT;

else else
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is not input or output", uri, rdfPort->Name); carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is not input or output", uri, rdfPort->Name);


// Data Type // Data Type
if (lilvPort.is_a(gLv2World.port_control)) if (lilvPort.is_a(gLv2World.port_control))
{
rdfPort->Types |= LV2_PORT_CONTROL; rdfPort->Types |= LV2_PORT_CONTROL;
}
else if (lilvPort.is_a(gLv2World.port_audio)) else if (lilvPort.is_a(gLv2World.port_audio))
{
rdfPort->Types |= LV2_PORT_AUDIO; rdfPort->Types |= LV2_PORT_AUDIO;
}
else if (lilvPort.is_a(gLv2World.port_cv)) else if (lilvPort.is_a(gLv2World.port_cv))
{
rdfPort->Types |= LV2_PORT_CV; rdfPort->Types |= LV2_PORT_CV;
}
else if (lilvPort.is_a(gLv2World.port_atom)) else if (lilvPort.is_a(gLv2World.port_atom))
{ {
rdfPort->Types |= LV2_PORT_ATOM; rdfPort->Types |= LV2_PORT_ATOM;
@@ -655,7 +656,6 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)
if (! supported) if (! supported)
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of atom type but has unsupported data", uri, rdfPort->Name); carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of atom type but has unsupported data", uri, rdfPort->Name);
} }

else if (lilvPort.is_a(gLv2World.port_event)) else if (lilvPort.is_a(gLv2World.port_event))
{ {
rdfPort->Types |= LV2_PORT_EVENT; rdfPort->Types |= LV2_PORT_EVENT;
@@ -680,13 +680,11 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)
if (! supported) if (! supported)
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of event type but has unsupported data", uri, rdfPort->Name); carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of event type but has unsupported data", uri, rdfPort->Name);
} }

else if (lilvPort.is_a(gLv2World.port_midi)) else if (lilvPort.is_a(gLv2World.port_midi))
{ {
rdfPort->Types |= LV2_PORT_MIDI_LL; rdfPort->Types |= LV2_PORT_MIDI_LL;
rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT; rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT;
} }

else else
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of unkown data type", uri, rdfPort->Name); carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of unkown data type", uri, rdfPort->Name);
} }
@@ -726,6 +724,66 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)


if (lilvPort.has_property(gLv2World.reportsLatency)) if (lilvPort.has_property(gLv2World.reportsLatency))
rdfPort->Designation = LV2_PORT_DESIGNATION_LATENCY; rdfPort->Designation = LV2_PORT_DESIGNATION_LATENCY;

// no port properties, check if port uses old ones
if (rdfPort->Properties == 0x0)
{
static const Lilv::Node oldPropArtifacts(gLv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#causesArtifacts"));
static const Lilv::Node oldPropContinuousCV(gLv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#continuousCV"));
static const Lilv::Node oldPropDiscreteCV(gLv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#discreteCV"));
static const Lilv::Node oldPropExpensive(gLv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#expensive"));
static const Lilv::Node oldPropStrictBounds(gLv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#hasStrictBounds"));
static const Lilv::Node oldPropLogarithmic(gLv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#logarithmic"));
static const Lilv::Node oldPropNotAutomatic(gLv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#notAutomatic"));
static const Lilv::Node oldPropNotOnGUI(gLv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#notOnGUI"));
static const Lilv::Node oldPropTrigger(gLv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#trigger"));

if (lilvPort.has_property(oldPropArtifacts))
{
rdfPort->Properties |= LV2_PORT_CAUSES_ARTIFACTS;
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/broken LV2 property for 'causesArtifacts'", uri, rdfPort->Name);
}
if (lilvPort.has_property(oldPropContinuousCV))
{
rdfPort->Properties |= LV2_PORT_CONTINUOUS_CV;
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/broken LV2 property for 'continuousCV'", uri, rdfPort->Name);
}
if (lilvPort.has_property(oldPropDiscreteCV))
{
rdfPort->Properties |= LV2_PORT_DISCRETE_CV;
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/broken LV2 property for 'discreteCV'", uri, rdfPort->Name);
}
if (lilvPort.has_property(oldPropExpensive))
{
rdfPort->Properties |= LV2_PORT_EXPENSIVE;
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/broken LV2 property for 'expensive'", uri, rdfPort->Name);
}
if (lilvPort.has_property(oldPropStrictBounds))
{
rdfPort->Properties |= LV2_PORT_STRICT_BOUNDS;
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/broken LV2 property for 'hasStrictBounds'", uri, rdfPort->Name);
}
if (lilvPort.has_property(oldPropLogarithmic))
{
rdfPort->Properties |= LV2_PORT_LOGARITHMIC;
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/broken LV2 property for 'logarithmic'", uri, rdfPort->Name);
}
if (lilvPort.has_property(oldPropNotAutomatic))
{
rdfPort->Properties |= LV2_PORT_NOT_AUTOMATIC;
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/broken LV2 property for 'notAutomatic'", uri, rdfPort->Name);
}
if (lilvPort.has_property(oldPropNotOnGUI))
{
rdfPort->Properties |= LV2_PORT_NOT_ON_GUI;
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/broken LV2 property for 'notOnGUI'", uri, rdfPort->Name);
}
if (lilvPort.has_property(oldPropTrigger))
{
rdfPort->Properties |= LV2_PORT_TRIGGER;
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses old/broken LV2 property for 'trigger'", uri, rdfPort->Name);
}
}
} }


// -------------------------------------- // --------------------------------------
@@ -946,8 +1004,10 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)
uint32_t h = 0; uint32_t h = 0;
LILV_FOREACH(scale_points, j, lilvScalePoints) LILV_FOREACH(scale_points, j, lilvScalePoints)
{ {
CARLA_ASSERT(h < rdfPort->ScalePointCount);

Lilv::ScalePoint lilvScalePoint(lilvScalePoints.get(j)); Lilv::ScalePoint lilvScalePoint(lilvScalePoints.get(j));
LV2_RDF_PortScalePoint* const rdfScalePoint = &rdfPort->ScalePoints[h++];
LV2_RDF_PortScalePoint* const rdfScalePoint(&rdfPort->ScalePoints[h++]);


if (const char* const label = Lilv::Node(lilvScalePoint.get_label()).as_string()) if (const char* const label = Lilv::Node(lilvScalePoint.get_label()).as_string())
rdfScalePoint->Label = carla_strdup(label); rdfScalePoint->Label = carla_strdup(label);
@@ -971,7 +1031,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)
LILV_FOREACH(nodes, j, presetNodes) LILV_FOREACH(nodes, j, presetNodes)
{ {
Lilv::Node presetNode(presetNodes.get(j)); Lilv::Node presetNode(presetNodes.get(j));
// FIXME - check appliesTo
// FIXME - check appliesTo?


QString presetURI(presetNode.as_uri()); QString presetURI(presetNode.as_uri());


@@ -995,12 +1055,14 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)


if (const char* const presetURI = presetNode.as_uri()) if (const char* const presetURI = presetNode.as_uri())
{ {
int32_t index = presetListURIs.indexOf(QString(presetURI));
const int index(presetListURIs.indexOf(QString(presetURI)));

CARLA_ASSERT(index >= 0);


if (index < 0) if (index < 0)
continue; continue;


LV2_RDF_Preset* const rdfPreset = &rdfDescriptor->Presets[index];
LV2_RDF_Preset* const rdfPreset(&rdfDescriptor->Presets[index]);


// -------------------------------------- // --------------------------------------
// Set Preset Information // Set Preset Information
@@ -1036,9 +1098,10 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)
LILV_FOREACH(nodes, j, lilvFeatureNodes) LILV_FOREACH(nodes, j, lilvFeatureNodes)
{ {
CARLA_ASSERT(h < rdfDescriptor->FeatureCount); CARLA_ASSERT(h < rdfDescriptor->FeatureCount);

Lilv::Node lilvFeatureNode(lilvFeatureNodes.get(j)); Lilv::Node lilvFeatureNode(lilvFeatureNodes.get(j));
LV2_RDF_Feature* const rdfFeature(&rdfDescriptor->Features[h++]);


LV2_RDF_Feature* const rdfFeature = &rdfDescriptor->Features[h++];
rdfFeature->Type = lilvFeatureNodesR.contains(lilvFeatureNode) ? LV2_FEATURE_REQUIRED : LV2_FEATURE_OPTIONAL; rdfFeature->Type = lilvFeatureNodesR.contains(lilvFeatureNode) ? LV2_FEATURE_REQUIRED : LV2_FEATURE_OPTIONAL;


if (const char* const featureURI = lilvFeatureNode.as_uri()) if (const char* const featureURI = lilvFeatureNode.as_uri())
@@ -1061,9 +1124,9 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)
LILV_FOREACH(nodes, j, lilvExtensionDataNodes) LILV_FOREACH(nodes, j, lilvExtensionDataNodes)
{ {
CARLA_ASSERT(h < rdfDescriptor->ExtensionCount); CARLA_ASSERT(h < rdfDescriptor->ExtensionCount);
Lilv::Node lilvExtensionDataNode(lilvExtensionDataNodes.get(j));


LV2_URI* const rdfExtension = &rdfDescriptor->Extensions[h++];
Lilv::Node lilvExtensionDataNode(lilvExtensionDataNodes.get(j));
LV2_URI* const rdfExtension(&rdfDescriptor->Extensions[h++]);


if (const char* const extURI = lilvExtensionDataNode.as_uri()) if (const char* const extURI = lilvExtensionDataNode.as_uri())
*rdfExtension = carla_strdup(extURI); *rdfExtension = carla_strdup(extURI);
@@ -1085,9 +1148,9 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)
LILV_FOREACH(uis, j, lilvUIs) LILV_FOREACH(uis, j, lilvUIs)
{ {
CARLA_ASSERT(h < rdfDescriptor->UICount); CARLA_ASSERT(h < rdfDescriptor->UICount);
Lilv::UI lilvUI(lilvUIs.get(j));


LV2_RDF_UI* const rdfUI = &rdfDescriptor->UIs[h++];
Lilv::UI lilvUI(lilvUIs.get(j));
LV2_RDF_UI* const rdfUI(&rdfDescriptor->UIs[h++]);


// -------------------------------------- // --------------------------------------
// Set UI Type // Set UI Type
@@ -1142,9 +1205,10 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)
LILV_FOREACH(nodes, k, lilvFeatureNodes) LILV_FOREACH(nodes, k, lilvFeatureNodes)
{ {
CARLA_ASSERT(x < rdfUI->FeatureCount); CARLA_ASSERT(x < rdfUI->FeatureCount);

Lilv::Node lilvFeatureNode(lilvFeatureNodes.get(k)); Lilv::Node lilvFeatureNode(lilvFeatureNodes.get(k));
LV2_RDF_Feature* const rdfFeature(&rdfUI->Features[x++]);


LV2_RDF_Feature* const rdfFeature = &rdfUI->Features[x++];
rdfFeature->Type = lilvFeatureNodesR.contains(lilvFeatureNode) ? LV2_FEATURE_REQUIRED : LV2_FEATURE_OPTIONAL; rdfFeature->Type = lilvFeatureNodesR.contains(lilvFeatureNode) ? LV2_FEATURE_REQUIRED : LV2_FEATURE_OPTIONAL;


if (const char* const featureURI = lilvFeatureNode.as_uri()) if (const char* const featureURI = lilvFeatureNode.as_uri())
@@ -1167,9 +1231,9 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri)
LILV_FOREACH(nodes, k, lilvExtensionDataNodes) LILV_FOREACH(nodes, k, lilvExtensionDataNodes)
{ {
CARLA_ASSERT(x < rdfUI->ExtensionCount); CARLA_ASSERT(x < rdfUI->ExtensionCount);
Lilv::Node lilvExtensionDataNode(lilvExtensionDataNodes.get(k));


LV2_URI* const rdfExtension = &rdfUI->Extensions[x++];
Lilv::Node lilvExtensionDataNode(lilvExtensionDataNodes.get(k));
LV2_URI* const rdfExtension(&rdfUI->Extensions[x++]);


if (const char* const extURI = lilvExtensionDataNode.as_uri()) if (const char* const extURI = lilvExtensionDataNode.as_uri())
*rdfExtension = carla_strdup(extURI); *rdfExtension = carla_strdup(extURI);
@@ -1269,10 +1333,10 @@ bool is_lv2_ui_feature_supported(const LV2_URI uri)
return true; return true;
if (std::strcmp(uri, LV2_INSTANCE_ACCESS_URI) == 0) if (std::strcmp(uri, LV2_INSTANCE_ACCESS_URI) == 0)
return true; return true;
if (std::strcmp(uri, LV2_UI__idle) == 0)
return true;
if (std::strcmp(uri, LV2_UI__fixedSize) == 0) if (std::strcmp(uri, LV2_UI__fixedSize) == 0)
return true; return true;
if (std::strcmp(uri, LV2_UI__idle) == 0)
return true;
if (std::strcmp(uri, LV2_UI__makeResident) == 0) if (std::strcmp(uri, LV2_UI__makeResident) == 0)
return true; return true;
if (std::strcmp(uri, LV2_UI__noUserResize) == 0) if (std::strcmp(uri, LV2_UI__noUserResize) == 0)


+ 10
- 10
source/utils/CarlaMutex.hpp View File

@@ -1,6 +1,6 @@
/* /*
* Carla Mutex * Carla Mutex
* Copyright (C) 2011-2013 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -35,7 +35,7 @@ class CarlaMutex
{ {
public: public:
CarlaMutex() CarlaMutex()
: fTryLockCalled(false)
: fTryLockWasCalled(false)
{ {
#ifndef CPP11_MUTEX #ifndef CPP11_MUTEX
pthread_mutex_init(&pmutex, nullptr); pthread_mutex_init(&pmutex, nullptr);
@@ -60,7 +60,7 @@ public:


bool tryLock() bool tryLock()
{ {
fTryLockCalled = true;
fTryLockWasCalled = true;


#ifdef CPP11_MUTEX #ifdef CPP11_MUTEX
return cmutex.try_lock(); return cmutex.try_lock();
@@ -80,27 +80,27 @@ public:


bool wasTryLockCalled() bool wasTryLockCalled()
{ {
const bool ret = fTryLockCalled;
fTryLockCalled = false;
const bool ret = fTryLockWasCalled;
fTryLockWasCalled = false;
return ret; return ret;
} }


class ScopedLocker class ScopedLocker
{ {
public: public:
ScopedLocker(CarlaMutex* const mutex)
ScopedLocker(CarlaMutex& mutex)
: fMutex(mutex) : fMutex(mutex)
{ {
fMutex->lock();
fMutex.lock();
} }


~ScopedLocker() ~ScopedLocker()
{ {
fMutex->unlock();
fMutex.unlock();
} }


private: private:
CarlaMutex* const fMutex;
CarlaMutex& fMutex;


CARLA_PREVENT_HEAP_ALLOCATION CARLA_PREVENT_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ScopedLocker) CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ScopedLocker)
@@ -112,7 +112,7 @@ private:
#else #else
pthread_mutex_t pmutex; pthread_mutex_t pmutex;
#endif #endif
bool fTryLockCalled;
bool fTryLockWasCalled;


CARLA_PREVENT_HEAP_ALLOCATION CARLA_PREVENT_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaMutex) CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaMutex)


+ 39
- 31
source/utils/RtList.hpp View File

@@ -138,7 +138,7 @@ public:
{ {
std::memcpy(&data->value, &value, sizeof(T)); std::memcpy(&data->value, &value, sizeof(T));
list_add_tail(&data->siblings, &fQueue); list_add_tail(&data->siblings, &fQueue);
fCount++;
++fCount;
return true; return true;
} }


@@ -151,7 +151,7 @@ public:
{ {
std::memcpy(&data->value, &value, sizeof(T)); std::memcpy(&data->value, &value, sizeof(T));
list_add_tail(&data->siblings, it.fEntry->next); list_add_tail(&data->siblings, it.fEntry->next);
fCount++;
++fCount;
return true; return true;
} }


@@ -164,7 +164,7 @@ public:
{ {
std::memcpy(&data->value, &value, sizeof(T)); std::memcpy(&data->value, &value, sizeof(T));
list_add(&data->siblings, &fQueue); list_add(&data->siblings, &fQueue);
fCount++;
++fCount;
return true; return true;
} }


@@ -177,7 +177,7 @@ public:
{ {
std::memcpy(&data->value, &value, sizeof(T)); std::memcpy(&data->value, &value, sizeof(T));
list_add(&data->siblings, it.fEntry->prev); list_add(&data->siblings, it.fEntry->prev);
fCount++;
++fCount;
return true; return true;
} }


@@ -203,7 +203,7 @@ public:


if (remove) if (remove)
{ {
fCount--;
--fCount;
list_del(entry); list_del(entry);


if (data != nullptr) if (data != nullptr)
@@ -235,7 +235,7 @@ public:


if (it.fEntry != nullptr && it.fData != nullptr) if (it.fEntry != nullptr && it.fData != nullptr)
{ {
fCount--;
--fCount;
list_del(it.fEntry); list_del(it.fEntry);
_deallocate(it.fData); _deallocate(it.fData);
} }
@@ -255,7 +255,7 @@ public:


if (data != nullptr && data->value == value) if (data != nullptr && data->value == value)
{ {
fCount--;
--fCount;
list_del(entry); list_del(entry);
_deallocate(data); _deallocate(data);
break; break;
@@ -269,9 +269,9 @@ public:
{ {
Data* data; Data* data;
k_list_head* entry; k_list_head* entry;
k_list_head* tmp;
k_list_head* entry2;


list_for_each_safe(entry, tmp, &fQueue)
list_for_each_safe(entry, entry2, &fQueue)
{ {
data = list_entry(entry, Data, siblings); data = list_entry(entry, Data, siblings);


@@ -279,14 +279,14 @@ public:


if (data != nullptr && data->value == value) if (data != nullptr && data->value == value)
{ {
fCount--;
--fCount;
list_del(entry); list_del(entry);
_deallocate(data); _deallocate(data);
} }
} }
} }


virtual void spliceAppend(List& list, const bool init = false)
void spliceAppend(List& list, const bool init = false)
{ {
if (init) if (init)
{ {
@@ -301,7 +301,7 @@ public:
} }
} }


virtual void spliceInsert(List& list, const bool init = false)
void spliceInsert(List& list, const bool init = false)
{ {
if (init) if (init)
{ {
@@ -348,7 +348,7 @@ private:


if (data != nullptr && remove) if (data != nullptr && remove)
{ {
fCount--;
--fCount;
list_del(entry); list_del(entry);
_deallocate(data); _deallocate(data);
} }
@@ -358,7 +358,6 @@ private:


T& _getEmpty() T& _getEmpty()
{ {
// FIXME ?
static T value; static T value;
static bool reset = true; static bool reset = true;


@@ -391,14 +390,16 @@ public:
: fHandle(nullptr), : fHandle(nullptr),
kDataSize(sizeof(typename List<T>::Data)) kDataSize(sizeof(typename List<T>::Data))
{ {
rtsafe_memory_pool_create(&fHandle, nullptr, kDataSize, minPreallocated, maxPreallocated);
CARLA_ASSERT(fHandle != nullptr);
resize(minPreallocated, maxPreallocated);
} }


~Pool() ~Pool()
{ {
if (fHandle != nullptr) if (fHandle != nullptr)
{
rtsafe_memory_pool_destroy(fHandle); rtsafe_memory_pool_destroy(fHandle);
fHandle = nullptr;
}
} }


void* allocate_atomic() void* allocate_atomic()
@@ -418,8 +419,6 @@ public:


void resize(const size_t minPreallocated, const size_t maxPreallocated) void resize(const size_t minPreallocated, const size_t maxPreallocated)
{ {
CARLA_ASSERT(this->fCount == 0);

if (fHandle != nullptr) if (fHandle != nullptr)
{ {
rtsafe_memory_pool_destroy(fHandle); rtsafe_memory_pool_destroy(fHandle);
@@ -430,6 +429,16 @@ public:
CARLA_ASSERT(fHandle != nullptr); CARLA_ASSERT(fHandle != nullptr);
} }


bool operator==(const Pool& pool) const
{
return (fHandle == pool.fHandle && kDataSize == pool.kDataSize);
}

bool operator!=(const Pool& pool) const
{
return (fHandle != pool.fHandle || kDataSize != pool.kDataSize);
}

private: private:
RtMemPool_Handle fHandle; RtMemPool_Handle fHandle;
const size_t kDataSize; const size_t kDataSize;
@@ -438,10 +447,9 @@ public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Now the actual list code // Now the actual list code


RtList(Pool* const memPool)
: kMemPool(memPool)
RtList(Pool& memPool)
: fMemPool(memPool)
{ {
CARLA_ASSERT(kMemPool != nullptr);
} }


~RtList() override ~RtList() override
@@ -454,7 +462,7 @@ public:
{ {
std::memcpy(&data->value, &value, sizeof(T)); std::memcpy(&data->value, &value, sizeof(T));
list_add_tail(&data->siblings, &this->fQueue); list_add_tail(&data->siblings, &this->fQueue);
this->fCount++;
++this->fCount;
} }
} }


@@ -464,7 +472,7 @@ public:
{ {
std::memcpy(&data->value, &value, sizeof(T)); std::memcpy(&data->value, &value, sizeof(T));
list_add(&data->siblings, &this->fQueue); list_add(&data->siblings, &this->fQueue);
this->fCount++;
++this->fCount;
} }
} }


@@ -472,25 +480,25 @@ public:
{ {
this->clear(); this->clear();


kMemPool->resize(minPreallocated, maxPreallocated);
fMemPool.resize(minPreallocated, maxPreallocated);
} }


void spliceAppend(RtList& list, const bool init = false) void spliceAppend(RtList& list, const bool init = false)
{ {
CARLA_ASSERT(kMemPool == list.kMemPool);
CARLA_ASSERT(fMemPool == list.fMemPool);


List<T>::spliceAppend(list, init); List<T>::spliceAppend(list, init);
} }


void spliceInsert(RtList& list, const bool init = false) void spliceInsert(RtList& list, const bool init = false)
{ {
CARLA_ASSERT(kMemPool == list.kMemPool);
CARLA_ASSERT(fMemPool == list.fMemPool);


List<T>::spliceInsert(list, init); List<T>::spliceInsert(list, init);
} }


private: private:
Pool* const kMemPool;
Pool& fMemPool;


typename List<T>::Data* _allocate() override typename List<T>::Data* _allocate() override
{ {
@@ -499,17 +507,17 @@ private:


typename List<T>::Data* _allocate_atomic() typename List<T>::Data* _allocate_atomic()
{ {
return (typename List<T>::Data*)kMemPool->allocate_atomic();
return (typename List<T>::Data*)fMemPool.allocate_atomic();
} }


typename List<T>::Data* _allocate_sleepy() typename List<T>::Data* _allocate_sleepy()
{ {
return (typename List<T>::Data*)kMemPool->allocate_sleepy();
return (typename List<T>::Data*)fMemPool.allocate_sleepy();
} }


void _deallocate(typename List<T>::Data* const dataPtr) override void _deallocate(typename List<T>::Data* const dataPtr) override
{ {
kMemPool->deallocate(dataPtr);
fMemPool.deallocate(dataPtr);
} }


LIST_DECLARATIONS(RtList) LIST_DECLARATIONS(RtList)
@@ -526,7 +534,7 @@ public:
{ {
} }


~NonRtList()
~NonRtList() override
{ {
} }




Loading…
Cancel
Save