| @@ -241,6 +241,7 @@ struct EngineOptions { | |||
| #ifndef DOXYGEN | |||
| EngineOptions() noexcept; | |||
| ~EngineOptions() noexcept; | |||
| CARLA_DECLARE_NON_COPY_STRUCT(EngineOptions) | |||
| #endif | |||
| }; | |||
| @@ -137,6 +137,7 @@ typedef struct _CarlaPluginInfo { | |||
| */ | |||
| _CarlaPluginInfo() noexcept; | |||
| ~_CarlaPluginInfo() noexcept; | |||
| CARLA_DECLARE_NON_COPY_STRUCT(_CarlaPluginInfo) | |||
| #endif | |||
| } CarlaPluginInfo; | |||
| @@ -212,6 +213,7 @@ typedef struct _CarlaNativePluginInfo { | |||
| * C++ constructor. | |||
| */ | |||
| _CarlaNativePluginInfo() noexcept; | |||
| CARLA_DECLARE_NON_COPY_STRUCT(_CarlaNativePluginInfo) | |||
| #endif | |||
| } CarlaNativePluginInfo; | |||
| @@ -267,6 +269,7 @@ typedef struct _CarlaParameterInfo { | |||
| */ | |||
| _CarlaParameterInfo() noexcept; | |||
| ~_CarlaParameterInfo() noexcept; | |||
| CARLA_DECLARE_NON_COPY_STRUCT(_CarlaParameterInfo) | |||
| #endif | |||
| } CarlaParameterInfo; | |||
| @@ -292,6 +295,7 @@ typedef struct _CarlaScalePointInfo { | |||
| */ | |||
| _CarlaScalePointInfo() noexcept; | |||
| ~_CarlaScalePointInfo() noexcept; | |||
| CARLA_DECLARE_NON_COPY_STRUCT(_CarlaScalePointInfo) | |||
| #endif | |||
| } CarlaScalePointInfo; | |||
| @@ -57,8 +57,10 @@ struct CarlaBackendStandalone { | |||
| : engine(nullptr), | |||
| engineCallback(nullptr), | |||
| engineCallbackPtr(nullptr), | |||
| engineOptions(), | |||
| fileCallback(nullptr), | |||
| fileCallbackPtr(nullptr) | |||
| fileCallbackPtr(nullptr), | |||
| lastError() | |||
| { | |||
| #ifdef BUILD_BRIDGE | |||
| engineOptions.processMode = CB::ENGINE_PROCESS_MODE_BRIDGE; | |||
| @@ -102,6 +104,8 @@ class CarlaNSM | |||
| public: | |||
| CarlaNSM() noexcept | |||
| : fOscServer(nullptr), | |||
| fClientId(), | |||
| fProjectPath(), | |||
| fHasBroadcast(false), | |||
| fHasShowHideUI(false) {} | |||
| @@ -245,7 +245,8 @@ EngineTimeInfo::EngineTimeInfo() noexcept | |||
| : playing(false), | |||
| frame(0), | |||
| usecs(0), | |||
| valid(0x0) {} | |||
| valid(0x0), | |||
| bbt() {} | |||
| void EngineTimeInfo::clear() noexcept | |||
| { | |||
| @@ -123,10 +123,28 @@ uint RackGraph::MIDI::getPortId(const bool isInput, const char portName[], bool* | |||
| // ----------------------------------------------------------------------- | |||
| // RackGraph | |||
| RackGraph::Audio::Audio() noexcept | |||
| : mutex(), | |||
| connectedIn1(), | |||
| connectedIn2(), | |||
| connectedOut1(), | |||
| connectedOut2(), | |||
| inBuf{0, 0}, | |||
| inBufTmp{0, 0}, | |||
| outBuf{0, 0} {} | |||
| RackGraph::MIDI::MIDI() noexcept | |||
| : ins(), | |||
| outs() {} | |||
| RackGraph::RackGraph(const uint32_t bufferSize, const uint32_t ins, const uint32_t outs) noexcept | |||
| : inputs(ins), | |||
| : connections(), | |||
| inputs(ins), | |||
| outputs(outs), | |||
| isOffline(false) | |||
| isOffline(false), | |||
| retCon(), | |||
| audio(), | |||
| midi() | |||
| { | |||
| audio.inBuf[0] = audio.inBuf[1] = nullptr; | |||
| audio.inBufTmp[0] = audio.inBufTmp[1] = nullptr; | |||
| @@ -76,6 +76,10 @@ struct RackGraph { | |||
| float* inBuf[2]; | |||
| float* inBufTmp[2]; | |||
| float* outBuf[2]; | |||
| // c++ compat stuff | |||
| Audio() noexcept; | |||
| CARLA_PREVENT_HEAP_ALLOCATION | |||
| CARLA_DECLARE_NON_COPY_CLASS(Audio) | |||
| } audio; | |||
| struct MIDI { | |||
| @@ -83,6 +87,10 @@ struct RackGraph { | |||
| LinkedList<PortNameToId> outs; | |||
| const char* getName(const bool isInput, const uint portId) const noexcept; | |||
| uint getPortId(const bool isInput, const char portName[], bool* const ok = nullptr) const noexcept; | |||
| MIDI() noexcept; | |||
| // c++ compat stuff | |||
| CARLA_PREVENT_HEAP_ALLOCATION | |||
| CARLA_DECLARE_NON_COPY_CLASS(MIDI) | |||
| } midi; | |||
| RackGraph(const uint32_t bufferSize, const uint32_t inputs, const uint32_t outputs) noexcept; | |||
| @@ -17,6 +17,8 @@ | |||
| #ifndef LILV_LILVMM_HPP | |||
| #define LILV_LILVMM_HPP | |||
| #include "CarlaDefines.h" | |||
| #include "lilv/lilv.h" | |||
| #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) | |||
| @@ -97,6 +99,12 @@ struct Node { | |||
| LILV_WRAP0_CONST(bool, node, is_bool); | |||
| LILV_WRAP0_CONST(bool, node, as_bool); | |||
| Node& operator=(const Node& copy) { | |||
| lilv_node_free(me); | |||
| me = lilv_node_duplicate(copy.me); | |||
| return *this; | |||
| } | |||
| LilvNode* me; | |||
| }; | |||
| @@ -108,6 +116,8 @@ struct ScalePoint { | |||
| LILV_WRAP0(const LilvNode*, scale_point, get_value); | |||
| const LilvScalePoint* me; | |||
| //CARLA_DECLARE_NON_COPY_STRUCT(ScalePoint) | |||
| }; | |||
| struct PluginClass { | |||
| @@ -120,6 +130,8 @@ struct PluginClass { | |||
| LILV_WRAP0(LilvPluginClasses*, plugin_class, get_children); | |||
| const LilvPluginClass* me; | |||
| //CARLA_DECLARE_NON_COPY_STRUCT(PluginClass) | |||
| }; | |||
| #define LILV_WRAP_COLL(CT, ET, prefix) \ | |||
| @@ -165,6 +177,8 @@ struct UI { | |||
| LILV_WRAP0(Nodes, ui, get_extension_data); | |||
| const LilvUI* me; | |||
| //CARLA_DECLARE_NON_COPY_STRUCT(UI) | |||
| }; | |||
| struct UIs { | |||
| @@ -198,6 +212,8 @@ struct Port { | |||
| const LilvPlugin* parent; | |||
| const LilvPort* me; | |||
| //CARLA_DECLARE_NON_COPY_STRUCT(Port) | |||
| }; | |||
| struct Plugin { | |||
| @@ -254,6 +270,8 @@ struct Plugin { | |||
| } | |||
| const LilvPlugin* me; | |||
| //CARLA_DECLARE_NON_COPY_STRUCT(Plugin) | |||
| }; | |||
| struct Plugins { | |||
| @@ -265,15 +283,13 @@ struct Instance { | |||
| inline Instance(LilvInstance* instance) : me(instance) {} | |||
| LILV_DEPRECATED | |||
| inline Instance(Plugin plugin, double sample_rate) { | |||
| me = lilv_plugin_instantiate(plugin, sample_rate, nullptr); | |||
| } | |||
| inline Instance(Plugin plugin, double sample_rate) | |||
| : me(lilv_plugin_instantiate(plugin, sample_rate, nullptr)) {} | |||
| LILV_DEPRECATED inline Instance(Plugin plugin, | |||
| double sample_rate, | |||
| LV2_Feature* const* features) { | |||
| me = lilv_plugin_instantiate(plugin, sample_rate, features); | |||
| } | |||
| LV2_Feature* const* features) | |||
| me(lilv_plugin_instantiate(plugin, sample_rate, features)) {} | |||
| static inline Instance* create(Plugin plugin, | |||
| double sample_rate, | |||
| @@ -307,11 +323,13 @@ struct Instance { | |||
| } | |||
| LilvInstance* me; | |||
| //CARLA_DECLARE_NON_COPY_STRUCT(Instance) | |||
| }; | |||
| struct World { | |||
| inline World() : me(lilv_world_new()) {} | |||
| inline ~World() { lilv_world_free(me); } | |||
| inline World() : me(lilv_world_new()) {} | |||
| inline virtual ~World() { lilv_world_free(me); } | |||
| inline LilvNode* new_uri(const char* uri) const { | |||
| return lilv_new_uri(me, uri); | |||
| @@ -343,6 +361,8 @@ struct World { | |||
| LILV_WRAP1(int, world, load_resource, const LilvNode*, resource); | |||
| LilvWorld* me; | |||
| CARLA_DECLARE_NON_COPY_STRUCT(World) | |||
| }; | |||
| } /* namespace Lilv */ | |||
| @@ -121,6 +121,8 @@ static void test_CarlaUtils() | |||
| str4 = nullptr; | |||
| } | |||
| } | |||
| CARLA_DECLARE_NON_COPY_STRUCT(TestStruct) | |||
| }; | |||
| TestStruct a, b, c; | |||
| @@ -30,7 +30,7 @@ | |||
| class LeakTestClass | |||
| { | |||
| public: | |||
| LeakTestClass()noexcept | |||
| LeakTestClass() noexcept | |||
| : i(0) {} | |||
| private: | |||
| @@ -56,6 +56,9 @@ public: | |||
| private: | |||
| const magic_t fMagic; | |||
| CARLA_PREVENT_HEAP_ALLOCATION | |||
| CARLA_DECLARE_NON_COPY_STRUCT(CarlaMagic) | |||
| }; | |||
| static const CarlaMagic& getCarlaMagicInstance() | |||
| @@ -96,9 +96,7 @@ private: | |||
| { | |||
| public: | |||
| LeakCounter() noexcept | |||
| { | |||
| numObjects = 0; | |||
| } | |||
| : numObjects(0) {} | |||
| ~LeakCounter() noexcept | |||
| { | |||
| @@ -27,7 +27,9 @@ | |||
| class LibCounter | |||
| { | |||
| public: | |||
| LibCounter() noexcept {} | |||
| LibCounter() noexcept | |||
| : fMutex(), | |||
| fLibs() {} | |||
| ~LibCounter() noexcept | |||
| { | |||
| @@ -429,7 +429,7 @@ public: | |||
| return cState; | |||
| } | |||
| CARLA_PREVENT_HEAP_ALLOCATION | |||
| CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| @@ -32,7 +32,8 @@ public: | |||
| * Constructor. | |||
| */ | |||
| CarlaMutex() noexcept | |||
| : fTryLockWasCalled(false) | |||
| : fMutex(), | |||
| fTryLockWasCalled(false) | |||
| { | |||
| pthread_mutex_init(&fMutex, nullptr); | |||
| } | |||
| @@ -103,6 +104,11 @@ public: | |||
| * Constructor. | |||
| */ | |||
| CarlaRecursiveMutex() noexcept | |||
| #ifdef CARLA_OS_WIN | |||
| : fSection() | |||
| #else | |||
| : fMutex() | |||
| #endif | |||
| { | |||
| #ifdef CARLA_OS_WIN | |||
| InitializeCriticalSection(&fSection); | |||
| @@ -66,7 +66,8 @@ struct PatchbayGroupList { | |||
| LinkedList<GroupNameToId> list; | |||
| PatchbayGroupList() noexcept | |||
| : lastId(0) {} | |||
| : lastId(0), | |||
| list() {} | |||
| void clear() noexcept | |||
| { | |||
| @@ -159,7 +160,8 @@ struct PatchbayPortList { | |||
| LinkedList<PortNameToId> list; | |||
| PatchbayPortList() noexcept | |||
| : lastId(0) {} | |||
| : lastId(0), | |||
| list() {} | |||
| void clear() noexcept | |||
| { | |||
| @@ -247,7 +249,8 @@ struct PatchbayConnectionList { | |||
| LinkedList<ConnectionToId> list; | |||
| PatchbayConnectionList() noexcept | |||
| : lastId(0) {} | |||
| : lastId(0), | |||
| list() {} | |||
| void clear() noexcept | |||
| { | |||
| @@ -41,10 +41,10 @@ static int temporaryErrorHandler(Display*, XErrorEvent*) | |||
| return 0; | |||
| } | |||
| class X11PluginUi : public CarlaPluginUI | |||
| class X11PluginUI : public CarlaPluginUI | |||
| { | |||
| public: | |||
| X11PluginUi(CloseCallback* const cb, const uintptr_t parentId) noexcept | |||
| X11PluginUI(CloseCallback* const cb, const uintptr_t parentId) noexcept | |||
| : CarlaPluginUI(cb), | |||
| fDisplay(nullptr), | |||
| fWindow(0), | |||
| @@ -88,7 +88,7 @@ public: | |||
| setTransientWinId(parentId); | |||
| } | |||
| ~X11PluginUi() override | |||
| ~X11PluginUI() override | |||
| { | |||
| CARLA_SAFE_ASSERT(! fIsVisible); | |||
| @@ -293,6 +293,8 @@ private: | |||
| bool fIsVisible; | |||
| bool fFirstShow; | |||
| EventProcPtr fEventProc; | |||
| CARLA_DECLARE_NON_COPY_CLASS(X11PluginUI) | |||
| }; | |||
| #endif | |||
| @@ -314,6 +316,9 @@ bool CarlaPluginUI::tryTransientWinIdMatch(const uintptr_t pid, const char* cons | |||
| Display* display; | |||
| ScopedDisplay() : display(XOpenDisplay(nullptr)) {} | |||
| ~ScopedDisplay() { if (display!=nullptr) XCloseDisplay(display); } | |||
| // c++ compat stuff | |||
| CARLA_PREVENT_HEAP_ALLOCATION | |||
| CARLA_DECLARE_NON_COPY_CLASS(ScopedDisplay) | |||
| }; | |||
| struct ScopedFreeData { | |||
| union { | |||
| @@ -323,6 +328,9 @@ bool CarlaPluginUI::tryTransientWinIdMatch(const uintptr_t pid, const char* cons | |||
| ScopedFreeData(char* d) : data(d) {} | |||
| ScopedFreeData(uchar* d) : udata(d) {} | |||
| ~ScopedFreeData() { XFree(data); } | |||
| // c++ compat stuff | |||
| CARLA_PREVENT_HEAP_ALLOCATION | |||
| CARLA_DECLARE_NON_COPY_CLASS(ScopedFreeData) | |||
| }; | |||
| const ScopedDisplay sd; | |||
| @@ -502,7 +510,7 @@ CarlaPluginUI* CarlaPluginUI::newWindows(CloseCallback*, uintptr_t) | |||
| #ifdef HAVE_X11 | |||
| CarlaPluginUI* CarlaPluginUI::newX11(CloseCallback* cb, uintptr_t parentId) | |||
| { | |||
| return new X11PluginUi(cb, parentId); | |||
| return new X11PluginUI(cb, parentId); | |||
| } | |||
| #endif | |||
| @@ -60,6 +60,8 @@ protected: | |||
| bool fIsIdling; | |||
| CloseCallback* fCallback; | |||
| CarlaPluginUI(CloseCallback* const cb) noexcept : fIsIdling(false), fCallback(cb) {} | |||
| CARLA_DECLARE_NON_COPY_CLASS(CarlaPluginUI) | |||
| }; | |||
| // ----------------------------------------------------- | |||
| @@ -152,7 +152,9 @@ StateSave::StateSave() noexcept | |||
| currentProgramName(nullptr), | |||
| currentMidiBank(-1), | |||
| currentMidiProgram(-1), | |||
| chunk(nullptr) {} | |||
| chunk(nullptr), | |||
| parameters(), | |||
| customData() {} | |||
| StateSave::~StateSave() noexcept | |||
| { | |||
| @@ -163,14 +163,12 @@ public: | |||
| CarlaStringList() noexcept | |||
| : LinkedList<CarlaString>(true) {} | |||
| #if 0 | |||
| CarlaStringList(const CarlaStringList& list) noexcept | |||
| : LinkedList<CarlaString>(true) | |||
| { | |||
| for (Itenerator it = list.begin(); it.valid(); it.next()) | |||
| LinkedList<CarlaString>::append(it.getValue()); | |||
| } | |||
| #endif | |||
| ~CarlaStringList() noexcept | |||
| { | |||
| @@ -226,8 +224,7 @@ public: | |||
| return *this; | |||
| } | |||
| private: | |||
| LinkedList<CarlaString> fList; | |||
| CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| @@ -37,11 +37,14 @@ protected: | |||
| * Constructor. | |||
| */ | |||
| CarlaThread(const char* const threadName = nullptr) noexcept | |||
| : fName(threadName), | |||
| fShouldExit(false) | |||
| { | |||
| _init(); | |||
| } | |||
| : fLock(), | |||
| fName(threadName), | |||
| #ifdef PTW32_DLLPORT | |||
| fHandle(nullptr, 0) | |||
| #else | |||
| fHandle(0), | |||
| #endif | |||
| fShouldExit(false) {} | |||
| /* | |||
| * Destructor. | |||
| @@ -47,22 +47,6 @@ | |||
| ((const type *)((const char *)(ptr)-offsetof(type, member))) | |||
| #endif | |||
| // ----------------------------------------------------------------------- | |||
| // Declare non copyable and prevent heap allocation | |||
| #ifdef CARLA_PROPER_CPP11_SUPPORT | |||
| # define LINKED_LIST_DECLARATIONS(ClassName) \ | |||
| ClassName(ClassName&) = delete; \ | |||
| ClassName(const ClassName&) = delete; \ | |||
| ClassName& operator=(const ClassName&) = delete; \ | |||
| static void* operator new(size_t) = delete; | |||
| #else | |||
| # define LINKED_LIST_DECLARATIONS(ClassName) \ | |||
| ClassName(ClassName&); \ | |||
| ClassName(const ClassName&); \ | |||
| ClassName& operator=(const ClassName&); | |||
| #endif | |||
| // ----------------------------------------------------------------------- | |||
| // Abstract Linked List class | |||
| // _allocate() and _deallocate are virtual calls provided by subclasses | |||
| @@ -85,10 +69,9 @@ protected: | |||
| AbstractLinkedList(const bool isClass) noexcept | |||
| : kIsClass(isClass), | |||
| kDataSize(sizeof(Data)) | |||
| { | |||
| _init(); | |||
| } | |||
| kDataSize(sizeof(Data)), | |||
| fCount(0), | |||
| fQueue({&fQueue, &fQueue}) {} | |||
| public: | |||
| virtual ~AbstractLinkedList() noexcept | |||
| @@ -384,9 +367,10 @@ private: | |||
| void _createData(Data* const data, const T& value) noexcept | |||
| { | |||
| if (kIsClass) | |||
| new(data)Data(); | |||
| new(data)Data({value, {nullptr, nullptr}}); | |||
| else | |||
| data->value = value; | |||
| data->value = value; | |||
| ++fCount; | |||
| } | |||
| @@ -397,9 +381,9 @@ private: | |||
| _createData(data, value); | |||
| if (inTail) | |||
| __list_add(&data->siblings, queue->prev, queue); | |||
| __list_add(data->siblings, queue->prev, queue); | |||
| else | |||
| __list_add(&data->siblings, queue, queue->next); | |||
| __list_add(data->siblings, queue, queue->next); | |||
| return true; | |||
| } | |||
| @@ -454,12 +438,12 @@ private: | |||
| /* | |||
| * Insert a new entry between two known consecutive entries. | |||
| */ | |||
| static void __list_add(ListHead* const new_, ListHead* const prev, ListHead* const next) noexcept | |||
| static void __list_add(ListHead& new_, ListHead* const prev, ListHead* const next) noexcept | |||
| { | |||
| next->prev = new_; | |||
| new_->next = next; | |||
| new_->prev = prev; | |||
| prev->next = new_; | |||
| next->prev = &new_; | |||
| new_.next = next; | |||
| new_.prev = prev; | |||
| prev->next = &new_; | |||
| } | |||
| /* | |||
| @@ -500,7 +484,8 @@ private: | |||
| template<typename> friend class RtLinkedList; | |||
| LINKED_LIST_DECLARATIONS(AbstractLinkedList) | |||
| CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||
| CARLA_DECLARE_NON_COPY_CLASS(AbstractLinkedList) | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| @@ -526,7 +511,8 @@ protected: | |||
| std::free(dataPtr); | |||
| } | |||
| LINKED_LIST_DECLARATIONS(LinkedList) | |||
| CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||
| CARLA_DECLARE_NON_COPY_CLASS(LinkedList) | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| @@ -93,6 +93,9 @@ public: | |||
| private: | |||
| mutable RtMemPool_Handle fHandle; | |||
| const size_t kDataSize; | |||
| CARLA_PREVENT_HEAP_ALLOCATION | |||
| CARLA_DECLARE_NON_COPY_CLASS(Pool) | |||
| }; | |||
| // ------------------------------------------------------------------- | |||
| @@ -161,9 +164,9 @@ private: | |||
| this->_createData(data, value); | |||
| if (inTail) | |||
| this->__list_add(&data->siblings, this->fQueue.prev, &this->fQueue); | |||
| this->__list_add(data->siblings, this->fQueue.prev, &(this->fQueue)); | |||
| else | |||
| this->__list_add(&data->siblings, &this->fQueue, this->fQueue.next); | |||
| this->__list_add(data->siblings, &(this->fQueue), this->fQueue.next); | |||
| return true; | |||
| } | |||
| @@ -171,7 +174,8 @@ private: | |||
| return false; | |||
| } | |||
| LINKED_LIST_DECLARATIONS(RtLinkedList) | |||
| CARLA_PREVENT_VIRTUAL_HEAP_ALLOCATION | |||
| CARLA_DECLARE_NON_COPY_CLASS(RtLinkedList) | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||