Browse Source

Test ANSI C code linking against carla backend lib

tags/1.9.4
falkTX 11 years ago
parent
commit
12c681dca0
10 changed files with 169 additions and 142 deletions
  1. +1
    -1
      source/backend/CarlaEngine.hpp
  2. +7
    -6
      source/backend/CarlaHost.h
  3. +1
    -1
      source/backend/CarlaPlugin.hpp
  4. +3
    -0
      source/backend/Makefile.mk
  5. +48
    -60
      source/backend/standalone/CarlaStandalone.cpp
  6. +55
    -55
      source/backend/standalone/Makefile
  7. +23
    -15
      source/carla_backend.py
  8. +4
    -3
      source/tests/Makefile
  9. +26
    -0
      source/tests/ansi-pedantic-test.c
  10. +1
    -1
      source/utils/CarlaUtils.hpp

+ 1
- 1
source/backend/CarlaEngine.hpp View File

@@ -18,7 +18,7 @@
#ifndef CARLA_ENGINE_HPP_INCLUDED
#define CARLA_ENGINE_HPP_INCLUDED

#include "CarlaBackend.hpp"
#include "CarlaBackend.h"
#include "CarlaMIDI.h"
#include "CarlaString.hpp"



+ 7
- 6
source/backend/CarlaHost.h View File

@@ -36,6 +36,7 @@ using CarlaBackend::MidiProgramData;
using CarlaBackend::CustomData;
using CarlaBackend::EngineDriverDeviceInfo;
using CarlaBackend::CarlaEngine;
using CarlaBackend::CarlaPlugin;
#endif

/*!
@@ -472,16 +473,16 @@ typedef struct _CarlaTransportInfo {
* Get the complete license text of used third-party code and features.\n
* Returned string is in basic html format.
*/
CARLA_EXPORT const char* carla_get_extended_license_text();
CARLA_EXPORT const char* carla_get_complete_license_text();

/*!
* Get the supported file types in carla_load_filename().\n
* Get all the supported file types in carla_load_filename().\n
* Returned string uses this syntax:
* \code
* @code
* "*.ext1;*.ext2;*.ext3"
* \endcode
* @endcode
*/
CARLA_EXPORT const char* carla_get_supported_file_types();
CARLA_EXPORT const char* carla_get_supported_file_extensions();

/*!
* Get how many engine drivers are available to use.
@@ -947,4 +948,4 @@ CARLA_EXPORT const char* carla_get_host_osc_url_udp();

/** @} */

#endif // CARLA_HOST_H_INCLUDED
#endif /* CARLA_HOST_H_INCLUDED */

+ 1
- 1
source/backend/CarlaPlugin.hpp View File

@@ -18,7 +18,7 @@
#ifndef CARLA_PLUGIN_HPP_INCLUDED
#define CARLA_PLUGIN_HPP_INCLUDED

#include "CarlaBackend.hpp"
#include "CarlaBackend.h"
#include "CarlaString.hpp"

// Avoid including extra libs here


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

@@ -47,6 +47,9 @@ endif

ifeq ($(HAVE_ZYN_DEPS),true)
BUILD_CXX_FLAGS += -DWANT_ZYNADDSUBFX
ifeq ($(HAVE_ZYN_UI_DEPS),true)
BUILD_CXX_FLAGS += -DWANT_ZYNADDSUBFX_UI
endif
endif

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

+ 48
- 60
source/backend/standalone/CarlaStandalone.cpp View File

@@ -22,31 +22,17 @@
#include "CarlaEngine.hpp"
#include "CarlaPlugin.hpp"

#include "CarlaBackendUtils.hpp"
#include "CarlaOscUtils.hpp"
#include "CarlaNative.h"
//#include "CarlaBackendUtils.hpp"
//#include "CarlaOscUtils.hpp"
//#include "CarlaNative.h"

#ifdef USE_JUCE
# include "juce_gui_basics.h"
#endif

//#include "CarlaLogThread.hpp"
//#if ! (defined(DEBUG) || defined(WANT_LOGS) || defined(BUILD_ANSI_TEST))
//# define WANT_LOGS
//#endif

namespace CB = CarlaBackend;

using CB::CarlaEngine;
using CB::CarlaPlugin;
using CB::EngineCallbackFunc;
using CB::EngineOptions;
using CB::EngineTimeInfo;
using CB::FileCallbackFunc;

