Browse Source

More cleanup&fixing; Make discovery build against Juce

tags/1.9.4
falkTX 11 years ago
parent
commit
9c53eb1d1a
11 changed files with 128 additions and 406 deletions
  1. +2
    -6
      source/backend/engine/CarlaEngineThread.hpp
  2. +24
    -16
      source/discovery/Makefile
  3. +20
    -29
      source/discovery/carla-discovery.cpp
  4. +1
    -1
      source/includes/CarlaDefines.hpp
  5. +1
    -3
      source/modules/Makefile
  6. +20
    -320
      source/modules/utils/CarlaJuceUtils.hpp
  7. +10
    -25
      source/modules/utils/CarlaLv2Utils.hpp
  8. +15
    -1
      source/modules/utils/CarlaString.hpp
  9. +24
    -4
      source/tests/ANSI.cpp
  10. +10
    -0
      source/tests/CarlaBackendDummy.cpp
  11. +1
    -1
      source/tests/Makefile

+ 2
- 6
source/backend/engine/CarlaEngineThread.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_ENGINE_THREAD_HPP_INCLUDED
@@ -38,15 +38,11 @@ public:
void startNow();
void stopNow();

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

protected:
void run();

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

private:
CarlaEngine* const kEngine;
CarlaEngine* const fEngine;

CarlaMutex fMutex;
bool fStopNow;


+ 24
- 16
source/discovery/Makefile View File

@@ -8,15 +8,15 @@ include ../Makefile.mk

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

BUILD_CXX_FLAGS += -I../backend -I../includes -I../modules/utils
BUILD_CXX_FLAGS += -I../backend -I../includes -I../modules -I../modules/utils

ifeq ($(HAVE_QT4),true)
BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtCore)
LINK_FLAGS += $(shell pkg-config --libs QtCore)
else
BUILD_CXX_FLAGS += $(shell pkg-config --cflags Qt5Core)
LINK_FLAGS += $(shell pkg-config --libs Qt5Core)
endif
# ifeq ($(HAVE_QT4),true)
# BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtCore)
# LINK_FLAGS += $(shell pkg-config --libs QtCore)
# else
# BUILD_CXX_FLAGS += $(shell pkg-config --cflags Qt5Core)
# LINK_FLAGS += $(shell pkg-config --libs Qt5Core)
# endif

ifeq ($(CARLA_PLUGIN_SUPPORT),true)
BUILD_CXX_FLAGS += -DWANT_LADSPA -DWANT_DSSI -DWANT_LV2 -DWANT_VST
@@ -51,7 +51,6 @@ WIN_64BIT_FLAGS = $(64BIT_FLAGS)
WIN_LINK_FLAGS = $(LINK_FLAGS) $(EXTRA_LIBS) -lole32 -luuid -lws2_32

ifeq ($(HAVE_FLUIDSYNTH),true)
WIN_BUILD_FLAGS +=
WIN_LINK_FLAGS += -ldsound -lwinmm
endif

@@ -59,12 +58,18 @@ ifeq ($(HAVE_LINUXSAMPLER),true)
WIN_LINK_FLAGS += -lrpcrt4
endif

LIBS = ../modules/juce_core.a
LIBS_posix32 = ../modules/juce_core.posix32.a
LIBS_posix64 = ../modules/juce_core.posix64.a
LIBS_win32 = ../modules/juce_core.win32.a
LIBS_win64 = ../modules/juce_core.win64.a

ifeq ($(CARLA_PLUGIN_SUPPORT),true)
LIBS = ../modules/lilv.a
LIBS_posix32 = ../modules/lilv.posix32.a
LIBS_posix64 = ../modules/lilv.posix64.a
LIBS_win32 = ../modules/lilv.win32.a
LIBS_win64 = ../modules/lilv.win64.a
LIBS += ../modules/lilv.a
LIBS_posix32 += ../modules/lilv.posix32.a
LIBS_posix64 += ../modules/lilv.posix64.a
LIBS_win32 += ../modules/lilv.win32.a
LIBS_win64 += ../modules/lilv.win64.a
endif

