diff --git a/source/backend/CarlaBackend.hpp b/source/backend/CarlaBackend.hpp index 4dea96715..c9a5ffc12 100644 --- a/source/backend/CarlaBackend.hpp +++ b/source/backend/CarlaBackend.hpp @@ -688,7 +688,7 @@ struct ParameterData { int16_t midiCC; #ifndef DOXYGEN - ParameterData() + ParameterData() noexcept : type(PARAMETER_UNKNOWN), index(PARAMETER_NULL), rindex(-1), @@ -710,7 +710,7 @@ struct ParameterRanges { float stepLarge; #ifndef DOXYGEN - ParameterRanges() + ParameterRanges() noexcept : def(0.0f), min(0.0f), max(1.0f), @@ -719,12 +719,12 @@ struct ParameterRanges { stepLarge(0.1f) {} #endif - void fixDefault() + void fixDefault() noexcept { fixValue(def); } - void fixValue(float& value) const + void fixValue(float& value) const noexcept { if (value < min) value = min; @@ -732,7 +732,7 @@ struct ParameterRanges { value = max; } - float getFixedValue(const float& value) const + float getFixedValue(const float& value) const noexcept { if (value < min) return min; @@ -741,7 +741,7 @@ struct ParameterRanges { return value; } - float getNormalizedValue(const float& value) const + float getNormalizedValue(const float& value) const noexcept { float newValue = (value - min) / (max - min); @@ -753,7 +753,7 @@ struct ParameterRanges { return newValue; } - float getUnnormalizedValue(const float& value) const + float getUnnormalizedValue(const float& value) const noexcept { return value * (max - min) + min; } @@ -768,7 +768,7 @@ struct MidiProgramData { const char* name; #ifndef DOXYGEN - MidiProgramData() + MidiProgramData() noexcept : bank(0), program(0), name(nullptr) {} @@ -786,7 +786,7 @@ struct CustomData { const char* value; #ifndef DOXYGEN - CustomData() + CustomData() noexcept : type(nullptr), key(nullptr), value(nullptr) {} diff --git a/source/backend/CarlaNative.hpp b/source/backend/CarlaNative.hpp index 3fe7d4cfd..c8bcbb9f0 100644 --- a/source/backend/CarlaNative.hpp +++ b/source/backend/CarlaNative.hpp @@ -47,12 +47,12 @@ protected: // ------------------------------------------------------------------- // Host calls - const HostDescriptor* getHostHandle() const + const HostDescriptor* getHostHandle() const noexcept { return pHost; } - const char* getResourceDir() const + const char* getResourceDir() const noexcept { CARLA_ASSERT(pHost != nullptr); @@ -62,7 +62,7 @@ protected: return nullptr; } - const char* getUiName() const + const char* getUiName() const noexcept { CARLA_ASSERT(pHost != nullptr); diff --git a/source/backend/CarlaPlugin.hpp b/source/backend/CarlaPlugin.hpp index 985b35783..8033f548f 100644 --- a/source/backend/CarlaPlugin.hpp +++ b/source/backend/CarlaPlugin.hpp @@ -41,7 +41,11 @@ CARLA_BACKEND_START_NAMESPACE */ /*! - * TODO. + * Post-Rt event type.\n + * These are events postponned from within the process function, + * + * During process, we cannot lock, allocate memory or do UI stuff,\n + * so events have to be postponned to be executed later, on a separate thread. */ enum PluginPostRtEventType { kPluginPostRtEventNull, @@ -67,12 +71,11 @@ struct CarlaPluginProtectedData; // ----------------------------------------------------------------------- /*! - * \class CarlaPlugin - * - * \brief Carla Backend base plugin class + * Carla Backend base plugin class * * This is the base class for all available plugin types available in Carla Backend.\n - * All virtual calls are implemented in this class as fallback, so it's safe to only override needed calls. + * All virtual calls are implemented in this class as fallback (except reload and process),\n + * so it's safe to only override needed calls. * * \see PluginType */ @@ -97,23 +100,23 @@ public: // Information (base) /*! - * Get the plugin's type (ie, a subclass of CarlaPlugin). + * Get the plugin's type (a subclass of CarlaPlugin). * * \note Plugin bridges will return their respective plugin type, there is no plugin type such as "bridge".\n * To check if a plugin is a bridge use: * \code - * if (hints() & PLUGIN_IS_BRIDGE) + * if (getHints() & PLUGIN_IS_BRIDGE) * ... * \endcode */ - virtual PluginType type() const = 0; + virtual PluginType getType() const noexcept = 0; /*! * Get the plugin's id (as passed in the constructor). * * \see setId() */ - unsigned int id() const + unsigned int getId() const noexcept { return fId; } @@ -123,29 +126,28 @@ public: * * \see PluginHints */ - unsigned int hints() const + unsigned int getHints() const noexcept { return fHints; } /*! - * Get the plugin's options. + * Get the plugin's options (currently in use). * - * \see PluginOptions, availableOptions() and setOption() + * \see PluginOptions, getAvailableOptions() and setOption() */ - unsigned int options() const + unsigned int getOptions() const noexcept { return fOptions; } /*! * Check if the plugin is enabled.\n - * When a plugin is disabled, it will never be processed or managed in any way.\n - * To 'bypass' a plugin use setActive() instead. + * When a plugin is disabled, it will never be processed or managed in any way. * * \see setEnabled() */ - bool enabled() const + bool isEnabled() const noexcept { return fEnabled; } @@ -154,9 +156,9 @@ public: * Get the plugin's internal name.\n * This name is unique within all plugins in an engine. * - * \see getRealName() + * \see getRealName() and setName() */ - const char* name() const + const char* getName() const noexcept { return (const char*)fName; } @@ -165,7 +167,7 @@ public: * Get the currently loaded DLL filename for this plugin.\n * (Sound kits return their exact filename). */ - const char* filename() const + const char* getFilename() const noexcept { return (const char*)fFilename; } @@ -173,7 +175,7 @@ public: /*! * Get the plugins's icon name. */ - const char* iconName() const + const char* getIconName() const noexcept { return (const char*)fIconName; } @@ -181,7 +183,7 @@ public: /*! * Get the plugin's category (delay, filter, synth, etc). */ - virtual PluginCategory category() + virtual PluginCategory getCategory() const { return PLUGIN_CATEGORY_NONE; } @@ -190,7 +192,7 @@ public: * Get the plugin's native unique Id.\n * May return 0 on plugin types that don't support Ids. */ - virtual long uniqueId() const + virtual long getUniqueId() const { return 0; } @@ -198,7 +200,7 @@ public: /*! * Get the plugin's latency, in sample frames. */ - uint32_t latency() const; + uint32_t getLatencyInFrames() const noexcept; // ------------------------------------------------------------------- // Information (count) @@ -206,48 +208,48 @@ public: /*! * Get the number of audio inputs. */ - uint32_t audioInCount() const; + uint32_t getAudioInCount() const noexcept; /*! * Get the number of audio outputs. */ - uint32_t audioOutCount() const; + uint32_t getAudioOutCount() const noexcept; /*! * Get the number of MIDI inputs. */ - virtual uint32_t midiInCount() const; + virtual uint32_t getMidiInCount() const noexcept; /*! * Get the number of MIDI outputs. */ - virtual uint32_t midiOutCount() const; + virtual uint32_t getMidiOutCount() const noexcept; /*! * Get the number of parameters.\n * To know the number of parameter inputs and outputs separately use getParameterCountInfo() instead. */ - uint32_t parameterCount() const; + uint32_t getParameterCount() const noexcept; /*! * Get the number of scalepoints for parameter \a parameterId. */ - virtual uint32_t parameterScalePointCount(const uint32_t parameterId) const; + virtual uint32_t getParameterScalePointCount(const uint32_t parameterId) const; /*! * Get the number of programs. */ - uint32_t programCount() const; + uint32_t getProgramCount() const noexcept; /*! * Get the number of MIDI programs. */ - uint32_t midiProgramCount() const; + uint32_t getMidiProgramCount() const noexcept; /*! * Get the number of custom data sets. */ - uint32_t customDataCount() const; + uint32_t getCustomDataCount() const noexcept; // ------------------------------------------------------------------- // Information (current data) @@ -257,7 +259,7 @@ public: * * \see setProgram() */ - int32_t currentProgram() const; + int32_t getCurrentProgram() const noexcept; /*! * Get the current MIDI program number (-1 if unset). @@ -265,36 +267,36 @@ public: * \see setMidiProgram() * \see setMidiProgramById() */ - int32_t currentMidiProgram() const; + int32_t getCurrentMidiProgram() const noexcept; /*! * Get the parameter data of \a parameterId. */ - const ParameterData& parameterData(const uint32_t parameterId) const; + const ParameterData& getParameterData(const uint32_t parameterId) const; /*! * Get the parameter ranges of \a parameterId. */ - const ParameterRanges& parameterRanges(const uint32_t parameterId) const; + const ParameterRanges& getParameterRanges(const uint32_t parameterId) const; /*! * Check if parameter \a parameterId is of output type. */ - bool parameterIsOutput(const uint32_t parameterId) const; + bool isParameterOutput(const uint32_t parameterId) const; /*! * Get the MIDI program at \a index. * * \see getMidiProgramName() */ - const MidiProgramData& midiProgramData(const uint32_t index) const; + const MidiProgramData& getMidiProgramData(const uint32_t index) const; /*! * Get the custom data set at \a index. * - * \see setCustomData() + * \see getCustomDataCount() and setCustomData() */ - const CustomData& customData(const uint32_t index) const; + const CustomData& getCustomData(const uint32_t index) const; /*! * Get the complete plugin chunk data into \a dataPtr. @@ -304,7 +306,7 @@ public: * * \see setChunkData() */ - virtual int32_t chunkData(void** const dataPtr); + virtual int32_t getChunkData(void** const dataPtr) const; // ------------------------------------------------------------------- // Information (per-plugin data) @@ -312,78 +314,78 @@ public: /*! * Get the plugin available options. * - * \see PluginOptions + * \see PluginOptions, getOptions() and setOption() */ - virtual unsigned int availableOptions(); + virtual unsigned int getAvailableOptions() const; /*! * Get the current parameter value of \a parameterId. */ - virtual float getParameterValue(const uint32_t parameterId); + virtual float getParameterValue(const uint32_t parameterId) const; /*! * Get the scalepoint \a scalePointId value of the parameter \a parameterId. */ - virtual float getParameterScalePointValue(const uint32_t parameterId, const uint32_t scalePointId); + virtual float getParameterScalePointValue(const uint32_t parameterId, const uint32_t scalePointId) const; /*! - * Get the plugin's label (URI for PLUGIN_LV2). + * Get the plugin's label (URI for LV2 plugins). */ - virtual void getLabel(char* const strBuf); + virtual void getLabel(char* const strBuf) const noexcept; /*! * Get the plugin's maker. */ - virtual void getMaker(char* const strBuf); + virtual void getMaker(char* const strBuf) const noexcept; /*! * Get the plugin's copyright/license. */ - virtual void getCopyright(char* const strBuf); + virtual void getCopyright(char* const strBuf) const noexcept; /*! * Get the plugin's (real) name. * - * \see name() + * \see getName() and setName() */ - virtual void getRealName(char* const strBuf); + virtual void getRealName(char* const strBuf) const noexcept; /*! * Get the name of the parameter \a parameterId. */ - virtual void getParameterName(const uint32_t parameterId, char* const strBuf); + virtual void getParameterName(const uint32_t parameterId, char* const strBuf) const; /*! * Get the symbol of the parameter \a parameterId. */ - virtual void getParameterSymbol(const uint32_t parameterId, char* const strBuf); + virtual void getParameterSymbol(const uint32_t parameterId, char* const strBuf) const; /*! * Get the custom text of the parameter \a parameterId. */ - virtual void getParameterText(const uint32_t parameterId, char* const strBuf); + virtual void getParameterText(const uint32_t parameterId, char* const strBuf) const; /*! * Get the unit of the parameter \a parameterId. */ - virtual void getParameterUnit(const uint32_t parameterId, char* const strBuf); + virtual void getParameterUnit(const uint32_t parameterId, char* const strBuf) const; /*! * Get the scalepoint \a scalePointId label of the parameter \a parameterId. */ - virtual void getParameterScalePointLabel(const uint32_t parameterId, const uint32_t scalePointId, char* const strBuf); + virtual void getParameterScalePointLabel(const uint32_t parameterId, const uint32_t scalePointId, char* const strBuf) const; /*! * Get the name of the program at \a index. */ - void getProgramName(const uint32_t index, char* const strBuf); + void getProgramName(const uint32_t index, char* const strBuf) const; /*! * Get the name of the MIDI program at \a index. * * \see getMidiProgramInfo() */ - void getMidiProgramName(const uint32_t index, char* const strBuf); + void getMidiProgramName(const uint32_t index, char* const strBuf) const; /*! * Get information about the plugin's parameter count.\n @@ -391,9 +393,9 @@ public: * * \note Some parameters might not be input or output (ie, invalid). * - * \see parameterCount() + * \see getParameterCount() */ - void getParameterCountInfo(uint32_t* const ins, uint32_t* const outs, uint32_t* const total); + void getParameterCountInfo(uint32_t* const ins, uint32_t* const outs, uint32_t* const total) const; // ------------------------------------------------------------------- // Set data (state) @@ -420,11 +422,15 @@ public: /*! * Save the current plugin state to \a filename. + * + * \see loadStateFromFile() */ bool saveStateToFile(const char* const filename); /*! * Save the plugin state from \a filename. + * + * \see saveStateToFile() */ bool loadStateFromFile(const char* const filename); @@ -434,31 +440,29 @@ public: /*! * Set the plugin's id to \a newId. * - * \see id() + * \see getId() */ - void setId(const unsigned int newId); + void setId(const unsigned int newId) noexcept; /*! * Set the plugin's name to \a newName. * - * \see name() + * \see getName() and getRealName() */ virtual void setName(const char* const newName); /*! * Set a plugin's option. * - * \see options() + * \see getOptions() and getAvailableOptions() */ void setOption(const unsigned int option, const bool yesNo); /*! - * Enable or disable the plugin according to \a yesNo. - * - * When a plugin is disabled, it will never be processed or managed in any way.\n - * To 'bypass' a plugin use setActive() instead. + * Enable or disable the plugin according to \a yesNo. \n + * When a plugin is disabled, it will never be processed or managed in any way. * - * \see enabled() + * \see isEnabled() */ void setEnabled(const bool yesNo); @@ -583,7 +587,7 @@ public: * \param value The value of the data set, of type \a type. * \param sendGui Send message change to plugin's custom GUI, if any * - * \see customData() + * \see getCustomDataCount() and getCustomData() */ virtual void setCustomData(const char* const type, const char* const key, const char* const value, const bool sendGui); @@ -591,7 +595,7 @@ public: * Set the complete chunk data as \a stringData.\n * \a stringData must a base64 encoded string of binary data. * - * \see chunkData() + * \see getChunkData() * * \note Make sure to verify the plugin supports chunks before calling this function! */ @@ -655,7 +659,7 @@ public: * Reload the plugin's entire state (including programs).\n * The plugin will be disabled during this call. */ - virtual void reload(); + virtual void reload() = 0; /*! * Reload the plugin's programs state. @@ -678,7 +682,7 @@ public: /*! * Plugin process call. */ - virtual void process(float** const inBuffer, float** const outBuffer, const uint32_t frames); + virtual void process(float** const inBuffer, float** const outBuffer, const uint32_t frames) = 0; /*! * Tell the plugin the current buffer size changed. @@ -696,12 +700,13 @@ public: virtual void offlineModeChanged(const bool isOffline); /*! - * TODO. + * Try to lock the plugin's master mutex. */ bool tryLock(); /*! - * TODO. + * Unlock the plugin's master mutex. + * \note The mutex wasTryLockCalled() flag will be unset */ void unlock(); @@ -735,7 +740,7 @@ public: /*! * Free the plugin's internal OSC memory data. */ - void freeOscData(); + //void freeOscData(); /*! * Show the plugin's OSC based GUI.\n @@ -809,6 +814,15 @@ public: // ------------------------------------------------------------------- // Plugin initializers + /*! + * Handy function used and required by CarlaEngine::clonePlugin(). + */ + virtual const void* getExtraStuff() const noexcept + { + return nullptr; + } + +#ifndef DOXYGEN struct Initializer { CarlaEngine* const engine; const unsigned int id; @@ -817,12 +831,6 @@ public: const char* const label; }; - // used in CarlaEngine::clonePlugin() - virtual const void* getExtraStuff() const - { - return nullptr; - } - static size_t getNativePluginCount(); static const PluginDescriptor* getNativePluginDescriptor(const size_t index); @@ -836,29 +844,51 @@ public: static CarlaPlugin* newGIG(const Initializer& init, const bool use16Outs); static CarlaPlugin* newSF2(const Initializer& init, const bool use16Outs); static CarlaPlugin* newSFZ(const Initializer& init, const bool use16Outs); +#endif // ------------------------------------------------------------------- protected: - unsigned int fId; //!< Plugin Id, as passed in the constructor, returned in id(). \see setId() - unsigned int fHints; //!< Hints, as returned in hints(). - unsigned int fOptions; //!< Defined and currently in-use options, returned in options(). \see availableOptions() + /*! + * Plugin Id, as passed in the constructor, returned in getId(). + * \see getId and setId() + */ + unsigned int fId; - bool fEnabled; //!< Wherever the plugin is ready for usage + /*! + * Hints, as returned in getHints(). + * \see PluginHints and getHints() + */ + unsigned int fHints; + + /*! + * Defined and currently in-use options, returned in getOptions(). + * \see PluginOptions, getOptions(), getAvailableOptions() and setOption() + */ + unsigned int fOptions; + + /*! + * Wherever the plugin is ready for usage.\n + * When a plugin is disabled, it will never be processed or managed in any way. + * \see isEnabled() and setEnabled() + */ + bool fEnabled; CarlaString fName; //!< Plugin name CarlaString fFilename; //!< Plugin filename, if applicable CarlaString fIconName; //!< Icon name - //friend class CarlaEngineBridge; - friend struct CarlaPluginProtectedData; CarlaPluginProtectedData* const pData; //!< Internal data, for CarlaPlugin subclasses only. + friend struct CarlaPluginProtectedData; + //friend class CarlaEngineBridge; // ------------------------------------------------------------------- // Helper classes - // Fully disable plugin in scope and also its engine client - // May wait-block on constructor for plugin process to end + /*! + * Fully disable plugin in scope and also its engine client.\n + * May wait-block on constructor for plugin process to end. + */ class ScopedDisabler { public: @@ -866,15 +896,17 @@ protected: ~ScopedDisabler(); private: - CarlaPlugin* const kPlugin; + CarlaPlugin* const fPlugin; CARLA_PREVENT_HEAP_ALLOCATION CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ScopedDisabler) }; - // Lock the plugin's own run/process call - // Plugin will still work as normal, but output only silence - // On destructor needsReset flag might be set if the plugin might have missed some events + /*! + * Lock the plugin's own run/process call.\n + * Plugin will still work as normal, but output only silence.\n + * On destructor needsReset flag might be set if the plugin might have missed some events. + */ class ScopedSingleProcessLocker { public: @@ -882,8 +914,8 @@ protected: ~ScopedSingleProcessLocker(); private: - CarlaPlugin* const kPlugin; - const bool kBlock; + CarlaPlugin* const fPlugin; + const bool fBlock; CARLA_PREVENT_HEAP_ALLOCATION CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ScopedSingleProcessLocker) diff --git a/source/backend/plugin/CarlaPlugin.cpp b/source/backend/plugin/CarlaPlugin.cpp index 8d6cfda49..b9852b122 100644 --- a/source/backend/plugin/CarlaPlugin.cpp +++ b/source/backend/plugin/CarlaPlugin.cpp @@ -288,7 +288,7 @@ CarlaPlugin::CarlaPlugin(CarlaEngine* const engine, const unsigned int id) fOptions(0x0), fEnabled(false), fIconName("plugin"), - kData(new CarlaPluginProtectedData(engine, this)) + pData(new CarlaPluginProtectedData(engine, this)) { CARLA_ASSERT(kData != nullptr); CARLA_ASSERT(engine != nullptr); @@ -321,116 +321,116 @@ CarlaPlugin::~CarlaPlugin() { carla_debug("CarlaPlugin::~CarlaPlugin()"); - kData->cleanup(); - delete kData; + pData->cleanup(); + delete pData; } // ------------------------------------------------------------------- // Information (base) -uint32_t CarlaPlugin::latency() const +uint32_t CarlaPlugin::latency() const noexcept { - return kData->latency; + return pData->latency; } // ------------------------------------------------------------------- // Information (count) -uint32_t CarlaPlugin::audioInCount() const +uint32_t CarlaPlugin::audioInCount() const noexcept { - return kData->audioIn.count; + return pData->audioIn.count; } -uint32_t CarlaPlugin::audioOutCount() const +uint32_t CarlaPlugin::audioOutCount() const noexcept { - return kData->audioOut.count; + return pData->audioOut.count; } -uint32_t CarlaPlugin::midiInCount() const +uint32_t CarlaPlugin::midiInCount() const noexcept { - return (kData->extraHints & PLUGIN_HINT_HAS_MIDI_IN) ? 1 : 0; + return (pData->extraHints & PLUGIN_HINT_HAS_MIDI_IN) ? 1 : 0; } uint32_t CarlaPlugin::midiOutCount() const { - return (kData->extraHints & PLUGIN_HINT_HAS_MIDI_OUT) ? 1 : 0; + return (pData->extraHints & PLUGIN_HINT_HAS_MIDI_OUT) ? 1 : 0; } -uint32_t CarlaPlugin::parameterCount() const +uint32_t CarlaPlugin::parameterCount() const noexcept { - return kData->param.count; + return pData->param.count; } uint32_t CarlaPlugin::parameterScalePointCount(const uint32_t parameterId) const { - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); return 0; // unused (void)parameterId; } -uint32_t CarlaPlugin::programCount() const +uint32_t CarlaPlugin::programCount() const noexcept { - return kData->prog.count; + return pData->prog.count; } -uint32_t CarlaPlugin::midiProgramCount() const +uint32_t CarlaPlugin::midiProgramCount() const noexcept { - return kData->midiprog.count; + return pData->midiprog.count; } -uint32_t CarlaPlugin::customDataCount() const +uint32_t CarlaPlugin::customDataCount() const noexcept { - return kData->custom.count(); + return pData->custom.count(); } // ------------------------------------------------------------------- // Information (current data) -int32_t CarlaPlugin::currentProgram() const +int32_t CarlaPlugin::currentProgram() const noexcept { - return kData->prog.current; + return pData->prog.current; } -int32_t CarlaPlugin::currentMidiProgram() const +int32_t CarlaPlugin::currentMidiProgram() const noexcept { - return kData->midiprog.current; + return pData->midiprog.current; } const ParameterData& CarlaPlugin::parameterData(const uint32_t parameterId) const { - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); - return (parameterId < kData->param.count) ? kData->param.data[parameterId] : kParameterDataNull; + return (parameterId < pData->param.count) ? pData->param.data[parameterId] : kParameterDataNull; } const ParameterRanges& CarlaPlugin::parameterRanges(const uint32_t parameterId) const { - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); - return (parameterId < kData->param.count) ? kData->param.ranges[parameterId] : kParameterRangesNull; + return (parameterId < pData->param.count) ? pData->param.ranges[parameterId] : kParameterRangesNull; } bool CarlaPlugin::parameterIsOutput(const uint32_t parameterId) const { - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); - return (parameterId < kData->param.count) ? (kData->param.data[parameterId].type == PARAMETER_OUTPUT) : false; + return (parameterId < pData->param.count) ? (pData->param.data[parameterId].type == PARAMETER_OUTPUT) : false; } const MidiProgramData& CarlaPlugin::midiProgramData(const uint32_t index) const { - CARLA_ASSERT(index < kData->midiprog.count); + CARLA_ASSERT(index < pData->midiprog.count); - return (index < kData->midiprog.count) ? kData->midiprog.data[index] : kMidiProgramDataNull; + return (index < pData->midiprog.count) ? pData->midiprog.data[index] : kMidiProgramDataNull; } const CustomData& CarlaPlugin::customData(const uint32_t index) const { - CARLA_ASSERT(index < kData->custom.count()); + CARLA_ASSERT(index < pData->custom.count()); - return (index < kData->custom.count()) ? kData->custom.getAt(index) : kCustomDataNull; + return (index < pData->custom.count()) ? pData->custom.getAt(index) : kCustomDataNull; } int32_t CarlaPlugin::chunkData(void** const dataPtr) @@ -474,22 +474,22 @@ float CarlaPlugin::getParameterScalePointValue(const uint32_t parameterId, const (void)scalePointId; } -void CarlaPlugin::getLabel(char* const strBuf) +void CarlaPlugin::getLabel(char* const strBuf) noexcept { *strBuf = '\0'; } -void CarlaPlugin::getMaker(char* const strBuf) +void CarlaPlugin::getMaker(char* const strBuf) noexcept { *strBuf = '\0'; } -void CarlaPlugin::getCopyright(char* const strBuf) +void CarlaPlugin::getCopyright(char* const strBuf) noexcept { *strBuf = '\0'; } -void CarlaPlugin::getRealName(char* const strBuf) +void CarlaPlugin::getRealName(char* const strBuf) noexcept { *strBuf = '\0'; } @@ -551,22 +551,22 @@ void CarlaPlugin::getParameterScalePointLabel(const uint32_t parameterId, const void CarlaPlugin::getProgramName(const uint32_t index, char* const strBuf) { - CARLA_ASSERT(index < kData->prog.count); - CARLA_ASSERT(kData->prog.names[index] != nullptr); + CARLA_ASSERT(index < pData->prog.count); + CARLA_ASSERT(pData->prog.names[index] != nullptr); - if (index < kData->prog.count && kData->prog.names[index]) - std::strncpy(strBuf, kData->prog.names[index], STR_MAX); + if (index < pData->prog.count && pData->prog.names[index]) + std::strncpy(strBuf, pData->prog.names[index], STR_MAX); else *strBuf = '\0'; } void CarlaPlugin::getMidiProgramName(const uint32_t index, char* const strBuf) { - CARLA_ASSERT(index < kData->midiprog.count); - CARLA_ASSERT(kData->midiprog.data[index].name != nullptr); + CARLA_ASSERT(index < pData->midiprog.count); + CARLA_ASSERT(pData->midiprog.data[index].name != nullptr); - if (index < kData->midiprog.count && kData->midiprog.data[index].name) - std::strncpy(strBuf, kData->midiprog.data[index].name, STR_MAX); + if (index < pData->midiprog.count && pData->midiprog.data[index].name) + std::strncpy(strBuf, pData->midiprog.data[index].name, STR_MAX); else *strBuf = '\0'; } @@ -582,13 +582,13 @@ void CarlaPlugin::getParameterCountInfo(uint32_t* const ins, uint32_t* const out *ins = 0; *outs = 0; - *total = kData->param.count; + *total = pData->param.count; - for (uint32_t i=0; i < kData->param.count; ++i) + for (uint32_t i=0; i < pData->param.count; ++i) { - if (kData->param.data[i].type == PARAMETER_INPUT) + if (pData->param.data[i].type == PARAMETER_INPUT) *ins += 1; - else if (kData->param.data[i].type == PARAMETER_OUTPUT) + else if (pData->param.data[i].type == PARAMETER_OUTPUT) *outs += 1; } } @@ -655,15 +655,15 @@ const SaveState& CarlaPlugin::getSaveState() // ---------------------------- // Internals - saveState.active = kData->active; + saveState.active = pData->active; #ifndef BUILD_BRIDGE - saveState.dryWet = kData->postProc.dryWet; - saveState.volume = kData->postProc.volume; - saveState.balanceLeft = kData->postProc.balanceLeft; - saveState.balanceRight = kData->postProc.balanceRight; - saveState.panning = kData->postProc.panning; - saveState.ctrlChannel = kData->ctrlChannel; + saveState.dryWet = pData->postProc.dryWet; + saveState.volume = pData->postProc.volume; + saveState.balanceLeft = pData->postProc.balanceLeft; + saveState.balanceRight = pData->postProc.balanceRight; + saveState.panning = pData->postProc.panning; + saveState.ctrlChannel = pData->ctrlChannel; #endif // ---------------------------- @@ -686,18 +686,18 @@ const SaveState& CarlaPlugin::getSaveState() // ---------------------------- // Current Program - if (kData->prog.current >= 0) + if (pData->prog.current >= 0) { - saveState.currentProgramIndex = kData->prog.current; - saveState.currentProgramName = carla_strdup(kData->prog.names[kData->prog.current]); + saveState.currentProgramIndex = pData->prog.current; + saveState.currentProgramName = carla_strdup(pData->prog.names[pData->prog.current]); } // ---------------------------- // Current MIDI Program - if (kData->midiprog.current >= 0) + if (pData->midiprog.current >= 0) { - const MidiProgramData& mpData(kData->midiprog.getCurrent()); + const MidiProgramData& mpData(pData->midiprog.getCurrent()); saveState.currentMidiBank = mpData.bank; saveState.currentMidiProgram = mpData.program; @@ -706,11 +706,11 @@ const SaveState& CarlaPlugin::getSaveState() // ---------------------------- // Parameters - const float sampleRate(kData->engine->getSampleRate()); + const float sampleRate(pData->engine->getSampleRate()); - for (uint32_t i=0, count=kData->param.count; i < count; ++i) + for (uint32_t i=0, count=pData->param.count; i < count; ++i) { - const ParameterData& paramData(kData->param.data[i]); + const ParameterData& paramData(pData->param.data[i]); if ((paramData.hints & PARAMETER_IS_AUTOMABLE) == 0) continue; @@ -738,7 +738,7 @@ const SaveState& CarlaPlugin::getSaveState() // ---------------------------- // Custom Data - for (NonRtList::Itenerator it = kData->custom.begin(); it.valid(); it.next()) + for (NonRtList::Itenerator it = pData->custom.begin(); it.valid(); it.next()) { const CustomData& cData(*it); @@ -821,14 +821,14 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) programId = saveState.currentProgramIndex; } // index < count - else if (saveState.currentProgramIndex < static_cast(kData->prog.count)) + else if (saveState.currentProgramIndex < static_cast(pData->prog.count)) { programId = saveState.currentProgramIndex; } // index not valid, try to find by name else { - for (uint32_t i=0; i < kData->prog.count; ++i) + for (uint32_t i=0; i < pData->prog.count; ++i) { getProgramName(i, strBuf); @@ -858,7 +858,7 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) if (type() == PLUGIN_LADSPA || type() == PLUGIN_LV2) { - for (uint32_t i=0; i < kData->param.count; ++i) + for (uint32_t i=0; i < pData->param.count; ++i) { getParameterSymbol(i, strBuf); @@ -873,7 +873,7 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) // --------------------------------------------------------------------- // Part 4b - set parameter values (carefully) - const float sampleRate(kData->engine->getSampleRate()); + const float sampleRate(pData->engine->getSampleRate()); for (NonRtList::Itenerator it = saveState.parameters.begin(); it.valid(); it.next()) { @@ -930,9 +930,9 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) } // Now set parameter - if (index >= 0 && index < static_cast(kData->param.count)) + if (index >= 0 && index < static_cast(pData->param.count)) { - if (kData->param.data[index].hints & PARAMETER_USES_SAMPLERATE) + if (pData->param.data[index].hints & PARAMETER_USES_SAMPLERATE) stateParameter->value *= sampleRate; setParameterValue(index, stateParameter->value, true, true, true); @@ -1031,7 +1031,7 @@ bool CarlaPlugin::loadStateFromFile(const char* const filename) if (xmlNode.toElement().tagName() != "CARLA-PRESET") { - kData->engine->setLastError("Not a valid Carla preset file"); + pData->engine->setLastError("Not a valid Carla preset file"); return false; } @@ -1043,7 +1043,7 @@ bool CarlaPlugin::loadStateFromFile(const char* const filename) // ------------------------------------------------------------------- // Set data (internal stuff) -void CarlaPlugin::setId(const unsigned int newId) +void CarlaPlugin::setId(const unsigned int newId) noexcept { fId = newId; } @@ -1064,18 +1064,18 @@ void CarlaPlugin::setOption(const unsigned int option, const bool yesNo) else fOptions &= ~option; - kData->saveSetting(option, yesNo); + pData->saveSetting(option, yesNo); } void CarlaPlugin::setEnabled(const bool yesNo) { + if (fEnabled == yesNo) + return; + fEnabled = yesNo; - if (! yesNo) - { - kData->masterMutex.lock(); - kData->masterMutex.unlock(); - } + pData->masterMutex.lock(); + pData->masterMutex.unlock(); } // ------------------------------------------------------------------- @@ -1087,7 +1087,7 @@ void CarlaPlugin::setActive(const bool active, const bool sendOsc, const bool se CARLA_ASSERT(sendOsc || sendCallback); // never call this from RT #endif - if (kData->active == active) + if (pData->active == active) return; { @@ -1099,16 +1099,16 @@ void CarlaPlugin::setActive(const bool active, const bool sendOsc, const bool se deactivate(); } - kData->active = active; + pData->active = active; #ifndef BUILD_BRIDGE const float value(active ? 1.0f : 0.0f); if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_ACTIVE, value); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_ACTIVE, value); if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_ACTIVE, 0, value, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_ACTIVE, 0, value, nullptr); #else return; @@ -1125,16 +1125,16 @@ void CarlaPlugin::setDryWet(const float value, const bool sendOsc, const bool se const float fixedValue(carla_fixValue(0.0f, 1.0f, value)); - if (kData->postProc.dryWet == fixedValue) + if (pData->postProc.dryWet == fixedValue) return; - kData->postProc.dryWet = fixedValue; + pData->postProc.dryWet = fixedValue; if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_DRYWET, fixedValue); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_DRYWET, fixedValue); if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_DRYWET, 0, fixedValue, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_DRYWET, 0, fixedValue, nullptr); } void CarlaPlugin::setVolume(const float value, const bool sendOsc, const bool sendCallback) @@ -1143,16 +1143,16 @@ void CarlaPlugin::setVolume(const float value, const bool sendOsc, const bool se const float fixedValue(carla_fixValue(0.0f, 1.27f, value)); - if (kData->postProc.volume == fixedValue) + if (pData->postProc.volume == fixedValue) return; - kData->postProc.volume = fixedValue; + pData->postProc.volume = fixedValue; if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_VOLUME, fixedValue); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_VOLUME, fixedValue); if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_VOLUME, 0, fixedValue, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_VOLUME, 0, fixedValue, nullptr); } void CarlaPlugin::setBalanceLeft(const float value, const bool sendOsc, const bool sendCallback) @@ -1161,16 +1161,16 @@ void CarlaPlugin::setBalanceLeft(const float value, const bool sendOsc, const bo const float fixedValue(carla_fixValue(-1.0f, 1.0f, value)); - if (kData->postProc.balanceLeft == fixedValue) + if (pData->postProc.balanceLeft == fixedValue) return; - kData->postProc.balanceLeft = fixedValue; + pData->postProc.balanceLeft = fixedValue; if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_LEFT, fixedValue); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_LEFT, fixedValue); if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_BALANCE_LEFT, 0, fixedValue, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_BALANCE_LEFT, 0, fixedValue, nullptr); } void CarlaPlugin::setBalanceRight(const float value, const bool sendOsc, const bool sendCallback) @@ -1179,16 +1179,16 @@ void CarlaPlugin::setBalanceRight(const float value, const bool sendOsc, const b const float fixedValue(carla_fixValue(-1.0f, 1.0f, value)); - if (kData->postProc.balanceRight == fixedValue) + if (pData->postProc.balanceRight == fixedValue) return; - kData->postProc.balanceRight = fixedValue; + pData->postProc.balanceRight = fixedValue; if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_RIGHT, fixedValue); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_RIGHT, fixedValue); if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_BALANCE_RIGHT, 0, fixedValue, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_BALANCE_RIGHT, 0, fixedValue, nullptr); } void CarlaPlugin::setPanning(const float value, const bool sendOsc, const bool sendCallback) @@ -1197,16 +1197,16 @@ void CarlaPlugin::setPanning(const float value, const bool sendOsc, const bool s const float fixedValue(carla_fixValue(-1.0f, 1.0f, value)); - if (kData->postProc.panning == fixedValue) + if (pData->postProc.panning == fixedValue) return; - kData->postProc.panning = fixedValue; + pData->postProc.panning = fixedValue; if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_PANNING, fixedValue); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_PANNING, fixedValue); if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_PANNING, 0, fixedValue, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_PANNING, 0, fixedValue, nullptr); } #endif @@ -1217,22 +1217,22 @@ void CarlaPlugin::setCtrlChannel(const int8_t channel, const bool sendOsc, const #endif CARLA_ASSERT_INT(channel >= -1 && channel < MAX_MIDI_CHANNELS, channel); - if (kData->ctrlChannel == channel) + if (pData->ctrlChannel == channel) return; - kData->ctrlChannel = channel; + pData->ctrlChannel = channel; #ifndef BUILD_BRIDGE const float ctrlf(channel); if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_CTRL_CHANNEL, ctrlf); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_CTRL_CHANNEL, ctrlf); if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_CTRL_CHANNEL, 0, ctrlf, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_CTRL_CHANNEL, 0, ctrlf, nullptr); if (fHints & PLUGIN_IS_BRIDGE) - osc_send_control(&kData->osc.data, PARAMETER_CTRL_CHANNEL, ctrlf); + osc_send_control(&pData->osc.data, PARAMETER_CTRL_CHANNEL, ctrlf); #else return; @@ -1247,7 +1247,7 @@ void CarlaPlugin::setCtrlChannel(const int8_t channel, const bool sendOsc, const void CarlaPlugin::setParameterValue(const uint32_t parameterId, const float value, const bool sendGui, const bool sendOsc, const bool sendCallback) { - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); #ifdef BUILD_BRIDGE CARLA_ASSERT(! sendGui); // this should never happen #endif @@ -1257,11 +1257,11 @@ void CarlaPlugin::setParameterValue(const uint32_t parameterId, const float valu uiParameterChange(parameterId, value); if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, parameterId, value); + pData->engine->osc_send_control_set_parameter_value(fId, parameterId, value); #endif if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, parameterId, 0, value, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, parameterId, 0, value, nullptr); #ifdef BUILD_BRIDGE return; @@ -1298,9 +1298,9 @@ void CarlaPlugin::setParameterValueByRealIndex(const int32_t rindex, const float return setPanning(value, sendOsc, sendCallback); #endif - for (uint32_t i=0; i < kData->param.count; ++i) + for (uint32_t i=0; i < pData->param.count; ++i) { - if (kData->param.data[i].rindex == rindex) + if (pData->param.data[i].rindex == rindex) { if (getParameterValue(i) != value) setParameterValue(i, value, sendGui, sendOsc, sendCallback); @@ -1313,20 +1313,20 @@ void CarlaPlugin::setParameterValueByRealIndex(const int32_t rindex, const float void CarlaPlugin::setParameterMidiChannel(const uint32_t parameterId, uint8_t channel, const bool sendOsc, const bool sendCallback) { CARLA_ASSERT(sendOsc || sendCallback); // never call this from RT - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); CARLA_ASSERT_INT(channel < MAX_MIDI_CHANNELS, channel); if (channel >= MAX_MIDI_CHANNELS) channel = MAX_MIDI_CHANNELS; - kData->param.data[parameterId].midiChannel = channel; + pData->param.data[parameterId].midiChannel = channel; #ifndef BUILD_BRIDGE if (sendOsc) - kData->engine->osc_send_control_set_parameter_midi_channel(fId, parameterId, channel); + pData->engine->osc_send_control_set_parameter_midi_channel(fId, parameterId, channel); if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED, fId, parameterId, channel, 0.0f, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED, fId, parameterId, channel, 0.0f, nullptr); if (fHints & PLUGIN_IS_BRIDGE) {} // TODO @@ -1342,20 +1342,20 @@ void CarlaPlugin::setParameterMidiChannel(const uint32_t parameterId, uint8_t ch void CarlaPlugin::setParameterMidiCC(const uint32_t parameterId, int16_t cc, const bool sendOsc, const bool sendCallback) { CARLA_ASSERT(sendOsc || sendCallback); // never call this from RT - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); CARLA_ASSERT_INT(cc >= -1 && cc <= 0x5F, cc); if (cc < -1 || cc > 0x5F) cc = -1; - kData->param.data[parameterId].midiCC = cc; + pData->param.data[parameterId].midiCC = cc; #ifndef BUILD_BRIDGE if (sendOsc) - kData->engine->osc_send_control_set_parameter_midi_cc(fId, parameterId, cc); + pData->engine->osc_send_control_set_parameter_midi_cc(fId, parameterId, cc); if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_MIDI_CC_CHANGED, fId, parameterId, cc, 0.0f, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_MIDI_CC_CHANGED, fId, parameterId, cc, 0.0f, nullptr); if (fHints & PLUGIN_IS_BRIDGE) {} // TODO @@ -1402,7 +1402,7 @@ void CarlaPlugin::setCustomData(const char* const type, const char* const key, c return; // Check if we already have this key - for (NonRtList::Itenerator it = kData->custom.begin(); it.valid(); it.next()) + for (NonRtList::Itenerator it = pData->custom.begin(); it.valid(); it.next()) { CustomData& cData(*it); @@ -1430,7 +1430,7 @@ void CarlaPlugin::setCustomData(const char* const type, const char* const key, c newData.type = carla_strdup(type); newData.key = carla_strdup(key); newData.value = carla_strdup(value); - kData->custom.append(newData); + pData->custom.append(newData); } void CarlaPlugin::setChunkData(const char* const stringData) @@ -1445,25 +1445,25 @@ void CarlaPlugin::setChunkData(const char* const stringData) void CarlaPlugin::setProgram(int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) { - CARLA_ASSERT(index >= -1 && index < static_cast(kData->prog.count)); + CARLA_ASSERT(index >= -1 && index < static_cast(pData->prog.count)); #ifdef BUILD_BRIDGE CARLA_ASSERT(! sendGui); // this should never happen #endif - if (index > static_cast(kData->prog.count)) + if (index > static_cast(pData->prog.count)) return; - const int32_t fixedIndex(carla_fixValue(-1, kData->prog.count, index)); + const int32_t fixedIndex(carla_fixValue(-1, pData->prog.count, index)); - kData->prog.current = fixedIndex; + pData->prog.current = fixedIndex; #ifndef BUILD_BRIDGE if (sendOsc) - kData->engine->osc_send_control_set_program(fId, fixedIndex); + pData->engine->osc_send_control_set_program(fId, fixedIndex); #endif if (sendCallback) - kData->engine->callback(CALLBACK_PROGRAM_CHANGED, fId, fixedIndex, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_PROGRAM_CHANGED, fId, fixedIndex, 0, 0.0f, nullptr); // Change default parameter values if (fixedIndex >= 0) @@ -1476,21 +1476,21 @@ void CarlaPlugin::setProgram(int32_t index, const bool sendGui, const bool sendO if (type() == PLUGIN_GIG || type() == PLUGIN_SF2 || type() == PLUGIN_SFZ) return; - for (uint32_t i=0; i < kData->param.count; ++i) + for (uint32_t i=0; i < pData->param.count; ++i) { - const float value(kData->param.ranges[i].fixValue(getParameterValue(i))); + const float value(pData->param.ranges[i].fixValue(getParameterValue(i))); - kData->param.ranges[i].def = value; + pData->param.ranges[i].def = value; if (sendOsc || sendCallback) { #ifndef BUILD_BRIDGE - kData->engine->osc_send_control_set_default_value(fId, i, value); - kData->engine->osc_send_control_set_parameter_value(fId, i, value); + pData->engine->osc_send_control_set_default_value(fId, i, value); + pData->engine->osc_send_control_set_parameter_value(fId, i, value); #endif - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, i, 0, value, nullptr); - kData->engine->callback(CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, i, 0, value, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, i, 0, value, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, i, 0, value, nullptr); } } } @@ -1505,25 +1505,25 @@ void CarlaPlugin::setProgram(int32_t index, const bool sendGui, const bool sendO void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) { - CARLA_ASSERT(index >= -1 && index < static_cast(kData->midiprog.count)); + CARLA_ASSERT(index >= -1 && index < static_cast(pData->midiprog.count)); #ifdef BUILD_BRIDGE CARLA_ASSERT(! sendGui); // this should never happen #endif - if (index > static_cast(kData->midiprog.count)) + if (index > static_cast(pData->midiprog.count)) return; - const int32_t fixedIndex(carla_fixValue(-1, kData->midiprog.count, index)); + const int32_t fixedIndex(carla_fixValue(-1, pData->midiprog.count, index)); - kData->midiprog.current = fixedIndex; + pData->midiprog.current = fixedIndex; #ifndef BUILD_BRIDGE if (sendOsc) - kData->engine->osc_send_control_set_midi_program(fId, fixedIndex); + pData->engine->osc_send_control_set_midi_program(fId, fixedIndex); #endif if (sendCallback) - kData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, fixedIndex, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, fixedIndex, 0, 0.0f, nullptr); if (fixedIndex >= 0) { @@ -1535,21 +1535,21 @@ void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool s if (type() == PLUGIN_GIG || type() == PLUGIN_SF2 || type() == PLUGIN_SFZ) return; - for (uint32_t i=0; i < kData->param.count; ++i) + for (uint32_t i=0; i < pData->param.count; ++i) { - const float value(kData->param.ranges[i].fixValue(getParameterValue(i))); + const float value(pData->param.ranges[i].fixValue(getParameterValue(i))); - kData->param.ranges[i].def = value; + pData->param.ranges[i].def = value; if (sendOsc || sendCallback) { #ifndef BUILD_BRIDGE - kData->engine->osc_send_control_set_default_value(fId, i, value); - kData->engine->osc_send_control_set_parameter_value(fId, i, value); + pData->engine->osc_send_control_set_default_value(fId, i, value); + pData->engine->osc_send_control_set_parameter_value(fId, i, value); #endif - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, i, 0, value, nullptr); - kData->engine->callback(CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, i, 0, value, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, i, 0, value, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, i, 0, value, nullptr); } } } @@ -1564,9 +1564,9 @@ void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool s void CarlaPlugin::setMidiProgramById(const uint32_t bank, const uint32_t program, const bool sendGui, const bool sendOsc, const bool sendCallback) { - for (uint32_t i=0; i < kData->midiprog.count; ++i) + for (uint32_t i=0; i < pData->midiprog.count; ++i) { - if (kData->midiprog.data[i].bank == bank && kData->midiprog.data[i].program == program) + if (pData->midiprog.data[i].bank == bank && pData->midiprog.data[i].program == program) return setMidiProgram(i, sendGui, sendOsc, sendCallback); } } @@ -1594,9 +1594,9 @@ void CarlaPlugin::idleGui() postRtEventsRun(); // Update parameter outputs - for (uint32_t i=0; i < kData->param.count; ++i) + for (uint32_t i=0; i < pData->param.count; ++i) { - if (kData->param.data[i].type == PARAMETER_OUTPUT) + if (pData->param.data[i].type == PARAMETER_OUTPUT) uiParameterChange(i, getParameterValue(i)); } } @@ -1605,10 +1605,6 @@ void CarlaPlugin::idleGui() // ------------------------------------------------------------------- // Plugin state -void CarlaPlugin::reload() -{ -} - void CarlaPlugin::reloadPrograms(const bool) { } @@ -1618,16 +1614,12 @@ void CarlaPlugin::reloadPrograms(const bool) void CarlaPlugin::activate() { - CARLA_ASSERT(! kData->active); + CARLA_ASSERT(! pData->active); } void CarlaPlugin::deactivate() { - CARLA_ASSERT(kData->active); -} - -void CarlaPlugin::process(float** const, float** const, const uint32_t) -{ + CARLA_ASSERT(pData->active); } void CarlaPlugin::bufferSizeChanged(const uint32_t) @@ -1644,12 +1636,12 @@ void CarlaPlugin::offlineModeChanged(const bool) bool CarlaPlugin::tryLock() { - return kData->masterMutex.tryLock(); + return pData->masterMutex.tryLock(); } void CarlaPlugin::unlock() { - kData->masterMutex.unlock(); + pData->masterMutex.unlock(true); } // ------------------------------------------------------------------- @@ -1657,14 +1649,14 @@ void CarlaPlugin::unlock() void CarlaPlugin::initBuffers() { - kData->audioIn.initBuffers(kData->engine); - kData->audioOut.initBuffers(kData->engine); - kData->event.initBuffers(kData->engine); + pData->audioIn.initBuffers(pData->engine); + pData->audioOut.initBuffers(pData->engine); + pData->event.initBuffers(pData->engine); } void CarlaPlugin::clearBuffers() { - kData->clearBuffers(); + pData->clearBuffers(); } // ------------------------------------------------------------------- @@ -1673,15 +1665,15 @@ void CarlaPlugin::clearBuffers() void CarlaPlugin::registerToOscClient() { #ifdef BUILD_BRIDGE - if (! kData->engine->isOscBridgeRegistered()) + if (! pData->engine->isOscBridgeRegistered()) return; #else - if (! kData->engine->isOscControlRegistered()) + if (! pData->engine->isOscControlRegistered()) return; #endif #ifndef BUILD_BRIDGE - kData->engine->osc_send_control_add_plugin_start(fId, fName); + pData->engine->osc_send_control_add_plugin_start(fId, fName); #endif // Base data @@ -1696,9 +1688,9 @@ void CarlaPlugin::registerToOscClient() getCopyright(bufCopyright); #ifdef BUILD_BRIDGE - kData->engine->osc_send_bridge_plugin_info(category(), fHints, bufName, bufLabel, bufMaker, bufCopyright, uniqueId()); + pData->engine->osc_send_bridge_plugin_info(category(), fHints, bufName, bufLabel, bufMaker, bufCopyright, uniqueId()); #else - kData->engine->osc_send_control_set_plugin_data(fId, type(), category(), fHints, bufName, bufLabel, bufMaker, bufCopyright, uniqueId()); + pData->engine->osc_send_control_set_plugin_data(fId, type(), category(), fHints, bufName, bufLabel, bufMaker, bufCopyright, uniqueId()); #endif } @@ -1708,20 +1700,20 @@ void CarlaPlugin::registerToOscClient() getParameterCountInfo(&cIns, &cOuts, &cTotals); #ifdef BUILD_BRIDGE - kData->engine->osc_send_bridge_audio_count(audioInCount(), audioOutCount(), audioInCount() + audioOutCount()); - kData->engine->osc_send_bridge_midi_count(midiInCount(), midiOutCount(), midiInCount() + midiOutCount()); - kData->engine->osc_send_bridge_parameter_count(cIns, cOuts, cTotals); + pData->engine->osc_send_bridge_audio_count(audioInCount(), audioOutCount(), audioInCount() + audioOutCount()); + pData->engine->osc_send_bridge_midi_count(midiInCount(), midiOutCount(), midiInCount() + midiOutCount()); + pData->engine->osc_send_bridge_parameter_count(cIns, cOuts, cTotals); #else - kData->engine->osc_send_control_set_plugin_ports(fId, audioInCount(), audioOutCount(), midiInCount(), midiOutCount(), cIns, cOuts, cTotals); + pData->engine->osc_send_control_set_plugin_ports(fId, audioInCount(), audioOutCount(), midiInCount(), midiOutCount(), cIns, cOuts, cTotals); #endif } // Plugin Parameters - if (kData->param.count > 0 && kData->param.count < kData->engine->getOptions().maxParameters) + if (pData->param.count > 0 && pData->param.count < pData->engine->getOptions().maxParameters) { char bufName[STR_MAX+1], bufUnit[STR_MAX+1]; - for (uint32_t i=0; i < kData->param.count; ++i) + for (uint32_t i=0; i < pData->param.count; ++i) { carla_fill(bufName, STR_MAX, '\0'); carla_fill(bufUnit, STR_MAX, '\0'); @@ -1729,83 +1721,83 @@ void CarlaPlugin::registerToOscClient() getParameterName(i, bufName); getParameterUnit(i, bufUnit); - const ParameterData& paramData(kData->param.data[i]); - const ParameterRanges& paramRanges(kData->param.ranges[i]); + const ParameterData& paramData(pData->param.data[i]); + const ParameterRanges& paramRanges(pData->param.ranges[i]); #ifdef BUILD_BRIDGE - kData->engine->osc_send_bridge_parameter_info(i, bufName, bufUnit); - kData->engine->osc_send_bridge_parameter_data(i, paramData.type, paramData.rindex, paramData.hints, paramData.midiChannel, paramData.midiCC); - kData->engine->osc_send_bridge_parameter_ranges(i, paramRanges.def, paramRanges.min, paramRanges.max, paramRanges.step, paramRanges.stepSmall, paramRanges.stepLarge); - kData->engine->osc_send_bridge_set_parameter_value(i, getParameterValue(i)); + pData->engine->osc_send_bridge_parameter_info(i, bufName, bufUnit); + pData->engine->osc_send_bridge_parameter_data(i, paramData.type, paramData.rindex, paramData.hints, paramData.midiChannel, paramData.midiCC); + pData->engine->osc_send_bridge_parameter_ranges(i, paramRanges.def, paramRanges.min, paramRanges.max, paramRanges.step, paramRanges.stepSmall, paramRanges.stepLarge); + pData->engine->osc_send_bridge_set_parameter_value(i, getParameterValue(i)); #else - kData->engine->osc_send_control_set_parameter_data(fId, i, paramData.type, paramData.hints, bufName, bufUnit, getParameterValue(i)); - kData->engine->osc_send_control_set_parameter_ranges(fId, i, paramRanges.min, paramRanges.max, paramRanges.def, paramRanges.step, paramRanges.stepSmall, paramRanges.stepLarge); - kData->engine->osc_send_control_set_parameter_midi_cc(fId, i, paramData.midiCC); - kData->engine->osc_send_control_set_parameter_midi_channel(fId, i, paramData.midiChannel); + pData->engine->osc_send_control_set_parameter_data(fId, i, paramData.type, paramData.hints, bufName, bufUnit, getParameterValue(i)); + pData->engine->osc_send_control_set_parameter_ranges(fId, i, paramRanges.min, paramRanges.max, paramRanges.def, paramRanges.step, paramRanges.stepSmall, paramRanges.stepLarge); + pData->engine->osc_send_control_set_parameter_midi_cc(fId, i, paramData.midiCC); + pData->engine->osc_send_control_set_parameter_midi_channel(fId, i, paramData.midiChannel); #endif } } // Programs - if (kData->prog.count > 0) + if (pData->prog.count > 0) { #ifdef BUILD_BRIDGE - kData->engine->osc_send_bridge_program_count(kData->prog.count); + pData->engine->osc_send_bridge_program_count(pData->prog.count); - for (uint32_t i=0; i < kData->prog.count; ++i) - kData->engine->osc_send_bridge_program_info(i, kData->prog.names[i]); + for (uint32_t i=0; i < pData->prog.count; ++i) + pData->engine->osc_send_bridge_program_info(i, pData->prog.names[i]); - kData->engine->osc_send_bridge_set_program(kData->prog.current); + pData->engine->osc_send_bridge_set_program(pData->prog.current); #else - kData->engine->osc_send_control_set_program_count(fId, kData->prog.count); + pData->engine->osc_send_control_set_program_count(fId, pData->prog.count); - for (uint32_t i=0; i < kData->prog.count; ++i) - kData->engine->osc_send_control_set_program_name(fId, i, kData->prog.names[i]); + for (uint32_t i=0; i < pData->prog.count; ++i) + pData->engine->osc_send_control_set_program_name(fId, i, pData->prog.names[i]); - kData->engine->osc_send_control_set_program(fId, kData->prog.current); + pData->engine->osc_send_control_set_program(fId, pData->prog.current); #endif } // MIDI Programs - if (kData->midiprog.count > 0) + if (pData->midiprog.count > 0) { #ifdef BUILD_BRIDGE - kData->engine->osc_send_bridge_midi_program_count(kData->midiprog.count); + pData->engine->osc_send_bridge_midi_program_count(pData->midiprog.count); - for (uint32_t i=0; i < kData->midiprog.count; ++i) + for (uint32_t i=0; i < pData->midiprog.count; ++i) { - const MidiProgramData& mpData(kData->midiprog.data[i]); + const MidiProgramData& mpData(pData->midiprog.data[i]); - kData->engine->osc_send_bridge_midi_program_info(i, mpData.bank, mpData.program, mpData.name); + pData->engine->osc_send_bridge_midi_program_info(i, mpData.bank, mpData.program, mpData.name); } - kData->engine->osc_send_bridge_set_midi_program(kData->midiprog.current); + pData->engine->osc_send_bridge_set_midi_program(pData->midiprog.current); #else - kData->engine->osc_send_control_set_midi_program_count(fId, kData->midiprog.count); + pData->engine->osc_send_control_set_midi_program_count(fId, pData->midiprog.count); - for (uint32_t i=0; i < kData->midiprog.count; ++i) + for (uint32_t i=0; i < pData->midiprog.count; ++i) { - const MidiProgramData& mpData(kData->midiprog.data[i]); + const MidiProgramData& mpData(pData->midiprog.data[i]); - kData->engine->osc_send_control_set_midi_program_data(fId, i, mpData.bank, mpData.program, mpData.name); + pData->engine->osc_send_control_set_midi_program_data(fId, i, mpData.bank, mpData.program, mpData.name); } - kData->engine->osc_send_control_set_midi_program(fId, kData->midiprog.current); + pData->engine->osc_send_control_set_midi_program(fId, pData->midiprog.current); #endif } #ifndef BUILD_BRIDGE - kData->engine->osc_send_control_add_plugin_end(fId); + pData->engine->osc_send_control_add_plugin_end(fId); // Internal Parameters { - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_DRYWET, kData->postProc.dryWet); - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_VOLUME, kData->postProc.volume); - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_LEFT, kData->postProc.balanceLeft); - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_RIGHT, kData->postProc.balanceRight); - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_PANNING, kData->postProc.panning); - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_CTRL_CHANNEL, kData->ctrlChannel); - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_ACTIVE, kData->active ? 1.0f : 0.0f); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_DRYWET, pData->postProc.dryWet); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_VOLUME, pData->postProc.volume); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_LEFT, pData->postProc.balanceLeft); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_RIGHT, pData->postProc.balanceRight); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_PANNING, pData->postProc.panning); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_CTRL_CHANNEL, pData->ctrlChannel); + pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_ACTIVE, pData->active ? 1.0f : 0.0f); } #endif } @@ -1815,14 +1807,14 @@ void CarlaPlugin::updateOscData(const lo_address& source, const char* const url) // FIXME - remove debug prints later carla_stdout("CarlaPlugin::updateOscData(%p, \"%s\")", source, url); - kData->osc.data.free(); + pData->osc.data.free(); const int proto = lo_address_get_protocol(source); { const char* host = lo_address_get_hostname(source); const char* port = lo_address_get_port(source); - kData->osc.data.source = lo_address_new_with_proto(proto, host, port); + pData->osc.data.source = lo_address_new_with_proto(proto, host, port); carla_stdout("CarlaPlugin::updateOscData() - source: host \"%s\", port \"%s\"", host, port); } @@ -1830,9 +1822,9 @@ void CarlaPlugin::updateOscData(const lo_address& source, const char* const url) { char* host = lo_url_get_hostname(url); char* port = lo_url_get_port(url); - kData->osc.data.path = carla_strdup_free(lo_url_get_path(url)); - kData->osc.data.target = lo_address_new_with_proto(proto, host, port); - carla_stdout("CarlaPlugin::updateOscData() - target: host \"%s\", port \"%s\", path \"%s\"", host, port, kData->osc.data.path); + pData->osc.data.path = carla_strdup_free(lo_url_get_path(url)); + pData->osc.data.target = lo_address_new_with_proto(proto, host, port); + carla_stdout("CarlaPlugin::updateOscData() - target: host \"%s\", port \"%s\", path \"%s\"", host, port, pData->osc.data.path); std::free(host); std::free(port); @@ -1843,9 +1835,9 @@ void CarlaPlugin::updateOscData(const lo_address& source, const char* const url) return; #endif - osc_send_sample_rate(&kData->osc.data, kData->engine->getSampleRate()); + osc_send_sample_rate(&pData->osc.data, pData->engine->getSampleRate()); - for (NonRtList::Itenerator it = kData->custom.begin(); it.valid(); it.next()) + for (NonRtList::Itenerator it = pData->custom.begin(); it.valid(); it.next()) { const CustomData& cData(*it); @@ -1854,45 +1846,45 @@ void CarlaPlugin::updateOscData(const lo_address& source, const char* const url) CARLA_ASSERT(cData.value != nullptr); if (std::strcmp(cData.type, CUSTOM_DATA_STRING) == 0) - osc_send_configure(&kData->osc.data, cData.key, cData.value); + osc_send_configure(&pData->osc.data, cData.key, cData.value); } - if (kData->prog.current >= 0) - osc_send_program(&kData->osc.data, kData->prog.current); + if (pData->prog.current >= 0) + osc_send_program(&pData->osc.data, pData->prog.current); - if (kData->midiprog.current >= 0) + if (pData->midiprog.current >= 0) { - const MidiProgramData& curMidiProg(kData->midiprog.getCurrent()); + const MidiProgramData& curMidiProg(pData->midiprog.getCurrent()); if (type() == PLUGIN_DSSI) - osc_send_program(&kData->osc.data, curMidiProg.bank, curMidiProg.program); + osc_send_program(&pData->osc.data, curMidiProg.bank, curMidiProg.program); else - osc_send_midi_program(&kData->osc.data, curMidiProg.bank, curMidiProg.program); + osc_send_midi_program(&pData->osc.data, curMidiProg.bank, curMidiProg.program); } - for (uint32_t i=0; i < kData->param.count; ++i) - osc_send_control(&kData->osc.data, kData->param.data[i].rindex, getParameterValue(i)); + for (uint32_t i=0; i < pData->param.count; ++i) + osc_send_control(&pData->osc.data, pData->param.data[i].rindex, getParameterValue(i)); carla_stdout("CarlaPlugin::updateOscData() - done"); } void CarlaPlugin::freeOscData() { - kData->osc.data.free(); + pData->osc.data.free(); } bool CarlaPlugin::waitForOscGuiShow() { carla_stdout("CarlaPlugin::waitForOscGuiShow()"); - uint i=0, oscUiTimeout = kData->engine->getOptions().oscUiTimeout; + uint i=0, oscUiTimeout = pData->engine->getOptions().oscUiTimeout; // wait for UI 'update' call for (; i < oscUiTimeout/100; ++i) { - if (kData->osc.data.target != nullptr) + if (pData->osc.data.target != nullptr) { carla_stdout("CarlaPlugin::waitForOscGuiShow() - got response, asking UI to show itself now"); - osc_send_show(&kData->osc.data); + osc_send_show(&pData->osc.data); return true; } else @@ -1913,7 +1905,7 @@ void CarlaPlugin::sendMidiSingleNote(const uint8_t channel, const uint8_t note, CARLA_ASSERT(note < MAX_MIDI_NOTE); CARLA_ASSERT(velo < MAX_MIDI_VALUE); - if (! kData->active) + if (! pData->active) return; ExternalMidiNote extNote; @@ -1921,7 +1913,7 @@ void CarlaPlugin::sendMidiSingleNote(const uint8_t channel, const uint8_t note, extNote.note = note; extNote.velo = velo; - kData->extNotes.append(extNote); + pData->extNotes.append(extNote); if (sendGui) { @@ -1934,31 +1926,31 @@ void CarlaPlugin::sendMidiSingleNote(const uint8_t channel, const uint8_t note, if (sendOsc) { if (velo > 0) - kData->engine->osc_send_control_note_on(fId, channel, note, velo); + pData->engine->osc_send_control_note_on(fId, channel, note, velo); else - kData->engine->osc_send_control_note_off(fId, channel, note); + pData->engine->osc_send_control_note_off(fId, channel, note); } if (sendCallback) - kData->engine->callback((velo > 0) ? CALLBACK_NOTE_ON : CALLBACK_NOTE_OFF, fId, channel, note, velo, nullptr); + pData->engine->callback((velo > 0) ? CALLBACK_NOTE_ON : CALLBACK_NOTE_OFF, fId, channel, note, velo, nullptr); } #endif void CarlaPlugin::sendMidiAllNotesOffToCallback() { - if (kData->ctrlChannel < 0 || kData->ctrlChannel >= MAX_MIDI_CHANNELS) + if (pData->ctrlChannel < 0 || pData->ctrlChannel >= MAX_MIDI_CHANNELS) return; PluginPostRtEvent postEvent; postEvent.type = kPluginPostRtEventNoteOff; - postEvent.value1 = kData->ctrlChannel; + postEvent.value1 = pData->ctrlChannel; postEvent.value2 = 0; postEvent.value3 = 0.0f; for (unsigned short i=0; i < MAX_MIDI_NOTE; ++i) { postEvent.value2 = i; - kData->postRtEvents.appendRT(postEvent); + pData->postRtEvents.appendRT(postEvent); } } @@ -1973,16 +1965,16 @@ void CarlaPlugin::postponeRtEvent(const PluginPostRtEventType type, const int32_ event.value2 = value2; event.value3 = value3; - kData->postRtEvents.appendRT(event); + pData->postRtEvents.appendRT(event); } void CarlaPlugin::postRtEventsRun() { - const CarlaMutex::ScopedLocker sl(kData->postRtEvents.mutex); + const CarlaMutex::ScopedLocker sl(pData->postRtEvents.mutex); - while (! kData->postRtEvents.data.isEmpty()) + while (! pData->postRtEvents.data.isEmpty()) { - const PluginPostRtEvent& event(kData->postRtEvents.data.getFirst(true)); + const PluginPostRtEvent& event(pData->postRtEvents.data.getFirst(true)); switch (event.type) { @@ -1991,7 +1983,7 @@ void CarlaPlugin::postRtEventsRun() case kPluginPostRtEventDebug: #ifndef BUILD_BRIDGE - kData->engine->callback(CALLBACK_DEBUG, fId, event.value1, event.value2, event.value3, nullptr); + pData->engine->callback(CALLBACK_DEBUG, fId, event.value1, event.value2, event.value3, nullptr); #endif break; @@ -2004,11 +1996,11 @@ void CarlaPlugin::postRtEventsRun() if (event.value2 != 1) { // Update OSC control client - if (kData->engine->isOscControlRegistered()) - kData->engine->osc_send_control_set_parameter_value(fId, event.value1, event.value3); + if (pData->engine->isOscControlRegistered()) + pData->engine->osc_send_control_set_parameter_value(fId, event.value1, event.value3); // Update Host - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, event.value1, 0, event.value3, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, event.value1, 0, event.value3, nullptr); } #endif break; @@ -2020,28 +2012,28 @@ void CarlaPlugin::postRtEventsRun() #ifndef BUILD_BRIDGE // Update OSC control client - if (kData->engine->isOscControlRegistered()) - kData->engine->osc_send_control_set_program(fId, event.value1); + if (pData->engine->isOscControlRegistered()) + pData->engine->osc_send_control_set_program(fId, event.value1); // Update Host - kData->engine->callback(CALLBACK_PROGRAM_CHANGED, fId, event.value1, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_PROGRAM_CHANGED, fId, event.value1, 0, 0.0f, nullptr); // Update param values { - const bool sendOsc(kData->engine->isOscControlRegistered()); + const bool sendOsc(pData->engine->isOscControlRegistered()); - for (uint32_t j=0; j < kData->param.count; ++j) + for (uint32_t j=0; j < pData->param.count; ++j) { const float value(getParameterValue(j)); if (sendOsc) { - kData->engine->osc_send_control_set_parameter_value(fId, j, value); - kData->engine->osc_send_control_set_default_value(fId, j, kData->param.ranges[j].def); + pData->engine->osc_send_control_set_parameter_value(fId, j, value); + pData->engine->osc_send_control_set_default_value(fId, j, pData->param.ranges[j].def); } - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, j, 0, value, nullptr); - kData->engine->callback(CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, j, 0, kData->param.ranges[j].def, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, j, 0, value, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, j, 0, pData->param.ranges[j].def, nullptr); } } #endif @@ -2054,28 +2046,28 @@ void CarlaPlugin::postRtEventsRun() #ifndef BUILD_BRIDGE // Update OSC control client - if (kData->engine->isOscControlRegistered()) - kData->engine->osc_send_control_set_midi_program(fId, event.value1); + if (pData->engine->isOscControlRegistered()) + pData->engine->osc_send_control_set_midi_program(fId, event.value1); // Update Host - kData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, event.value1, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, event.value1, 0, 0.0f, nullptr); // Update param values { - const bool sendOsc(kData->engine->isOscControlRegistered()); + const bool sendOsc(pData->engine->isOscControlRegistered()); - for (uint32_t j=0; j < kData->param.count; ++j) + for (uint32_t j=0; j < pData->param.count; ++j) { const float value(getParameterValue(j)); if (sendOsc) { - kData->engine->osc_send_control_set_parameter_value(fId, j, value); - kData->engine->osc_send_control_set_default_value(fId, j, kData->param.ranges[j].def); + pData->engine->osc_send_control_set_parameter_value(fId, j, value); + pData->engine->osc_send_control_set_default_value(fId, j, pData->param.ranges[j].def); } - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, j, 0, value, nullptr); - kData->engine->callback(CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, j, 0, kData->param.ranges[j].def, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, j, 0, value, nullptr); + pData->engine->callback(CALLBACK_PARAMETER_DEFAULT_CHANGED, fId, j, 0, pData->param.ranges[j].def, nullptr); } } #endif @@ -2087,11 +2079,11 @@ void CarlaPlugin::postRtEventsRun() #ifndef BUILD_BRIDGE // Update OSC control client - if (kData->engine->isOscControlRegistered()) - kData->engine->osc_send_control_note_on(fId, event.value1, event.value2, int(event.value3)); + if (pData->engine->isOscControlRegistered()) + pData->engine->osc_send_control_note_on(fId, event.value1, event.value2, int(event.value3)); // Update Host - kData->engine->callback(CALLBACK_NOTE_ON, fId, event.value1, event.value2, int(event.value3), nullptr); + pData->engine->callback(CALLBACK_NOTE_ON, fId, event.value1, event.value2, int(event.value3), nullptr); #endif break; @@ -2101,11 +2093,11 @@ void CarlaPlugin::postRtEventsRun() #ifndef BUILD_BRIDGE // Update OSC control client - if (kData->engine->isOscControlRegistered()) - kData->engine->osc_send_control_note_off(fId, event.value1, event.value2); + if (pData->engine->isOscControlRegistered()) + pData->engine->osc_send_control_note_off(fId, event.value1, event.value2); // Update Host - kData->engine->callback(CALLBACK_NOTE_OFF, fId, event.value1, event.value2, 0.0f, nullptr); + pData->engine->callback(CALLBACK_NOTE_OFF, fId, event.value1, event.value2, 0.0f, nullptr); #endif break; } @@ -2171,85 +2163,85 @@ void CarlaPlugin::uiNoteOff(const uint8_t channel, const uint8_t note) // Scoped Disabler CarlaPlugin::ScopedDisabler::ScopedDisabler(CarlaPlugin* const plugin) - : kPlugin(plugin) + : fPlugin(plugin) { carla_debug("CarlaPlugin::ScopedDisabler(%p)", plugin); CARLA_ASSERT(plugin != nullptr); CARLA_ASSERT(plugin->kData != nullptr); - CARLA_ASSERT(plugin->kData->client != nullptr); + CARLA_ASSERT(plugin->pData->client != nullptr); if (plugin == nullptr) return; - if (plugin->kData == nullptr) + if (plugin->pData == nullptr) return; - if (plugin->kData->client == nullptr) + if (plugin->pData->client == nullptr) return; - plugin->kData->masterMutex.lock(); + plugin->pData->masterMutex.lock(); if (plugin->fEnabled) plugin->fEnabled = false; - if (plugin->kData->client->isActive()) - plugin->kData->client->deactivate(); + if (plugin->pData->client->isActive()) + plugin->pData->client->deactivate(); } CarlaPlugin::ScopedDisabler::~ScopedDisabler() { carla_debug("CarlaPlugin::~ScopedDisabler()"); - CARLA_ASSERT(kPlugin != nullptr); - CARLA_ASSERT(kPlugin->kData != nullptr); - CARLA_ASSERT(kPlugin->kData->client != nullptr); + CARLA_ASSERT(fPlugin != nullptr); + CARLA_ASSERT(fPlugin->pData != nullptr); + CARLA_ASSERT(fPlugin->pData->client != nullptr); - if (kPlugin == nullptr) + if (fPlugin == nullptr) return; - if (kPlugin->kData == nullptr) + if (fPlugin->pData == nullptr) return; - if (kPlugin->kData->client == nullptr) + if (fPlugin->pData->client == nullptr) return; - kPlugin->fEnabled = true; - kPlugin->kData->client->activate(); - kPlugin->kData->masterMutex.unlock(); + fPlugin->fEnabled = true; + fPlugin->pData->client->activate(); + fPlugin->pData->masterMutex.unlock(); } // ------------------------------------------------------------------- // Scoped Process Locker CarlaPlugin::ScopedSingleProcessLocker::ScopedSingleProcessLocker(CarlaPlugin* const plugin, const bool block) - : kPlugin(plugin), - kBlock(block) + : fPlugin(plugin), + fBlock(block) { carla_debug("CarlaPlugin::ScopedSingleProcessLocker(%p, %s)", plugin, bool2str(block)); - CARLA_ASSERT(kPlugin != nullptr && kPlugin->kData != nullptr); + CARLA_ASSERT(fPlugin != nullptr && fPlugin->pData != nullptr); - if (kPlugin == nullptr) + if (fPlugin == nullptr) return; - if (kPlugin->kData == nullptr) + if (fPlugin->pData == nullptr) return; - if (kBlock) - plugin->kData->singleMutex.lock(); + if (fBlock) + plugin->pData->singleMutex.lock(); } CarlaPlugin::ScopedSingleProcessLocker::~ScopedSingleProcessLocker() { carla_debug("CarlaPlugin::~ScopedSingleProcessLocker()"); - CARLA_ASSERT(kPlugin != nullptr && kPlugin->kData != nullptr); + CARLA_ASSERT(fPlugin != nullptr && fPlugin->pData != nullptr); - if (kPlugin == nullptr) + if (fPlugin == nullptr) return; - if (kPlugin->kData == nullptr) + if (fPlugin->pData == nullptr) return; - if (kBlock) + if (fBlock) { #ifndef BUILD_BRIDGE - if (kPlugin->kData->singleMutex.wasTryLockCalled()) - kPlugin->kData->needsReset = true; + if (fPlugin->pData->singleMutex.wasTryLockCalled()) + fPlugin->pData->needsReset = true; #endif - kPlugin->kData->singleMutex.unlock(); + fPlugin->pData->singleMutex.unlock(); } } diff --git a/source/includes/ladspa_rdf.hpp b/source/includes/ladspa_rdf.hpp index 1da1f41d5..619c2745f 100644 --- a/source/includes/ladspa_rdf.hpp +++ b/source/includes/ladspa_rdf.hpp @@ -120,7 +120,7 @@ struct LADSPA_RDF_ScalePoint { LADSPA_Data Value; const char* Label; - LADSPA_RDF_ScalePoint() + LADSPA_RDF_ScalePoint() noexcept : Value(0.0f), Label(nullptr) {} @@ -145,7 +145,7 @@ struct LADSPA_RDF_Port { unsigned long ScalePointCount; LADSPA_RDF_ScalePoint* ScalePoints; - LADSPA_RDF_Port() + LADSPA_RDF_Port() noexcept : Type(0x0), Hints(0x0), Label(nullptr), @@ -179,7 +179,7 @@ struct LADSPA_RDF_Descriptor { unsigned long PortCount; LADSPA_RDF_Port* Ports; - LADSPA_RDF_Descriptor() + LADSPA_RDF_Descriptor() noexcept : Type(0x0), UniqueID(0), Title(nullptr), diff --git a/source/includes/lv2_rdf.hpp b/source/includes/lv2_rdf.hpp index d8610ec24..821eee24c 100644 --- a/source/includes/lv2_rdf.hpp +++ b/source/includes/lv2_rdf.hpp @@ -295,7 +295,7 @@ struct LV2_RDF_PortMidiMap { LV2_Property Type; uint32_t Number; - LV2_RDF_PortMidiMap() + LV2_RDF_PortMidiMap() noexcept : Type(0), Number(0) {} }; @@ -307,7 +307,7 @@ struct LV2_RDF_PortPoints { float Minimum; float Maximum; - LV2_RDF_PortPoints() + LV2_RDF_PortPoints() noexcept : Hints(0x0), Default(0.0f), Minimum(0.0f), @@ -322,7 +322,7 @@ struct LV2_RDF_PortUnit { const char* Symbol; LV2_Property Unit; - LV2_RDF_PortUnit() + LV2_RDF_PortUnit() noexcept : Hints(0x0), Name(nullptr), Render(nullptr), @@ -354,7 +354,7 @@ struct LV2_RDF_PortScalePoint { const char* Label; float Value; - LV2_RDF_PortScalePoint() + LV2_RDF_PortScalePoint() noexcept : Label(nullptr), Value(0.0f) {} @@ -383,7 +383,7 @@ struct LV2_RDF_Port { uint32_t ScalePointCount; LV2_RDF_PortScalePoint* ScalePoints; - LV2_RDF_Port() + LV2_RDF_Port() noexcept : Types(0x0), Properties(0x0), Designation(0), @@ -417,7 +417,7 @@ struct LV2_RDF_Preset { LV2_URI URI; const char* Label; - LV2_RDF_Preset() + LV2_RDF_Preset() noexcept : URI(nullptr), Label(nullptr) {} @@ -441,7 +441,7 @@ struct LV2_RDF_Feature { LV2_Property Type; LV2_URI URI; - LV2_RDF_Feature() + LV2_RDF_Feature() noexcept : Type(0), URI(nullptr) {} @@ -468,7 +468,7 @@ struct LV2_RDF_UI { uint32_t ExtensionCount; LV2_URI* Extensions; - LV2_RDF_UI() + LV2_RDF_UI() noexcept : Type(0), URI(nullptr), Binary(nullptr), @@ -534,7 +534,7 @@ struct LV2_RDF_Descriptor { uint32_t UICount; LV2_RDF_UI* UIs; - LV2_RDF_Descriptor() + LV2_RDF_Descriptor() noexcept #ifdef CARLA_PROPER_CPP11_SUPPORT : Type{0x0}, URI(nullptr), diff --git a/source/utils/CarlaJuceUtils.hpp b/source/utils/CarlaJuceUtils.hpp index 3ff13288f..f333f9bac 100644 --- a/source/utils/CarlaJuceUtils.hpp +++ b/source/utils/CarlaJuceUtils.hpp @@ -134,7 +134,7 @@ private: volatile int numObjects; }; - static const char* getLeakedObjectClassName() + static const char* getLeakedObjectClassName() noexcept { return OwnerClass::getLeakedObjectClassName(); } @@ -294,7 +294,7 @@ public: /** Swaps this object with that of another ScopedPointer. The two objects simply exchange their pointers. */ - void swapWith(ScopedPointer& other) noexcept + void swapWith(ScopedPointer& other) { // Two ScopedPointers should never be able to refer to the same object - if // this happens, you must have done something dodgy! @@ -308,7 +308,7 @@ private: ObjectType* object; // (Required as an alternative to the overloaded & operator). - const ScopedPointer* getAddress() const { return this; } + const ScopedPointer* getAddress() const noexcept { return this; } #if ! defined(CARLA_CC_MSVC) // (MSVC can't deal with multiple copy constructors) /* The copy constructors are private to stop people accidentally copying a const ScopedPointer diff --git a/source/utils/CarlaMutex.hpp b/source/utils/CarlaMutex.hpp index f8bd44033..963da3a76 100644 --- a/source/utils/CarlaMutex.hpp +++ b/source/utils/CarlaMutex.hpp @@ -69,8 +69,11 @@ public: #endif } - void unlock() + void unlock(const bool resetTryLock) { + if (resetTryLock) + fTryLockWasCalled = false; + #ifdef CPP11_MUTEX cmutex.unlock(); #else @@ -80,7 +83,7 @@ public: bool wasTryLockCalled() { - const bool ret = fTryLockWasCalled; + const bool ret(fTryLockWasCalled); fTryLockWasCalled = false; return ret; } diff --git a/source/utils/CarlaString.hpp b/source/utils/CarlaString.hpp index d224a9deb..5445ebdf8 100644 --- a/source/utils/CarlaString.hpp +++ b/source/utils/CarlaString.hpp @@ -124,17 +124,17 @@ public: // ------------------------------------------------------------------- // public methods - size_t length() const + size_t length() const noexcept { return fBufferLen; } - bool isEmpty() const + bool isEmpty() const noexcept { return (fBufferLen == 0); } - bool isNotEmpty() const + bool isNotEmpty() const noexcept { return (fBufferLen != 0); } @@ -170,7 +170,7 @@ public: } #endif - bool isDigit(const size_t pos) const + bool isDigit(const size_t pos) const noexcept { if (pos >= fBufferLen) return false; @@ -204,12 +204,12 @@ public: return (std::strncmp(fBuffer + (fBufferLen-suffixLen), suffix, suffixLen) == 0); } - void clear() + void clear() noexcept { truncate(0); } - size_t find(const char c) const + size_t find(const char c) const noexcept { for (size_t i=0; i < fBufferLen; ++i) { @@ -220,7 +220,7 @@ public: return 0; } - size_t rfind(const char c) const + size_t rfind(const char c) const noexcept { for (size_t i=fBufferLen; i > 0; --i) { @@ -251,7 +251,7 @@ public: return (ret > fBufferLen) ? fBufferLen : fBufferLen-ret; } - void replace(const char before, const char after) + void replace(const char before, const char after) noexcept { if (after == '\0') return; @@ -265,7 +265,7 @@ public: } } - void truncate(const size_t n) + void truncate(const size_t n) noexcept { if (n >= fBufferLen) return; @@ -276,7 +276,7 @@ public: fBufferLen = n; } - void toBasic() + void toBasic() noexcept { for (size_t i=0; i < fBufferLen; ++i) { @@ -296,9 +296,9 @@ public: #ifndef BUILD_ANSI_TEST // Using '+=' and '-=' temporarily converts char into int - void toLower() + void toLower() noexcept { - static const char kCharDiff = 'a' - 'A'; + static const char kCharDiff('a' - 'A'); for (size_t i=0; i < fBufferLen; ++i) { @@ -307,9 +307,9 @@ public: } } - void toUpper() + void toUpper() noexcept { - static const char kCharDiff = 'a' - 'A'; + static const char kCharDiff('a' - 'A'); for (size_t i=0; i < fBufferLen; ++i) { @@ -322,12 +322,12 @@ public: // ------------------------------------------------------------------- // public operators - operator const char*() const + operator const char*() const noexcept { return fBuffer; } - char& operator[](const size_t pos) + char& operator[](const size_t pos) const noexcept { return fBuffer[pos]; } @@ -405,7 +405,7 @@ private: size_t fBufferLen; bool fFirstInit; - void _init() + void _init() noexcept { fBuffer = nullptr; fBufferLen = 0; diff --git a/source/utils/CarlaUtils.hpp b/source/utils/CarlaUtils.hpp index 3ce30e7a5..314130525 100644 --- a/source/utils/CarlaUtils.hpp +++ b/source/utils/CarlaUtils.hpp @@ -47,13 +47,13 @@ // misc functions static inline -const char* bool2str(const bool yesNo) +const char* bool2str(const bool yesNo) noexcept { return yesNo ? "true" : "false"; } static inline -void pass() {} +void pass() noexcept {} // ----------------------------------------------------------------------- // string print functions @@ -225,14 +225,14 @@ const char* carla_strdup_free(char* const strBuf) template static inline -const T& carla_min(const T& v1, const T& v2, const T& min) +const T& carla_min(const T& v1, const T& v2, const T& min) noexcept { return ((v1 < min || v2 < min) ? min : (v1 < v2 ? v1 : v2)); } template static inline -const T& carla_max(const T& v1, const T& v2, const T& max) +const T& carla_max(const T& v1, const T& v2, const T& max) noexcept { return ((v1 > max || v2 > max) ? max : (v1 > v2 ? v1 : v2)); }