#ifdef USE_JUCE
using namespace juce;

// -----------------------------------------------------------------------
// Juce Message Thread

@@ -95,17 +81,22 @@ juce_ImplementSingleton(JuceMessageThread)
// Single, standalone engine

struct CarlaBackendStandalone {
EngineCallbackFunc callback;
void* callbackPtr;
CarlaEngine* engine;
EngineCallbackFunc engineCallback;
void* engineCallbackPtr;
//EngineOptions engineOptions;

FileCallbackFunc fileCallback;
void* fileCallbackPtr;

CarlaEngine* engine;
CarlaString lastError;
EngineOptions options;
CarlaString lastError;

CarlaBackendStandalone()
: callback(nullptr),
callbackPtr(nullptr),
engine(nullptr) {}
: engine(nullptr),
engineCallback(nullptr),
engineCallbackPtr(nullptr),
fileCallback(nullptr),
fileCallbackPtr(nullptr) {}

~CarlaBackendStandalone()
{
@@ -115,52 +106,35 @@ struct CarlaBackendStandalone {
#endif
}

#ifdef USE_JUCE
void init()
{
#ifdef USE_JUCE
JUCE_AUTORELEASEPOOL

initialiseJuce_GUI();
JuceMessageThread::getInstance();
#endif
}

void idle() {}

void close()
{
#ifdef USE_JUCE
JUCE_AUTORELEASEPOOL

JuceMessageThread::deleteInstance();
shutdownJuce_GUI();
#endif
}
#endif

CARLA_DECLARE_NON_COPY_STRUCT(CarlaBackendStandalone)
};

struct CarlaBackendFileHandler {
FileCallbackFunc callback;
void* callbackPtr;

CarlaBackendFileHandler()
: callback(nullptr),
callbackPtr(nullptr) {}
};

//#ifdef WANT_LOGS
//static CarlaLogThread gLogThread;
//#endif
static CarlaBackendStandalone gStandalone;
static CarlaBackendFileHandler gFileHandler;
static CarlaBackendStandalone gStandalone;

// -------------------------------------------------------------------------------------------------------------------
// API

const char* carla_get_extended_license_text()
const char* carla_get_complete_license_text()
{
carla_debug("carla_get_extended_license_text()");
carla_debug("carla_get_complete_license_text()");

static CarlaString retText;

@@ -205,23 +179,24 @@ const char* carla_get_extended_license_text()
text2 += "<li>LinuxSampler library for GIG and SFZ support*, http://www.linuxsampler.org/</li>";
#endif

#ifdef WANT_NATIVE
// Internal plugins
#ifdef WANT_OPENGL
# ifdef WANT_OPENGL
text3 += "<li>DISTRHO Mini-Series plugin code, based on LOSER-dev suite by Michael Gruhn</li>";
#endif
# endif
text3 += "<li>NekoFilter plugin code, based on lv2fil by Nedko Arnaudov and Fons Adriaensen</li>";
//text1 += "<li>SunVox library file support, http://www.warmplace.ru/soft/sunvox/</li>"; // unfinished

#ifdef WANT_AUDIOFILE
# ifdef WANT_AUDIOFILE
text3 += "<li>AudioDecoder library for Audio file support, by Robin Gareus</li>";
#endif
#ifdef WANT_MIDIFILE
# endif
# ifdef WANT_MIDIFILE
text3 += "<li>LibSMF library for MIDI file support, http://libsmf.sourceforge.net/</li>";
#endif
#ifdef WANT_ZYNADDSUBFX
# endif
# ifdef WANT_ZYNADDSUBFX
text3 += "<li>ZynAddSubFX plugin code, http://zynaddsubfx.sf.net/</li>";
# ifdef WANT_ZYNADDSUBFX_UI
# ifdef WANT_ZYNADDSUBFX_UI
text3 += "<li>ZynAddSubFX UI using NTK, http://non.tuxfamily.org/wiki/NTK</li>";
# endif
# endif
#endif

@@ -243,8 +218,8 @@ const char* carla_get_extended_license_text()
text5 += "<li>Real-time memory pool, by Nedko Arnaudov</li>";
text5 += "</ul>";

// LinuxSampler GPL exception
#ifdef WANT_LINUXSAMPLER
// LinuxSampler GPL exception
text5 += "<p>(*) Using LinuxSampler code in commercial hardware or software products is not allowed without prior written authorization by the authors.</p>";
#endif

@@ -254,9 +229,9 @@ const char* carla_get_extended_license_text()
return retText;
}

const char* carla_get_supported_file_types()
const char* carla_get_supported_file_extensions()
{
carla_debug("carla_get_supported_file_types()");
carla_debug("carla_get_supported_file_extensions()");

static CarlaString retText;

@@ -321,13 +296,14 @@ const char* const* carla_get_engine_driver_device_names(unsigned int index)
return CarlaEngine::getDriverDeviceNames(index);
}

const CarlaEngineDriverDeviceInfo* carla_get_engine_driver_device_info(unsigned int index, const char* deviceName)
const EngineDriverDeviceInfo* carla_get_engine_driver_device_info(unsigned int index, const char* deviceName)
{
carla_debug("carla_get_engine_driver_device_info(%i, \"%s\")", index, deviceName);

return CarlaEngine::getDriverDeviceInfo(index, deviceName);
}

#if 0
// -------------------------------------------------------------------------------------------------------------------

unsigned int carla_get_internal_plugin_count()
@@ -2245,6 +2221,18 @@ void carla_nsm_reply_save()

gCarlaNSM.replySave();
}
#endif

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