OBJS = carla-discovery.cpp
@@ -115,8 +120,11 @@ debug:
.FORCE:
.PHONY: .FORCE

../modules/lilv.a: .FORCE
$(MAKE) -C ../modules lilv
../modules/%.a: .FORCE
$(MAKE) -C ../modules $*

../modules/juce_core.%.a: .FORCE
$(MAKE) -C ../modules juce_core_$*

../modules/lilv.%.a: .FORCE
$(MAKE) -C ../modules lilv_$*

+ 20
- 29
source/discovery/carla-discovery.cpp View File

@@ -20,6 +20,8 @@
#include "CarlaString.hpp"
#include "CarlaMIDI.h"

#include "JuceHeader.h"

#ifdef WANT_LADSPA
# include "CarlaLadspaUtils.hpp"
#endif
@@ -28,7 +30,6 @@
#endif
#ifdef WANT_LV2
# include "CarlaLv2Utils.hpp"
# include <QtCore/QUrl>
#endif
#ifdef WANT_VST
# include "CarlaVstUtils.hpp"
@@ -38,7 +39,6 @@
#endif
#ifdef WANT_LINUXSAMPLER
# include "linuxsampler/EngineFactory.h"
# include <QtCore/QFileInfo>
#endif

#include <iostream>
@@ -923,43 +923,46 @@ void do_lv2_check(const char* const bundle, const bool init)
Lv2WorldClass& lv2World(Lv2WorldClass::getInstance());

// Convert bundle filename to URI
QString qBundle(QUrl::fromLocalFile(bundle).toString());
if (! qBundle.endsWith(QChar(OS_SEP)))
qBundle += QChar(OS_SEP);
const size_t bundleSize(std::strlen(bundle)+8);
char bundleURI[bundleSize];
std::strcpy(bundleURI, "file://");
std::strcat(bundleURI, bundle);

bundleURI[bundleSize-1] = OS_SEP;
bundleURI[bundleSize] = '\0';

// Load bundle
Lilv::Node lilvBundle(lv2World.new_uri(qBundle.toUtf8().constData()));
Lilv::Node lilvBundle(lv2World.new_uri(bundleURI));
lv2World.load_bundle(lilvBundle);

// Load plugins in this bundle
const Lilv::Plugins lilvPlugins(lv2World.get_all_plugins());

// Get all plugin URIs in this bundle
QStringList URIs;
juce::StringArray URIs;

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

if (const char* const uri = lilvPlugin.get_uri().as_string())
URIs.append(QString(uri));
URIs.add(String(uri));
}

if (URIs.count() == 0)
if (URIs.size() == 0)
{
DISCOVERY_OUT("warning", "LV2 Bundle doesn't provide any plugins");
return;
}

