Browse Source

discovery cleanup&fixing

tags/1.9.4
falkTX 11 years ago
parent
commit
dcfe940297
6 changed files with 140 additions and 69 deletions
  1. +2
    -0
      source/backend/Makefile.mk
  2. +11
    -10
      source/discovery/Makefile
  3. +123
    -47
      source/discovery/carla-discovery.cpp
  4. +1
    -9
      source/modules/Makefile
  5. +3
    -1
      source/modules/utils/CarlaDssiUtils.hpp
  6. +0
    -2
      source/tests/ANSI.cpp

+ 2
- 0
source/backend/Makefile.mk View File

@@ -9,6 +9,8 @@ include ../../Makefile.mk
# -------------------------------------------------------------- # --------------------------------------------------------------


BACKEND_FLAGS = -I. -I.. -I../../includes -I../../libs -I../../utils BACKEND_FLAGS = -I. -I.. -I../../includes -I../../libs -I../../utils
BACKEND_FLAGS += -pedantic -pedantic-errors -Wunused-parameter -Wuninitialized -Wno-vla
BACKEND_FLAGS += -Wcast-qual -Wconversion -Wsign-conversion -Wlogical-op -Waggregate-return


BUILD_C_FLAGS += $(BACKEND_FLAGS) BUILD_C_FLAGS += $(BACKEND_FLAGS)
BUILD_CXX_FLAGS += $(BACKEND_FLAGS) BUILD_CXX_FLAGS += $(BACKEND_FLAGS)


+ 11
- 10
source/discovery/Makefile View File

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


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


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


ifeq ($(HAVE_QT4),true) ifeq ($(HAVE_QT4),true)
BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtCore) BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtCore)
@@ -51,6 +51,7 @@ WIN_64BIT_FLAGS = $(64BIT_FLAGS)
WIN_LINK_FLAGS = $(LINK_FLAGS) $(EXTRA_LIBS) -lole32 -luuid -lws2_32 WIN_LINK_FLAGS = $(LINK_FLAGS) $(EXTRA_LIBS) -lole32 -luuid -lws2_32


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


@@ -59,11 +60,11 @@ WIN_LINK_FLAGS += -lrpcrt4
endif endif


ifeq ($(CARLA_PLUGIN_SUPPORT),true) ifeq ($(CARLA_PLUGIN_SUPPORT),true)
LIBS = ../libs/lilv.a
LIBS_posix32 = ../libs/lilv.posix32.a
LIBS_posix64 = ../libs/lilv.posix64.a
LIBS_win32 = ../libs/lilv.win32.a
LIBS_win64 = ../libs/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 endif


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


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


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

+ 123
- 47
source/discovery/carla-discovery.cpp View File

@@ -12,11 +12,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * 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.
*/ */


#include "CarlaBackendUtils.hpp" #include "CarlaBackendUtils.hpp"
#include "CarlaJuceUtils.hpp"
#include "CarlaLibUtils.hpp" #include "CarlaLibUtils.hpp"
#include "CarlaString.hpp" #include "CarlaString.hpp"
#include "CarlaMIDI.h" #include "CarlaMIDI.h"
@@ -25,12 +24,11 @@
# include "CarlaLadspaUtils.hpp" # include "CarlaLadspaUtils.hpp"
#endif #endif
#ifdef WANT_DSSI #ifdef WANT_DSSI
# include "CarlaLadspaUtils.hpp"
# include "dssi/dssi.h"
# include "CarlaDssiUtils.hpp"
#endif #endif
#ifdef WANT_LV2 #ifdef WANT_LV2
# include <QtCore/QUrl>
# include "CarlaLv2Utils.hpp" # include "CarlaLv2Utils.hpp"
# include <QtCore/QUrl>
#endif #endif
#ifdef WANT_VST #ifdef WANT_VST
# include "CarlaVstUtils.hpp" # include "CarlaVstUtils.hpp"
@@ -39,8 +37,8 @@
# include <fluidsynth.h> # include <fluidsynth.h>
#endif #endif
#ifdef WANT_LINUXSAMPLER #ifdef WANT_LINUXSAMPLER
# include <QtCore/QFileInfo>
# include "linuxsampler/EngineFactory.h" # include "linuxsampler/EngineFactory.h"
# include <QtCore/QFileInfo>
#endif #endif


