@@ -620,7 +620,7 @@ enum ProcessMode { | |||
*/ | |||
enum TransportMode { | |||
TRANSPORT_MODE_INTERNAL = 0, //!< Internal transport mode. | |||
TRANSPORT_MODE_JACK = 1, //!< JACK transport, only available if driver name is "JACK" | |||
TRANSPORT_MODE_JACK = 1 //!< JACK transport, only available if driver name is "JACK" | |||
}; | |||
/*! | |||
@@ -107,7 +107,7 @@ INCLUDEPATH = .. \ | |||
# ----------------------------------------------------------- | |||
DEFINES = QTCREATOR_TEST | |||
DEFINES = QTCREATOR_TEST HAVE_CPP11_SUPPORT | |||
DEFINES += DEBUG | |||
#DEFINES += VESTIGE_HEADER | |||
DEFINES += BUILD_BRIDGE BUILD_BRIDGE_PLUGIN BRIDGE_PLUGIN | |||
@@ -316,6 +316,7 @@ PROCESS_MODE_SINGLE_CLIENT = 0 | |||
PROCESS_MODE_MULTIPLE_CLIENTS = 1 | |||
PROCESS_MODE_CONTINUOUS_RACK = 2 | |||
PROCESS_MODE_PATCHBAY = 3 | |||
PROCESS_MODE_BRIDGE = 4 | |||
# Transport Mode | |||
TRANSPORT_MODE_INTERNAL = 0 | |||
@@ -23,7 +23,7 @@ | |||
# define CARLA_OS_MAC | |||
#elif defined(__HAIKU__) | |||
# define CARLA_OS_HAIKU | |||
#elif defined(__linux__) || defined(__linux) || defined(QTCREATOR_TEST) | |||
#elif defined(__linux__) || defined(__linux) | |||
# define CARLA_OS_LINUX | |||
#elif defined(WIN64) || defined(_WIN64) || defined(__WIN64__) | |||
# define CARLA_OS_WIN64 | |||
@@ -40,7 +40,7 @@ | |||
#endif | |||
// Check for C++11 support | |||
#if defined(HAVE_CPP11_SUPPORT) || defined(QTCREATOR_TEST) | |||
#if defined(HAVE_CPP11_SUPPORT) | |||
# define CARLA_PROPER_CPP11_SUPPORT | |||
#elif defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) | |||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 | |||
@@ -25,7 +25,9 @@ | |||
#define __LINUX_LIST_H__ | |||
/* This file is from Linux Kernel (include/linux/list.h) | |||
* and modified by simply removing hardware prefetching of list items. | |||
* and modified by removing hardware prefetching of list items | |||
* and added list_split_tail* functions. | |||
* | |||
* Here by copyright, credits attributed to wherever they belong. | |||
* Filipe Coelho (aka falkTX <falktx@falktx.com>) | |||
*/ | |||
@@ -224,6 +226,19 @@ static inline void __list_splice(struct list_head *list, struct list_head *head) | |||
at->prev = last; | |||
} | |||
static inline void __list_splice_tail(struct list_head *list, struct list_head *head) | |||
{ | |||
struct list_head *first = list->next; | |||
struct list_head *last = list->prev; | |||
struct list_head *at = head->prev; | |||
first->prev = at; | |||
at->next = first; | |||
last->next = head; | |||
head->prev = last; | |||
} | |||
/** | |||
* list_splice - join two lists | |||
* @list: the new list to add. | |||
@@ -235,6 +250,19 @@ static inline void list_splice(struct list_head *list, struct list_head *head) | |||
__list_splice(list, head); | |||
} | |||
/** | |||
* list_splice_tail - join two lists | |||
* @list: the new list to add. | |||
* @head: the place to add it in the first list. | |||
* | |||
* @list goes to the end (at head->prev) | |||
*/ | |||
static inline void list_splice_tail(struct list_head *list, struct list_head *head) | |||
{ | |||
if (!list_empty(list)) | |||
__list_splice_tail(list, head); | |||
} | |||
/** | |||
* list_splice_init - join two lists and reinitialise the emptied list. | |||
* @list: the new list to add. | |||
@@ -250,6 +278,22 @@ static inline void list_splice_init(struct list_head *list, struct list_head *he | |||
} | |||
} | |||
/** | |||
* list_splice_init - join two lists and reinitialise the emptied list. | |||
* @list: the new list to add. | |||
* @head: the place to add it in the first list. | |||
* | |||
* The list at @list is reinitialised | |||
* @list goes to the end (at head->prev) | |||
*/ | |||
static inline void list_splice_tail_init(struct list_head *list, struct list_head *head) | |||
{ | |||
if (!list_empty(list)) { | |||
__list_splice_tail(list, head); | |||
INIT_LIST_HEAD(list); | |||
} | |||
} | |||
/** | |||
* list_entry - get the struct for this entry | |||
* @ptr: the &struct list_head pointer. | |||
@@ -17,7 +17,7 @@ | |||
// still need qt classes check | |||
//#include "CarlaPlugin.hpp" | |||
#include "plugin/DssiPlugin.cpp" | |||
//#include "plugin/DssiPlugin.cpp" | |||
#if 0 | |||
#include "CarlaDefines.hpp" | |||
@@ -71,7 +71,7 @@ struct PostRtEvents { | |||
{ | |||
if (mutex.tryLock()) | |||
{ | |||
dataPendingRT.splice(data, true); | |||
dataPendingRT.spliceAppend(data, true); | |||
mutex.unlock(); | |||
} | |||
} | |||
@@ -145,6 +145,13 @@ int main() | |||
assert(postRtEvents.data.count() == 4); | |||
assert(postRtEvents.dataPendingRT.count() == 0); | |||
for (auto it = postRtEvents.data.begin(); it.valid(); it.next()) | |||
{ | |||
MyData& my = *it; | |||
printf("FOR DATA!!!: %i %s\n", my.idStr, (const char*)my.str); | |||
} | |||
run4Tests(); | |||
// reset | |||
@@ -26,9 +26,9 @@ extern "C" { | |||
} | |||
// Declare non copyable and prevent heap allocation | |||
#define LIST_DECLARATIONS(className) \ | |||
className(const className&); \ | |||
className& operator= (const className&); \ | |||
#define LIST_DECLARATIONS(className) \ | |||
className(const className&); \ | |||
className& operator= (const className&); \ | |||
static void* operator new (size_t) { return nullptr; } \ | |||
static void operator delete (void*) {} | |||
@@ -42,6 +42,46 @@ template<typename T> | |||
class List | |||
{ | |||
protected: | |||
struct Data { | |||
T value; | |||
k_list_head siblings; | |||
}; | |||
class Itenerator { | |||
public: | |||
Itenerator(k_list_head* queue) | |||
: kQueue(queue), | |||
fEntry(queue->next), | |||
fData(nullptr) | |||
{ | |||
CARLA_ASSERT(kQueue != nullptr); | |||
CARLA_ASSERT(fEntry != nullptr); | |||
} | |||
bool valid() | |||
{ | |||
prefetch(fEntry->next); | |||
return (fEntry != kQueue); | |||
} | |||
void next() | |||
{ | |||
fEntry = fEntry->next; | |||
} | |||
T& operator*() | |||
{ | |||
fData = list_entry(fEntry, Data, siblings); | |||
CARLA_ASSERT(fData != nullptr); | |||
return fData->value; | |||
} | |||
private: | |||
k_list_head* const kQueue; | |||
k_list_head* fEntry; | |||
Data* fData; | |||
}; | |||
List() | |||
: kDataSize(sizeof(Data)), | |||
fCount(0) | |||
@@ -55,6 +95,11 @@ public: | |||
CARLA_ASSERT(fCount == 0); | |||
} | |||
Itenerator begin() | |||
{ | |||
return Itenerator(&fQueue); | |||
} | |||
void clear() | |||
{ | |||
if (fCount != 0) | |||
@@ -110,7 +155,7 @@ public: | |||
T& getAt(const size_t index, const bool remove = false) | |||
{ | |||
if (fCount == 0 || index >= fCount) | |||
return _retEmpty(); | |||
return _getEmpty(); | |||
size_t i = 0; | |||
Data* data = nullptr; | |||
@@ -137,7 +182,7 @@ public: | |||
CARLA_ASSERT(data != nullptr); | |||
return (data != nullptr) ? data->value : _retEmpty(); | |||
return (data != nullptr) ? data->value : _getEmpty(); | |||
} | |||
T& getFirst(const bool remove = false) | |||
@@ -194,7 +239,22 @@ public: | |||
} | |||
} | |||
virtual void splice(List& list, const bool init = false) | |||
virtual void spliceAppend(List& list, const bool init = false) | |||
{ | |||
if (init) | |||
{ | |||
list_splice_tail_init(&fQueue, &list.fQueue); | |||
list.fCount += fCount; | |||
fCount = 0; | |||
} | |||
else | |||
{ | |||
list_splice_tail(&fQueue, &list.fQueue); | |||
list.fCount += fCount; | |||
} | |||
} | |||
virtual void spliceInsert(List& list, const bool init = false) | |||
{ | |||
if (init) | |||
{ | |||
@@ -214,11 +274,6 @@ protected: | |||
size_t fCount; | |||
k_list_head fQueue; | |||
struct Data { | |||
T value; | |||
k_list_head siblings; | |||
}; | |||
virtual Data* _allocate() = 0; | |||
virtual void _deallocate(Data* const dataPtr) = 0; | |||
@@ -232,7 +287,7 @@ private: | |||
T& _getFirstOrLast(const bool first, const bool remove) | |||
{ | |||
if (fCount == 0) | |||
return _retEmpty(); | |||
return _getEmpty(); | |||
k_list_head* const entry = first ? fQueue.next : fQueue.prev; | |||
Data* const data = list_entry(entry, Data, siblings); | |||
@@ -240,7 +295,7 @@ private: | |||
CARLA_ASSERT(data != nullptr); | |||
if (data == nullptr) | |||
return _retEmpty(); | |||
return _getEmpty(); | |||
T& ret = data->value; | |||
@@ -254,7 +309,7 @@ private: | |||
return ret; | |||
} | |||
T& _retEmpty() | |||
T& _getEmpty() | |||
{ | |||
// FIXME ? | |||
static T value; | |||
@@ -371,11 +426,18 @@ public: | |||
kMemPool->resize(minPreallocated, maxPreallocated); | |||
} | |||
void splice(RtList& list, const bool init = false) | |||
void spliceAppend(RtList& list, const bool init = false) | |||
{ | |||
CARLA_ASSERT(kMemPool == list.kMemPool); | |||
List<T>::spliceAppend(list, init); | |||
} | |||
void spliceInsert(RtList& list, const bool init = false) | |||
{ | |||
CARLA_ASSERT(kMemPool == list.kMemPool); | |||
List<T>::splice(list, init); | |||
List<T>::spliceInsert(list, init); | |||
} | |||
private: | |||