Browse Source

CarlaString and misc fixes

tags/1.9.4
falkTX 12 years ago
parent
commit
14d7a22045
7 changed files with 43 additions and 29 deletions
  1. +4
    -2
      source/Makefile.mk
  2. +3
    -4
      source/backend/engine/carla_engine.cpp
  3. +3
    -3
      source/backend/engine/jack.cpp
  4. +13
    -2
      source/backend/plugin/carla_plugin.cpp
  5. +2
    -2
      source/backend/plugin/carla_plugin_internal.hpp
  6. +10
    -11
      source/utils/carla_utils.hpp
  7. +8
    -5
      source/utils/rt_list.hpp

+ 4
- 2
source/Makefile.mk View File

@@ -17,12 +17,14 @@ WINDRES ?= windres


DEBUG ?= false DEBUG ?= false


BASE_FLAGS = -Wall -Wextra

ifeq ($(DEBUG),true) ifeq ($(DEBUG),true)
BASE_FLAGS = -O0 -g
BASE_FLAGS += -O0 -g
BASE_FLAGS += -DDEBUG BASE_FLAGS += -DDEBUG
STRIP = true # FIXME STRIP = true # FIXME
else else
BASE_FLAGS = -O2 -ffast-math -mtune=generic -msse -mfpmath=sse
BASE_FLAGS += -O2 -ffast-math -mtune=generic -msse -mfpmath=sse
BASE_FLAGS += -DNDEBUG BASE_FLAGS += -DNDEBUG
endif endif




+ 3
- 4
source/backend/engine/carla_engine.cpp View File

@@ -819,11 +819,10 @@ void CarlaEngine::removeAllPlugins()


const unsigned int oldCount = fData->curPluginCount; const unsigned int oldCount = fData->curPluginCount;


// wait for processing
// TODO

fData->curPluginCount = 0; fData->curPluginCount = 0;
fData->maxPluginNumber = 0;

// wait for processing
waitForProccessEnd();


for (unsigned int i=0; i < oldCount; i++) for (unsigned int i=0; i < oldCount; i++)
{ {


+ 3
- 3
source/backend/engine/jack.cpp View File

@@ -146,7 +146,7 @@ public:


if (! kIsInput) if (! kIsInput)
return 0; return 0;
if (fJackBuffer != nullptr)
if (fJackBuffer == nullptr)
return 0; return 0;


return jackbridge_midi_get_event_count(fJackBuffer); return jackbridge_midi_get_event_count(fJackBuffer);
@@ -717,6 +717,8 @@ protected:


void handleJackProcessCallback(const uint32_t nframes) void handleJackProcessCallback(const uint32_t nframes)
{ {
proccessPendingEvents();

#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
if (fData->curPluginCount == 0) if (fData->curPluginCount == 0)
return; return;
@@ -944,8 +946,6 @@ protected:
#endif #endif
} }
#endif #endif

proccessPendingEvents();
} }


void handleJackLatencyCallback(const jack_latency_callback_mode_t mode) void handleJackLatencyCallback(const jack_latency_callback_mode_t mode)


+ 13
- 2
source/backend/plugin/carla_plugin.cpp View File

@@ -44,12 +44,19 @@ CarlaPlugin::CarlaPlugin(CarlaEngine* const engine, const unsigned int id)
CARLA_ASSERT(id < engine->maxPluginNumber()); CARLA_ASSERT(id < engine->maxPluginNumber());
qDebug("CarlaPlugin::CarlaPlugin(%p, %i)", engine, id); qDebug("CarlaPlugin::CarlaPlugin(%p, %i)", engine, id);


if (engine->getProccessMode() == PROCESS_MODE_CONTINUOUS_RACK)
switch (engine->getProccessMode())
{ {
case PROCESS_MODE_SINGLE_CLIENT:
case PROCESS_MODE_MULTIPLE_CLIENTS:
fData->ctrlInChannel = 0;
break;
case PROCESS_MODE_CONTINUOUS_RACK:
CARLA_ASSERT(id < MAX_RACK_PLUGINS && id < MAX_MIDI_CHANNELS); CARLA_ASSERT(id < MAX_RACK_PLUGINS && id < MAX_MIDI_CHANNELS);


if (id < MAX_RACK_PLUGINS && id < MAX_MIDI_CHANNELS) if (id < MAX_RACK_PLUGINS && id < MAX_MIDI_CHANNELS)
fData->ctrlInChannel = id; fData->ctrlInChannel = id;

break;
} }
} }


@@ -1201,7 +1208,8 @@ void CarlaPlugin::postRtEventsRun()
while (! fData->postRtEvents.data.isEmpty()) while (! fData->postRtEvents.data.isEmpty())
{ {
PluginPostRtEvent& event = fData->postRtEvents.data.getFirst(true); PluginPostRtEvent& event = fData->postRtEvents.data.getFirst(true);
listData[i++] = event;
//listData[i++] = event;
std::memcpy(&listData[i++], &event, sizeof(PluginPostRtEvent));
} }


