Signed-off-by: falkTX <falktx@falktx.com>pull/1775/head
| @@ -32,8 +32,10 @@ struct LADSPA_RDF_Descriptor; | |||||
| CARLA_BACKEND_START_NAMESPACE | CARLA_BACKEND_START_NAMESPACE | ||||
| #if 0 | |||||
| } /* Fix editor indentation */ | |||||
| #ifdef _MSC_VER | |||||
| # define CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| #else | |||||
| # define CARLA_PLUGIN_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | |||||
| #endif | #endif | ||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| @@ -304,19 +306,19 @@ public: | |||||
| /*! | /*! | ||||
| * Get the plugin's label (URI for LV2 plugins). | * Get the plugin's label (URI for LV2 plugins). | ||||
| */ | */ | ||||
| __attribute__((warn_unused_result)) | |||||
| CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| virtual bool getLabel(char* strBuf) const noexcept; | virtual bool getLabel(char* strBuf) const noexcept; | ||||
| /*! | /*! | ||||
| * Get the plugin's maker. | * Get the plugin's maker. | ||||
| */ | */ | ||||
| __attribute__((warn_unused_result)) | |||||
| CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| virtual bool getMaker(char* strBuf) const noexcept; | virtual bool getMaker(char* strBuf) const noexcept; | ||||
| /*! | /*! | ||||
| * Get the plugin's copyright/license. | * Get the plugin's copyright/license. | ||||
| */ | */ | ||||
| __attribute__((warn_unused_result)) | |||||
| CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| virtual bool getCopyright(char* strBuf) const noexcept; | virtual bool getCopyright(char* strBuf) const noexcept; | ||||
| /*! | /*! | ||||
| @@ -324,51 +326,51 @@ public: | |||||
| * | * | ||||
| * @see getName() and setName() | * @see getName() and setName() | ||||
| */ | */ | ||||
| __attribute__((warn_unused_result)) | |||||
| CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| virtual bool getRealName(char* strBuf) const noexcept; | virtual bool getRealName(char* strBuf) const noexcept; | ||||
| /*! | /*! | ||||
| * Get the name of the parameter @a parameterId. | * Get the name of the parameter @a parameterId. | ||||
| */ | */ | ||||
| __attribute__((warn_unused_result)) | |||||
| CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| virtual bool getParameterName(uint32_t parameterId, char* strBuf) const noexcept; | virtual bool getParameterName(uint32_t parameterId, char* strBuf) const noexcept; | ||||
| /*! | /*! | ||||
| * Get the symbol of the parameter @a parameterId. | * Get the symbol of the parameter @a parameterId. | ||||
| */ | */ | ||||
| __attribute__((warn_unused_result)) | |||||
| CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| virtual bool getParameterSymbol(uint32_t parameterId, char* strBuf) const noexcept; | virtual bool getParameterSymbol(uint32_t parameterId, char* strBuf) const noexcept; | ||||
| /*! | /*! | ||||
| * Get the custom text of the parameter @a parameterId. | * Get the custom text of the parameter @a parameterId. | ||||
| * @see PARAMETER_USES_CUSTOM_TEXT | * @see PARAMETER_USES_CUSTOM_TEXT | ||||
| */ | */ | ||||
| __attribute__((warn_unused_result)) | |||||
| CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| virtual bool getParameterText(uint32_t parameterId, char* strBuf) noexcept; | virtual bool getParameterText(uint32_t parameterId, char* strBuf) noexcept; | ||||
| /*! | /*! | ||||
| * Get the unit of the parameter @a parameterId. | * Get the unit of the parameter @a parameterId. | ||||
| */ | */ | ||||
| __attribute__((warn_unused_result)) | |||||
| CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| virtual bool getParameterUnit(uint32_t parameterId, char* strBuf) const noexcept; | virtual bool getParameterUnit(uint32_t parameterId, char* strBuf) const noexcept; | ||||
| /*! | /*! | ||||
| * Get the comment (documentation) of the parameter @a parameterId. | * Get the comment (documentation) of the parameter @a parameterId. | ||||
| */ | */ | ||||
| __attribute__((warn_unused_result)) | |||||
| CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| virtual bool getParameterComment(uint32_t parameterId, char* strBuf) const noexcept; | virtual bool getParameterComment(uint32_t parameterId, char* strBuf) const noexcept; | ||||
| /*! | /*! | ||||
| * Get the group name of the parameter @a parameterId. | * Get the group name of the parameter @a parameterId. | ||||
| * @note The group name is prefixed by a unique symbol and ":". | * @note The group name is prefixed by a unique symbol and ":". | ||||
| */ | */ | ||||
| __attribute__((warn_unused_result)) | |||||
| CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| virtual bool getParameterGroupName(uint32_t parameterId, char* strBuf) const noexcept; | virtual bool getParameterGroupName(uint32_t parameterId, char* strBuf) const noexcept; | ||||
| /*! | /*! | ||||
| * Get the scalepoint @a scalePointId label of the parameter @a parameterId. | * Get the scalepoint @a scalePointId label of the parameter @a parameterId. | ||||
| */ | */ | ||||
| __attribute__((warn_unused_result)) | |||||
| CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| virtual bool getParameterScalePointLabel(uint32_t parameterId, uint32_t scalePointId, char* strBuf) const noexcept; | virtual bool getParameterScalePointLabel(uint32_t parameterId, uint32_t scalePointId, char* strBuf) const noexcept; | ||||
| /*! | /*! | ||||
| @@ -381,7 +383,7 @@ public: | |||||
| /*! | /*! | ||||
| * Get the name of the program at @a index. | * Get the name of the program at @a index. | ||||
| */ | */ | ||||
| __attribute__((warn_unused_result)) | |||||
| CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| bool getProgramName(uint32_t index, char* strBuf) const noexcept; | bool getProgramName(uint32_t index, char* strBuf) const noexcept; | ||||
| /*! | /*! | ||||
| @@ -389,7 +391,7 @@ public: | |||||
| * | * | ||||
| * @see getMidiProgramInfo() | * @see getMidiProgramInfo() | ||||
| */ | */ | ||||
| __attribute__((warn_unused_result)) | |||||
| CARLA_PLUGIN_WARN_UNUSED_RESULT | |||||
| bool getMidiProgramName(uint32_t index, char* strBuf) const noexcept; | bool getMidiProgramName(uint32_t index, char* strBuf) const noexcept; | ||||
| /*! | /*! | ||||
| @@ -1,6 +1,6 @@ | |||||
| /* | /* | ||||
| * Carla Thread | * Carla Thread | ||||
| * Copyright (C) 2013-2022 Filipe Coelho <falktx@falktx.com> | |||||
| * Copyright (C) 2013-2023 Filipe Coelho <falktx@falktx.com> | |||||
| * | * | ||||
| * This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
| * modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
| @@ -37,9 +37,7 @@ protected: | |||||
| */ | */ | ||||
| CarlaThread(const char* const threadName) noexcept | CarlaThread(const char* const threadName) noexcept | ||||
| : fLock(), | : fLock(), | ||||
| #ifndef CARLA_OS_WASM | |||||
| fSignal(), | fSignal(), | ||||
| #endif | |||||
| fName(threadName), | fName(threadName), | ||||
| #ifdef PTW32_DLLPORT | #ifdef PTW32_DLLPORT | ||||
| fHandle({nullptr, 0}), | fHandle({nullptr, 0}), | ||||
| @@ -71,11 +69,11 @@ public: | |||||
| */ | */ | ||||
| bool isThreadRunning() const noexcept | bool isThreadRunning() const noexcept | ||||
| { | { | ||||
| #ifdef PTW32_DLLPORT | |||||
| return (fHandle.p != nullptr); | |||||
| #else | |||||
| return (fHandle != 0); | |||||
| #endif | |||||
| #ifdef PTW32_DLLPORT | |||||
| return fHandle.p != nullptr; | |||||
| #else | |||||
| return fHandle != 0; | |||||
| #endif | |||||
| } | } | ||||
| /* | /* | ||||
| @@ -109,19 +107,19 @@ public: | |||||
| { | { | ||||
| sched_param.sched_priority = 80; | sched_param.sched_priority = 80; | ||||
| #if !defined(CARLA_OS_HAIKU) && !defined(CARLA_OS_WASM) | |||||
| #ifndef CARLA_OS_HAIKU | |||||
| if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) == 0 && | if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) == 0 && | ||||
| pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED) == 0 && | pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED) == 0 && | ||||
| # ifndef CARLA_OS_WIN | |||||
| #ifndef CARLA_OS_WIN | |||||
| (pthread_attr_setschedpolicy(&attr, SCHED_FIFO) == 0 || | (pthread_attr_setschedpolicy(&attr, SCHED_FIFO) == 0 || | ||||
| pthread_attr_setschedpolicy(&attr, SCHED_RR) == 0) && | pthread_attr_setschedpolicy(&attr, SCHED_RR) == 0) && | ||||
| # endif | |||||
| #endif | |||||
| pthread_attr_setschedparam(&attr, &sched_param) == 0) | pthread_attr_setschedparam(&attr, &sched_param) == 0) | ||||
| { | { | ||||
| carla_stdout("CarlaThread setup with realtime priority successful"); | carla_stdout("CarlaThread setup with realtime priority successful"); | ||||
| } | } | ||||
| else | else | ||||
| #endif | |||||
| #endif | |||||
| { | { | ||||
| carla_stdout("CarlaThread setup with realtime priority failed, going with normal priority instead"); | carla_stdout("CarlaThread setup with realtime priority failed, going with normal priority instead"); | ||||
| pthread_attr_destroy(&attr); | pthread_attr_destroy(&attr); | ||||
| @@ -147,20 +145,16 @@ public: | |||||
| pthread_attr_destroy(&attr); | pthread_attr_destroy(&attr); | ||||
| } | } | ||||
| #ifndef CARLA_OS_WASM | |||||
| CARLA_SAFE_ASSERT_RETURN(ok, false); | CARLA_SAFE_ASSERT_RETURN(ok, false); | ||||
| # ifdef PTW32_DLLPORT | |||||
| #ifdef PTW32_DLLPORT | |||||
| CARLA_SAFE_ASSERT_RETURN(handle.p != nullptr, false); | CARLA_SAFE_ASSERT_RETURN(handle.p != nullptr, false); | ||||
| # else | |||||
| #else | |||||
| CARLA_SAFE_ASSERT_RETURN(handle != 0, false); | CARLA_SAFE_ASSERT_RETURN(handle != 0, false); | ||||
| # endif | |||||
| #endif | |||||
| #endif | |||||
| _copyFrom(handle); | _copyFrom(handle); | ||||
| #ifndef CARLA_OS_WASM | |||||
| // wait for thread to start | // wait for thread to start | ||||
| fSignal.wait(); | fSignal.wait(); | ||||
| #endif | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -240,7 +234,12 @@ public: | |||||
| */ | */ | ||||
| pthread_t getThreadId() const noexcept | pthread_t getThreadId() const noexcept | ||||
| { | { | ||||
| #ifdef PTW32_DLLPORT | |||||
| const pthread_t handle = { fHandle.p, fHandle.x }; | |||||
| return handle; | |||||
| #else | |||||
| return fHandle; | return fHandle; | ||||
| #endif | |||||
| } | } | ||||
| /* | /* | ||||
| @@ -251,18 +250,16 @@ public: | |||||
| CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0',); | CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0',); | ||||
| carla_setProcessName(name); | carla_setProcessName(name); | ||||
| #if defined(__GLIBC__) && (__GLIBC__ * 1000 + __GLIBC_MINOR__) >= 2012 && !defined(CARLA_OS_GNU_HURD) | |||||
| #if defined(__GLIBC__) && (__GLIBC__ * 1000 + __GLIBC_MINOR__) >= 2012 && !defined(CARLA_OS_GNU_HURD) | |||||
| pthread_setname_np(pthread_self(), name); | pthread_setname_np(pthread_self(), name); | ||||
| #endif | |||||
| #endif | |||||
| } | } | ||||
| // ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
| private: | private: | ||||
| CarlaMutex fLock; // Thread lock | CarlaMutex fLock; // Thread lock | ||||
| #ifndef CARLA_OS_WASM | |||||
| CarlaSignal fSignal; // Thread start wait signal | CarlaSignal fSignal; // Thread start wait signal | ||||
| #endif | |||||
| const CarlaString fName; // Thread name | const CarlaString fName; // Thread name | ||||
| volatile pthread_t fHandle; // Handle for this thread | volatile pthread_t fHandle; // Handle for this thread | ||||
| volatile bool fShouldExit; // true if thread should exit | volatile bool fShouldExit; // true if thread should exit | ||||
| @@ -272,12 +269,12 @@ private: | |||||
| */ | */ | ||||
| void _init() noexcept | void _init() noexcept | ||||
| { | { | ||||
| #ifdef PTW32_DLLPORT | |||||
| #ifdef PTW32_DLLPORT | |||||
| fHandle.p = nullptr; | fHandle.p = nullptr; | ||||
| fHandle.x = 0; | fHandle.x = 0; | ||||
| #else | |||||
| #else | |||||
| fHandle = 0; | fHandle = 0; | ||||
| #endif | |||||
| #endif | |||||
| } | } | ||||
| /* | /* | ||||
| @@ -285,12 +282,12 @@ private: | |||||
| */ | */ | ||||
| void _copyFrom(const pthread_t& handle) noexcept | void _copyFrom(const pthread_t& handle) noexcept | ||||
| { | { | ||||
| #ifdef PTW32_DLLPORT | |||||
| #ifdef PTW32_DLLPORT | |||||
| fHandle.p = handle.p; | fHandle.p = handle.p; | ||||
| fHandle.x = handle.x; | fHandle.x = handle.x; | ||||
| #else | |||||
| #else | |||||
| fHandle = handle; | fHandle = handle; | ||||
| #endif | |||||
| #endif | |||||
| } | } | ||||
| /* | /* | ||||
| @@ -298,12 +295,12 @@ private: | |||||
| */ | */ | ||||
| void _copyTo(volatile pthread_t& handle) const noexcept | void _copyTo(volatile pthread_t& handle) const noexcept | ||||
| { | { | ||||
| #ifdef PTW32_DLLPORT | |||||
| #ifdef PTW32_DLLPORT | |||||
| handle.p = fHandle.p; | handle.p = fHandle.p; | ||||
| handle.x = fHandle.x; | handle.x = fHandle.x; | ||||
| #else | |||||
| #else | |||||
| handle = fHandle; | handle = fHandle; | ||||
| #endif | |||||
| #endif | |||||
| } | } | ||||
| /* | /* | ||||
| @@ -314,10 +311,8 @@ private: | |||||
| if (fName.isNotEmpty()) | if (fName.isNotEmpty()) | ||||
| setCurrentThreadName(fName); | setCurrentThreadName(fName); | ||||
| #ifndef CARLA_OS_WASM | |||||
| // report ready | // report ready | ||||
| fSignal.signal(); | fSignal.signal(); | ||||
| #endif | |||||
| try { | try { | ||||
| run(); | run(); | ||||