| @@ -43,8 +43,8 @@ struct PostRtEvents { | |||||
| PostRtEvents() | PostRtEvents() | ||||
| : dataPool(MIN_RT_EVENTS, MAX_RT_EVENTS), | : dataPool(MIN_RT_EVENTS, MAX_RT_EVENTS), | ||||
| data(dataPool), | |||||
| dataPendingRT(dataPool) {} | |||||
| data(dataPool, true), | |||||
| dataPendingRT(dataPool, true) {} | |||||
| ~PostRtEvents() | ~PostRtEvents() | ||||
| { | { | ||||
| @@ -23,38 +23,41 @@ | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| const char* find_dssi_ui(const char* const filename, const char* const label) | |||||
| const char* find_dssi_ui(const char* const filename, const char* const label) noexcept | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', nullptr); | CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', nullptr); | ||||
| CARLA_SAFE_ASSERT_RETURN(label != nullptr && label[0] != '\0', nullptr); | CARLA_SAFE_ASSERT_RETURN(label != nullptr && label[0] != '\0', nullptr); | ||||
| carla_debug("find_dssi_ui(\"%s\", \"%s\")", filename, label); | carla_debug("find_dssi_ui(\"%s\", \"%s\")", filename, label); | ||||
| QString guiFilename; | |||||
| QString pluginDir(filename); | |||||
| pluginDir.resize(pluginDir.lastIndexOf(".")); | |||||
| try { | |||||
| QString guiFilename; | |||||
| QString pluginDir(filename); | |||||
| pluginDir.resize(pluginDir.lastIndexOf(".")); | |||||
| QString checkLabel(label); | |||||
| QString checkSName(QFileInfo(pluginDir).baseName()); | |||||
| QString checkLabel(label); | |||||
| QString checkSName(QFileInfo(pluginDir).baseName()); | |||||
| if (! checkLabel.endsWith("_")) checkLabel += "_"; | |||||
| if (! checkSName.endsWith("_")) checkSName += "_"; | |||||
| if (! checkLabel.endsWith("_")) checkLabel += "_"; | |||||
| if (! checkSName.endsWith("_")) checkSName += "_"; | |||||
| QStringList guiFiles(QDir(pluginDir).entryList()); | |||||
| QStringList guiFiles(QDir(pluginDir).entryList()); | |||||
| foreach (const QString& gui, guiFiles) | |||||
| { | |||||
| if (gui.startsWith(checkLabel) || gui.startsWith(checkSName)) | |||||
| foreach (const QString& gui, guiFiles) | |||||
| { | { | ||||
| QFileInfo finalname(pluginDir + QDir::separator() + gui); | |||||
| guiFilename = finalname.absoluteFilePath(); | |||||
| break; | |||||
| if (gui.startsWith(checkLabel) || gui.startsWith(checkSName)) | |||||
| { | |||||
| QFileInfo finalname(pluginDir + QDir::separator() + gui); | |||||
| guiFilename = finalname.absoluteFilePath(); | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| } | |||||
| if (guiFilename.isEmpty()) | |||||
| return nullptr; | |||||
| if (guiFilename.isEmpty()) | |||||
| return nullptr; | |||||
| return carla_strdup(guiFilename.toUtf8().constData()); | |||||
| return carla_strdup(guiFilename.toUtf8().constData()); | |||||
| } CARLA_SAFE_EXCEPTION_RETURN("find_dssi_ui", nullptr); | |||||
| } | } | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -24,7 +24,7 @@ | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // Find UI binary for a plugin (returned value must be deleted) | // Find UI binary for a plugin (returned value must be deleted) | ||||
| const char* find_dssi_ui(const char* const filename, const char* const label); | |||||
| const char* find_dssi_ui(const char* const filename, const char* const label) noexcept; | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -49,7 +49,7 @@ const LADSPA_RDF_Descriptor* ladspa_rdf_dup(const LADSPA_RDF_Descriptor* const o | |||||
| { | { | ||||
| newDescriptor->Ports = new LADSPA_RDF_Port[newDescriptor->PortCount]; | newDescriptor->Ports = new LADSPA_RDF_Port[newDescriptor->PortCount]; | ||||
| for (unsigned long i=0; i < newDescriptor->PortCount; ++i) | |||||
| for (ulong i=0; i < newDescriptor->PortCount; ++i) | |||||
| { | { | ||||
| LADSPA_RDF_Port* const oldPort(&oldDescriptor->Ports[i]); | LADSPA_RDF_Port* const oldPort(&oldDescriptor->Ports[i]); | ||||
| LADSPA_RDF_Port* const newPort(&newDescriptor->Ports[i]); | LADSPA_RDF_Port* const newPort(&newDescriptor->Ports[i]); | ||||
| @@ -67,7 +67,7 @@ const LADSPA_RDF_Descriptor* ladspa_rdf_dup(const LADSPA_RDF_Descriptor* const o | |||||
| { | { | ||||
| newPort->ScalePoints = new LADSPA_RDF_ScalePoint[oldPort->ScalePointCount]; | newPort->ScalePoints = new LADSPA_RDF_ScalePoint[oldPort->ScalePointCount]; | ||||
| for (unsigned long j=0; j < oldPort->ScalePointCount; ++j) | |||||
| for (ulong j=0; j < oldPort->ScalePointCount; ++j) | |||||
| { | { | ||||
| LADSPA_RDF_ScalePoint* const oldScalePoint(&oldPort->ScalePoints[j]); | LADSPA_RDF_ScalePoint* const oldScalePoint(&oldPort->ScalePoints[j]); | ||||
| LADSPA_RDF_ScalePoint* const newScalePoint(&newPort->ScalePoints[j]); | LADSPA_RDF_ScalePoint* const newScalePoint(&newPort->ScalePoints[j]); | ||||
| @@ -124,7 +124,7 @@ bool is_ladspa_rdf_descriptor_valid(const LADSPA_RDF_Descriptor* const rdfDescri | |||||
| return false; | return false; | ||||
| } | } | ||||
| for (unsigned long i=0; i < rdfDescriptor->PortCount; ++i) | |||||
| for (ulong i=0; i < rdfDescriptor->PortCount; ++i) | |||||
| { | { | ||||
| if (! is_ladspa_port_good(rdfDescriptor->Ports[i].Type, descriptor->PortDescriptors[i])) | if (! is_ladspa_port_good(rdfDescriptor->Ports[i].Type, descriptor->PortDescriptors[i])) | ||||
| { | { | ||||
| @@ -169,7 +169,7 @@ LADSPA_Data get_default_ladspa_port_value(const LADSPA_PortRangeHintDescriptor h | |||||
| { | { | ||||
| try { | try { | ||||
| return std::exp((std::log(min)*0.75f) + (std::log(max)*0.25f)); | return std::exp((std::log(min)*0.75f) + (std::log(max)*0.25f)); | ||||
| } catch(...) {} | |||||
| } CARLA_SAFE_EXCEPTION("exp(log)"); | |||||
| } | } | ||||
| return (min*0.75f) + (max*0.25f); | return (min*0.75f) + (max*0.25f); | ||||
| @@ -178,7 +178,7 @@ LADSPA_Data get_default_ladspa_port_value(const LADSPA_PortRangeHintDescriptor h | |||||
| { | { | ||||
| try { | try { | ||||
| return std::sqrt(min*max); | return std::sqrt(min*max); | ||||
| } catch(...) {} | |||||
| } CARLA_SAFE_EXCEPTION("sqrt"); | |||||
| } | } | ||||
| return (min+max)/2; | return (min+max)/2; | ||||
| @@ -187,7 +187,7 @@ LADSPA_Data get_default_ladspa_port_value(const LADSPA_PortRangeHintDescriptor h | |||||
| { | { | ||||
| try { | try { | ||||
| return std::exp((std::log(min)*0.25f) + (std::log(max)*0.75f)); | return std::exp((std::log(min)*0.25f) + (std::log(max)*0.75f)); | ||||
| } catch(...) {} | |||||
| } CARLA_SAFE_EXCEPTION("exp(log)"); | |||||
| } | } | ||||
| return (min*0.25f) + (max*0.75f); | return (min*0.25f) + (max*0.75f); | ||||
| } | } | ||||
| @@ -25,7 +25,7 @@ | |||||
| #define try_lo_send(...) \ | #define try_lo_send(...) \ | ||||
| try { \ | try { \ | ||||
| lo_send(__VA_ARGS__); \ | lo_send(__VA_ARGS__); \ | ||||
| } catch(...) {} | |||||
| } CARLA_SAFE_EXCEPTION("lo_send"); | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -57,9 +57,10 @@ protected: | |||||
| k_list_head siblings; | k_list_head siblings; | ||||
| }; | }; | ||||
| AbstractLinkedList() noexcept | |||||
| AbstractLinkedList(const bool needsCopyCtr) noexcept | |||||
| : fDataSize(sizeof(Data)), | : fDataSize(sizeof(Data)), | ||||
| fCount(0) | |||||
| fCount(0), | |||||
| fNeedsCopyCtr(needsCopyCtr) | |||||
| { | { | ||||
| _init(); | _init(); | ||||
| } | } | ||||
| @@ -146,86 +147,22 @@ public: | |||||
| bool append(const T& value) noexcept | bool append(const T& value) noexcept | ||||
| { | { | ||||
| if (Data* const data = _allocate()) | |||||
| { | |||||
| try { | |||||
| new(data)Data(); | |||||
| } | |||||
| catch(...) { | |||||
| _deallocate(data); | |||||
| return false; | |||||
| } | |||||
| data->value = value; | |||||
| list_add_tail(&data->siblings, &fQueue); | |||||
| ++fCount; | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| return _add(value, true, &fQueue); | |||||
| } | } | ||||
| bool appendAt(const T& value, const Itenerator& it) noexcept | bool appendAt(const T& value, const Itenerator& it) noexcept | ||||
| { | { | ||||
| if (Data* const data = _allocate()) | |||||
| { | |||||
| try { | |||||
| new(data)Data(); | |||||
| } | |||||
| catch(...) { | |||||
| _deallocate(data); | |||||
| return false; | |||||
| } | |||||
| data->value = value; | |||||
| list_add_tail(&data->siblings, it.fEntry->next); | |||||
| ++fCount; | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| return _add(value, true, it.fEntry->next); | |||||
| } | } | ||||
| bool insert(const T& value) noexcept | bool insert(const T& value) noexcept | ||||
| { | { | ||||
| if (Data* const data = _allocate()) | |||||
| { | |||||
| try { | |||||
| new(data)Data(); | |||||
| } | |||||
| catch(...) { | |||||
| _deallocate(data); | |||||
| return false; | |||||
| } | |||||
| data->value = value; | |||||
| list_add(&data->siblings, &fQueue); | |||||
| ++fCount; | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| return _add(value, false, &fQueue); | |||||
| } | } | ||||
| bool insertAt(const T& value, const Itenerator& it) noexcept | bool insertAt(const T& value, const Itenerator& it) noexcept | ||||
| { | { | ||||
| if (Data* const data = _allocate()) | |||||
| { | |||||
| try { | |||||
| new(data)Data(); | |||||
| } | |||||
| catch(...) { | |||||
| _deallocate(data); | |||||
| return false; | |||||
| } | |||||
| data->value = value; | |||||
| list_add(&data->siblings, it.fEntry->prev); | |||||
| ++fCount; | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| return _add(value, false, it.fEntry->prev); | |||||
| } | } | ||||
| T& getAt(const size_t index) const noexcept | T& getAt(const size_t index) const noexcept | ||||
| @@ -399,6 +336,8 @@ protected: | |||||
| size_t fCount; | size_t fCount; | ||||
| k_list_head fQueue; | k_list_head fQueue; | ||||
| const bool fNeedsCopyCtr; | |||||
| virtual Data* _allocate() noexcept = 0; | virtual Data* _allocate() noexcept = 0; | ||||
| virtual void _deallocate(Data* const dataPtr) noexcept = 0; | virtual void _deallocate(Data* const dataPtr) noexcept = 0; | ||||
| @@ -411,6 +350,46 @@ private: | |||||
| INIT_LIST_HEAD(&fQueue); | INIT_LIST_HEAD(&fQueue); | ||||
| } | } | ||||
| bool _add(const T& value, const bool inTail, k_list_head* const queue) noexcept | |||||
| { | |||||
| if (Data* const data = _allocate()) | |||||
| { | |||||
| if (fNeedsCopyCtr) | |||||
| { | |||||
| try { | |||||
| new(data)Data(); | |||||
| } | |||||
| catch(...) { | |||||
| _deallocate(data); | |||||
| return false; | |||||
| } | |||||
| try { | |||||
| data->value = value; | |||||
| } | |||||
| catch(...) { | |||||
| data->~Data(); | |||||
| _deallocate(data); | |||||
| return false; | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| std::memcpy(&data->value, &value, fDataSize); | |||||
| } | |||||
| if (inTail) | |||||
| list_add_tail(&data->siblings, queue); | |||||
| else | |||||
| list_add(&data->siblings, queue); | |||||
| ++fCount; | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| T& _getFirstOrLast(const bool first, const bool removeObj) noexcept | T& _getFirstOrLast(const bool first, const bool removeObj) noexcept | ||||
| { | { | ||||
| if (fCount == 0) | if (fCount == 0) | ||||
| @@ -447,7 +426,8 @@ template<typename T> | |||||
| class LinkedList : public AbstractLinkedList<T> | class LinkedList : public AbstractLinkedList<T> | ||||
| { | { | ||||
| public: | public: | ||||
| LinkedList() noexcept {} | |||||
| LinkedList(const bool needsCopyCtr = false) noexcept | |||||
| : AbstractLinkedList<T>(needsCopyCtr) {} | |||||
| private: | private: | ||||
| typename AbstractLinkedList<T>::Data* _allocate() noexcept override | typename AbstractLinkedList<T>::Data* _allocate() noexcept override | ||||
| @@ -98,51 +98,18 @@ public: | |||||
| // ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
| // Now the actual rt-linkedlist code | // Now the actual rt-linkedlist code | ||||
| RtLinkedList(Pool& memPool) noexcept | |||||
| : fMemPool(memPool) {} | |||||
| RtLinkedList(Pool& memPool, const bool needsCopyCtr = false) noexcept | |||||
| : AbstractLinkedList<T>(needsCopyCtr), | |||||
| fMemPool(memPool) {} | |||||
| bool append_sleepy(const T& value) noexcept | bool append_sleepy(const T& value) noexcept | ||||
| { | { | ||||
| if (typename AbstractLinkedList<T>::Data* const data = _allocate_sleepy()) | |||||
| { | |||||
| try { | |||||
| new(data)typename AbstractLinkedList<T>::Data(); | |||||
| } | |||||
| catch(...) { | |||||
| _deallocate(data); | |||||
| return false; | |||||
| } | |||||
| data->value = value; | |||||
| list_add_tail(&data->siblings, &this->fQueue); | |||||
| ++(this->fCount); | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| return _add_sleepy(value, true); | |||||
| } | } | ||||
| bool insert_sleepy(const T& value) noexcept | bool insert_sleepy(const T& value) noexcept | ||||
| { | { | ||||
| if (typename AbstractLinkedList<T>::Data* const data = _allocate_sleepy()) | |||||
| { | |||||
| try { | |||||
| new(data)typename AbstractLinkedList<T>::Data(); | |||||
| } | |||||
| catch(...) { | |||||
| _deallocate(data); | |||||
| return false; | |||||
| } | |||||
| data->value = value; | |||||
| list_add(&data->siblings, &this->fQueue); | |||||
| ++(this->fCount); | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| return _add_sleepy(value, false); | |||||
| } | } | ||||
| void resize(const size_t minPreallocated, const size_t maxPreallocated) noexcept | void resize(const size_t minPreallocated, const size_t maxPreallocated) noexcept | ||||
| @@ -186,6 +153,46 @@ private: | |||||
| fMemPool.deallocate(dataPtr); | fMemPool.deallocate(dataPtr); | ||||
| } | } | ||||
| bool _add_sleepy(const T& value, const bool inTail) noexcept | |||||
| { | |||||
| if (typename AbstractLinkedList<T>::Data* const data = _allocate_sleepy()) | |||||
| { | |||||
| if (this->fNeedsCopyCtr) | |||||
| { | |||||
| try { | |||||
| new(data)typename AbstractLinkedList<T>::Data(); | |||||
| } | |||||
| catch(...) { | |||||
| _deallocate(data); | |||||
| return false; | |||||
| } | |||||
| try { | |||||
| data->value = value; | |||||
| } | |||||
| catch(...) { | |||||
| data->~Data(); | |||||
| _deallocate(data); | |||||
| return false; | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| std::memcpy(&data->value, &value, this->fDataSize); | |||||
| } | |||||
| if (inTail) | |||||
| list_add_tail(&data->siblings, &this->fQueue); | |||||
| else | |||||
| list_add(&data->siblings, &this->fQueue); | |||||
| ++(this->fCount); | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| LINKED_LIST_DECLARATIONS(RtLinkedList) | LINKED_LIST_DECLARATIONS(RtLinkedList) | ||||
| }; | }; | ||||