//#include "CarlaLogThread.hpp"
//#if ! (defined(DEBUG) || defined(WANT_LOGS) || defined(BUILD_ANSI_TEST))
//# define WANT_LOGS
//#endif

//#ifdef WANT_LOGS
//static CarlaLogThread gLogThread;
//#endif

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



+ 55
- 55
source/backend/standalone/Makefile View File

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

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

BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo)
# BUILD_CXX_FLAGS += $(shell pkg-config --cflags liblo)

# --------------------------------------------------------------
# Common

LINK_FLAGS += $(shell pkg-config --libs liblo)
# LINK_FLAGS += $(shell pkg-config --libs liblo)

LINK_FLAGS += $(JACKBRIDGE_LIBS)
# LINK_FLAGS += $(JACKBRIDGE_LIBS)
# LINK_FLAGS += $(JUCE_AUDIO_BASICS_LIBS)
# LINK_FLAGS += $(JUCE_CORE_LIBS)
# LINK_FLAGS += $(JUCE_DATA_STRUCTURES_LIBS)
# LINK_FLAGS += $(JUCE_EVENTS_LIBS)
# LINK_FLAGS += $(JUCE_GRAPHICS_LIBS)
# LINK_FLAGS += $(JUCE_GUI_BASICS_LIBS)
LINK_FLAGS += $(RTAUDIO_LIBS)
LINK_FLAGS += $(RTMIDI_LIBS)
LINK_FLAGS += $(RTMEMPOOL_LIBS)
ifeq ($(HAVE_OPENGL),true)
LINK_FLAGS += $(DGL_LIBS)
endif
ifeq ($(CARLA_PLUGIN_SUPPORT),true)
LINK_FLAGS += $(LILV_LIBS)
endif
# LINK_FLAGS += $(RTAUDIO_LIBS)
# LINK_FLAGS += $(RTMIDI_LIBS)
# LINK_FLAGS += $(RTMEMPOOL_LIBS)
#
# ifeq ($(HAVE_OPENGL),true)
# LINK_FLAGS += $(DGL_LIBS)
# endif
#
# ifeq ($(CARLA_PLUGIN_SUPPORT),true)
# LINK_FLAGS += $(LILV_LIBS)
# endif

# --------------------------------------------------------------
# Plugin

ifeq ($(HAVE_FLUIDSYNTH),true)
LINK_FLAGS += $(shell pkg-config --libs fluidsynth)
endif
ifeq ($(HAVE_LINUXSAMPLER),true)
LINK_FLAGS += $(shell pkg-config --libs linuxsampler)
ifeq ($(WIN32),true)
LINK_FLAGS += lrpcrt4
endif
endif
# ifeq ($(HAVE_FLUIDSYNTH),true)
# LINK_FLAGS += $(shell pkg-config --libs fluidsynth)
# endif
#
# ifeq ($(HAVE_LINUXSAMPLER),true)
# LINK_FLAGS += $(shell pkg-config --libs linuxsampler)
# ifeq ($(WIN32),true)
# LINK_FLAGS += lrpcrt4
# endif
# endif

# --------------------------------------------------------------
# Native

