Browse Source

Continue cleanup

tags/1.9.4
falkTX 12 years ago
parent
commit
2716863000
14 changed files with 245 additions and 255 deletions
  1. +2
    -4
      source/includes/lv2_rdf.hpp
  2. +1
    -1
      source/modules/lilv/serd-0.18.2/serd/serd.h
  3. +1
    -1
      source/modules/lilv/sratom-0.4.2/sratom/sratom.h
  4. +5
    -5
      source/modules/utils/CarlaBackendUtils.hpp
  5. +34
    -0
      source/modules/utils/CarlaDssiUtils.hpp
  6. +2
    -0
      source/modules/utils/CarlaLadspaUtils.hpp
  7. +1
    -1
      source/modules/utils/CarlaLibUtils.hpp
  8. +3
    -1
      source/modules/utils/CarlaLogThread.hpp
  9. +144
    -139
      source/modules/utils/CarlaLv2Utils.hpp
  10. +4
    -3
      source/modules/utils/CarlaRingBuffer.hpp
  11. +13
    -37
      source/modules/utils/CarlaStateUtils.hpp
  12. +8
    -15
      source/modules/utils/CarlaString.hpp
  13. +8
    -8
      source/modules/utils/CarlaUtils.hpp
  14. +19
    -40
      source/modules/utils/Lv2AtomQueue.hpp

+ 2
- 4
source/includes/lv2_rdf.hpp View File

@@ -118,11 +118,10 @@ typedef uint32_t LV2_Property;
#define LV2_PORT_ATOM_SEQUENCE (0x040 | LV2_PORT_ATOM)
#define LV2_PORT_EVENT 0x080
#define LV2_PORT_MIDI_LL 0x100
#define LV2_PORT_OSC 0x200

// Port Data Types
#define LV2_PORT_DATA_MIDI_EVENT 0x1000
#define LV2_PORT_DATA_OSC 0x2000
#define LV2_PORT_DATA_OSC_EVENT 0x2000
#define LV2_PORT_DATA_PATCH_MESSAGE 0x4000
#define LV2_PORT_DATA_TIME_POSITION 0x8000

@@ -134,10 +133,9 @@ typedef uint32_t LV2_Property;
#define LV2_IS_PORT_ATOM_SEQUENCE(x) ((x) & LV2_PORT_ATOM_SEQUENCE)
#define LV2_IS_PORT_EVENT(x) ((x) & LV2_PORT_EVENT)
#define LV2_IS_PORT_MIDI_LL(x) ((x) & LV2_PORT_MIDI_LL)
#define LV2_IS_PORT_OSC(x) ((x) & LV2_PORT_OSC)

#define LV2_PORT_SUPPORTS_MIDI_EVENT(x) ((x) & LV2_PORT_DATA_MIDI_EVENT)
#define LV2_PORT_SUPPORTS_OSC(x) ((x) & LV2_PORT_DATA_OSC)
#define LV2_PORT_SUPPORTS_OSC_EVENT(x) ((x) & LV2_PORT_DATA_OSC_EVENT)
#define LV2_PORT_SUPPORTS_PATCH_MESSAGE(x) ((x) & LV2_PORT_DATA_PATCH_MESSAGE)
#define LV2_PORT_SUPPORTS_TIME_POSITION(x) ((x) & LV2_PORT_DATA_TIME_POSITION)



+ 1
- 1
source/modules/lilv/serd-0.18.2/serd/serd.h View File

@@ -183,7 +183,7 @@ typedef enum {
@see <a href="http://www.w3.org/TeamSubmission/turtle#nodeID">Turtle
<tt>nodeID</tt></a>
*/
SERD_BLANK = 4,
SERD_BLANK = 4

} SerdType;



+ 1
- 1
source/modules/lilv/sratom-0.4.2/sratom/sratom.h View File

@@ -83,7 +83,7 @@ typedef enum {
to sratom_read(); if this is a resource it will be read as an Object,
but all other named resources encountered will be read as URIs.
*/
SRATOM_OBJECT_MODE_BLANK_SUBJECT,
SRATOM_OBJECT_MODE_BLANK_SUBJECT
} SratomObjectMode;

