Browse Source

Build discovery with dssi, lv2, ls enabled; Misc LV2 code changes

tags/1.9.4
falkTX 11 years ago
parent
commit
a872b96b13
4 changed files with 77 additions and 121 deletions
  1. +5
    -5
      source/discovery/Makefile
  2. +7
    -7
      source/discovery/carla-discovery.cpp
  3. +6
    -6
      source/includes/lv2/atom-forge.h
  4. +59
    -103
      source/utils/CarlaLv2Utils.hpp

+ 5
- 5
source/discovery/Makefile View File

@@ -18,8 +18,8 @@ LINK_FLAGS += $(QTCORE_LIBS)
BUILD_CXX_FLAGS += -DWANT_NATIVE

ifeq ($(CARLA_PLUGIN_SUPPORT),true)
BUILD_CXX_FLAGS += -DWANT_LADSPA
# -DWANT_DSSI -DWANT_LV2 -DWANT_VST
BUILD_CXX_FLAGS += -DWANT_LADSPA -DWANT_DSSI -DWANT_LV2
# -DWANT_VST
# ifeq ($(CARLA_VESTIGE_HEADER),true)
# BUILD_CXX_FLAGS += -DVESTIGE_HEADER
# endif
@@ -35,9 +35,9 @@ ifeq ($(HAVE_FLUIDSYNTH),true)
NATIVE_FLAGS += $(FLUIDSYNTH_FLAGS) $(FLUIDSYNTH_LIBS) -DWANT_FLUIDSYNTH
endif

# ifeq ($(HAVE_LINUXSAMPLER),true)
# NATIVE_FLAGS += $(shell pkg-config --cflags --libs linuxsampler) -DWANT_LINUXSAMPLER
# endif
ifeq ($(HAVE_LINUXSAMPLER),true)
NATIVE_FLAGS += $(LINUXSAMPLER_FLAGS) $(LINUXSAMPLER_LIBS) -DWANT_LINUXSAMPLER
endif

# --------------------------------------------------------------



+ 7
- 7
source/discovery/carla-discovery.cpp View File

@@ -361,7 +361,7 @@ public:
}
}