ifeq ($(HAVE_AF_DEPS),true)
LINK_FLAGS += $(shell pkg-config --libs sndfile)
ifeq ($(HAVE_FFMPEG),true)
LINK_FLAGS += $(shell pkg-config --libs libavcodec libavformat libavutil)
endif
endif
ifeq ($(HAVE_MF_DEPS),true)
LINK_FLAGS += $(shell pkg-config --libs smf)
endif
ifeq ($(HAVE_ZYN_DEPS),true)
LINK_FLAGS += $(shell pkg-config --libs fftw3 mxml zlib)
ifeq ($(HAVE_ZYN_UI_DEPS),true)
LINK_FLAGS += $(shell pkg-config --libs ntk_images ntk)
endif
endif
# ifeq ($(HAVE_AF_DEPS),true)
# LINK_FLAGS += $(shell pkg-config --libs sndfile)
# ifeq ($(HAVE_FFMPEG),true)
# LINK_FLAGS += $(shell pkg-config --libs libavcodec libavformat libavutil)
# endif
# endif
#
# ifeq ($(HAVE_MF_DEPS),true)
# LINK_FLAGS += $(shell pkg-config --libs smf)
# endif
#
# ifeq ($(HAVE_ZYN_DEPS),true)
# LINK_FLAGS += $(shell pkg-config --libs fftw3 mxml zlib)
# ifeq ($(HAVE_ZYN_UI_DEPS),true)
# LINK_FLAGS += $(shell pkg-config --libs ntk_images ntk)
# endif
# endif

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

LIBS = ../libcarla_engine.a
LIBS += ../libcarla_plugin.a
# LIBS = ../libcarla_engine.a
# LIBS += ../libcarla_plugin.a

LIBS += ../../modules/carla_native.a
LIBS += ../../modules/jackbridge.a
# LIBS += ../../modules/carla_native.a
# LIBS += ../../modules/jackbridge.a
# LIBS += ../../modules/juce_audio_basics.a
# LIBS += ../../modules/juce_core.a
# LIBS += ../../modules/juce_data_structures.a
# LIBS += ../../modules/juce_events.a
# LIBS += ../../modules/juce_graphics.a
# LIBS += ../../modules/juce_gui_basics.a
LIBS += ../../modules/rtaudio.a
LIBS += ../../modules/rtmidi.a
LIBS += ../../modules/rtmempool.a
# LIBS += ../../modules/rtaudio.a
# LIBS += ../../modules/rtmidi.a
# LIBS += ../../modules/rtmempool.a

ifeq ($(HAVE_OPENGL),true)
LIBS += ../../modules/dgl.a
endif
# ifeq ($(HAVE_OPENGL),true)
# LIBS += ../../modules/dgl.a
# endif

ifeq ($(CARLA_PLUGIN_SUPPORT),true)
LIBS += ../../modules/lilv.a
endif
# ifeq ($(CARLA_PLUGIN_SUPPORT),true)
# LIBS += ../../modules/lilv.a
# endif

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

@@ -100,7 +100,7 @@ OBJS = \
CarlaStandalone.cpp.o

HEADERS = \
../CarlaBackend.hpp ../CarlaEngine.hpp ../CarlaPlugin.hpp ../CarlaHost.hpp ../../modules/CarlaNative.h
../CarlaBackend.h ../CarlaHost.h ../CarlaEngine.hpp ../CarlaPlugin.hpp ../../modules/CarlaNative.h

ifeq ($(WIN32),true)
TARGET = ../libcarla_standalone2.dll


+ 23
- 15
source/carla_backend.py View File

@@ -889,16 +889,16 @@ class CarlaPluginInfo(Structure):
# @see PluginOptions
("optionsAvailable", c_uint),

# Plugin options currently enabled.\n
# Plugin options currently enabled.
# Some options are enabled but not available, which means they will always be on.
# @see PluginOptions
("optionsEnabled", c_uint),

# Plugin filename.\n
# Plugin filename.
# This can be the plugin binary or resource file.
("filename", c_char_p),

# Plugin name.\n
# Plugin name.
# This name is unique within a Carla instance.
# @see carla_get_real_plugin_name()
("name", c_char_p),
@@ -912,15 +912,15 @@ class CarlaPluginInfo(Structure):
# Plugin copyright/license.
("copyright", c_char_p),

# Icon name for this plugin, in lowercase.\n
# Icon name for this plugin, in lowercase.
# Default is "plugin".
("iconName", c_char_p),