/**


+ 5
- 5
source/modules/utils/CarlaBackendUtils.hpp View File

@@ -196,9 +196,9 @@ const char* InternalParametersIndex2Str(const InternalParametersIndex index)
}

static inline
const char* OptionsType2Str(const OptionsType type)
const char* OptionsType2Str(const OptionsType option)
{
switch (type)
switch (option)
{
case OPTION_PROCESS_NAME:
return "OPTION_PROCESS_NAME";
@@ -272,7 +272,7 @@ const char* OptionsType2Str(const OptionsType type)
#endif
}

carla_stderr("CarlaBackend::OptionsType2Str(%i) - invalid type", type);
carla_stderr("CarlaBackend::OptionsType2Str(%i) - invalid option", option);
return nullptr;
}

@@ -376,7 +376,7 @@ const char* ProcessMode2Str(const ProcessMode mode)
return "PROCESS_MODE_BRIDGE";
}

carla_stderr("CarlaBackend::ProcessMode2Str(%i) - invalid type", mode);
carla_stderr("CarlaBackend::ProcessMode2Str(%i) - invalid mode", mode);
return nullptr;
}

@@ -395,7 +395,7 @@ const char* TransportMode2Str(const TransportMode mode)
return "TRANSPORT_MODE_BRIDGE";
}

carla_stderr("CarlaBackend::TransportMode2Str(%i) - invalid type", mode);
carla_stderr("CarlaBackend::TransportMode2Str(%i) - invalid mode", mode);
return nullptr;
}



+ 34
- 0
source/modules/utils/CarlaDssiUtils.hpp View File

@@ -0,0 +1,34 @@
/*
* Carla DSSI utils
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef CARLA_DSSI_UTILS_HPP_INCLUDED
#define CARLA_DSSI_UTILS_HPP_INCLUDED

#include "CarlaUtils.hpp"

// -----------------------------------------------------------------------
// ...

static inline
bool func()
{
return false;
}

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

#endif // CARLA_DSSI_UTILS_HPP_INCLUDED

+ 2
- 0
source/modules/utils/CarlaLadspaUtils.hpp View File

@@ -90,6 +90,8 @@ const LADSPA_RDF_Descriptor* ladspa_rdf_dup(const LADSPA_RDF_Descriptor* const o
static inline
bool is_ladspa_port_good(const LADSPA_PortDescriptor port1, const LADSPA_PortDescriptor port2)
{
if (port1 == 0x0 || port2 == 0x0)
return false;
if (LADSPA_IS_PORT_INPUT(port1) && ! LADSPA_IS_PORT_INPUT(port2))
return false;
if (LADSPA_IS_PORT_OUTPUT(port1) && ! LADSPA_IS_PORT_OUTPUT(port2))


+ 1
- 1
source/modules/utils/CarlaLibUtils.hpp View File

@@ -71,7 +71,7 @@ const char* lib_error(const char* const filename)

#ifdef CARLA_OS_WIN
static char libError[2048+1];
carla_zeroChar(libError, 2048);
carla_zeroChar(libError, 2048+1);

LPVOID winErrorString;
DWORD winErrorCode = GetLastError();


+ 3
- 1
source/modules/utils/CarlaLogThread.hpp View File

@@ -12,7 +12,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the GPL.txt file
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef CARLA_LOG_THREAD_HPP_INCLUDED
@@ -135,6 +135,8 @@ private:
void* fCallbackPtr;
};

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

CARLA_BACKEND_END_NAMESPACE

#endif // CARLA_LOG_THREAD_HPP_INCLUDED

+ 144
- 139
source/modules/utils/CarlaLv2Utils.hpp View File

@@ -66,7 +66,6 @@
#include "lilv/lilvmm.hpp"
#include "sratom/sratom.h"

#include <QtCore/QMap>
#include <QtCore/QStringList>

// -----------------------------------------------------------------------
@@ -90,7 +89,7 @@
#define LV2_UI__idle LV2_UI_PREFIX "idle"
#define LV2_UI__makeResident LV2_UI_PREFIX "makeResident"

// -------------------------------------------------
// -----------------------------------------------------------------------
// Custom Atom types

struct LV2_Atom_MidiEvent {
@@ -98,7 +97,7 @@ struct LV2_Atom_MidiEvent {
uint8_t data[4];
};

// -------------------------------------------------
// -----------------------------------------------------------------------
// Our LV2 World class

class Lv2WorldClass : public Lilv::World
@@ -224,7 +223,7 @@ public:
Lilv::Node rdf_type;
Lilv::Node rdfs_label;

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

Lv2WorldClass()
: Lilv::World(),
@@ -350,6 +349,12 @@ public:
Lilv::World::load_all();
}

static Lv2WorldClass& getInstance()
{
static Lv2WorldClass lv2World;
return lv2World;
}

const LilvPlugin* getPlugin(const LV2_URI uri)
{
CARLA_SAFE_ASSERT_RETURN(uri != nullptr, nullptr);
@@ -405,15 +410,11 @@ public:
private:
bool fNeedsInit;

CARLA_PREVENT_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Lv2WorldClass)
};

// -----------------------------------------------------
// Our LV2 World class object

extern Lv2WorldClass gLv2World;

// -----------------------------------------------------
// -----------------------------------------------------------------------
// Create new RDF object (using lilv)

static inline
@@ -421,7 +422,9 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
{
CARLA_SAFE_ASSERT_RETURN(uri != nullptr, nullptr);

const LilvPlugin* const cPlugin(gLv2World.getPlugin(uri));
Lv2WorldClass& lv2World(Lv2WorldClass::getInstance());

const LilvPlugin* const cPlugin(lv2World.getPlugin(uri));

if (cPlugin == nullptr)
{
@@ -432,91 +435,91 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
Lilv::Plugin lilvPlugin(cPlugin);
LV2_RDF_Descriptor* const rdfDescriptor(new LV2_RDF_Descriptor());

// --------------------------------------------------
// -------------------------------------------------------------------
// Set Plugin Type
{
Lilv::Nodes typeNodes(lilvPlugin.get_value(gLv2World.rdf_type));
Lilv::Nodes typeNodes(lilvPlugin.get_value(lv2World.rdf_type));

if (typeNodes.size() > 0)
{
if (typeNodes.contains(gLv2World.class_allpass))
if (typeNodes.contains(lv2World.class_allpass))
rdfDescriptor->Type[0] |= LV2_PLUGIN_ALLPASS;
if (typeNodes.contains(gLv2World.class_amplifier))
if (typeNodes.contains(lv2World.class_amplifier))
rdfDescriptor->Type[0] |= LV2_PLUGIN_AMPLIFIER;
if (typeNodes.contains(gLv2World.class_analyzer))
if (typeNodes.contains(lv2World.class_analyzer))
rdfDescriptor->Type[1] |= LV2_PLUGIN_ANALYSER;
if (typeNodes.contains(gLv2World.class_bandpass))
if (typeNodes.contains(lv2World.class_bandpass))
rdfDescriptor->Type[0] |= LV2_PLUGIN_BANDPASS;
if (typeNodes.contains(gLv2World.class_chorus))
if (typeNodes.contains(lv2World.class_chorus))
rdfDescriptor->Type[1] |= LV2_PLUGIN_CHORUS;
if (typeNodes.contains(gLv2World.class_comb))
if (typeNodes.contains(lv2World.class_comb))
rdfDescriptor->Type[1] |= LV2_PLUGIN_COMB;
if (typeNodes.contains(gLv2World.class_compressor))
if (typeNodes.contains(lv2World.class_compressor))
rdfDescriptor->Type[0] |= LV2_PLUGIN_COMPRESSOR;
if (typeNodes.contains(gLv2World.class_constant))
if (typeNodes.contains(lv2World.class_constant))
rdfDescriptor->Type[1] |= LV2_PLUGIN_CONSTANT;
if (typeNodes.contains(gLv2World.class_converter))
if (typeNodes.contains(lv2World.class_converter))
rdfDescriptor->Type[1] |= LV2_PLUGIN_CONVERTER;
if (typeNodes.contains(gLv2World.class_delay))
if (typeNodes.contains(lv2World.class_delay))
rdfDescriptor->Type[0] |= LV2_PLUGIN_DELAY;
if (typeNodes.contains(gLv2World.class_distortion))
if (typeNodes.contains(lv2World.class_distortion))
rdfDescriptor->Type[0] |= LV2_PLUGIN_DISTORTION;
if (typeNodes.contains(gLv2World.class_dynamics))
if (typeNodes.contains(lv2World.class_dynamics))
rdfDescriptor->Type[0] |= LV2_PLUGIN_DYNAMICS;
if (typeNodes.contains(gLv2World.class_eq))
if (typeNodes.contains(lv2World.class_eq))
rdfDescriptor->Type[0] |= LV2_PLUGIN_EQ;
if (typeNodes.contains(gLv2World.class_envelope))
if (typeNodes.contains(lv2World.class_envelope))
rdfDescriptor->Type[0] |= LV2_PLUGIN_ENVELOPE;
if (typeNodes.contains(gLv2World.class_expander))
if (typeNodes.contains(lv2World.class_expander))
rdfDescriptor->Type[0] |= LV2_PLUGIN_EXPANDER;
if (typeNodes.contains(gLv2World.class_filter))
if (typeNodes.contains(lv2World.class_filter))
rdfDescriptor->Type[0] |= LV2_PLUGIN_FILTER;
if (typeNodes.contains(gLv2World.class_flanger))
if (typeNodes.contains(lv2World.class_flanger))
rdfDescriptor->Type[1] |= LV2_PLUGIN_FLANGER;
if (typeNodes.contains(gLv2World.class_function))
if (typeNodes.contains(lv2World.class_function))
rdfDescriptor->Type[1] |= LV2_PLUGIN_FUNCTION;
if (typeNodes.contains(gLv2World.class_gate))
if (typeNodes.contains(lv2World.class_gate))
rdfDescriptor->Type[0] |= LV2_PLUGIN_GATE;
if (typeNodes.contains(gLv2World.class_generator))
if (typeNodes.contains(lv2World.class_generator))
rdfDescriptor->Type[1] |= LV2_PLUGIN_GENERATOR;
if (typeNodes.contains(gLv2World.class_highpass))
if (typeNodes.contains(lv2World.class_highpass))
rdfDescriptor->Type[0] |= LV2_PLUGIN_HIGHPASS;
if (typeNodes.contains(gLv2World.class_instrument))
if (typeNodes.contains(lv2World.class_instrument))
rdfDescriptor->Type[1] |= LV2_PLUGIN_INSTRUMENT;
if (typeNodes.contains(gLv2World.class_limiter))
if (typeNodes.contains(lv2World.class_limiter))
rdfDescriptor->Type[0] |= LV2_PLUGIN_LIMITER;
if (typeNodes.contains(gLv2World.class_lowpass))
if (typeNodes.contains(lv2World.class_lowpass))
rdfDescriptor->Type[0] |= LV2_PLUGIN_LOWPASS;
if (typeNodes.contains(gLv2World.class_mixer))
if (typeNodes.contains(lv2World.class_mixer))
rdfDescriptor->Type[1] |= LV2_PLUGIN_MIXER;
if (typeNodes.contains(gLv2World.class_modulator))
if (typeNodes.contains(lv2World.class_modulator))
rdfDescriptor->Type[1] |= LV2_PLUGIN_MODULATOR;
if (typeNodes.contains(gLv2World.class_multiEQ))
if (typeNodes.contains(lv2World.class_multiEQ))
rdfDescriptor->Type[0] |= LV2_PLUGIN_MULTI_EQ;
if (typeNodes.contains(gLv2World.class_oscillator))
if (typeNodes.contains(lv2World.class_oscillator))
rdfDescriptor->Type[1] |= LV2_PLUGIN_OSCILLATOR;
if (typeNodes.contains(gLv2World.class_paraEQ))
if (typeNodes.contains(lv2World.class_paraEQ))
rdfDescriptor->Type[0] |= LV2_PLUGIN_PARA_EQ;
if (typeNodes.contains(gLv2World.class_phaser))
if (typeNodes.contains(lv2World.class_phaser))
rdfDescriptor->Type[1] |= LV2_PLUGIN_PHASER;
if (typeNodes.contains(gLv2World.class_pitch))
if (typeNodes.contains(lv2World.class_pitch))
rdfDescriptor->Type[1] |= LV2_PLUGIN_PITCH;
if (typeNodes.contains(gLv2World.class_reverb))
if (typeNodes.contains(lv2World.class_reverb))
rdfDescriptor->Type[0] |= LV2_PLUGIN_REVERB;
if (typeNodes.contains(gLv2World.class_simulator))
if (typeNodes.contains(lv2World.class_simulator))
rdfDescriptor->Type[0] |= LV2_PLUGIN_SIMULATOR;
if (typeNodes.contains(gLv2World.class_spatial))
if (typeNodes.contains(lv2World.class_spatial))
rdfDescriptor->Type[1] |= LV2_PLUGIN_SPATIAL;
if (typeNodes.contains(gLv2World.class_spectral))
if (typeNodes.contains(lv2World.class_spectral))
rdfDescriptor->Type[1] |= LV2_PLUGIN_SPECTRAL;
if (typeNodes.contains(gLv2World.class_utility))
if (typeNodes.contains(lv2World.class_utility))
rdfDescriptor->Type[1] |= LV2_PLUGIN_UTILITY;
if (typeNodes.contains(gLv2World.class_waveshaper))
if (typeNodes.contains(lv2World.class_waveshaper))
rdfDescriptor->Type[0] |= LV2_PLUGIN_WAVESHAPER;
}
}

// --------------------------------------------------
// -------------------------------------------------------------------
// Set Plugin Information
{
rdfDescriptor->URI = carla_strdup(uri);
@@ -533,7 +536,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
if (const char* const bundle = lilvPlugin.get_bundle_uri().as_string())
rdfDescriptor->Bundle = carla_strdup(lilv_uri_to_path(bundle));

Lilv::Nodes licenseNodes(lilvPlugin.get_value(gLv2World.doap_license));
Lilv::Nodes licenseNodes(lilvPlugin.get_value(lv2World.doap_license));

if (licenseNodes.size() > 0)
{
@@ -542,10 +545,10 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

// --------------------------------------------------
// -------------------------------------------------------------------
// Set Plugin UniqueID
{
Lilv::Nodes replaceNodes(lilvPlugin.get_value(gLv2World.dct_replaces));
Lilv::Nodes replaceNodes(lilvPlugin.get_value(lv2World.dct_replaces));

if (replaceNodes.size() > 0)
{
@@ -569,7 +572,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

// --------------------------------------------------
// -------------------------------------------------------------------
// Set Plugin Ports

if (lilvPlugin.get_num_ports() > 0)
@@ -582,7 +585,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
Lilv::Port lilvPort(lilvPlugin.get_port_by_index(j));
LV2_RDF_Port* const rdfPort(&rdfDescriptor->Ports[j]);

// --------------------------------------
// -----------------------------------------------------------
// Set Port Information
{
if (const char* const name = Lilv::Node(lilvPort.get_name()).as_string())
@@ -592,55 +595,55 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
rdfPort->Symbol = carla_strdup(symbol);
}

// --------------------------------------
// -----------------------------------------------------------
// Set Port Mode and Type
{
// Input or Output
if (lilvPort.is_a(gLv2World.port_input))
if (lilvPort.is_a(lv2World.port_input))
rdfPort->Types |= LV2_PORT_INPUT;
else if (lilvPort.is_a(gLv2World.port_output))
else if (lilvPort.is_a(lv2World.port_output))
rdfPort->Types |= LV2_PORT_OUTPUT;
else
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is not input or output", uri, rdfPort->Name);

// Data Type
if (lilvPort.is_a(gLv2World.port_control))
if (lilvPort.is_a(lv2World.port_control))
{
rdfPort->Types |= LV2_PORT_CONTROL;
}
else if (lilvPort.is_a(gLv2World.port_audio))
else if (lilvPort.is_a(lv2World.port_audio))
{
rdfPort->Types |= LV2_PORT_AUDIO;
}
else if (lilvPort.is_a(gLv2World.port_cv))
else if (lilvPort.is_a(lv2World.port_cv))
{
rdfPort->Types |= LV2_PORT_CV;
}
else if (lilvPort.is_a(gLv2World.port_atom))
else if (lilvPort.is_a(lv2World.port_atom))
{
rdfPort->Types |= LV2_PORT_ATOM;

Lilv::Nodes bufferTypeNodes(lilvPort.get_value(gLv2World.atom_bufferType));
Lilv::Nodes bufferTypeNodes(lilvPort.get_value(lv2World.atom_bufferType));

if (bufferTypeNodes.contains(gLv2World.atom_sequence))
if (bufferTypeNodes.contains(lv2World.atom_sequence))
rdfPort->Types |= LV2_PORT_ATOM_SEQUENCE;
else
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' uses an unknown atom buffer type", uri, rdfPort->Name);

Lilv::Nodes supportNodes(lilvPort.get_value(gLv2World.atom_supports));
Lilv::Nodes supportNodes(lilvPort.get_value(lv2World.atom_supports));
bool supported = false;

if (supportNodes.contains(gLv2World.midi_event))
if (supportNodes.contains(lv2World.midi_event))
{
rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT;
supported = true;
}
if (supportNodes.contains(gLv2World.patch_message))
if (supportNodes.contains(lv2World.patch_message))
{
rdfPort->Types |= LV2_PORT_DATA_PATCH_MESSAGE;
supported = true;
}
if (supportNodes.contains(gLv2World.time_position))
if (supportNodes.contains(lv2World.time_position))
{
rdfPort->Types |= LV2_PORT_DATA_TIME_POSITION;
supported = true;
@@ -649,22 +652,22 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
if (! supported)
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(lv2World.port_event))
{
rdfPort->Types |= LV2_PORT_EVENT;
bool supported = false;

if (lilvPort.supports_event(gLv2World.midi_event))
if (lilvPort.supports_event(lv2World.midi_event))
{
rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT;
supported = true;
}
if (lilvPort.supports_event(gLv2World.patch_message))
if (lilvPort.supports_event(lv2World.patch_message))
{
rdfPort->Types |= LV2_PORT_DATA_PATCH_MESSAGE;
supported = true;
}
if (lilvPort.supports_event(gLv2World.time_position))
if (lilvPort.supports_event(lv2World.time_position))
{
rdfPort->Types |= LV2_PORT_DATA_TIME_POSITION;
supported = true;
@@ -673,7 +676,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
if (! supported)
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(lv2World.port_midi))
{
rdfPort->Types |= LV2_PORT_MIDI_LL;
rdfPort->Types |= LV2_PORT_DATA_MIDI_EVENT;
@@ -682,54 +685,54 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
carla_stderr("lv2_rdf_new(\"%s\") - port '%s' is of unkown data type", uri, rdfPort->Name);
}

// --------------------------------------
// -----------------------------------------------------------
// Set Port Properties
{
if (lilvPort.has_property(gLv2World.pprop_optional))
if (lilvPort.has_property(lv2World.pprop_optional))
rdfPort->Properties |= LV2_PORT_OPTIONAL;
if (lilvPort.has_property(gLv2World.pprop_enumeration))
if (lilvPort.has_property(lv2World.pprop_enumeration))
rdfPort->Properties |= LV2_PORT_ENUMERATION;
if (lilvPort.has_property(gLv2World.pprop_integer))
if (lilvPort.has_property(lv2World.pprop_integer))
rdfPort->Properties |= LV2_PORT_INTEGER;
if (lilvPort.has_property(gLv2World.pprop_sampleRate))
if (lilvPort.has_property(lv2World.pprop_sampleRate))
rdfPort->Properties |= LV2_PORT_SAMPLE_RATE;
if (lilvPort.has_property(gLv2World.pprop_toggled))
if (lilvPort.has_property(lv2World.pprop_toggled))
rdfPort->Properties |= LV2_PORT_TOGGLED;

if (lilvPort.has_property(gLv2World.pprop_artifacts))
if (lilvPort.has_property(lv2World.pprop_artifacts))
rdfPort->Properties |= LV2_PORT_CAUSES_ARTIFACTS;
if (lilvPort.has_property(gLv2World.pprop_continuousCV))
if (lilvPort.has_property(lv2World.pprop_continuousCV))
rdfPort->Properties |= LV2_PORT_CONTINUOUS_CV;
if (lilvPort.has_property(gLv2World.pprop_discreteCV))
if (lilvPort.has_property(lv2World.pprop_discreteCV))
rdfPort->Properties |= LV2_PORT_DISCRETE_CV;
if (lilvPort.has_property(gLv2World.pprop_expensive))
if (lilvPort.has_property(lv2World.pprop_expensive))
rdfPort->Properties |= LV2_PORT_EXPENSIVE;
if (lilvPort.has_property(gLv2World.pprop_strictBounds))
if (lilvPort.has_property(lv2World.pprop_strictBounds))
rdfPort->Properties |= LV2_PORT_STRICT_BOUNDS;
if (lilvPort.has_property(gLv2World.pprop_logarithmic))
if (lilvPort.has_property(lv2World.pprop_logarithmic))
rdfPort->Properties |= LV2_PORT_LOGARITHMIC;
if (lilvPort.has_property(gLv2World.pprop_notAutomatic))
if (lilvPort.has_property(lv2World.pprop_notAutomatic))
rdfPort->Properties |= LV2_PORT_NOT_AUTOMATIC;
if (lilvPort.has_property(gLv2World.pprop_notOnGUI))
if (lilvPort.has_property(lv2World.pprop_notOnGUI))
rdfPort->Properties |= LV2_PORT_NOT_ON_GUI;
if (lilvPort.has_property(gLv2World.pprop_trigger))
if (lilvPort.has_property(lv2World.pprop_trigger))
rdfPort->Properties |= LV2_PORT_TRIGGER;

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

// no port properties set, check if using old/invalid 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"));
static const Lilv::Node oldPropArtifacts(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#causesArtifacts"));
static const Lilv::Node oldPropContinuousCV(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#continuousCV"));
static const Lilv::Node oldPropDiscreteCV(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#discreteCV"));
static const Lilv::Node oldPropExpensive(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#expensive"));
static const Lilv::Node oldPropStrictBounds(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#hasStrictBounds"));
static const Lilv::Node oldPropLogarithmic(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#logarithmic"));
static const Lilv::Node oldPropNotAutomatic(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#notAutomatic"));
static const Lilv::Node oldPropNotOnGUI(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#notOnGUI"));
static const Lilv::Node oldPropTrigger(lv2World.new_uri("http://lv2plug.in/ns/dev/extportinfo#trigger"));

if (lilvPort.has_property(oldPropArtifacts))
{
@@ -779,10 +782,10 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

// --------------------------------------
// -----------------------------------------------------------
// Set Port Designation
{
Lilv::Nodes designationNodes(lilvPort.get_value(gLv2World.designation));
Lilv::Nodes designationNodes(lilvPort.get_value(lv2World.designation));

if (designationNodes.size() > 0)
{
@@ -824,10 +827,10 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

// --------------------------------------
// -----------------------------------------------------------
// Set Port MIDI Map
{
Lilv::Nodes midiMapNodes(lilvPort.get_value(gLv2World.mm_defaultControl));
Lilv::Nodes midiMapNodes(lilvPort.get_value(lv2World.mm_defaultControl));

if (midiMapNodes.size() > 0)
{
@@ -835,8 +838,8 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)

if (midiMapNode.is_blank())
{
Lilv::Nodes midiMapTypeNodes(gLv2World.find_nodes(midiMapNode, gLv2World.mm_controlType, nullptr));
Lilv::Nodes midiMapNumberNodes(gLv2World.find_nodes(midiMapNode, gLv2World.mm_controlNumber, nullptr));
Lilv::Nodes midiMapTypeNodes(lv2World.find_nodes(midiMapNode, lv2World.mm_controlType, nullptr));
Lilv::Nodes midiMapNumberNodes(lv2World.find_nodes(midiMapNode, lv2World.mm_controlNumber, nullptr));

if (midiMapTypeNodes.size() == 1 && midiMapNumberNodes.size() == 1)
{
@@ -858,10 +861,10 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
// TODO - also check using new official MIDI API too
}

// --------------------------------------
// -----------------------------------------------------------
// Set Port Points
{
Lilv::Nodes valueNodes(lilvPort.get_value(gLv2World.value_default));
Lilv::Nodes valueNodes(lilvPort.get_value(lv2World.value_default));

if (valueNodes.size() > 0)
{
@@ -869,7 +872,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
rdfPort->Points.Default = valueNodes.get_first().as_float();
}

valueNodes = lilvPort.get_value(gLv2World.value_minimum);
valueNodes = lilvPort.get_value(lv2World.value_minimum);

if (valueNodes.size() > 0)
{
@@ -877,7 +880,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
rdfPort->Points.Minimum = valueNodes.get_first().as_float();
}

valueNodes = lilvPort.get_value(gLv2World.value_maximum);
valueNodes = lilvPort.get_value(lv2World.value_maximum);

if (valueNodes.size() > 0)
{
@@ -886,10 +889,10 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

// --------------------------------------
// -----------------------------------------------------------
// Set Port Unit
{
Lilv::Nodes unitUnitNodes(lilvPort.get_value(gLv2World.unit_unit));
Lilv::Nodes unitUnitNodes(lilvPort.get_value(lv2World.unit_unit));

if (unitUnitNodes.size() > 0)
{
@@ -950,7 +953,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

Lilv::Nodes unitNameNodes(lilvPort.get_value(gLv2World.unit_name));
Lilv::Nodes unitNameNodes(lilvPort.get_value(lv2World.unit_name));

if (unitNameNodes.size() > 0)
{
@@ -961,7 +964,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

Lilv::Nodes unitRenderNodes(lilvPort.get_value(gLv2World.unit_render));
Lilv::Nodes unitRenderNodes(lilvPort.get_value(lv2World.unit_render));

if (unitRenderNodes.size() > 0)
{
@@ -972,7 +975,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

Lilv::Nodes unitSymbolNodes(lilvPort.get_value(gLv2World.unit_symbol));
Lilv::Nodes unitSymbolNodes(lilvPort.get_value(lv2World.unit_symbol));

if (unitSymbolNodes.size() > 0)
{
@@ -984,7 +987,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

// --------------------------------------
// -----------------------------------------------------------
// Set Port Scale Points

Lilv::ScalePoints lilvScalePoints(lilvPort.get_scale_points());
@@ -1011,12 +1014,12 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

// --------------------------------------------------
// -------------------------------------------------------------------
// Set Plugin Presets

if (fillPresets)
{
Lilv::Nodes presetNodes(lilvPlugin.get_related(gLv2World.preset_preset));
Lilv::Nodes presetNodes(lilvPlugin.get_related(lv2World.preset_preset));

if (presetNodes.size() > 0)
{
@@ -1045,7 +1048,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
{
Lilv::Node presetNode(presetNodes.get(j));

if (gLv2World.load_resource(presetNode) == -1)
if (lv2World.load_resource(presetNode) == -1)
continue;

if (const char* const presetURI = presetNode.as_uri())
@@ -1059,12 +1062,12 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)

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

// --------------------------------------
// ---------------------------------------------------
// Set Preset Information
{
rdfPreset->URI = carla_strdup(presetURI);

Lilv::Nodes presetLabelNodes(gLv2World.find_nodes(presetNode, gLv2World.rdfs_label, nullptr));
Lilv::Nodes presetLabelNodes(lv2World.find_nodes(presetNode, lv2World.rdfs_label, nullptr));

if (presetLabelNodes.size() > 0)
{
@@ -1077,7 +1080,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

// --------------------------------------------------
// -------------------------------------------------------------------
// Set Plugin Features
{
Lilv::Nodes lilvFeatureNodes(lilvPlugin.get_supported_features());
@@ -1105,7 +1108,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

// --------------------------------------------------
// -------------------------------------------------------------------
// Set Plugin Extensions
{
Lilv::Nodes lilvExtensionDataNodes(lilvPlugin.get_extension_data());
@@ -1129,7 +1132,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

// --------------------------------------------------
// -------------------------------------------------------------------
// Set Plugin UIs
{
Lilv::UIs lilvUIs(lilvPlugin.get_uis());
@@ -1147,31 +1150,31 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
Lilv::UI lilvUI(lilvUIs.get(j));
LV2_RDF_UI* const rdfUI(&rdfDescriptor->UIs[h++]);

// --------------------------------------
// -------------------------------------------------------
// Set UI Type

if (lilvUI.is_a(gLv2World.ui_gtk2))
if (lilvUI.is_a(lv2World.ui_gtk2))
rdfUI->Type = LV2_UI_GTK2;
else if (lilvUI.is_a(gLv2World.ui_gtk3))
else if (lilvUI.is_a(lv2World.ui_gtk3))
rdfUI->Type = LV2_UI_GTK3;
else if (lilvUI.is_a(gLv2World.ui_qt4))
else if (lilvUI.is_a(lv2World.ui_qt4))
rdfUI->Type = LV2_UI_QT4;
else if (lilvUI.is_a(gLv2World.ui_qt5))
else if (lilvUI.is_a(lv2World.ui_qt5))
rdfUI->Type = LV2_UI_QT5;
else if (lilvUI.is_a(gLv2World.ui_cocoa))
else if (lilvUI.is_a(lv2World.ui_cocoa))
rdfUI->Type = LV2_UI_COCOA;
else if (lilvUI.is_a(gLv2World.ui_windows))
else if (lilvUI.is_a(lv2World.ui_windows))
rdfUI->Type = LV2_UI_WINDOWS;
else if (lilvUI.is_a(gLv2World.ui_x11))
else if (lilvUI.is_a(lv2World.ui_x11))
rdfUI->Type = LV2_UI_X11;
else if (lilvUI.is_a(gLv2World.ui_external))
else if (lilvUI.is_a(lv2World.ui_external))
rdfUI->Type = LV2_UI_EXTERNAL;
else if (lilvUI.is_a(gLv2World.ui_externalOld))
else if (lilvUI.is_a(lv2World.ui_externalOld))
rdfUI->Type = LV2_UI_OLD_EXTERNAL;
else
carla_stderr("lv2_rdf_new(\"%s\") - UI '%s' is of unknown type", uri, lilvUI.get_uri().as_uri());

// --------------------------------------
// -------------------------------------------------------
// Set UI Information
{
if (const char* const uiURI = lilvUI.get_uri().as_uri())
@@ -1184,7 +1187,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
rdfUI->Bundle = carla_strdup(lilv_uri_to_path(uiBundle));
}

// --------------------------------------
// -------------------------------------------------------
// Set UI Features
{
Lilv::Nodes lilvFeatureNodes(lilvUI.get_supported_features());
@@ -1212,7 +1215,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
}
}

// --------------------------------------
// -------------------------------------------------------
// Set UI Extensions
{
Lilv::Nodes lilvExtensionDataNodes(lilvUI.get_extension_data());
@@ -1242,7 +1245,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
return rdfDescriptor;
}

// -------------------------------------------------
// -----------------------------------------------------------------------
// Check if we support a plugin port

static inline
@@ -1263,7 +1266,7 @@ bool is_lv2_port_supported(const LV2_Property types)
return false;
}

// -------------------------------------------------
// -----------------------------------------------------------------------
// Check if we support a plugin feature

static inline
@@ -1318,7 +1321,7 @@ bool is_lv2_feature_supported(const LV2_URI uri)
return false;
}

// -------------------------------------------------
// -----------------------------------------------------------------------
// Check if we support a plugin or UI feature

static inline
@@ -1359,4 +1362,6 @@ bool is_lv2_ui_feature_supported(const LV2_URI uri)
return false;
}

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

#endif // CARLA_LV2_UTILS_HPP_INCLUDED

+ 4
- 3
source/modules/utils/CarlaRingBuffer.hpp View File

@@ -150,9 +150,7 @@ public:

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

private:
RingBuffer* fRingBuf;

protected:
void tryRead(void* const buf, const size_t size)
{
CARLA_SAFE_ASSERT_RETURN(fRingBuf != nullptr,);
@@ -238,6 +236,9 @@ private:
fRingBuf->written = static_cast<int32_t>(writeto);
}

private:
RingBuffer* fRingBuf;

CARLA_PREVENT_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(RingBufferControl)
};


+ 13
- 37
source/modules/utils/CarlaStateUtils.hpp View File

@@ -265,18 +265,14 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
if (xmlNode.isNull())
return;

QDomNode node(xmlNode.firstChild());

while (! node.isNull())
for (QDomNode node = xmlNode.firstChild(); ! node.isNull(); node = node.nextSibling())
{
// ---------------------------------------------------------------
// Info

if (node.toElement().tagName().compare("Info", Qt::CaseInsensitive) == 0)
{
QDomNode xmlInfo(node.toElement().firstChild());

while (! xmlInfo.isNull())
for (QDomNode xmlInfo = node.toElement().firstChild(); ! xmlInfo.isNull(); xmlInfo = xmlInfo.nextSibling())
{
const QString tag(xmlInfo.toElement().tagName());
const QString text(xmlInfo.toElement().text().trimmed());
@@ -295,8 +291,6 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
const long uniqueID(text.toLong(&ok));
if (ok) saveState.uniqueID = uniqueID;
}

xmlInfo = xmlInfo.nextSibling();
}
}

@@ -305,9 +299,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)

else if (node.toElement().tagName().compare("Data", Qt::CaseInsensitive) == 0)
{
QDomNode xmlData(node.toElement().firstChild());

while (! xmlData.isNull())
for (QDomNode xmlData = node.toElement().firstChild(); ! xmlData.isNull(); xmlData = xmlData.nextSibling())
{
const QString tag(xmlData.toElement().tagName());
const QString text(xmlData.toElement().text().trimmed());
@@ -323,37 +315,37 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
{
bool ok;
const float value(text.toFloat(&ok));
if (ok) saveState.dryWet = value;
if (ok) saveState.dryWet = carla_fixValue(0.0f, 1.0f, value);
}
else if (tag.compare("Volume", Qt::CaseInsensitive) == 0)
{
bool ok;
const float value(text.toFloat(&ok));
if (ok) saveState.volume = value;
if (ok) saveState.volume = carla_fixValue(0.0f, 1.27f, value);
}
else if (tag.compare("Balance-Left", Qt::CaseInsensitive) == 0)
{
bool ok;
const float value(text.toFloat(&ok));
if (ok) saveState.balanceLeft = value;
if (ok) saveState.balanceLeft = carla_fixValue(-1.0f, 1.0f, value);
}
else if (tag.compare("Balance-Right", Qt::CaseInsensitive) == 0)
{
bool ok;
const float value(text.toFloat(&ok));
if (ok) saveState.balanceRight = value;
if (ok) saveState.balanceRight = carla_fixValue(-1.0f, 1.0f, value);
}
else if (tag.compare("Panning", Qt::CaseInsensitive) == 0)
{
bool ok;
const float value(text.toFloat(&ok));
if (ok) saveState.panning = value;
if (ok) saveState.panning = carla_fixValue(-1.0f, 1.0f, value);
}
else if (tag.compare("ControlChannel", Qt::CaseInsensitive) == 0)
{
bool ok;
const short value(text.toShort(&ok));
if (ok && value >= 1 && value < INT8_MAX)
if (ok && value >= 1 && value <= MAX_MIDI_CHANNELS)
saveState.ctrlChannel = static_cast<int8_t>(value-1);
}

@@ -397,9 +389,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
{
StateParameter* const stateParameter(new StateParameter());

QDomNode xmlSubData(xmlData.toElement().firstChild());

while (! xmlSubData.isNull())
for (QDomNode xmlSubData = xmlData.toElement().firstChild(); ! xmlSubData.isNull(); xmlSubData = xmlSubData.nextSibling())
{
const QString pTag(xmlSubData.toElement().tagName());
const QString pText(xmlSubData.toElement().text().trimmed());
@@ -428,18 +418,16 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
{
bool ok;
const ushort channel(pText.toUShort(&ok));
if (ok && channel >= 1 && channel < MAX_MIDI_CHANNELS)
if (ok && channel >= 1 && channel <= MAX_MIDI_CHANNELS)
stateParameter->midiChannel = static_cast<uint8_t>(channel-1);
}
else if (pTag.compare("MidiCC", Qt::CaseInsensitive) == 0)
{
bool ok;
const int cc(pText.toInt(&ok));
if (ok && cc >= 1 && cc < INT16_MAX)
if (ok && cc >= 1 && cc < 0x5F)
stateParameter->midiCC = static_cast<int16_t>(cc);
}

xmlSubData = xmlSubData.nextSibling();
}

saveState.parameters.append(stateParameter);
@@ -452,9 +440,7 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
{
StateCustomData* const stateCustomData(new StateCustomData());

QDomNode xmlSubData(xmlData.toElement().firstChild());

while (! xmlSubData.isNull())
for (QDomNode xmlSubData = xmlData.toElement().firstChild(); ! xmlSubData.isNull(); xmlSubData = xmlSubData.nextSibling())
{
const QString cTag(xmlSubData.toElement().tagName());
const QString cText(xmlSubData.toElement().text().trimmed());
@@ -465,8 +451,6 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
stateCustomData->key = xmlSafeStringCharDup(cText, false);
else if (cTag.compare("Value", Qt::CaseInsensitive) == 0)
stateCustomData->value = xmlSafeStringCharDup(cText, false);

xmlSubData = xmlSubData.nextSibling();
}

saveState.customData.append(stateCustomData);
@@ -479,16 +463,8 @@ void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
{
saveState.chunk = xmlSafeStringCharDup(text, false);
}

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

xmlData = xmlData.nextSibling();
}
}

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

node = node.nextSibling();
}
}



+ 8
- 15
source/modules/utils/CarlaString.hpp View File

@@ -121,7 +121,7 @@ public:

~CarlaString()
{
CARLA_ASSERT(fBuffer != nullptr);
CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr,)

delete[] fBuffer;
fBuffer = nullptr;
@@ -148,8 +148,7 @@ public:
#ifdef __USE_GNU
bool contains(const char* const strBuf, const bool ignoreCase = false) const
{
if (strBuf == nullptr)
return false;
CARLA_SAFE_ASSERT_RETURN(strBuf != nullptr, false)

if (ignoreCase)
return (strcasestr(fBuffer, strBuf) != nullptr);
@@ -164,8 +163,7 @@ public:
#else
bool contains(const char* const strBuf) const
{
if (strBuf == nullptr)
return false;
CARLA_SAFE_ASSERT_RETURN(strBuf != nullptr, false)

return (std::strstr(fBuffer, strBuf) != nullptr);
}
@@ -178,16 +176,14 @@ public:

bool isDigit(const size_t pos) const noexcept
{
if (pos >= fBufferLen)
return false;
CARLA_SAFE_ASSERT_RETURN(pos < fBufferLen, false)

return (fBuffer[pos] >= '0' && fBuffer[pos] <= '9');
}

bool startsWith(const char* const prefix) const
{
if (prefix == nullptr)
return false;
CARLA_SAFE_ASSERT_RETURN(prefix != nullptr, false)

const size_t prefixLen(std::strlen(prefix));

@@ -199,8 +195,7 @@ public:

bool endsWith(const char* const suffix) const
{
if (suffix == nullptr)
return false;
CARLA_SAFE_ASSERT_RETURN(suffix != nullptr, false)

const size_t suffixLen(std::strlen(suffix));

@@ -239,8 +234,7 @@ public:

size_t rfind(const char* const strBuf) const
{
if (strBuf == nullptr || strBuf[0] == '\0')
return fBufferLen;
CARLA_SAFE_ASSERT_RETURN(strBuf != nullptr && strBuf[0] != '\0', fBufferLen)

size_t ret = fBufferLen+1;
const char* tmpBuf = fBuffer;
@@ -259,8 +253,7 @@ public:

void replace(const char before, const char after) noexcept
{
if (after == '\0')
return;
CARLA_SAFE_ASSERT_RETURN(before != '\0' && after != '\0',)

for (size_t i=0; i < fBufferLen; ++i)
{


+ 8
- 8
source/modules/utils/CarlaUtils.hpp View File

@@ -256,7 +256,7 @@ void carla_add(T* dataDst, T* dataSrc, const size_t size)
{
CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,);
CARLA_SAFE_ASSERT_RETURN(size != 0,);
CARLA_SAFE_ASSERT_RETURN(size > 0,);

for (size_t i=0; i < size; ++i)
*dataDst++ += *dataSrc++;
@@ -268,7 +268,7 @@ void carla_add(T* dataDst, const T* dataSrc, const size_t size)
{
CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,);
CARLA_SAFE_ASSERT_RETURN(size != 0,);
CARLA_SAFE_ASSERT_RETURN(size > 0,);

for (size_t i=0; i < size; ++i)
*dataDst++ += *dataSrc++;
@@ -280,7 +280,7 @@ void carla_copy(T* dataDst, T* dataSrc, const size_t size)
{
CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,);
CARLA_SAFE_ASSERT_RETURN(size != 0,);
CARLA_SAFE_ASSERT_RETURN(size > 0,);

for (size_t i=0; i < size; ++i)
*dataDst++ = *dataSrc++;
@@ -292,7 +292,7 @@ void carla_copy(T* dataDst, const T* dataSrc, const size_t size)
{
CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,);
CARLA_SAFE_ASSERT_RETURN(size != 0,);
CARLA_SAFE_ASSERT_RETURN(size > 0,);

for (size_t i=0; i < size; ++i)
*dataDst++ = *dataSrc++;
@@ -303,7 +303,7 @@ static inline
void carla_fill(T* data, const size_t size, const T v)
{
CARLA_SAFE_ASSERT_RETURN(data != nullptr,);
CARLA_SAFE_ASSERT_RETURN(size != 0,);
CARLA_SAFE_ASSERT_RETURN(size > 0,);

for (size_t i=0; i < size; ++i)
*data++ = v;
@@ -398,7 +398,7 @@ void carla_copyStruct(T* const struct1, T* const struct2, const size_t count)
{
CARLA_SAFE_ASSERT_RETURN(struct1 != nullptr,);
CARLA_SAFE_ASSERT_RETURN(struct2 != nullptr,);
CARLA_SAFE_ASSERT_RETURN(count != 0,);
CARLA_SAFE_ASSERT_RETURN(count > 0,);

std::memcpy(struct1, struct2, count*sizeof(T));
}
@@ -407,7 +407,7 @@ static inline
void carla_zeroMem(void* const memory, const size_t numBytes)
{
CARLA_SAFE_ASSERT_RETURN(memory != nullptr,);
CARLA_SAFE_ASSERT_RETURN(numBytes != 0,);
CARLA_SAFE_ASSERT_RETURN(numBytes > 0,);

std::memset(memory, 0, numBytes);
}
@@ -424,7 +424,7 @@ static inline
void carla_zeroStruct(T* const structure, const size_t count)
{
CARLA_SAFE_ASSERT_RETURN(structure != nullptr,);
CARLA_SAFE_ASSERT_RETURN(count != 0,);
CARLA_SAFE_ASSERT_RETURN(count > 0,);

std::memset(structure, 0, count*sizeof(T));
}


+ 19
- 40
source/modules/utils/Lv2AtomQueue.hpp View File

@@ -18,7 +18,6 @@
#ifndef LV2_ATOM_QUEUE_HPP_INCLUDED
#define LV2_ATOM_QUEUE_HPP_INCLUDED

//#include "CarlaLv2Utils.hpp"
#include "CarlaMutex.hpp"
#include "CarlaRingBuffer.hpp"

@@ -36,7 +35,7 @@ public:

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

const RetAtom* readAtom(uint32_t* const portIndex)
const LV2_Atom* readAtom(uint32_t* const portIndex)
{
fRetAtom.atom.size = 0;
fRetAtom.atom.type = 0;
@@ -45,16 +44,21 @@ public:
if (fRetAtom.atom.size == 0 || fRetAtom.atom.type == 0)
return nullptr;

CARLA_SAFE_ASSERT_RETURN(fRetAtom.atom.size < RING_BUFFER_SIZE, nullptr)

int32_t index = -1;
tryRead(&index, sizeof(int32_t));

if (index == -1)
return nullptr;

*portIndex = index;
if (portIndex != nullptr)
*portIndex = static_cast<uint32_t>(index);

carla_zeroChar(fRetAtom.data, fRetAtom.atom.size);
tryRead(fRetAtom.data, fRetAtom.atom.size);
return &RetAtom;

return &fRetAtom.atom;
}

// -------------------------------------------------------------------
@@ -74,7 +78,7 @@ private:

struct RetAtom {
LV2_Atom atom;
unsigned char data[RING_BUFFER_SIZE];
char data[RING_BUFFER_SIZE];
} fRetAtom;

friend class Lv2AtomQueue;
@@ -123,48 +127,23 @@ public:
{
CARLA_SAFE_ASSERT_RETURN(atom != nullptr && atom->size > 0, false);

const CarlaMutex::ScopedLocker sl(fMutex);

return fRingBufferCtrl.writeAtom(atom, portIndex);
return fRingBufferCtrl.writeAtom(atom, static_cast<int32_t>(portIndex));
}

bool get(const LV2_Atom** const atom, uint32_t* const portIndex)
{
CARLA_SAFE_ASSERT_RETURN(portIndex != nullptr && atom != nullptr, false);
CARLA_SAFE_ASSERT_RETURN(atom != nullptr && portIndex != nullptr, false);

if (! fRingBufferCtrl.dataAvailable())
return false;

const LV2_Atom atom = fRingBufferCtrl.readAtom();
const int32_t portIndex = fRingBufferCtrl.readAndCheckInt();
const uint8_t* atomBody = fRingBufferCtrl.readAtomBody();

// fFull = false;
//
// if (fData[fIndex].size == 0)
// {
// fIndex = fIndexPool = 0;
// fEmpty = true;
//
// unlock();
// return false;
// }
//
// fRetAtom.atom.size = fData[fIndex].size;
// fRetAtom.atom.type = fData[fIndex].type;
// std::memcpy(fRetAtom.data, fDataPool + fData[fIndex].poolOffset, fData[fIndex].size);
//
// *portIndex = fData[fIndex].portIndex;
// *atom = (LV2_Atom*)&fRetAtom;
//
// fData[fIndex].portIndex = 0;
// fData[fIndex].size = 0;
// fData[fIndex].type = 0;
// fData[fIndex].poolOffset = 0;
// fEmpty = false;
// ++fIndex;

return true;
if (const LV2_Atom* retAtom = fRingBufferCtrl.readAtom(portIndex))
{
*atom = retAtom;
return true;
}

return false;
}

private:
@@ -172,7 +151,7 @@ private:
Lv2AtomRingBufferControl fRingBufferCtrl;

CARLA_PREVENT_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Lv2AtomQueue)
};

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


Loading…
Cancel
Save