@@ -39,7 +39,6 @@ CARLA_BACKEND_START_NAMESPACE | |||
* @{ | |||
*/ | |||
class CarlaEngine; | |||
class CarlaEngineClient; | |||
class CarlaEngineAudioPort; | |||
@@ -109,24 +109,6 @@ | |||
# define BINARY_NATIVE BINARY_OTHER | |||
#endif | |||
// Define CARLA_DECLARE_NON_COPY_STRUCT | |||
#ifdef CARLA_PROPER_CPP11_SUPPORT | |||
# define CARLA_DECLARE_NON_COPY_STRUCT(StructName) \ | |||
StructName(StructName&) = delete; \ | |||
StructName(const StructName&) = delete; \ | |||
StructName& operator=(const StructName&) = delete; | |||
#else | |||
# define CARLA_DECLARE_NON_COPY_STRUCT(StructName) | |||
#endif | |||
// Define CARLA_SAFE_ASSERT* | |||
#define CARLA_SAFE_ASSERT(cond) if (cond) pass(); else carla_assert (#cond, __FILE__, __LINE__); | |||
#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_RETURN(cond, ret) if (cond) pass(); else { carla_assert(#cond, __FILE__, __LINE__); return ret; } | |||
// Define CARLA_ASSERT* | |||
#if defined(CARLA_NO_ASSERTS) | |||
# define CARLA_ASSERT(cond) | |||
@@ -142,6 +124,24 @@ | |||
# define CARLA_ASSERT_INT2(cond, v1, v2) assert(cond) | |||
#endif | |||
// Define CARLA_SAFE_ASSERT* | |||
#define CARLA_SAFE_ASSERT(cond) if (cond) pass(); else carla_assert (#cond, __FILE__, __LINE__); | |||
#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_RETURN(cond, ret) if (cond) pass(); else { carla_assert(#cond, __FILE__, __LINE__); return ret; } | |||
// Define CARLA_DECLARE_NON_COPY_STRUCT | |||
#ifdef CARLA_PROPER_CPP11_SUPPORT | |||
# define CARLA_DECLARE_NON_COPY_STRUCT(StructName) \ | |||
StructName(StructName&) = delete; \ | |||
StructName(const StructName&) = delete; \ | |||
StructName& operator=(const StructName&) = delete; | |||
#else | |||
# define CARLA_DECLARE_NON_COPY_STRUCT(StructName) | |||
#endif | |||
// Define CARLA_EXPORT | |||
#ifdef BUILD_BRIDGE | |||
# define CARLA_EXPORT extern "C" | |||
@@ -0,0 +1 @@ | |||
../modules/lilv/serd-0.18.2/serd/ |
@@ -0,0 +1 @@ | |||
../modules/lilv/sord-0.12.0/sord/ |
@@ -0,0 +1 @@ | |||
../modules/lilv/sratom-0.4.2/sratom/ |
@@ -16,6 +16,14 @@ dgl_%: | |||
# -------------------------------------------------------------- | |||
juce_core: | |||
$(MAKE) -C juce_core | |||
juce_core_%: | |||
$(MAKE) -C juce_core $* | |||
# -------------------------------------------------------------- | |||
lilv: | |||
$(MAKE) -C lilv | |||
@@ -15,7 +15,6 @@ LILV_VERSION = 0.16.0 | |||
BUILD_C_FLAGS += -w | |||
BUILD_C_FLAGS += -Iconfig -I../../includes | |||
BUILD_C_FLAGS += -Iserd-$(SERD_VERSION) -Isord-$(SORD_VERSION) -Isratom-$(SRATOM_VERSION) | |||
OBJS = serd.c.o sord.c.o sratom.c.o lilv.c.o | |||
OBJS_posix32 = serd.c.posix32.o sord.c.posix32.o sratom.c.posix32.o lilv.c.posix32.o | |||
@@ -1,6 +1,5 @@ | |||
/* | |||
* Carla Bridge utils imported from dssi-vst code | |||
* Copyright (C) 2004-2010 Chris Cannam <cannam@all-day-breakfast.com> | |||
* Carla Bridge utils | |||
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
@@ -13,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_BRIDGE_UTILS_HPP_INCLUDED | |||
@@ -69,20 +68,16 @@ const char* const CARLA_BRIDGE_MSG_SET_CUSTOM = "CarlaBridgeSetCustom"; //!< Hos | |||
// ----------------------------------------------------------------------- | |||
struct BridgeShmControl { | |||
// 32 and 64-bit binaries align semaphores differently. | |||
// Let's make sure there's plenty of room for either one. | |||
union { | |||
void* runServer; | |||
char _alignServer[128]; | |||
char _padServer[32]; | |||
}; | |||
union { | |||
void* runClient; | |||
char _alignClient[128]; | |||
char _padClient[32]; | |||
}; | |||
RingBuffer ringBuffer; | |||
CARLA_DECLARE_NON_COPY_STRUCT(BridgeShmControl) | |||
}; | |||
} __attribute__((__packed__)); | |||
// ----------------------------------------------------------------------- | |||
@@ -168,4 +163,6 @@ const char* PluginBridgeOpcode2str(const PluginBridgeOpcode opcode) | |||
return nullptr; | |||
} | |||
// ----------------------------------------------------------------------- | |||
#endif // CARLA_BRIDGE_UTILS_HPP_INCLUDED |
@@ -1,5 +1,5 @@ | |||
/* | |||
* Carla Ring Buffer imported from dssi-vst code | |||
* Carla Ring Buffer based on dssi-vst code | |||
* Copyright (C) 2004-2010 Chris Cannam <cannam@all-day-breakfast.com> | |||
* Copyright (C) 2013 Filipe Coelho <falktx@falktx.com> | |||
* | |||
@@ -13,26 +13,26 @@ | |||
* 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_RING_BUFFER_HPP_INCLUDED | |||
#define CARLA_RING_BUFFER_HPP_INCLUDED | |||
#include "CarlaJuceUtils.hpp" | |||
#include "CarlaUtils.hpp" | |||
#define RING_BUFFER_SIZE 2048 | |||
#ifndef RING_BUFFER_SIZE | |||
# define RING_BUFFER_SIZE 2048 | |||
#endif | |||
// ----------------------------------------------------------------------- | |||
// RingBuffer struct | |||
struct RingBuffer { | |||
int head, tail, written; | |||
bool invalidateCommit; | |||
char buf[RING_BUFFER_SIZE]; | |||
CARLA_DECLARE_NON_COPY_STRUCT(RingBuffer) | |||
}; | |||
int32_t head, tail, written; | |||
bool invalidateCommit; | |||
char buf[RING_BUFFER_SIZE]; | |||
} __attribute__((__packed__)); | |||
// ----------------------------------------------------------------------- | |||
// RingBufferControl class | |||
@@ -61,18 +61,14 @@ public: | |||
fRingBuf->tail = 0; | |||
fRingBuf->written = 0; | |||
fRingBuf->invalidateCommit = false; | |||
carla_fill<char>(fRingBuf->buf, RING_BUFFER_SIZE, 0); | |||
carla_zeroChar(fRingBuf->buf, RING_BUFFER_SIZE); | |||
} | |||
// --------------------------------------------- | |||
// ------------------------------------------------------------------- | |||
void commitWrite() | |||
{ | |||
CARLA_ASSERT(fRingBuf != nullptr); | |||
if (fRingBuf == nullptr) | |||
return; | |||
CARLA_SAFE_ASSERT_RETURN(fRingBuf != nullptr,); | |||
if (fRingBuf->invalidateCommit) | |||
{ | |||
@@ -87,23 +83,12 @@ public: | |||
bool dataAvailable() const | |||
{ | |||
CARLA_ASSERT(fRingBuf != nullptr); | |||
if (fRingBuf == nullptr) | |||
return false; | |||
CARLA_SAFE_ASSERT_RETURN(fRingBuf != nullptr, false); | |||
return (fRingBuf->tail != fRingBuf->head); | |||
return (fRingBuf->head != fRingBuf->tail); | |||
} | |||
// --------------------------------------------- | |||
template<typename T> | |||
T read() | |||
{ | |||
T t = 0; | |||
tryRead(&t, sizeof(T)); | |||
return t; | |||
} | |||
// ------------------------------------------------------------------- | |||
char readChar() | |||
{ | |||
@@ -112,17 +97,17 @@ public: | |||
return c; | |||
} | |||
int readInt() | |||
int32_t readInt() | |||
{ | |||
int i = 0; | |||
tryRead(&i, sizeof(int)); | |||
int32_t i = 0; | |||
tryRead(&i, sizeof(int32_t)); | |||
return i; | |||
} | |||
long readLong() | |||
int64_t readLong() | |||
{ | |||
long l = 0; | |||
tryRead(&l, sizeof(long)); | |||
int64_t l = 0; | |||
tryRead(&l, sizeof(int64_t)); | |||
return l; | |||
} | |||
@@ -133,27 +118,21 @@ public: | |||
return f; | |||
} | |||
// --------------------------------------------- | |||
template<typename T> | |||
void write(const T value) | |||
{ | |||
tryWrite(&value, sizeof(T)); | |||
} | |||
// ------------------------------------------------------------------- | |||
void writeChar(const char value) | |||
{ | |||
tryWrite(&value, sizeof(char)); | |||
} | |||
void writeInt(const int value) | |||
void writeInt(const int32_t value) | |||
{ | |||
tryWrite(&value, sizeof(int)); | |||
tryWrite(&value, sizeof(int32_t)); | |||
} | |||
void writeLong(const long value) | |||
void writeLong(const int64_t value) | |||
{ | |||
tryWrite(&value, sizeof(long)); | |||
tryWrite(&value, sizeof(int64_t)); | |||
} | |||
void writeFloat(const float value) | |||
@@ -161,37 +140,37 @@ public: | |||
tryWrite(&value, sizeof(float)); | |||
} | |||
// --------------------------------------------- | |||
// ------------------------------------------------------------------- | |||
private: | |||
RingBuffer* fRingBuf; | |||
void tryRead(void* const buf, const size_t size) | |||
{ | |||
CARLA_ASSERT(fRingBuf != nullptr); | |||
CARLA_ASSERT(buf != nullptr); | |||
CARLA_ASSERT(size != 0); | |||
if (fRingBuf == nullptr) | |||
return; | |||
if (buf == nullptr) | |||
return; | |||
if (size == 0) | |||
return; | |||
CARLA_SAFE_ASSERT_RETURN(fRingBuf != nullptr,); | |||
CARLA_SAFE_ASSERT_RETURN(buf != nullptr,); | |||
CARLA_SAFE_ASSERT_RETURN(size != 0,); | |||
// this should not happen | |||
CARLA_ASSERT(fRingBuf->head >= 0); | |||
CARLA_ASSERT(fRingBuf->tail >= 0); | |||
CARLA_ASSERT(fRingBuf->written >= 0); | |||
// empty | |||
if (fRingBuf->head == fRingBuf->tail) | |||
return; | |||
char* const charbuf(static_cast<char*>(buf)); | |||
const size_t head(fRingBuf->head); | |||
const size_t tail(fRingBuf->tail); | |||
const size_t wrap((head <= tail) ? RING_BUFFER_SIZE : 0); | |||
const size_t head(static_cast<size_t>(fRingBuf->head)); | |||
const size_t tail(static_cast<size_t>(fRingBuf->tail)); | |||
const size_t wrap((head < tail) ? RING_BUFFER_SIZE : 0); | |||
if (head - tail + wrap < size) | |||
{ | |||
carla_stderr2("RingBufferControl::tryRead() - failed"); | |||
return; | |||
} | |||
size_t readto = tail + size; | |||
@@ -207,50 +186,48 @@ private: | |||
std::memcpy(charbuf, fRingBuf->buf + tail, size); | |||
} | |||
fRingBuf->tail = readto; | |||
fRingBuf->tail = static_cast<int32_t>(readto); | |||
} | |||
void tryWrite(const void* const buf, const size_t size) | |||
{ | |||
CARLA_ASSERT(fRingBuf != nullptr); | |||
CARLA_ASSERT(buf != nullptr); | |||
CARLA_ASSERT(size != 0); | |||
CARLA_SAFE_ASSERT_RETURN(fRingBuf != nullptr,); | |||
CARLA_SAFE_ASSERT_RETURN(buf != nullptr,); | |||
CARLA_SAFE_ASSERT_RETURN(size != 0,); | |||
if (fRingBuf == nullptr) | |||
return; | |||
if (buf == nullptr) | |||
return; | |||
if (size == 0) | |||
return; | |||
// this should not happen | |||
CARLA_ASSERT(fRingBuf->head >= 0); | |||
CARLA_ASSERT(fRingBuf->tail >= 0); | |||
CARLA_ASSERT(fRingBuf->written >= 0); | |||
const char* const charbuf(static_cast<const char*>(buf)); | |||
const size_t tail(fRingBuf->tail); | |||
const size_t written(fRingBuf->written); | |||
const size_t wrap((tail <= written) ? RING_BUFFER_SIZE : 0); | |||
const size_t tail(static_cast<size_t>(fRingBuf->tail)); | |||
const size_t wrtn(static_cast<size_t>(fRingBuf->written)); | |||
const size_t wrap((tail <= wrtn) ? RING_BUFFER_SIZE : 0); | |||
if (tail - written + wrap < size) | |||
if (tail - wrtn + wrap <= size) | |||
{ | |||
carla_stderr2("RingBufferControl::tryWrite() - buffer full!"); | |||
fRingBuf->invalidateCommit = true; | |||
return; | |||
} | |||
size_t writeto = written + size; | |||
size_t writeto = wrtn + size; | |||
if (writeto >= RING_BUFFER_SIZE) | |||
{ | |||
writeto -= RING_BUFFER_SIZE; | |||
const size_t firstpart(RING_BUFFER_SIZE - written); | |||
std::memcpy(fRingBuf->buf + written, charbuf, firstpart); | |||
const size_t firstpart(RING_BUFFER_SIZE - wrtn); | |||
std::memcpy(fRingBuf->buf + wrtn, charbuf, firstpart); | |||
std::memcpy(fRingBuf->buf, charbuf + firstpart, writeto); | |||
} | |||
else | |||
{ | |||
std::memcpy(fRingBuf->buf + written, charbuf, size); | |||
std::memcpy(fRingBuf->buf + wrtn, charbuf, size); | |||
} | |||
fRingBuf->written = writeto; | |||
fRingBuf->written = static_cast<int32_t>(writeto); | |||
} | |||
}; | |||
@@ -18,6 +18,8 @@ | |||
#undef NDEBUG | |||
#define DEBUG | |||
#define RING_BUFFER_SIZE 48 | |||
// includes | |||
#include "CarlaDefines.hpp" | |||
#include "CarlaMIDI.h" | |||
@@ -27,27 +29,29 @@ | |||
// Carla Backend API | |||
#include "CarlaBackend.hpp" | |||
// Carla utils (part 1/3) | |||
// Carla utils (part 1/4) | |||
#include "CarlaUtils.hpp" | |||
#include "CarlaJuceUtils.hpp" | |||
// Carla utils (part 2/3) | |||
// Carla utils (part 2/4) | |||
#include "CarlaMutex.hpp" | |||
#include "CarlaRingBuffer.hpp" | |||
#include "CarlaString.hpp" | |||
#include "Lv2AtomQueue.hpp" | |||
#include "RtList.hpp" | |||
// Carla utils (part 3/3) | |||
// Carla utils (part 3/4) | |||
#include "CarlaBackendUtils.hpp" | |||
#include "CarlaBridgeUtils.hpp" | |||
#include "CarlaLadspaUtils.hpp" | |||
#include "CarlaLibUtils.hpp" | |||
#include "CarlaLv2Utils.hpp" | |||
#include "CarlaOscUtils.hpp" | |||
#include "CarlaShmUtils.hpp" | |||
#include "CarlaStateUtils.hpp" | |||
#include "CarlaVstUtils.hpp" | |||
// #include "CarlaLadspaUtils.hpp" | |||
// #include "CarlaLibUtils.hpp" | |||
// #include "CarlaLv2Utils.hpp" | |||
// #include "CarlaOscUtils.hpp" | |||
// #include "CarlaShmUtils.hpp" | |||
// #include "CarlaStateUtils.hpp" | |||
// #include "CarlaVstUtils.hpp" | |||
// Carla utils (part 4/4) | |||
// #include "Lv2AtomQueue.hpp" | |||
// Carla Native Plugin API | |||
#include "CarlaNative.h" | |||
@@ -80,6 +84,7 @@ int safe_assert_return_test(bool test) | |||
int main() | |||
{ | |||
#if 0 | |||
// ladspa rdf | |||
{ | |||
LADSPA_RDF_ScalePoint a; | |||
@@ -459,6 +464,67 @@ int main() | |||
m.unlock(); | |||
const CarlaMutex::ScopedLocker sl(m); | |||
} | |||
#endif | |||
// RingBuffer | |||
{ | |||
RingBuffer buf; | |||
RingBufferControl ctrl(&buf); | |||
assert(! ctrl.dataAvailable()); | |||
assert(ctrl.readInt() == 0); | |||
assert(ctrl.readFloat() == 0.0f); | |||
assert(! ctrl.dataAvailable()); | |||
ctrl.writeChar('z'); | |||
ctrl.commitWrite(); | |||
assert(ctrl.dataAvailable()); | |||
const char c = ctrl.readChar(); | |||
carla_stdout("BufRead c = \"%c\"", c); | |||
assert(c != '\0'); | |||
assert(c == 'z'); | |||
assert(! ctrl.dataAvailable()); | |||
ctrl.writeInt(9999); | |||
ctrl.commitWrite(); | |||
const int i = ctrl.readInt(); | |||
carla_stdout("BufRead i = \"%i\"", i); | |||
assert(i != 0); | |||
assert(i == 9999); | |||
ctrl.writeLong(-88088); | |||
ctrl.commitWrite(); | |||
const long l = ctrl.readLong(); | |||
carla_stdout("BufRead l = \"%li\"", l); | |||
assert(l != 0); | |||
assert(l == -88088); | |||
ctrl.writeFloat(5.6789f); | |||
ctrl.commitWrite(); | |||
const float f = ctrl.readFloat(); | |||
carla_stdout("BufRead f = \"%f\"", f); | |||
assert(f != 0.0f); | |||
assert(f == 5.6789f); | |||
assert(! ctrl.dataAvailable()); | |||
for (char i='1'; i <= 'z'; ++i) | |||
{ | |||
ctrl.writeChar(char(i)); | |||
ctrl.commitWrite(); | |||
} | |||
assert(ctrl.dataAvailable()); | |||
printf("CHAR DUMP:\n"); | |||
while (ctrl.dataAvailable()) | |||
printf("%c", ctrl.readChar()); | |||
assert(! ctrl.dataAvailable()); | |||
printf("\nDUMP FINISHED"); | |||
} | |||
return 0; | |||
} |
@@ -8,11 +8,12 @@ include ../Makefile.mk | |||
# -------------------------------------------------------------- | |||
BUILD_CXX_FLAGS += -I../backend -I../backend/plugin -I../includes -I../libs -I../theme -I../utils | |||
BUILD_CXX_FLAGS += -I../backend -I../includes -I../modules -I../modules/theme -I../modules/utils | |||
BUILD_CXX_FLAGS += -DWANT_NATIVE -DWANT_LADSPA -DWANT_DSSI -DWANT_LV2 -DWANT_VST -DWANT_FLUIDSYNTH -DWANT_LINUXSAMPLER | |||
BUILD_CXX_FLAGS += -DWANT_RTAUDIO -DWANT_OPENGL -DWANT_AUDIOFILE -DWANT_MIDIFILE -DWANT_ZYNADDSUBFX -DWANT_ZYNADDSUBFX_UI | |||
# BUILD_CXX_FLAGS += -isystem ../libs/juce | |||
BUILD_CXX_FLAGS += -isystem /usr/include/qt4 | |||
BUILD_CXX_FLAGS += -isystem /opt/kxstudio/include | |||
# BUILD_CXX_FLAGS += -isystem ../backend/engine/rtaudio-4.0.11 | |||
# BUILD_CXX_FLAGS += -I/opt/mingw32/include | |||