// Get & check every plugin-instance
for (int i=0; i < URIs.count(); ++i)
for (juce::String* it = URIs.begin(); it != URIs.end(); ++it)
{
const LV2_RDF_Descriptor* const rdfDescriptor = lv2_rdf_new(URIs.at(i).toUtf8().constData(), false);
CARLA_ASSERT(rdfDescriptor != nullptr && rdfDescriptor->URI != nullptr);
const LV2_RDF_Descriptor* const rdfDescriptor(lv2_rdf_new(it->toRawUTF8(), false));

if (rdfDescriptor == nullptr || rdfDescriptor->URI == nullptr)
{
DISCOVERY_OUT("error", "Failed to find LV2 plugin '" << URIs.at(i).toUtf8().constData() << "'");
DISCOVERY_OUT("error", "Failed to find LV2 plugin '" << it->toRawUTF8() << "'");
continue;
}

@@ -1506,30 +1509,18 @@ void do_fluidsynth_check(const char* const filename, const bool init)
void do_linuxsampler_check(const char* const filename, const char* const stype, const bool init)
{
#ifdef WANT_LINUXSAMPLER
const QFileInfo file(filename);

if (! file.exists())
{
DISCOVERY_OUT("error", "Requested file does not exist");
return;
}

if (! file.isFile())
{
DISCOVERY_OUT("error", "Requested file is not valid");
return;
}
const juce::File file(filename);

if (! file.isReadable())
if (! file.existsAsFile())
{
DISCOVERY_OUT("error", "Requested file is not readable");
DISCOVERY_OUT("error", "Requested file is not valid or does not exist");
return;
}

if (init)
const LinuxSamplerScopedEngine engine(filename, stype);
else
LinuxSamplerScopedEngine::outputInfo(nullptr, 0, file.baseName().toUtf8().constData());
LinuxSamplerScopedEngine::outputInfo(nullptr, 0, file.getFileNameWithoutExtension().toRawUTF8());
#else
DISCOVERY_OUT("error", stype << " support not available");
return;


+ 1
- 1
source/includes/CarlaDefines.hpp View File

@@ -129,7 +129,7 @@
#define CARLA_SAFE_ASSERT_INT(cond, value) if (cond) pass(); else carla_assert_int (#cond, __FILE__, __LINE__, value);
#define CARLA_SAFE_ASSERT_INT2(cond, v1, v2) if (cond) pass(); else carla_assert_int2(#cond, __FILE__, __LINE__, v1, v2);

// Define CARLA_SAFE_ASSERT_RETURN*
#define CARLA_SAFE_ASSERT_CONTINUE(cond) if (cond) pass(); else { carla_assert(#cond, __FILE__, __LINE__); continue; }
#define CARLA_SAFE_ASSERT_RETURN(cond, ret) if (cond) pass(); else { carla_assert(#cond, __FILE__, __LINE__); return ret; }

// Define CARLA_DECLARE_NON_COPY_STRUCT


+ 1
- 3
source/modules/Makefile View File

@@ -51,9 +51,6 @@ theme_%:
widgets:
$(MAKE) -C widgets

widgets_%:
$(MAKE) -C widgets $*

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

jackbridge-win32:
@@ -75,6 +72,7 @@ clean:
$(MAKE) clean -C distrho/dgl
$(MAKE) clean -C lilv
$(MAKE) clean -C jackbridge
$(MAKE) clean -C juce_core
$(MAKE) clean -C rtmempool
$(MAKE) clean -C theme
$(MAKE) clean -C utils


+ 20
- 320
source/modules/utils/CarlaJuceUtils.hpp View File

@@ -1,18 +1,18 @@
/*
* Carla misc utils imported from Juce source code
* Copyright (c) 2013 Raw Material Software Ltd.
* Carla misc utils using Juce resources
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
* 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.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* 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_JUCE_UTILS_HPP_INCLUDED
@@ -20,323 +20,23 @@

#include "CarlaUtils.hpp"

#include <algorithm>
#include "JuceHeader.h"

#define CARLA_PREVENT_HEAP_ALLOCATION \
private: \
static void* operator new(size_t); \
static void operator delete(void*);

#define CARLA_DECLARE_NON_COPYABLE(ClassName) \
private: \
ClassName(ClassName&); \
ClassName(const ClassName&); \
ClassName& operator=(const ClassName&);

/** This is a shorthand way of writing both a CARLA_DECLARE_NON_COPYABLE and
CARLA_LEAK_DETECTOR macro for a class.
*/
#define CARLA_LEAK_DETECTOR(ClassName) \
JUCE_LEAK_DETECTOR(ClassName)
#define CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ClassName) \
CARLA_DECLARE_NON_COPYABLE(ClassName) \
CARLA_LEAK_DETECTOR(ClassName)

/** This macro can be added to class definitions to disable the use of new/delete to
allocate the object on the heap, forcing it to only be used as a stack or member variable.
*/
#define CARLA_PREVENT_HEAP_ALLOCATION \
private: \
static void* operator new (size_t); \
static void operator delete (void*);

/** A good old-fashioned C macro concatenation helper.
This combines two items (which may themselves be macros) into a single string,
avoiding the pitfalls of the ## macro operator.
*/
#define CARLA_JOIN_MACRO_HELPER(a, b) a ## b
#define CARLA_JOIN_MACRO(item1, item2) CARLA_JOIN_MACRO_HELPER (item1, item2)

//==============================================================================
/**
Embedding an instance of this class inside another class can be used as a low-overhead
way of detecting leaked instances.

This class keeps an internal static count of the number of instances that are
active, so that when the app is shutdown and the static destructors are called,
it can check whether there are any left-over instances that may have been leaked.

To use it, use the CARLA_LEAK_DETECTOR macro as a simple way to put one in your
class declaration. Have a look through the carla codebase for examples, it's used
in most of the classes.
*/
template <class OwnerClass>
class LeakedObjectDetector
{
public:
//==============================================================================
LeakedObjectDetector() noexcept { ++(getCounter().numObjects); }
LeakedObjectDetector(const LeakedObjectDetector&) noexcept { ++(getCounter().numObjects); }

~LeakedObjectDetector()
{
if (--(getCounter().numObjects) < 0)
{
carla_stderr("*** Dangling pointer deletion! Class: '%s'", getLeakedObjectClassName());

/** If you hit this, then you've managed to delete more instances of this class than you've
created.. That indicates that you're deleting some dangling pointers.

Note that although this assertion will have been triggered during a destructor, it might
not be this particular deletion that's at fault - the incorrect one may have happened
at an earlier point in the program, and simply not been detected until now.

Most errors like this are caused by using old-fashioned, non-RAII techniques for
your object management. Tut, tut. Always, always use ScopedPointers, OwnedArrays,
ReferenceCountedObjects, etc, and avoid the 'delete' operator at all costs!
*/
//assert(false);
}
}

private:
//==============================================================================
class LeakCounter
{
public:
LeakCounter() noexcept
{
numObjects = 0;
}

~LeakCounter()
{
if (numObjects > 0)
{
carla_stderr("*** Leaked objects detected: %i instance(s) of class '%s'", numObjects, getLeakedObjectClassName());

/** If you hit this, then you've leaked one or more objects of the type specified by
the 'OwnerClass' template parameter - the name should have been printed by the line above.

If you're leaking, it's probably because you're using old-fashioned, non-RAII techniques for
your object management. Tut, tut. Always, always use ScopedPointers, OwnedArrays,
ReferenceCountedObjects, etc, and avoid the 'delete' operator at all costs!
*/
//assert(false);
}
}

volatile int numObjects;
};

static const char* getLeakedObjectClassName() noexcept
{
return OwnerClass::getLeakedObjectClassName();
}

static LeakCounter& getCounter() noexcept
{
static LeakCounter counter;
return counter;
}
};

#define CARLA_LEAK_DETECTOR(OwnerClass) \
friend class LeakedObjectDetector<OwnerClass>; \
static const char* getLeakedObjectClassName() noexcept { return #OwnerClass; } \
LeakedObjectDetector<OwnerClass> CARLA_JOIN_MACRO (leakDetector, __LINE__);


//==============================================================================
/**
This class holds a pointer which is automatically deleted when this object goes
out of scope.

Once a pointer has been passed to a ScopedPointer, it will make sure that the pointer
gets deleted when the ScopedPointer is deleted. Using the ScopedPointer on the stack or
as member variables is a good way to use RAII to avoid accidentally leaking dynamically
created objects.

A ScopedPointer can be used in pretty much the same way that you'd use a normal pointer
to an object. If you use the assignment operator to assign a different object to a
ScopedPointer, the old one will be automatically deleted.

Important note: The class is designed to hold a pointer to an object, NOT to an array!
It calls delete on its payload, not delete[], so do not give it an array to hold! For
that kind of purpose, you should be using HeapBlock or Array instead.

A const ScopedPointer is guaranteed not to lose ownership of its object or change the
object to which it points during its lifetime. This means that making a copy of a const
ScopedPointer is impossible, as that would involve the new copy taking ownership from the
old one.

If you need to get a pointer out of a ScopedPointer without it being deleted, you
can use the release() method.

Something to note is the main difference between this class and the std::auto_ptr class,
which is that ScopedPointer provides a cast-to-object operator, wheras std::auto_ptr
requires that you always call get() to retrieve the pointer. The advantages of providing
the cast is that you don't need to call get(), so can use the ScopedPointer in pretty much
exactly the same way as a raw pointer. The disadvantage is that the compiler is free to
use the cast in unexpected and sometimes dangerous ways - in particular, it becomes difficult
to return a ScopedPointer as the result of a function. To avoid this causing errors,
ScopedPointer contains an overloaded constructor that should cause a syntax error in these
circumstances, but it does mean that instead of returning a ScopedPointer from a function,
you'd need to return a raw pointer (or use a std::auto_ptr instead).
*/
template <class ObjectType>
class ScopedPointer
{
public:
//==============================================================================
/** Creates a ScopedPointer containing a null pointer. */
ScopedPointer() noexcept
: object(nullptr)
{
}

/** Creates a ScopedPointer that owns the specified object. */
ScopedPointer(ObjectType* const objectToTakePossessionOf) noexcept
: object(objectToTakePossessionOf)
{
}

/** Creates a ScopedPointer that takes its pointer from another ScopedPointer.

Because a pointer can only belong to one ScopedPointer, this transfers
the pointer from the other object to this one, and the other object is reset to
be a null pointer.
*/
ScopedPointer(ScopedPointer& objectToTransferFrom) noexcept
: object(objectToTransferFrom.object)
{
objectToTransferFrom.object = nullptr;
}

/** Destructor.
This will delete the object that this ScopedPointer currently refers to.
*/
~ScopedPointer()
{
delete object;
}

/** Changes this ScopedPointer to point to a new object.

Because a pointer can only belong to one ScopedPointer, this transfers
the pointer from the other object to this one, and the other object is reset to
be a null pointer.

If this ScopedPointer already points to an object, that object
will first be deleted.
*/
ScopedPointer& operator=(ScopedPointer& objectToTransferFrom)
{
if (this != objectToTransferFrom.getAddress())
{
// Two ScopedPointers should never be able to refer to the same object - if
// this happens, you must have done something dodgy!
assert(object == nullptr || object != objectToTransferFrom.object);

ObjectType* const oldObject = object;
object = objectToTransferFrom.object;
objectToTransferFrom.object = nullptr;
delete oldObject;
}

return *this;
}

/** Changes this ScopedPointer to point to a new object.

If this ScopedPointer already points to an object, that object
will first be deleted.

The pointer that you pass in may be a nullptr.
*/
ScopedPointer& operator=(ObjectType* const newObjectToTakePossessionOf)
{
if (object != newObjectToTakePossessionOf)
{
ObjectType* const oldObject = object;
object = newObjectToTakePossessionOf;
delete oldObject;
}

return *this;
}

//==============================================================================
/** Returns the object that this ScopedPointer refers to. */
operator ObjectType*() const noexcept { return object; }

/** Returns the object that this ScopedPointer refers to. */
ObjectType* get() const noexcept { return object; }

/** Returns the object that this ScopedPointer refers to. */
ObjectType& operator*() const noexcept { return *object; }

/** Lets you access methods and properties of the object that this ScopedPointer refers to. */
ObjectType* operator->() const noexcept { return object; }

//==============================================================================
/** Removes the current object from this ScopedPointer without deleting it.
This will return the current object, and set the ScopedPointer to a null pointer.
*/
ObjectType* release() noexcept { ObjectType* const o = object; object = nullptr; return o; }

//==============================================================================
/** Swaps this object with that of another ScopedPointer.
The two objects simply exchange their pointers.
*/
void swapWith(ScopedPointer<ObjectType>& other)
{
// Two ScopedPointers should never be able to refer to the same object - if
// this happens, you must have done something dodgy!
assert(object != other.object || this == other.getAddress());

std::swap(object, other.object);
}

private:
//==============================================================================
ObjectType* object;

// (Required as an alternative to the overloaded & operator).
const ScopedPointer* getAddress() const noexcept { return this; }

#if ! defined(CARLA_CC_MSVC) // (MSVC can't deal with multiple copy constructors)
/* The copy constructors are private to stop people accidentally copying a const ScopedPointer
(the compiler would let you do so by implicitly casting the source to its raw object pointer).

A side effect of this is that in a compiler that doesn't support C++11, you may hit an
error when you write something like this:

ScopedPointer<MyClass> m = new MyClass(); // Compile error: copy constructor is private.

Even though the compiler would normally ignore the assignment here, it can't do so when the
copy constructor is private. It's very easy to fix though - just write it like this:

ScopedPointer<MyClass> m (new MyClass()); // Compiles OK

It's probably best to use the latter form when writing your object declarations anyway, as
this is a better representation of the code that you actually want the compiler to produce.
*/
ScopedPointer(const ScopedPointer&);
ScopedPointer& operator=(const ScopedPointer&);
#endif
};

//==============================================================================
/** Compares a ScopedPointer with another pointer.
This can be handy for checking whether this is a null pointer.
*/
template <class ObjectType>
bool operator==(const ScopedPointer<ObjectType>& pointer1, ObjectType* const pointer2) noexcept
{
return static_cast<ObjectType*>(pointer1) == pointer2;
}

/** Compares a ScopedPointer with another pointer.
This can be handy for checking whether this is a null pointer.
*/
template <class ObjectType>
bool operator!=(const ScopedPointer<ObjectType>& pointer1, ObjectType* const pointer2) noexcept
{
return static_cast<ObjectType*>(pointer1) != pointer2;
}

#endif // CARLA_JUCE_UTILS_HPP_INCLUDED

+ 10
- 25
source/modules/utils/CarlaLv2Utils.hpp View File

@@ -20,11 +20,6 @@

#include "CarlaJuceUtils.hpp"

#include <cstddef>

#undef NULL
#define NULL nullptr

#include "lv2/lv2.h"
#include "lv2/atom.h"
#include "lv2/atom-forge.h"
@@ -66,8 +61,6 @@
#include "lilv/lilvmm.hpp"
#include "sratom/sratom.h"

#include <QtCore/QStringList>

// -----------------------------------------------------------------------
// Define namespaces and missing prefixes

@@ -556,16 +549,11 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)

if (replaceNode.is_uri())
{
const QString replaceURI(replaceNode.as_uri());
const juce::String replaceURI(replaceNode.as_uri());

if (replaceURI.startsWith("urn:"))
{
const QString replaceId(replaceURI.split(":").last());

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

if (ok && uniqueId != 0)
if (int uniqueId = replaceURI.getTrailingIntValue())
rdfDescriptor->UniqueID = uniqueId;
}
}
@@ -1024,23 +1012,23 @@ 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)
QStringList presetListURIs;
juce::StringArray presetListURIs;

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

QString presetURI(presetNode.as_uri());
juce::String presetURI(presetNode.as_uri());

if (! presetListURIs.contains(presetURI))
presetListURIs.append(presetURI);
if (presetURI.trim().isNotEmpty())
presetListURIs.addIfNotAlreadyThere(presetURI);
}