fData->postRtEvents.mutex.unlock(); fData->postRtEvents.mutex.unlock();
@@ -1211,6 +1219,9 @@ void CarlaPlugin::postRtEventsRun()
{ {
const PluginPostRtEvent* const event = &listData[i]; const PluginPostRtEvent* const event = &listData[i];


if (event->type != kPluginPostRtEventNull)
qWarning("postRtEventsRun() - event type %i", i);

switch (event->type) switch (event->type)
{ {
case kPluginPostRtEventNull: case kPluginPostRtEventNull:


+ 2
- 2
source/backend/plugin/carla_plugin_internal.hpp View File

@@ -73,7 +73,7 @@ struct PluginAudioData {
CARLA_ASSERT(ports == nullptr); CARLA_ASSERT(ports == nullptr);
} }


void createNew(const size_t count)
void createNew(const uint32_t count)
{ {
CARLA_ASSERT(ports == nullptr); CARLA_ASSERT(ports == nullptr);


@@ -176,7 +176,7 @@ struct PluginParameterData {
CARLA_ASSERT(ranges == nullptr); CARLA_ASSERT(ranges == nullptr);
} }


void createNew(const size_t count)
void createNew(const uint32_t count)
{ {
CARLA_ASSERT(data == nullptr); CARLA_ASSERT(data == nullptr);
CARLA_ASSERT(ranges == nullptr); CARLA_ASSERT(ranges == nullptr);


+ 10
- 11
source/utils/carla_utils.hpp View File

@@ -321,7 +321,7 @@ public:


explicit CarlaString(const int value) explicit CarlaString(const int value)
{ {
const size_t strBufSize = (unsigned int)std::abs(value/10) + 3;
const size_t strBufSize = std::abs(value/10) + 3;
char strBuf[strBufSize]; char strBuf[strBufSize];
std::snprintf(strBuf, strBufSize, "%d", value); std::snprintf(strBuf, strBufSize, "%d", value);


@@ -341,7 +341,7 @@ public:


explicit CarlaString(const long int value) explicit CarlaString(const long int value)
{ {
const size_t strBufSize = (unsigned long)std::abs(value/10) + 3;
const size_t strBufSize = std::abs(value/10) + 3;
char strBuf[strBufSize]; char strBuf[strBufSize];
std::snprintf(strBuf, strBufSize, "%ld", value); std::snprintf(strBuf, strBufSize, "%ld", value);


@@ -364,6 +364,7 @@ public:
char strBuf[0xff]; char strBuf[0xff];
std::snprintf(strBuf, 0xff, "%f", value); std::snprintf(strBuf, 0xff, "%f", value);


_init();
_dup(strBuf); _dup(strBuf);
} }


@@ -418,8 +419,6 @@ public:
{ {
if (strBuf == nullptr) if (strBuf == nullptr)
return false; return false;
if (bufferLen == 0)
return false;


if (ignoreCase) if (ignoreCase)
return (std::strcasestr(buffer, strBuf) != nullptr); return (std::strcasestr(buffer, strBuf) != nullptr);
@@ -436,8 +435,6 @@ public:
{ {
if (strBuf == nullptr) if (strBuf == nullptr)
return false; return false;
if (bufferLen == 0)
return false;


return (std::strstr(buffer, strBuf) != nullptr); return (std::strstr(buffer, strBuf) != nullptr);
} }
@@ -477,11 +474,13 @@ public:


void truncate(const size_t n) void truncate(const size_t n)
{ {
if (n >= bufferLen)
return;

for (size_t i=n; i < bufferLen; i++) for (size_t i=n; i < bufferLen; i++)
buffer[i] = '\0'; buffer[i] = '\0';


// FIXME
bufferLen = std::strlen(buffer);
bufferLen = n;
} }


void toBasic() void toBasic()
@@ -570,13 +569,13 @@ public:


CarlaString& operator+=(const char* const strBuf) CarlaString& operator+=(const char* const strBuf)
{ {
const size_t newBufSize = std::strlen(buffer) + ((strBuf != nullptr) ? std::strlen(strBuf) : 0) + 1;
const size_t newBufSize = bufferLen + ((strBuf != nullptr) ? std::strlen(strBuf) : 0) + 1;
char newBuf[newBufSize]; char newBuf[newBufSize];


std::strcpy(newBuf, buffer); std::strcpy(newBuf, buffer);
std::strcat(newBuf, strBuf); std::strcat(newBuf, strBuf);


_dup(newBuf, newBufSize);
_dup(newBuf, newBufSize-1);


return *this; return *this;
} }
@@ -588,7 +587,7 @@ public:


CarlaString operator+(const char* const strBuf) CarlaString operator+(const char* const strBuf)
{ {
const size_t newBufSize = std::strlen(buffer) + ((strBuf != nullptr) ? std::strlen(strBuf) : 0) + 1;
const size_t newBufSize = bufferLen + ((strBuf != nullptr) ? std::strlen(strBuf) : 0) + 1;
char newBuf[newBufSize]; char newBuf[newBufSize];


std::strcpy(newBuf, buffer); std::strcpy(newBuf, buffer);


+ 8
- 5
source/utils/rt_list.hpp View File

@@ -26,14 +26,17 @@ extern "C" {
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>


// list_entry C++11 version (using nullptr instead of 0)
#undef list_entry
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)nullptr)->member)))

// Declare non copyable and prevent heap allocation // Declare non copyable and prevent heap allocation
#define LIST_DECLARATIONS(className) \ #define LIST_DECLARATIONS(className) \
className(const className&); \ className(const className&); \
className& operator= (const className&);

// FIXME
//static void* operator new (size_t);
//static void operator delete (void*);
className& operator= (const className&); \
static void* operator new (size_t) { return nullptr; } \
static void operator delete (void*) {}


typedef struct list_head k_list_head; typedef struct list_head k_list_head;




Loading…
Cancel
Save