static void outputInfo(const LinuxSampler::InstrumentManager::instrument_info_t* const info, const int programs, const char* const basename = nullptr)
static void outputInfo(const LinuxSampler::InstrumentManager::instrument_info_t* const info, const size_t programs, const char* const basename = nullptr)
{
DISCOVERY_OUT("init", "-----------");

@@ -976,9 +976,9 @@ void do_lv2_check(const char* const bundle, const bool init)
// Get all plugin URIs in this bundle
QStringList URIs;

LILV_FOREACH(plugins, i, lilvPlugins)
LILV_FOREACH(plugins, it, lilvPlugins)
{
Lilv::Plugin lilvPlugin(lilv_plugins_get(lilvPlugins, i));
Lilv::Plugin lilvPlugin(lilv_plugins_get(lilvPlugins, it));

if (const char* const uri = lilvPlugin.get_uri().as_string())
URIs.append(QString(uri));
@@ -1033,7 +1033,7 @@ void do_lv2_check(const char* const bundle, const bool init)

for (uint32_t j=0; j < rdfDescriptor->PortCount && supported; ++j)
{
const LV2_RDF_Port* const rdfPort = &rdfDescriptor->Ports[j];
const LV2_RDF_Port* const rdfPort(&rdfDescriptor->Ports[j]);

if (is_lv2_port_supported(rdfPort->Types))
{
@@ -1049,7 +1049,7 @@ void do_lv2_check(const char* const bundle, const bool init)

for (uint32_t j=0; j < rdfDescriptor->FeatureCount && supported; ++j)
{
const LV2_RDF_Feature* const rdfFeature = &rdfDescriptor->Features[j];
const LV2_RDF_Feature* const rdfFeature(&rdfDescriptor->Features[j]);

if (is_lv2_feature_supported(rdfFeature->URI))
{
@@ -1081,7 +1081,7 @@ void do_lv2_check(const char* const bundle, const bool init)

for (uint32_t j=0; j < rdfDescriptor->FeatureCount; ++j)
{
const LV2_RDF_Feature* const rdfFeature = &rdfDescriptor->Features[j];
const LV2_RDF_Feature* const rdfFeature(&rdfDescriptor->Features[j]);

if (std::strcmp(rdfFeature->URI, LV2_CORE__hardRTCapable) == 0)
hints |= PLUGIN_IS_RTSAFE;
@@ -1089,7 +1089,7 @@ void do_lv2_check(const char* const bundle, const bool init)

for (uint32_t j=0; j < rdfDescriptor->PortCount; ++j)
{
const LV2_RDF_Port* const rdfPort = &rdfDescriptor->Ports[j];
const LV2_RDF_Port* const rdfPort(&rdfDescriptor->Ports[j]);

if (LV2_IS_PORT_AUDIO(rdfPort->Types))
{


+ 6
- 6
source/includes/lv2/atom-forge.h View File

@@ -199,7 +199,7 @@ static inline void
lv2_atom_forge_set_buffer(LV2_Atom_Forge* forge, uint8_t* buf, size_t size)
{
forge->buf = buf;
forge->size = size;
forge->size = (uint32_t)size;
forge->offset = 0;
forge->deref = NULL;
forge->sink = NULL;
@@ -321,7 +321,7 @@ lv2_atom_forge_primitive(LV2_Atom_Forge* forge, const LV2_Atom* a)
if (lv2_atom_forge_top_is(forge, forge->Vector)) {
return lv2_atom_forge_raw(forge, LV2_ATOM_BODY_CONST(a), a->size);
} else {
return lv2_atom_forge_write(forge, a, sizeof(LV2_Atom) + a->size);
return lv2_atom_forge_write(forge, a, (uint32_t)sizeof(LV2_Atom) + a->size);
}
}

@@ -533,7 +533,7 @@ lv2_atom_forge_resource(LV2_Atom_Forge* forge,
LV2_URID otype)
{
const LV2_Atom_Object a = {
{ sizeof(LV2_Atom_Object) - sizeof(LV2_Atom), forge->Resource },
{ (uint32_t)(sizeof(LV2_Atom_Object) - sizeof(LV2_Atom)), forge->Resource },
{ id, otype }
};
return lv2_atom_forge_push(
@@ -550,7 +550,7 @@ lv2_atom_forge_blank(LV2_Atom_Forge* forge,
LV2_URID otype)
{
const LV2_Atom_Object a = {
{ sizeof(LV2_Atom_Object) - sizeof(LV2_Atom), forge->Blank },
{ (uint32_t)(sizeof(LV2_Atom_Object) - sizeof(LV2_Atom)), forge->Blank },
{ id, otype }
};
return lv2_atom_forge_push(
@@ -567,7 +567,7 @@ lv2_atom_forge_property_head(LV2_Atom_Forge* forge,
LV2_URID context)
{
const LV2_Atom_Property_Body a = { key, context, { 0, 0 } };
return lv2_atom_forge_write(forge, &a, 2 * sizeof(uint32_t));
return lv2_atom_forge_write(forge, &a, (uint32_t)sizeof(uint32_t) * 2);
}

/**
@@ -579,7 +579,7 @@ lv2_atom_forge_sequence_head(LV2_Atom_Forge* forge,
uint32_t unit)
{
const LV2_Atom_Sequence a = {
{ sizeof(LV2_Atom_Sequence) - sizeof(LV2_Atom), forge->Sequence },
{ (uint32_t)(sizeof(LV2_Atom_Sequence) - sizeof(LV2_Atom)), forge->Sequence },
{ unit, 0 }
};
return lv2_atom_forge_push(


+ 59
- 103
source/utils/CarlaLv2Utils.hpp View File

@@ -23,13 +23,13 @@
#include "lv2/lv2.h"
#include "lv2/atom.h"
#include "lv2/atom-forge.h"
#include "lv2/atom-helpers.h"
//#include "lv2/atom-helpers.h"
#include "lv2/atom-util.h"
#include "lv2/buf-size.h"
#include "lv2/data-access.h"
// dynmanifest
#include "lv2/event.h"
#include "lv2/event-helpers.h"
//#include "lv2/event-helpers.h"
#include "lv2/instance-access.h"
#include "lv2/log.h"
// logger
@@ -51,7 +51,7 @@
#include "lv2/worker.h"

#include "lv2/lv2-miditype.h"
#include "lv2/lv2-midifunctions.h"
//#include "lv2/lv2-midifunctions.h"
#include "lv2/lv2_external_ui.h"
#include "lv2/lv2_programs.h"
#include "lv2/lv2_rtmempool.h"
@@ -61,7 +61,6 @@
#include "lilv/lilvmm.hpp"
#include "sratom/sratom.h"

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

// -----------------------------------------------------------------------
@@ -324,19 +323,7 @@ public:
dct_replaces (new_uri(NS_dct "replaces")),
doap_license (new_uri(NS_doap "license")),
rdf_type (new_uri(NS_rdf "type")),
rdfs_label (new_uri(NS_rdfs "label"))
{
fNeedsInit = true;
}

void init()
{
if (! fNeedsInit)
return;

fNeedsInit = false;
Lilv::World::load_all();
}
rdfs_label (new_uri(NS_rdfs "label")) {}

static Lv2WorldClass& getInstance()
{
@@ -344,11 +331,17 @@ public:
return lv2World;
}

const LilvPlugin* getPlugin(const LV2_URI uri)
const LilvPlugin* getPlugin(const LV2_URI uri) /*const*/
{
CARLA_SAFE_ASSERT_RETURN(uri != nullptr, nullptr);
CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', nullptr);

static const Lilv::Plugins lilvPlugins(Lilv::World::get_all_plugins());
const LilvPlugins* const cPlugins(lilv_world_get_all_plugins(this->me));

if (cPlugins == nullptr)
{
carla_stderr("Lv2WorldClass::getPlugin(\"%s\") - Failed to get plugins from world", uri);
return nullptr;
}

LilvNode* const uriNode(Lilv::World::new_uri(uri));

@@ -358,22 +351,22 @@ public:
return nullptr;
}

if (const LilvPlugin* const cPlugin = lilv_plugins_get_by_uri(lilvPlugins.me, uriNode))
{
lilv_node_free(uriNode);
return cPlugin;
}
else
const LilvPlugin* const cPlugin(lilv_plugins_get_by_uri(cPlugins, uriNode));
lilv_node_free(uriNode);

if (cPlugin == nullptr)
{
carla_stderr("Lv2WorldClass::getPlugin(\"%s\") - Failed to get plugin", uri);
lilv_node_free(uriNode);
return nullptr;
}

return cPlugin;
}

const LilvState* getState(const LV2_URI uri, const LV2_URID_Map* const uridMap)
const LilvState* getState(const LV2_URI uri, const LV2_URID_Map* const uridMap) /*const*/
{
CARLA_SAFE_ASSERT_RETURN(uri != nullptr, nullptr);
CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', nullptr);
CARLA_SAFE_ASSERT_RETURN(uridMap != nullptr, nullptr);

LilvNode* const uriNode(Lilv::World::new_uri(uri));

@@ -383,21 +376,17 @@ public:
return nullptr;
}

if (const LilvState* cState = lilv_state_new_from_world(this->me, uridMap, uriNode))
{
lilv_node_free(uriNode);
return cState;
}
else
const LilvState* const cState(lilv_state_new_from_world(this->me, uridMap, uriNode));
lilv_node_free(uriNode);

if (cState == nullptr)
{
carla_stderr("Lv2WorldClass::getState(\"%s\", %p) - Failed to get state", uri, uridMap);
lilv_node_free(uriNode);
return nullptr;
}
}

private:
bool fNeedsInit;
return cState;
}

CARLA_PREVENT_HEAP_ALLOCATION
};
@@ -408,7 +397,7 @@ private:
static inline
const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
{
CARLA_SAFE_ASSERT_RETURN(uri != nullptr, nullptr);
CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', nullptr);

Lv2WorldClass& lv2World(Lv2WorldClass::getInstance());

@@ -544,15 +533,6 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)

if (replaceNode.is_uri())
{
#if 0//def HAVE_JUCE
const juce::String replaceURI(replaceNode.as_uri());

if (replaceURI.startsWith("urn:"))
{
if (int uniqueId = replaceURI.getTrailingIntValue())
rdfDescriptor->UniqueID = (unsigned long)uniqueId;
}
#else
const QString replaceURI(replaceNode.as_uri());

if (replaceURI.startsWith("urn:"))
@@ -565,7 +545,6 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
if (ok && uniqueId != 0)
rdfDescriptor->UniqueID = uniqueId;
}
#endif
}
}
}
@@ -578,10 +557,10 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
rdfDescriptor->PortCount = lilvPlugin.get_num_ports();
rdfDescriptor->Ports = new LV2_RDF_Port[rdfDescriptor->PortCount];

for (uint32_t j = 0; j < rdfDescriptor->PortCount; ++j)
for (uint32_t i = 0; i < rdfDescriptor->PortCount; ++i)
{
Lilv::Port lilvPort(lilvPlugin.get_port_by_index(j));
LV2_RDF_Port* const rdfPort(&rdfDescriptor->Ports[j]);
Lilv::Port lilvPort(lilvPlugin.get_port_by_index(i));
LV2_RDF_Port* const rdfPort(&rdfDescriptor->Ports[i]);

// -----------------------------------------------------------
// Set Port Information
@@ -947,7 +926,7 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
else if (std::strcmp(unitUnit, LV2_UNITS__semitone12TET) == 0)
rdfPort->Unit.Unit = LV2_PORT_UNIT_SEMITONE;
else
carla_stderr("lv2_rdf_new(\"%s\") - got unknown unit type '%s'", uri, unitUnit);
carla_stderr("lv2_rdf_new(\"%s\") - got unknown unit unit '%s'", uri, unitUnit);
}
}

@@ -996,11 +975,11 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
rdfPort->ScalePoints = new LV2_RDF_PortScalePoint[rdfPort->ScalePointCount];

uint32_t h = 0;
LILV_FOREACH(scale_points, j, lilvScalePoints)
LILV_FOREACH(scale_points, it, lilvScalePoints)
{
CARLA_ASSERT(h < rdfPort->ScalePointCount);
CARLA_SAFE_ASSERT_BREAK(h < rdfPort->ScalePointCount);

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

if (const char* const label = Lilv::Node(lilvScalePoint.get_label()).as_string())
@@ -1022,59 +1001,36 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
if (presetNodes.size() > 0)
{
// create a list of preset URIs (for checking appliesTo, sorting and unique-ness)
#if 0//def HAVE_JUCE
juce::StringArray presetListURIs;
#else
QStringList presetListURIs;
#endif

LILV_FOREACH(nodes, j, presetNodes)
LILV_FOREACH(nodes, it, presetNodes)
{
Lilv::Node presetNode(presetNodes.get(j));
Lilv::Node presetNode(presetNodes.get(it));
// FIXME - check appliesTo?

#if 0//def HAVE_JUCE
juce::String presetURI(presetNode.as_uri());

if (presetURI.trim().isNotEmpty())
presetListURIs.addIfNotAlreadyThere(presetURI);
#else
QString presetURI(presetNode.as_uri());

if (! (presetURI.trimmed().isEmpty() || presetListURIs.contains(presetURI)))
presetListURIs.append(presetURI);
#endif
}

#if 0//def HAVE_JUCE
presetListURIs.sort(false);
#else
presetListURIs.sort();
#endif

// create presets with unique URIs
#if 0//def HAVE_JUCE
rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.size());
#else
rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.count());
#endif
rdfDescriptor->Presets = new LV2_RDF_Preset[rdfDescriptor->PresetCount];

// set preset data
LILV_FOREACH(nodes, j, presetNodes)
LILV_FOREACH(nodes, it, presetNodes)
{
Lilv::Node presetNode(presetNodes.get(j));
Lilv::Node presetNode(presetNodes.get(it));

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

if (const char* const presetURI = presetNode.as_uri())
{
#if 0//def HAVE_JUCE
const int index(presetListURIs.indexOf(juce::String(presetURI)));
#else
const int index(presetListURIs.indexOf(QString(presetURI)));
#endif
CARLA_SAFE_ASSERT_CONTINUE(index >= 0);

LV2_RDF_Preset* const rdfPreset(&rdfDescriptor->Presets[index]);
@@ -1110,11 +1066,11 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
rdfDescriptor->Features = new LV2_RDF_Feature[rdfDescriptor->FeatureCount];

uint32_t h = 0;
LILV_FOREACH(nodes, j, lilvFeatureNodes)
LILV_FOREACH(nodes, it, lilvFeatureNodes)
{
CARLA_ASSERT(h < rdfDescriptor->FeatureCount);
CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->FeatureCount);

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

rdfFeature->Type = lilvFeatureNodesR.contains(lilvFeatureNode) ? LV2_FEATURE_REQUIRED : LV2_FEATURE_OPTIONAL;
@@ -1136,11 +1092,11 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
rdfDescriptor->Extensions = new LV2_URI[rdfDescriptor->ExtensionCount];

uint32_t h = 0;
LILV_FOREACH(nodes, j, lilvExtensionDataNodes)
LILV_FOREACH(nodes, it, lilvExtensionDataNodes)
{
CARLA_ASSERT(h < rdfDescriptor->ExtensionCount);
CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->ExtensionCount);

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

if (const char* const extURI = lilvExtensionDataNode.as_uri())
@@ -1160,11 +1116,11 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
rdfDescriptor->UIs = new LV2_RDF_UI[rdfDescriptor->UICount];

uint32_t h = 0;
LILV_FOREACH(uis, j, lilvUIs)
LILV_FOREACH(uis, it, lilvUIs)
{
CARLA_ASSERT(h < rdfDescriptor->UICount);
CARLA_SAFE_ASSERT_BREAK(h < rdfDescriptor->UICount);

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

// -------------------------------------------------------
@@ -1216,13 +1172,13 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
rdfUI->FeatureCount = lilvFeatureNodes.size();
rdfUI->Features = new LV2_RDF_Feature[rdfUI->FeatureCount];

uint32_t x = 0;
LILV_FOREACH(nodes, k, lilvFeatureNodes)
uint32_t h2 = 0;
LILV_FOREACH(nodes, it2, lilvFeatureNodes)
{
CARLA_ASSERT(x < rdfUI->FeatureCount);
CARLA_SAFE_ASSERT_BREAK(h2 < rdfUI->FeatureCount);

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

rdfFeature->Type = lilvFeatureNodesR.contains(lilvFeatureNode) ? LV2_FEATURE_REQUIRED : LV2_FEATURE_OPTIONAL;

@@ -1242,13 +1198,13 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)
rdfUI->ExtensionCount = lilvExtensionDataNodes.size();
rdfUI->Extensions = new LV2_URI[rdfUI->ExtensionCount];

uint32_t x = 0;
LILV_FOREACH(nodes, k, lilvExtensionDataNodes)
uint32_t h2 = 0;
LILV_FOREACH(nodes, it2, lilvExtensionDataNodes)
{
CARLA_ASSERT(x < rdfUI->ExtensionCount);
CARLA_SAFE_ASSERT_BREAK(h2 < rdfUI->ExtensionCount);

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

if (const char* const extURI = lilvExtensionDataNode.as_uri())
*rdfExtension = carla_strdup(extURI);


Loading…
Cancel
Save