presetListURIs.sort();
presetListURIs.sort(false);

// create presets with unique URIs
rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.count());
rdfDescriptor->PresetCount = static_cast<uint32_t>(presetListURIs.size());
rdfDescriptor->Presets = new LV2_RDF_Preset[rdfDescriptor->PresetCount];

// set preset data
@@ -1053,12 +1041,9 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool fillPresets)

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

CARLA_ASSERT(index >= 0);
const int index(presetListURIs.indexOf(juce::String(presetURI)));

if (index < 0)
continue;
CARLA_SAFE_ASSERT_CONTINUE(index >= 0);

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



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

@@ -181,6 +181,13 @@ public:
return (fBuffer[pos] >= '0' && fBuffer[pos] <= '9');
}

bool startsWith(const char c) const
{
CARLA_SAFE_ASSERT_RETURN(c != '\0', false)

return (fBufferLen > 0 && fBuffer[0] == c);
}

bool startsWith(const char* const prefix) const
{
CARLA_SAFE_ASSERT_RETURN(prefix != nullptr, false)
@@ -193,6 +200,13 @@ public:
return (std::strncmp(fBuffer + (fBufferLen-prefixLen), prefix, prefixLen) == 0);
}

bool endsWith(const char c) const
{
CARLA_SAFE_ASSERT_RETURN(c != '\0', false)

return (fBufferLen > 0 && fBuffer[fBufferLen] == c);
}