# Patchbay client Id for this plugin.\n
# Patchbay client Id for this plugin.
# When 0, Id is considered invalid or unused.
("patchbayClientId", c_int),

# Plugin unique Id.\n
# Plugin unique Id.
# This Id is dependant on the plugin type and may sometimes be 0.
("uniqueId", c_long)
]
@@ -1104,12 +1104,18 @@ class Host(object):
object.__init__(self)
self._init(libName)

# ...
def get_extended_license_text(self):
return self.lib.carla_get_extended_license_text()
# Get the complete license text of used third-party code and features.
# Returned string is in basic html format.
def get_complete_license_text(self):
return self.lib.carla_get_complete_license_text()

def get_supported_file_types(self):
return self.lib.carla_get_supported_file_types()
# Get all the supported file types in carla_load_filename().
# Returned string uses this syntax:
# @code
# "*.ext1;*.ext2;*.ext3"
# @endcode
def get_supported_file_extensions(self):
return self.lib.carla_get_supported_file_extensions()

def get_engine_driver_count(self):
return self.lib.carla_get_engine_driver_count()
@@ -1373,11 +1379,13 @@ class Host(object):
def _init(self, libName):
self.lib = cdll.LoadLibrary(libName)

self.lib.carla_get_extended_license_text.argtypes = None
self.lib.carla_get_extended_license_text.restype = c_char_p
self.lib.carla_get_complete_license_text.argtypes = None
self.lib.carla_get_complete_license_text.restype = c_char_p

self.lib.carla_get_supported_file_extensions.argtypes = None
self.lib.carla_get_supported_file_extensions.restype = c_char_p

self.lib.carla_get_supported_file_types.argtypes = None
self.lib.carla_get_supported_file_types.restype = c_char_p
return

self.lib.carla_get_engine_driver_count.argtypes = None
self.lib.carla_get_engine_driver_count.restype = c_uint


+ 4
- 3
source/tests/Makefile View File

@@ -26,9 +26,10 @@ BUILD_CXX_FLAGS += -isystem /opt/kxstudio/include

ANSI_FLAGS = -DBUILD_ANSI_TEST -DREAL_BUILD -I/usr/include/carla -I/usr/include/carla/includes
ANSI_FLAGS += -Wall -Wextra -Werror
BASE_FLAGS += -DDEBUG -O0 -g
BASE_FLAGS += -ansi -pedantic -pedantic-errors
BASE_FLAGS += -Wunused-parameter -Wuninitialized -Wcast-qual -Wconversion -Wsign-conversion -Wlogical-op -Waggregate-return
ANSI_FLAGS += -DDEBUG -O0 -g
ANSI_FLAGS += -ansi -pedantic -pedantic-errors
ANSI_FLAGS += -Wunused-parameter -Wuninitialized -Wcast-qual -Wconversion -Wsign-conversion -Wlogical-op -Waggregate-return
ANSI_FLAGS += -L../backend -lcarla_standalone2

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



+ 26
- 0
source/tests/ansi-pedantic-test.c View File

@@ -18,11 +18,37 @@
#include "CarlaBackend.h"
#include "CarlaHost.h"

#include <stdio.h>

int main(int argc, char* argv[])
{
ParameterData a;
ParameterRanges b;
MidiProgramData c;
CustomData d;
EngineDriverDeviceInfo e;

CarlaPluginInfo f;
CarlaNativePluginInfo g;
CarlaPortCountInfo h;
CarlaParameterInfo i;
CarlaScalePointInfo j;
CarlaTransportInfo k;

const char* licenseText;
const char* fileExtensions;

licenseText = carla_get_complete_license_text();
printf("LICENSE:\n%s\n", licenseText);

fileExtensions = carla_get_supported_file_extensions();
printf("FILE EXTENSIONS:\n%s\n", fileExtensions);

return 0;

/* unused */
(void)argc;
(void)argv;
(void)a; (void)b; (void)c; (void)d; (void)e;
(void)f; (void)g; (void)h; (void)i; (void)j; (void)k;
}

+ 1
- 1
source/utils/CarlaUtils.hpp View File

@@ -18,7 +18,7 @@
#ifndef CARLA_UTILS_HPP_INCLUDED
#define CARLA_UTILS_HPP_INCLUDED

#include "CarlaDefines.hpp"
#include "CarlaDefines.h"

#include <cassert>
#include <cstdarg>


Loading…
Cancel
Save