#include <iostream> #include <iostream>
@@ -49,13 +47,6 @@


CARLA_BACKEND_USE_NAMESPACE CARLA_BACKEND_USE_NAMESPACE


#ifdef WANT_LV2
// --------------------------------------------------------------------------
// Our LV2 World class object

Lv2WorldClass gLv2World;
#endif

// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Dummy values to test plugins with // Dummy values to test plugins with


@@ -67,8 +58,9 @@ const double kSampleRate = 44100.0;


void print_lib_error(const char* const filename) void print_lib_error(const char* const filename)
{ {
const char* const error = lib_error(filename);
if (error && strstr(error, "wrong ELF class") == nullptr && strstr(error, "Bad EXE format") == nullptr)
const char* const error(lib_error(filename));

if (error != nullptr && strstr(error, "wrong ELF class") == nullptr && strstr(error, "Bad EXE format") == nullptr)
DISCOVERY_OUT("error", error); DISCOVERY_OUT("error", error);
} }


@@ -133,7 +125,9 @@ intptr_t vstHostCanDo(const char* const feature)
// Host-side callback // Host-side callback
intptr_t VSTCALLBACK vstHostCallback(AEffect* const effect, const int32_t opcode, const int32_t index, const intptr_t value, void* const ptr, const float opt) intptr_t VSTCALLBACK vstHostCallback(AEffect* const effect, const int32_t opcode, const int32_t index, const intptr_t value, void* const ptr, const float opt)
{ {
carla_debug("vstHostCallback(%p, %s, %i, " P_INTPTR ", %p, %f)", effect, vstMasterOpcode2str(opcode), index, value, ptr, opt);
carla_debug("vstHostCallback(%p, %i:%s, %i, " P_INTPTR ", %p, %f)", effect, opcode, vstMasterOpcode2str(opcode), index, value, ptr, opt);

static VstTimeInfo_R timeInfo;


intptr_t ret = 0; intptr_t ret = 0;


@@ -159,7 +153,6 @@ intptr_t VSTCALLBACK vstHostCallback(AEffect* const effect, const int32_t opcode
#endif #endif


case audioMasterGetTime: case audioMasterGetTime:
static VstTimeInfo_R timeInfo;
carla_zeroStruct<VstTimeInfo_R>(timeInfo); carla_zeroStruct<VstTimeInfo_R>(timeInfo);
timeInfo.sampleRate = kSampleRate; timeInfo.sampleRate = kSampleRate;


@@ -185,7 +178,7 @@ intptr_t VSTCALLBACK vstHostCallback(AEffect* const effect, const int32_t opcode
break; break;


case audioMasterGetNumAutomatableParameters: case audioMasterGetNumAutomatableParameters:
ret = carla_min<int32_t>(effect->numParams, MAX_DEFAULT_PARAMETERS, 0);
ret = carla_min<intptr_t>(effect->numParams, MAX_DEFAULT_PARAMETERS, 0);
break; break;


case audioMasterGetParameterQuantization: case audioMasterGetParameterQuantization:
@@ -251,16 +244,11 @@ intptr_t VSTCALLBACK vstHostCallback(AEffect* const effect, const int32_t opcode
break; break;


default: default:
carla_stdout("vstHostCallback(%p, %s, %i, " P_INTPTR ", %p, %f)", effect, vstMasterOpcode2str(opcode), index, value, ptr, opt);
carla_stdout("vstHostCallback(%p, %i:%s, %i, " P_INTPTR ", %p, %f)", effect, opcode, vstMasterOpcode2str(opcode), index, value, ptr, opt);
break; break;
} }


return ret; return ret;

// unused
(void)index;
(void)value;
(void)opt;
} }
#endif #endif


@@ -272,8 +260,7 @@ class LinuxSamplerScopedEngine
{ {
public: public:
LinuxSamplerScopedEngine(const char* const filename, const char* const stype) LinuxSamplerScopedEngine(const char* const filename, const char* const stype)
: fEngine(nullptr),
fIns(nullptr)
: fEngine(nullptr)
{ {
using namespace LinuxSampler; using namespace LinuxSampler;


@@ -289,9 +276,9 @@ public:
if (fEngine == nullptr) if (fEngine == nullptr)
return; return;


fIns = fEngine->GetInstrumentManager();
InstrumentManager* const insMan(fEngine->GetInstrumentManager());


if (fIns == nullptr)
if (insMan == nullptr)
{ {
DISCOVERY_OUT("error", "Failed to get LinuxSampler instrument manager"); DISCOVERY_OUT("error", "Failed to get LinuxSampler instrument manager");
return; return;
@@ -300,7 +287,7 @@ public:
std::vector<InstrumentManager::instrument_id_t> ids; std::vector<InstrumentManager::instrument_id_t> ids;


try { try {
ids = fIns->GetInstrumentFileContent(filename);
ids = insMan->GetInstrumentFileContent(filename);
} }
catch (const InstrumentManagerException& e) catch (const InstrumentManagerException& e)
{ {
@@ -314,7 +301,7 @@ public:
InstrumentManager::instrument_info_t info; InstrumentManager::instrument_info_t info;


try { try {
info = fIns->GetInstrumentInfo(ids[0]);
info = insMan->GetInstrumentInfo(ids[0]);
} }
catch (const InstrumentManagerException& e) catch (const InstrumentManagerException& e)
{ {
@@ -328,7 +315,10 @@ public:
~LinuxSamplerScopedEngine() ~LinuxSamplerScopedEngine()
{ {
if (fEngine != nullptr) if (fEngine != nullptr)
{
LinuxSampler::EngineFactory::Destroy(fEngine); LinuxSampler::EngineFactory::Destroy(fEngine);
fEngine = nullptr;
}
} }


static void outputInfo(LinuxSampler::InstrumentManager::instrument_info_t* const info, const int programs, const char* const basename = nullptr) static void outputInfo(LinuxSampler::InstrumentManager::instrument_info_t* const info, const int programs, const char* const basename = nullptr)
@@ -363,18 +353,18 @@ public:


private: private:
LinuxSampler::Engine* fEngine; LinuxSampler::Engine* fEngine;
LinuxSampler::InstrumentManager* fIns;


CARLA_PREVENT_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LinuxSamplerScopedEngine) CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LinuxSamplerScopedEngine)
}; };
#endif #endif


// ------------------------------ Plugin Checks ----------------------------- // ------------------------------ Plugin Checks -----------------------------


void do_ladspa_check(void* const libHandle, const bool init)
void do_ladspa_check(void*& libHandle, const char* const filename, const bool init)
{ {
#ifdef WANT_LADSPA #ifdef WANT_LADSPA
const LADSPA_Descriptor_Function descFn = (LADSPA_Descriptor_Function)lib_symbol(libHandle, "ladspa_descriptor");
LADSPA_Descriptor_Function descFn = (LADSPA_Descriptor_Function)lib_symbol(libHandle, "ladspa_descriptor");


if (descFn == nullptr) if (descFn == nullptr)
{ {
@@ -385,6 +375,46 @@ void do_ladspa_check(void* const libHandle, const bool init)
unsigned long i = 0; unsigned long i = 0;
const LADSPA_Descriptor* descriptor; const LADSPA_Descriptor* descriptor;


{
descriptor = descFn(0);

if (descriptor == nullptr)
{
DISCOVERY_OUT("error", "Binary doesn't contain any plugins");
return;
}

if (init && descriptor->instantiate != nullptr && descriptor->cleanup != nullptr)
{
LADSPA_Handle handle = descriptor->instantiate(descriptor, kSampleRate);

if (handle == nullptr)
{
DISCOVERY_OUT("error", "Failed to init first LADSPA plugin");
return;
}

descriptor->cleanup(handle);

lib_close(libHandle);
libHandle = lib_open(filename);

if (libHandle == nullptr)
{
print_lib_error(filename);
return;
}

descFn = (LADSPA_Descriptor_Function)lib_symbol(libHandle, "ladspa_descriptor");

if (descFn == nullptr)
{
DISCOVERY_OUT("error", "Not a LADSPA plugin (#2)");
return;
}
}
}

while ((descriptor = descFn(i++)) != nullptr) while ((descriptor = descFn(i++)) != nullptr)
{ {
if (descriptor->instantiate == nullptr) if (descriptor->instantiate == nullptr)
@@ -463,7 +493,7 @@ void do_ladspa_check(void* const libHandle, const bool init)


if (handle == nullptr) if (handle == nullptr)
{ {
DISCOVERY_OUT("error", "Failed to init LADSPA plugin #2");
DISCOVERY_OUT("error", "Failed to init LADSPA plugin (#2)");
continue; continue;
} }


@@ -571,14 +601,15 @@ void do_ladspa_check(void* const libHandle, const bool init)


// unused // unused
(void)libHandle; (void)libHandle;
(void)filename;
(void)init; (void)init;
#endif #endif
} }


void do_dssi_check(void* const libHandle, const bool init)
void do_dssi_check(void*& libHandle, const char* const filename, const bool init)
{ {
#ifdef WANT_DSSI #ifdef WANT_DSSI
const DSSI_Descriptor_Function descFn = (DSSI_Descriptor_Function)lib_symbol(libHandle, "dssi_descriptor");
DSSI_Descriptor_Function descFn = (DSSI_Descriptor_Function)lib_symbol(libHandle, "dssi_descriptor");


if (descFn == nullptr) if (descFn == nullptr)
{ {
@@ -589,9 +620,51 @@ void do_dssi_check(void* const libHandle, const bool init)
unsigned long i = 0; unsigned long i = 0;
const DSSI_Descriptor* descriptor; const DSSI_Descriptor* descriptor;


{
descriptor = descFn(0);

if (descriptor == nullptr)
{
DISCOVERY_OUT("error", "Binary doesn't contain any plugins");
return;
}

const LADSPA_Descriptor* const ldescriptor(descriptor->LADSPA_Plugin);

if (init && ldescriptor->instantiate != nullptr && ldescriptor->cleanup != nullptr)
{
LADSPA_Handle handle = ldescriptor->instantiate(ldescriptor, kSampleRate);

if (handle == nullptr)
{
DISCOVERY_OUT("error", "Failed to init first LADSPA plugin");
return;
}

ldescriptor->cleanup(handle);

lib_close(libHandle);
libHandle = lib_open(filename);

if (libHandle == nullptr)
{
print_lib_error(filename);
return;
}

DSSI_Descriptor_Function descFn = (DSSI_Descriptor_Function)lib_symbol(libHandle, "dssi_descriptor");

if (descFn == nullptr)
{
DISCOVERY_OUT("error", "Not a DSSI plugin (#2)");
return;
}
}
}

while ((descriptor = descFn(i++)) != nullptr) while ((descriptor = descFn(i++)) != nullptr)
{ {
const LADSPA_Descriptor* const ldescriptor = descriptor->LADSPA_Plugin;
const LADSPA_Descriptor* const ldescriptor(descriptor->LADSPA_Plugin);


if (ldescriptor == nullptr) if (ldescriptor == nullptr)
{ {
@@ -688,7 +761,7 @@ void do_dssi_check(void* const libHandle, const bool init)


if (handle == nullptr) if (handle == nullptr)
{ {
DISCOVERY_OUT("error", "Failed to init DSSI plugin #2");
DISCOVERY_OUT("error", "Failed to init DSSI plugin (#2)");
continue; continue;
} }


@@ -779,7 +852,7 @@ void do_dssi_check(void* const libHandle, const bool init)
if (descriptor->run_synth != nullptr || descriptor->run_multiple_synths != nullptr) if (descriptor->run_synth != nullptr || descriptor->run_multiple_synths != nullptr)
{ {
snd_seq_event_t midiEvents[2]; snd_seq_event_t midiEvents[2];
memset(midiEvents, 0, sizeof(snd_seq_event_t)*2); //FIXME
carla_zeroStruct<snd_seq_event_t>(midiEvents, 2);


const unsigned long midiEventCount = 2; const unsigned long midiEventCount = 2;


@@ -839,6 +912,7 @@ void do_dssi_check(void* const libHandle, const bool init)


// unused // unused
(void)libHandle; (void)libHandle;
(void)filename;
(void)init; (void)init;
#endif #endif
} }
@@ -846,17 +920,19 @@ void do_dssi_check(void* const libHandle, const bool init)
void do_lv2_check(const char* const bundle, const bool init) void do_lv2_check(const char* const bundle, const bool init)
{ {
#ifdef WANT_LV2 #ifdef WANT_LV2
Lv2WorldClass& lv2World(Lv2WorldClass::getInstance());

// Convert bundle filename to URI // Convert bundle filename to URI
QString qBundle(QUrl::fromLocalFile(bundle).toString()); QString qBundle(QUrl::fromLocalFile(bundle).toString());
if (! qBundle.endsWith(QChar(OS_SEP))) if (! qBundle.endsWith(QChar(OS_SEP)))
qBundle += QChar(OS_SEP); qBundle += QChar(OS_SEP);


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


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


// Get all plugin URIs in this bundle // Get all plugin URIs in this bundle
QStringList URIs; QStringList URIs;
@@ -1069,7 +1145,7 @@ void do_lv2_check(const char* const bundle, const bool init)
#endif #endif
} }


void do_vst_check(void* const libHandle, const bool init)
void do_vst_check(void*& libHandle, const bool init)
{ {
#ifdef WANT_VST #ifdef WANT_VST
VST_Function vstFn = (VST_Function)lib_symbol(libHandle, "VSTPluginMain"); VST_Function vstFn = (VST_Function)lib_symbol(libHandle, "VSTPluginMain");
@@ -1556,9 +1632,9 @@ int main(int argc, char* argv[])


// never do init for dssi-vst, takes too long and it's crashy // never do init for dssi-vst, takes too long and it's crashy
#ifdef __USE_GNU #ifdef __USE_GNU
bool doInit = (strcasestr(filename, "dssi-vst") != nullptr);
bool doInit = (strcasestr(filename, "dssi-vst") == nullptr);
#else #else
bool doInit = (std::strstr(filename, "dssi-vst") != nullptr);
bool doInit = (std::strstr(filename, "dssi-vst") == nullptr);
#endif #endif


if (doInit && getenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS") != nullptr) if (doInit && getenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS") != nullptr)
@@ -1585,10 +1661,10 @@ int main(int argc, char* argv[])
switch (type) switch (type)
{ {
case PLUGIN_LADSPA: case PLUGIN_LADSPA:
do_ladspa_check(handle, doInit);
do_ladspa_check(handle, filename, doInit);
break; break;
case PLUGIN_DSSI: case PLUGIN_DSSI:
do_dssi_check(handle, doInit);
do_dssi_check(handle, filename, doInit);
break; break;
case PLUGIN_LV2: case PLUGIN_LV2:
do_lv2_check(filename, doInit); do_lv2_check(filename, doInit);


+ 1
- 9
source/modules/Makefile View File

@@ -48,14 +48,6 @@ theme_%:


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


utils:
$(MAKE) -C utils

utils_%:
$(MAKE) -C utils $*

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

widgets: widgets:
$(MAKE) -C widgets $(MAKE) -C widgets


@@ -90,4 +82,4 @@ clean:


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


.PHONY: dgl lilv rtmempool theme widgets
.PHONY: dgl juce_core lilv rtmempool theme widgets

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

@@ -18,7 +18,9 @@
#ifndef CARLA_DSSI_UTILS_HPP_INCLUDED #ifndef CARLA_DSSI_UTILS_HPP_INCLUDED
#define CARLA_DSSI_UTILS_HPP_INCLUDED #define CARLA_DSSI_UTILS_HPP_INCLUDED


#include "CarlaUtils.hpp"
#include "CarlaLadspaUtils.hpp"

#include "dssi/dssi.h"


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


+ 0
- 2
source/tests/ANSI.cpp View File

@@ -83,8 +83,6 @@
// #include "plugin/CarlaPluginThread.hpp" // #include "plugin/CarlaPluginThread.hpp"
// #include "plugin/CarlaPluginInternal.hpp" // #include "plugin/CarlaPluginInternal.hpp"


// #include "standalone/CarlaStandalone.cpp"

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




Loading…
Cancel
Save