bool endsWith(const char* const suffix) const
{
CARLA_SAFE_ASSERT_RETURN(suffix != nullptr, false)
@@ -251,7 +265,7 @@ public:
return (ret > fBufferLen) ? fBufferLen : fBufferLen-ret;
}

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



+ 24
- 4
source/tests/ANSI.cpp View File

@@ -21,6 +21,10 @@

#define RING_BUFFER_SIZE 48

// 1 - utils
// 2 - engine
// 3 - plugin
// 4 - standalone
#define ANSI_TEST_N 2

#if ANSI_TEST_N == 1
@@ -75,14 +79,22 @@
#endif

#if ANSI_TEST_N == 2
// Carla Engine
#include "engine/CarlaEngineThread.hpp"
#endif

#if ANSI_TEST_N == 3
// Carla Plugin
#include "plugin/CarlaPluginThread.hpp"
#include "plugin/CarlaPluginInternal.hpp"
#endif

#if ANSI_TEST_N == 4
// Carla Standalone
#include "CarlaStandalone.hpp"
#include "CarlaUtils.hpp"
#endif

// #include "plugin/CarlaPluginThread.hpp"
// #include "plugin/CarlaPluginInternal.hpp"

#if ANSI_TEST_N == 1
// -----------------------------------------------------------------------

@@ -592,6 +604,14 @@ int main()
#endif

#if ANSI_TEST_N == 2
// ANSI_TEST_N == 2
#endif

#if ANSI_TEST_N == 3
// ANSI_TEST_N == 3
#endif

#if ANSI_TEST_N == 4
carla_stdout("NOTICE LICENSE:");
carla_stdout(carla_get_extended_license_text());
carla_stdout("");
@@ -606,7 +626,7 @@ int main()
carla_engine_close();
carla_stdout(carla_get_last_error());

// ANSI_TEST_N == 2
// ANSI_TEST_N == 4
#endif

return 0;


+ 10
- 0
source/tests/CarlaBackendDummy.cpp View File

@@ -20,6 +20,13 @@

CARLA_BACKEND_START_NAMESPACE

// 1 - utils
// 2 - engine
// 3 - plugin
// 4 - standalone
#define ANSI_TEST_N 2

#if ANSI_TEST_N != 3
struct SaveState {};

// -----------------------------------------------------------------------
@@ -129,7 +136,9 @@ void CarlaPlugin::uiNoteOff(const uint8_t, const uint8_t) {}

size_t CarlaPlugin::getNativePluginCount() { return 0; }
const PluginDescriptor* CarlaPlugin::getNativePluginDescriptor(const size_t) { return nullptr; }
#endif

#if ANSI_TEST_N != 2
// -----------------------------------------------------------------------
// CarlaEngine

@@ -191,6 +200,7 @@ bool CarlaEngine::isOscControlRegistered() const noexcept { return fa
void CarlaEngine::idleOsc() {}
const char* CarlaEngine::getOscServerPathTCP() const noexcept { return nullptr; }
const char* CarlaEngine::getOscServerPathUDP() const noexcept { return nullptr; }
#endif

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



+ 1
- 1
source/tests/Makefile View File

@@ -34,7 +34,7 @@ endif
ifeq ($(MACOS),true)
TARGETS = CarlaString DGL1 DGL2 Print
else
TARGETS = ANSI CarlaString DGL1 DGL2 Print RtList Utils
TARGETS = ANSI CarlaString DGL1 DGL2 Print RtList Utils Widgets
endif

all: $(TARGETS) RUN


Loading…
Cancel
Save