Browse Source

Continue cleanup

tags/1.9.4
falkTX 12 years ago
parent
commit
4b681b0e26
14 changed files with 763 additions and 687 deletions
  1. +159
    -145
      source/backend/CarlaEngine.hpp
  2. +53
    -33
      source/backend/CarlaPlugin.hpp
  3. +415
    -415
      source/backend/engine/CarlaEngine.cpp
  4. +4
    -4
      source/backend/engine/CarlaEngineOsc.hpp
  5. +0
    -11
      source/backend/plugin/CarlaPlugin.cpp
  6. +65
    -38
      source/backend/plugin/CarlaPluginInternal.hpp
  7. +8
    -0
      source/includes/ladspa_rdf.hpp
  8. +16
    -0
      source/includes/lv2_rdf.hpp
  9. +12
    -10
      source/tests/ANSI.cpp
  10. +1
    -1
      source/utils/CarlaLibUtils.hpp
  11. +1
    -1
      source/utils/CarlaLv2Utils.hpp
  12. +1
    -1
      source/utils/CarlaOscUtils.hpp
  13. +16
    -22
      source/utils/CarlaStateUtils.hpp
  14. +12
    -6
      source/utils/CarlaString.hpp

+ 159
- 145
source/backend/CarlaEngine.hpp View File

@@ -12,7 +12,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* For a full copy of the GNU General Public License see the doc/GPL.txt file
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/ */


#ifndef CARLA_ENGINE_HPP_INCLUDED #ifndef CARLA_ENGINE_HPP_INCLUDED
@@ -32,7 +32,6 @@ CARLA_BACKEND_START_NAMESPACE
* @defgroup CarlaEngineAPI Carla Engine API * @defgroup CarlaEngineAPI Carla Engine API
* *
* The Carla Engine API. * The Carla Engine API.
*
* @{ * @{
*/ */


@@ -161,14 +160,12 @@ struct EngineControlEvent {
uint16_t param; //!< Parameter Id, midi bank or midi program. uint16_t param; //!< Parameter Id, midi bank or midi program.
float value; //!< Parameter value, normalized to 0.0f<->1.0f. float value; //!< Parameter value, normalized to 0.0f<->1.0f.


void clear()
void clear() noexcept
{ {
type = kEngineControlEventTypeNull; type = kEngineControlEventTypeNull;
param = 0; param = 0;
value = 0.0f; value = 0.0f;
} }

CARLA_DECLARE_NON_COPY_STRUCT(EngineControlEvent)
}; };


/*! /*!
@@ -179,7 +176,7 @@ struct EngineMidiEvent {
uint8_t data[4]; //!< MIDI data, without channel bit uint8_t data[4]; //!< MIDI data, without channel bit
uint8_t size; //!< Number of bytes used uint8_t size; //!< Number of bytes used


void clear()
void clear() noexcept
{ {
port = 0; port = 0;
data[0] = 0; data[0] = 0;
@@ -188,8 +185,6 @@ struct EngineMidiEvent {
data[3] = 0; data[3] = 0;
size = 0; size = 0;
} }

CARLA_DECLARE_NON_COPY_STRUCT(EngineMidiEvent)
}; };


/*! /*!
@@ -206,24 +201,18 @@ struct EngineEvent {
}; };


#ifndef DOXYGEN #ifndef DOXYGEN
EngineEvent()
EngineEvent() noexcept
{ {
clear(); clear();
} }
#endif #endif


void clear()
void clear() noexcept
{ {
type = kEngineEventTypeNull; type = kEngineEventTypeNull;
time = 0; time = 0;
channel = 0; channel = 0;
} }

#ifndef DEBUG
CARLA_DECLARE_NON_COPY_STRUCT(EngineEvent)
#else
CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(EngineEvent)
#endif
}; };


/*! /*!
@@ -278,7 +267,7 @@ struct EngineOptions {
#endif #endif


#ifndef DOXYGEN #ifndef DOXYGEN
EngineOptions()
EngineOptions() noexcept
# if defined(CARLA_OS_LINUX) # if defined(CARLA_OS_LINUX)
: processMode(PROCESS_MODE_MULTIPLE_CLIENTS), : processMode(PROCESS_MODE_MULTIPLE_CLIENTS),
transportMode(TRANSPORT_MODE_JACK), transportMode(TRANSPORT_MODE_JACK),
@@ -302,8 +291,6 @@ struct EngineOptions {
rtaudioSampleRate(44100), rtaudioSampleRate(44100),
# endif # endif
resourceDir() {} resourceDir() {}

CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(EngineOptions)
#endif #endif
}; };


@@ -323,7 +310,7 @@ struct EngineTimeInfoBBT {
double beatsPerMinute; double beatsPerMinute;


#ifndef DOXYGEN #ifndef DOXYGEN
EngineTimeInfoBBT()
EngineTimeInfoBBT() noexcept
: bar(0), : bar(0),
beat(0), beat(0),
tick(0), tick(0),
@@ -332,12 +319,6 @@ struct EngineTimeInfoBBT {
beatType(0.0f), beatType(0.0f),
ticksPerBeat(0.0), ticksPerBeat(0.0),
beatsPerMinute(0.0) {} beatsPerMinute(0.0) {}

# ifndef DEBUG
CARLA_DECLARE_NON_COPY_STRUCT(EngineTimeInfoBBT)
# else
CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(EngineTimeInfoBBT)
# endif
#endif #endif
}; };


@@ -354,13 +335,13 @@ struct EngineTimeInfo {
EngineTimeInfoBBT bbt; EngineTimeInfoBBT bbt;


#ifndef DOXYGEN #ifndef DOXYGEN
EngineTimeInfo()
EngineTimeInfo() noexcept
{ {
clear(); clear();
} }
#endif #endif


void clear()
void clear() noexcept
{ {
playing = false; playing = false;
frame = 0; frame = 0;
@@ -370,7 +351,7 @@ struct EngineTimeInfo {


#ifndef DOXYGEN #ifndef DOXYGEN
// quick operator, doesn't check all values // quick operator, doesn't check all values
bool operator==(const EngineTimeInfo& timeInfo) const
bool operator==(const EngineTimeInfo& timeInfo) const noexcept
{ {
if (timeInfo.playing != playing || timeInfo.frame != frame) if (timeInfo.playing != playing || timeInfo.frame != frame)
return false; return false;
@@ -381,16 +362,10 @@ struct EngineTimeInfo {
return true; return true;
} }


bool operator!=(const EngineTimeInfo& timeInfo) const
bool operator!=(const EngineTimeInfo& timeInfo) const noexcept
{ {
return !operator==(timeInfo); return !operator==(timeInfo);
} }

# ifndef DEBUG
CARLA_DECLARE_NON_COPY_STRUCT(EngineTimeInfo)
# else
CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(EngineTimeInfo)
# endif
#endif #endif
}; };


@@ -418,7 +393,7 @@ public:
/*! /*!
* Get the type of the port, as provided by the respective subclasses. * Get the type of the port, as provided by the respective subclasses.
*/ */
virtual EnginePortType type() const = 0;
virtual EnginePortType type() const noexcept = 0;


/*! /*!
* Initialize the port's internal buffer for \a engine. * Initialize the port's internal buffer for \a engine.
@@ -427,15 +402,13 @@ public:


#ifndef DOXYGEN #ifndef DOXYGEN
protected: protected:
const bool kIsInput;
const ProcessMode kProcessMode;
const bool fIsInput;
const ProcessMode fProcessMode;


CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEnginePort) CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEnginePort)
#endif #endif
}; };


// -----------------------------------------------------------------------

/*! /*!
* Carla Engine Audio port. * Carla Engine Audio port.
*/ */
@@ -456,7 +429,7 @@ public:
/*! /*!
* Get the type of the port, in this case CarlaEnginePortTypeAudio. * Get the type of the port, in this case CarlaEnginePortTypeAudio.
*/ */
EnginePortType type() const override
EnginePortType type() const noexcept override
{ {
return kEnginePortTypeAudio; return kEnginePortTypeAudio;
} }
@@ -469,7 +442,7 @@ public:
/*! /*!
* Direct access to the port's audio buffer. * Direct access to the port's audio buffer.
*/ */
float* getBuffer() const
float* getBuffer() const noexcept
{ {
return fBuffer; return fBuffer;
} }
@@ -482,8 +455,6 @@ protected:
#endif #endif
}; };


// -----------------------------------------------------------------------

/*! /*!
* Carla Engine CV port. * Carla Engine CV port.
*/ */
@@ -504,7 +475,7 @@ public:
/*! /*!
* Get the type of the port, in this case CarlaEnginePortTypeAudio. * Get the type of the port, in this case CarlaEnginePortTypeAudio.
*/ */
EnginePortType type() const override
EnginePortType type() const noexcept override
{ {
return kEnginePortTypeCV; return kEnginePortTypeCV;
} }
@@ -527,7 +498,7 @@ public:
/*! /*!
* Direct access to the port's audio buffer. * Direct access to the port's audio buffer.
*/ */
float* getBuffer() const
float* getBuffer() const noexcept
{ {
return fBuffer; return fBuffer;
} }
@@ -541,8 +512,6 @@ protected:
#endif #endif
}; };


// -----------------------------------------------------------------------

/*! /*!
* Carla Engine Event port. * Carla Engine Event port.
*/ */
@@ -563,7 +532,7 @@ public:
/*! /*!
* Get the type of the port, in this case CarlaEnginePortTypeControl. * Get the type of the port, in this case CarlaEnginePortTypeControl.
*/ */
EnginePortType type() const override
EnginePortType type() const noexcept override
{ {
return kEnginePortTypeEvent; return kEnginePortTypeEvent;
} }
@@ -695,7 +664,7 @@ public:


#ifndef DOXYGEN #ifndef DOXYGEN
protected: protected:
const CarlaEngine& kEngine;
const CarlaEngine& fEngine;


bool fActive; bool fActive;
uint32_t fLatency; uint32_t fLatency;
@@ -707,7 +676,7 @@ protected:
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


/*! /*!
* Protected data used in CarlaEngine.
* Protected data used in CarlaEngine and subclasses.\n
* Non-engine code MUST NEVER have direct access to this. * Non-engine code MUST NEVER have direct access to this.
*/ */
struct CarlaEngineProtectedData; struct CarlaEngineProtectedData;
@@ -752,8 +721,9 @@ public:
static const char** getDriverDeviceNames(const unsigned int index); static const char** getDriverDeviceNames(const unsigned int index);


/*! /*!
* Create a new engine, using driver \a driverName.\n
* Create a new engine, using driver \a driverName. \n
* Returned variable must be deleted when no longer needed. * Returned variable must be deleted when no longer needed.
* \note This only initializes engine data, it doesn't initialize the engine itself.
*/ */
static CarlaEngine* newDriverByName(const char* const driverName); static CarlaEngine* newDriverByName(const char* const driverName);


@@ -763,23 +733,23 @@ public:
/*! /*!
* Maximum client name size. * Maximum client name size.
*/ */
virtual unsigned int maxClientNameSize() const;
virtual unsigned int getMaxClientNameSize() const noexcept;


/*! /*!
* Maximum port name size. * Maximum port name size.
*/ */
virtual unsigned int maxPortNameSize() const;
virtual unsigned int getMaxPortNameSize() const noexcept;


/*! /*!
* Current number of plugins loaded. * Current number of plugins loaded.
*/ */
unsigned int currentPluginCount() const;
unsigned int getCurrentPluginCount() const noexcept;


/*! /*!
* Maximum number of loadable plugins allowed. * Maximum number of loadable plugins allowed.
* \note This function returns 0 if engine is not started. * \note This function returns 0 if engine is not started.
*/ */
unsigned int maxPluginNumber() const;
unsigned int getMaxPluginNumber() const noexcept;


// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Virtual, per-engine type calls // Virtual, per-engine type calls
@@ -802,21 +772,21 @@ public:
/*! /*!
* Check if engine is running. * Check if engine is running.
*/ */
virtual bool isRunning() const = 0;
virtual bool isRunning() const noexcept = 0;


/*! /*!
* Check if engine is running offline (aka freewheel mode). * Check if engine is running offline (aka freewheel mode).
*/ */
virtual bool isOffline() const = 0;
virtual bool isOffline() const noexcept = 0;


/*! /*!
* Get engine type. * Get engine type.
*/ */
virtual EngineType type() const = 0;
virtual EngineType getType() const noexcept = 0;


/*! /*!
* Add new engine client. * Add new engine client.
* \note This must only be called within a plugin class.
* \note This function must only be called within a plugin class.
*/ */
virtual CarlaEngineClient* addClient(CarlaPlugin* const plugin); virtual CarlaEngineClient* addClient(CarlaPlugin* const plugin);


@@ -877,7 +847,7 @@ public:
/*! /*!
* Get plugin with id \a id, faster unchecked version. * Get plugin with id \a id, faster unchecked version.
*/ */
CarlaPlugin* getPluginUnchecked(const unsigned int id) const;
CarlaPlugin* getPluginUnchecked(const unsigned int id) const noexcept;


/*! /*!
* Get a unique plugin name within the engine.\n * Get a unique plugin name within the engine.\n
@@ -914,7 +884,7 @@ public:
/*! /*!
* Get current buffer size. * Get current buffer size.
*/ */
uint32_t getBufferSize() const
uint32_t getBufferSize() const noexcept
{ {
return fBufferSize; return fBufferSize;
} }
@@ -922,7 +892,7 @@ public:
/*! /*!
* Get current sample rate. * Get current sample rate.
*/ */
double getSampleRate() const
double getSampleRate() const noexcept
{ {
return fSampleRate; return fSampleRate;
} }
@@ -930,7 +900,7 @@ public:
/*! /*!
* Get engine name. * Get engine name.
*/ */
const char* getName() const
const char* getName() const noexcept
{ {
return (const char*)fName; return (const char*)fName;
} }
@@ -938,7 +908,7 @@ public:
/*! /*!
* Get the engine options (read-only). * Get the engine options (read-only).
*/ */
const EngineOptions& getOptions() const
const EngineOptions& getOptions() const noexcept
{ {
return fOptions; return fOptions;
} }
@@ -946,7 +916,7 @@ public:
/*! /*!
* Get the engine proccess mode. * Get the engine proccess mode.
*/ */
ProcessMode getProccessMode() const
ProcessMode getProccessMode() const noexcept
{ {
return fOptions.processMode; return fOptions.processMode;
} }
@@ -954,7 +924,7 @@ public:
/*! /*!
* Get current Time information (read-only). * Get current Time information (read-only).
*/ */
const EngineTimeInfo& getTimeInfo() const
const EngineTimeInfo& getTimeInfo() const noexcept
{ {
return fTimeInfo; return fTimeInfo;
} }
@@ -1029,7 +999,7 @@ public:
/*! /*!
* Get last error. * Get last error.
*/ */
const char* getLastError() const;
const char* getLastError() const noexcept;


/*! /*!
* Set last error. * Set last error.
@@ -1060,12 +1030,12 @@ public:
/*! /*!
* Check if OSC bridge is registered. * Check if OSC bridge is registered.
*/ */
bool isOscBridgeRegistered() const;
bool isOscBridgeRegistered() const noexcept;
#else #else
/*! /*!
* Check if OSC controller is registered. * Check if OSC controller is registered.
*/ */
bool isOscControlRegistered() const;
bool isOscControlRegistered() const noexcept;
#endif #endif


/*! /*!
@@ -1076,34 +1046,76 @@ public:
/*! /*!
* Get OSC TCP server path. * Get OSC TCP server path.
*/ */
const char* getOscServerPathTCP() const;
const char* getOscServerPathTCP() const noexcept;


/*! /*!
* Get OSC UDP server path. * Get OSC UDP server path.
*/ */
const char* getOscServerPathUDP() const;
const char* getOscServerPathUDP() const noexcept;


#ifdef BUILD_BRIDGE #ifdef BUILD_BRIDGE
/*! /*!
* Set OSC bridge data. * Set OSC bridge data.
*/ */
void setOscBridgeData(const CarlaOscData* const oscData);
void setOscBridgeData(const CarlaOscData* const oscData) noexcept;
#endif #endif


// -------------------------------------
// -------------------------------------------------------------------
// Helper functions

/*!
* Return internal data, needed for EventPorts when used in Rack and Bridge modes.
* \note RT call
*/
EngineEvent* getInternalEventBuffer(const bool isInput) const noexcept;

/*!
* Force register a plugin into slot \a id. \n
* This is needed so that we can receive OSC events for the plugin while it initializes.
*/
void registerEnginePlugin(const unsigned int id, CarlaPlugin* const plugin);

// -------------------------------------------------------------------


#ifndef DOXYGEN
protected: protected:
/*!
* Current buffer size.
* \see getBufferSize()
*/
uint32_t fBufferSize; uint32_t fBufferSize;
double fSampleRate;


/*!
* Current sample rate.
* \see getSampleRate()
*/
double fSampleRate;

/*!
* Engine name.
* \see getName()
*/
CarlaString fName; CarlaString fName;


EngineOptions fOptions;
/*!
* Engine options.
* \see getOptions() and setOption()
*/
EngineOptions fOptions;

/*!
* Current time-pos information.
* \see getTimeInfo()
*/
EngineTimeInfo fTimeInfo; EngineTimeInfo fTimeInfo;


/*!
* Internal data, for CarlaEngine subclasses only.
*/
CarlaEngineProtectedData* const pData;
friend struct CarlaEngineProtectedData; friend struct CarlaEngineProtectedData;
CarlaEngineProtectedData* const kData;

// -------------------------------------------------------------------
// Internal stuff


/*! /*!
* Report to all plugins about buffer size change. * Report to all plugins about buffer size change.
@@ -1112,8 +1124,7 @@ protected:


/*! /*!
* Report to all plugins about sample rate change.\n * Report to all plugins about sample rate change.\n
* This is not supported on all plugin types, on which case they will be re-initiated.\n
* TODO: Not implemented yet.
* This is not supported on all plugin types, in which case they will have to be re-initiated.
*/ */
void sampleRateChanged(const double newSampleRate); void sampleRateChanged(const double newSampleRate);


@@ -1123,34 +1134,44 @@ protected:
void offlineModeChanged(const bool isOffline); void offlineModeChanged(const bool isOffline);


/*! /*!
* TODO.
* Run any RT pending events.\n
* Must always be called at the end of audio processing.
* \note RT call
*/ */
void proccessPendingEvents();
void runRtPendingEvents();


/*! /*!
* TODO.
* Set a plugin (stereo) peak values.
* \note RT call
*/ */
void setPeaks(const unsigned int pluginId, float const inPeaks[2], float const outPeaks[2]);

// Internal data, used in Rack and Bridge modes
EngineEvent* getInternalEventBuffer(const bool isInput) const;
void setPluginPeaks(const unsigned int pluginId, float const inPeaks[2], float const outPeaks[2]) noexcept;


# ifndef BUILD_BRIDGE
#ifndef BUILD_BRIDGE
/*! /*!
* Proccess audio buffer in rack mode. * Proccess audio buffer in rack mode.
* \note RT call
*/ */
void processRack(float* inBuf[2], float* outBuf[2], const uint32_t frames); void processRack(float* inBuf[2], float* outBuf[2], const uint32_t frames);


/*! /*!
* Proccess audio buffer in patchbay mode. * Proccess audio buffer in patchbay mode.
* In \a bufCount, [0]=inBufCount and [1]=outBufCount * In \a bufCount, [0]=inBufCount and [1]=outBufCount
* \note RT call
*/ */
void processPatchbay(float** inBuf, float** outBuf, const uint32_t bufCount[2], const uint32_t frames); void processPatchbay(float** inBuf, float** outBuf, const uint32_t bufCount[2], const uint32_t frames);
# endif
#endif

// -------------------------------------------------------------------
// Engine initializers

#ifdef BUILD_BRIDGE
public:
static CarlaEngine* newBridge(const char* const audioBaseName, const char* const controlBaseName);
#endif


private: private:
static CarlaEngine* newJack(); static CarlaEngine* newJack();
# ifdef WANT_RTAUDIO
#ifdef WANT_RTAUDIO
enum RtAudioApi { enum RtAudioApi {
RTAUDIO_DUMMY = 0, RTAUDIO_DUMMY = 0,
RTAUDIO_LINUX_ALSA = 1, RTAUDIO_LINUX_ALSA = 1,
@@ -1166,66 +1187,59 @@ private:
static size_t getRtAudioApiCount(); static size_t getRtAudioApiCount();
static const char* getRtAudioApiName(const unsigned int index); static const char* getRtAudioApiName(const unsigned int index);
static const char** getRtAudioApiDeviceNames(const unsigned int index); static const char** getRtAudioApiDeviceNames(const unsigned int index);
# endif

public:
# ifdef BUILD_BRIDGE
static CarlaEngine* newBridge(const char* const audioBaseName, const char* const controlBaseName);
#endif


void osc_send_bridge_audio_count(const int32_t ins, const int32_t outs, const int32_t total);
void osc_send_bridge_midi_count(const int32_t ins, const int32_t outs, const int32_t total);
void osc_send_bridge_parameter_count(const int32_t ins, const int32_t outs, const int32_t total);
void osc_send_bridge_program_count(const int32_t count);
void osc_send_bridge_midi_program_count(const int32_t count);
void osc_send_bridge_plugin_info(const int32_t category, const int32_t hints, const char* const name, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId);
void osc_send_bridge_parameter_info(const int32_t index, const char* const name, const char* const unit);
void osc_send_bridge_parameter_data(const int32_t index, const int32_t type, const int32_t rindex, const int32_t hints, const int32_t midiChannel, const int32_t midiCC);
void osc_send_bridge_parameter_ranges(const int32_t index, const float def, const float min, const float max, const float step, const float stepSmall, const float stepLarge);
void osc_send_bridge_program_info(const int32_t index, const char* const name);
void osc_send_bridge_midi_program_info(const int32_t index, const int32_t bank, const int32_t program, const char* const label);
void osc_send_bridge_configure(const char* const key, const char* const value);
void osc_send_bridge_set_parameter_value(const int32_t index, const float value);
void osc_send_bridge_set_default_value(const int32_t index, const float value);
void osc_send_bridge_set_program(const int32_t index);
void osc_send_bridge_set_midi_program(const int32_t index);
void osc_send_bridge_set_custom_data(const char* const type, const char* const key, const char* const value);
void osc_send_bridge_set_chunk_data(const char* const chunkFile);
void osc_send_bridge_set_peaks();
# else
static void registerNativePlugin();

void osc_send_control_add_plugin_start(const int32_t pluginId, const char* const pluginName);
void osc_send_control_add_plugin_end(const int32_t pluginId);
void osc_send_control_remove_plugin(const int32_t pluginId);
void osc_send_control_set_plugin_data(const int32_t pluginId, const int32_t type, const int32_t category, const int32_t hints, const char* const realName, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId);
void osc_send_control_set_plugin_ports(const int32_t pluginId, const int32_t audioIns, const int32_t audioOuts, const int32_t midiIns, const int32_t midiOuts, const int32_t cIns, const int32_t cOuts, const int32_t cTotals);
void osc_send_control_set_parameter_data(const int32_t pluginId, const int32_t index, const int32_t type, const int32_t hints, const char* const name, const char* const label, const float current);
void osc_send_control_set_parameter_ranges(const int32_t pluginId, const int32_t index, const float min, const float max, const float def, const float step, const float stepSmall, const float stepLarge);
void osc_send_control_set_parameter_midi_cc(const int32_t pluginId, const int32_t index, const int32_t cc);
void osc_send_control_set_parameter_midi_channel(const int32_t pluginId, const int32_t index, const int32_t channel);
void osc_send_control_set_parameter_value(const int32_t pluginId, const int32_t index, const float value);
void osc_send_control_set_default_value(const int32_t pluginId, const int32_t index, const float value);
void osc_send_control_set_program(const int32_t pluginId, const int32_t index);
void osc_send_control_set_program_count(const int32_t pluginId, const int32_t count);
void osc_send_control_set_program_name(const int32_t pluginId, const int32_t index, const char* const name);
void osc_send_control_set_midi_program(const int32_t pluginId, const int32_t index);
void osc_send_control_set_midi_program_count(const int32_t pluginId, const int32_t count);
void osc_send_control_set_midi_program_data(const int32_t pluginId, const int32_t index, const int32_t bank, const int32_t program, const char* const name);
void osc_send_control_note_on(const int32_t pluginId, const int32_t channel, const int32_t note, const int32_t velo);
void osc_send_control_note_off(const int32_t pluginId, const int32_t channel, const int32_t note);
void osc_send_control_set_peaks(const int32_t pluginId);
void osc_send_control_exit();
# endif
// -------------------------------------------------------------------
// Bridge/Controller OSC stuff


private:
friend class CarlaEngineEventPort;
#ifdef BUILD_BRIDGE
void oscSend_bridge_audio_count(const int32_t ins, const int32_t outs, const int32_t total);
void oscSend_bridge_midi_count(const int32_t ins, const int32_t outs, const int32_t total);
void oscSend_bridge_parameter_count(const int32_t ins, const int32_t outs, const int32_t total);
void oscSend_bridge_program_count(const int32_t count);
void oscSend_bridge_midi_program_count(const int32_t count);
void oscSend_bridge_plugin_info(const int32_t category, const int32_t hints, const char* const name, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId);
void oscSend_bridge_parameter_info(const int32_t index, const char* const name, const char* const unit);
void oscSend_bridge_parameter_data(const int32_t index, const int32_t type, const int32_t rindex, const int32_t hints, const int32_t midiChannel, const int32_t midiCC);
void oscSend_bridge_parameter_ranges(const int32_t index, const float def, const float min, const float max, const float step, const float stepSmall, const float stepLarge);
void oscSend_bridge_program_info(const int32_t index, const char* const name);
void oscSend_bridge_midi_program_info(const int32_t index, const int32_t bank, const int32_t program, const char* const label);
void oscSend_bridge_configure(const char* const key, const char* const value);
void oscSend_bridge_set_parameter_value(const int32_t index, const float value);
void oscSend_bridge_set_default_value(const int32_t index, const float value);
void oscSend_bridge_set_program(const int32_t index);
void oscSend_bridge_set_midi_program(const int32_t index);
void oscSend_bridge_set_custom_data(const char* const type, const char* const key, const char* const value);
void oscSend_bridge_set_chunk_data(const char* const chunkFile);
void oscSend_bridge_set_peaks();
#else
public:
void oscSend_control_add_plugin_start(const int32_t pluginId, const char* const pluginName);
void oscSend_control_add_plugin_end(const int32_t pluginId);
void oscSend_control_remove_plugin(const int32_t pluginId);
void oscSend_control_set_plugin_data(const int32_t pluginId, const int32_t type, const int32_t category, const int32_t hints, const char* const realName, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId);
void oscSend_control_set_plugin_ports(const int32_t pluginId, const int32_t audioIns, const int32_t audioOuts, const int32_t midiIns, const int32_t midiOuts, const int32_t cIns, const int32_t cOuts, const int32_t cTotals);
void oscSend_control_set_parameter_data(const int32_t pluginId, const int32_t index, const int32_t type, const int32_t hints, const char* const name, const char* const label, const float current);
void oscSend_control_set_parameter_ranges(const int32_t pluginId, const int32_t index, const float min, const float max, const float def, const float step, const float stepSmall, const float stepLarge);
void oscSend_control_set_parameter_midi_cc(const int32_t pluginId, const int32_t index, const int32_t cc);
void oscSend_control_set_parameter_midi_channel(const int32_t pluginId, const int32_t index, const int32_t channel);
void oscSend_control_set_parameter_value(const int32_t pluginId, const int32_t index, const float value);
void oscSend_control_set_default_value(const int32_t pluginId, const int32_t index, const float value);
void oscSend_control_set_program(const int32_t pluginId, const int32_t index);
void oscSend_control_set_program_count(const int32_t pluginId, const int32_t count);
void oscSend_control_set_program_name(const int32_t pluginId, const int32_t index, const char* const name);
void oscSend_control_set_midi_program(const int32_t pluginId, const int32_t index);
void oscSend_control_set_midi_program_count(const int32_t pluginId, const int32_t count);
void oscSend_control_set_midi_program_data(const int32_t pluginId, const int32_t index, const int32_t bank, const int32_t program, const char* const name);
void oscSend_control_note_on(const int32_t pluginId, const int32_t channel, const int32_t note, const int32_t velo);
void oscSend_control_note_off(const int32_t pluginId, const int32_t channel, const int32_t note);
void oscSend_control_set_peaks(const int32_t pluginId);
void oscSend_control_exit();
#endif


CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngine) CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngine)
#endif
}; };


// -----------------------------------------------------------------------

/**@}*/ /**@}*/


CARLA_BACKEND_END_NAMESPACE CARLA_BACKEND_END_NAMESPACE


+ 53
- 33
source/backend/CarlaPlugin.hpp View File

@@ -36,26 +36,12 @@ CARLA_BACKEND_START_NAMESPACE
* @defgroup CarlaPluginAPI Carla Plugin API * @defgroup CarlaPluginAPI Carla Plugin API
* *
* The Carla Plugin API. * The Carla Plugin API.
*
* @{ * @{
*/ */


/*!
* 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,
kPluginPostRtEventDebug,
kPluginPostRtEventParameterChange, // param, SP*, value (SP: if 1, don't report change to Callback and OSC)
kPluginPostRtEventProgramChange, // index
kPluginPostRtEventMidiProgramChange, // index
kPluginPostRtEventNoteOn, // channel, note, velo
kPluginPostRtEventNoteOff // channel, note
};
class CarlaEngine;
class CarlaEngineClient;
class CarlaEngineAudioPort;


/*! /*!
* Save state data. * Save state data.
@@ -770,13 +756,6 @@ public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Post-poned events // Post-poned events


/*!
* Post pone an event of type \a type.\n
* The event will be processed later, but as soon as possible.
* \note RT call
*/
void postponeRtEvent(const PluginPostRtEventType type, const int32_t value1, const int32_t value2, const float value3);

/*! /*!
* Process all the post-poned events. * Process all the post-poned events.
* This function must be called from the main thread (ie, idleGui()) if PLUGIN_USES_SINGLE_THREAD is set. * This function must be called from the main thread (ie, idleGui()) if PLUGIN_USES_SINGLE_THREAD is set.
@@ -811,16 +790,41 @@ public:
*/ */
virtual void uiNoteOff(const uint8_t channel, const uint8_t note); virtual void uiNoteOff(const uint8_t channel, const uint8_t note);


// -------------------------------------------------------------------
// Helper functions

/*!
* Check if the plugin can run in rack mode.
*/
bool canRunInRack() const noexcept;

/*!
* Get the plugin's engine, as passed in the constructor.
*/
CarlaEngine* getEngine() const noexcept;

/*!
* Get the plugin's engine client.
*/
CarlaEngineClient* getEngineClient() const noexcept;

/*!
* Get a plugin's audio input port.
*/
CarlaEngineAudioPort* getAudioInPort(const uint32_t index) const noexcept;

/*!
* Get a plugin's audio output port.
*/
CarlaEngineAudioPort* getAudioOutPort(const uint32_t index) const noexcept;

// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Plugin initializers // Plugin initializers


/*! /*!
* Handy function used and required by CarlaEngine::clonePlugin(). * Handy function used and required by CarlaEngine::clonePlugin().
*/ */
virtual const void* getExtraStuff() const noexcept
{
return nullptr;
}
virtual const void* getExtraStuff() const noexcept;


#ifndef DOXYGEN #ifndef DOXYGEN
struct Initializer { struct Initializer {
@@ -874,13 +878,29 @@ protected:
*/ */
bool fEnabled; bool fEnabled;


CarlaString fName; //!< Plugin name
CarlaString fFilename; //!< Plugin filename, if applicable
CarlaString fIconName; //!< Icon name
/*!
* Plugin name
* \see getName(), getRealName() and setName()
*/
CarlaString fName;


CarlaPluginProtectedData* const pData; //!< Internal data, for CarlaPlugin subclasses only.
/*!
* Plugin filename, if applicable
* \see getFilename()
*/
CarlaString fFilename;

/*!
* Icon name
* \see getIconName()
*/
CarlaString fIconName;

/*!
* Internal data, for CarlaPlugin subclasses only.
*/
CarlaPluginProtectedData* const pData;
friend struct CarlaPluginProtectedData; friend struct CarlaPluginProtectedData;
//friend class CarlaEngineBridge;


// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Helper classes // Helper classes


+ 415
- 415
source/backend/engine/CarlaEngine.cpp
File diff suppressed because it is too large
View File


+ 4
- 4
source/backend/engine/CarlaEngineOsc.hpp View File

@@ -66,12 +66,12 @@ public:


// ------------------------------------------------------------------- // -------------------------------------------------------------------


const char* getServerPathTCP() const
const char* getServerPathTCP() const noexcept
{ {
return (const char*)fServerPathTCP; return (const char*)fServerPathTCP;
} }


const char* getServerPathUDP() const
const char* getServerPathUDP() const noexcept
{ {
return (const char*)fServerPathUDP; return (const char*)fServerPathUDP;
} }
@@ -79,12 +79,12 @@ public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------


#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
bool isControlRegistered() const
bool isControlRegistered() const noexcept
{ {
return (fControlData.target != nullptr); return (fControlData.target != nullptr);
} }


const CarlaOscData* getControlData() const
const CarlaOscData* getControlData() const noexcept
{ {
return &fControlData; return &fControlData;
} }


+ 0
- 11
source/backend/plugin/CarlaPlugin.cpp View File

@@ -1957,17 +1957,6 @@ void CarlaPlugin::sendMidiAllNotesOffToCallback()
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Post-poned events // Post-poned events


void CarlaPlugin::postponeRtEvent(const PluginPostRtEventType type, const int32_t value1, const int32_t value2, const float value3)
{
PluginPostRtEvent event;
event.type = type;
event.value1 = value1;
event.value2 = value2;
event.value3 = value3;

pData->postRtEvents.appendRT(event);
}

void CarlaPlugin::postRtEventsRun() void CarlaPlugin::postRtEventsRun()
{ {
const CarlaMutex::ScopedLocker sl(pData->postRtEvents.mutex); const CarlaMutex::ScopedLocker sl(pData->postRtEvents.mutex);


+ 65
- 38
source/backend/plugin/CarlaPluginInternal.hpp View File

@@ -43,6 +43,42 @@ const unsigned int PLUGIN_HINT_CAN_RUN_RACK = 0x4;


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


/*!
* 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,
kPluginPostRtEventDebug,
kPluginPostRtEventParameterChange, // param, SP*, value (SP: if 1, don't report change to Callback and OSC)
kPluginPostRtEventProgramChange, // index
kPluginPostRtEventMidiProgramChange, // index
kPluginPostRtEventNoteOn, // channel, note, velo
kPluginPostRtEventNoteOff // channel, note
};

/*!
* A Post-RT event.
* \see PluginPostRtEventType
*/
struct PluginPostRtEvent {
PluginPostRtEventType type;
int32_t value1;
int32_t value2;
float value3;

PluginPostRtEvent() noexcept
: type(kPluginPostRtEventNull),
value1(-1),
value2(-1),
value3(0.0f) {}
};

// -----------------------------------------------------------------------

struct PluginAudioPort { struct PluginAudioPort {
uint32_t rindex; uint32_t rindex;
CarlaEngineAudioPort* port; CarlaEngineAudioPort* port;
@@ -56,7 +92,7 @@ struct PluginAudioPort {
CARLA_ASSERT(port == nullptr); CARLA_ASSERT(port == nullptr);
} }


CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(PluginAudioPort)
CARLA_DECLARE_NON_COPY_STRUCT(PluginAudioPort)
}; };


struct PluginAudioData { struct PluginAudioData {
@@ -115,7 +151,7 @@ struct PluginAudioData {
} }
} }


CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(PluginAudioData)
CARLA_DECLARE_NON_COPY_STRUCT(PluginAudioData)
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -135,7 +171,7 @@ struct PluginCVPort {
CARLA_ASSERT(port == nullptr); CARLA_ASSERT(port == nullptr);
} }


CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(PluginCVPort)
CARLA_DECLARE_NON_COPY_STRUCT(PluginCVPort)
}; };


struct PluginCVData { struct PluginCVData {
@@ -194,7 +230,7 @@ struct PluginCVData {
} }
} }


CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(PluginCVData)
CARLA_DECLARE_NON_COPY_STRUCT(PluginCVData)
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -237,7 +273,7 @@ struct PluginEventData {
portOut->initBuffer(engine); portOut->initBuffer(engine);
} }


CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(PluginEventData)
CARLA_DECLARE_NON_COPY_STRUCT(PluginEventData)
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -297,7 +333,7 @@ struct PluginParameterData {
return ranges[parameterId].fixValue(value); return ranges[parameterId].fixValue(value);
} }


CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(PluginParameterData)
CARLA_DECLARE_NON_COPY_STRUCT(PluginParameterData)
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -359,7 +395,7 @@ struct PluginProgramData {
current = -1; current = -1;
} }


CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(PluginProgramData)
CARLA_DECLARE_NON_COPY_STRUCT(PluginProgramData)
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -422,28 +458,7 @@ struct PluginMidiProgramData {
return data[current]; return data[current];
} }


CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(PluginMidiProgramData)
};

// -----------------------------------------------------------------------

struct PluginPostRtEvent {
PluginPostRtEventType type;
int32_t value1;
int32_t value2;
float value3;

PluginPostRtEvent()
: type(kPluginPostRtEventNull),
value1(-1),
value2(-1),
value3(0.0f) {}

#ifndef DEBUG
CARLA_DECLARE_NON_COPY_STRUCT(PluginPostRtEvent)
#else
CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(PluginPostRtEvent)
#endif
CARLA_DECLARE_NON_COPY_STRUCT(PluginMidiProgramData)
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -458,11 +473,7 @@ struct ExternalMidiNote {
note(0), note(0),
velo(0) {} velo(0) {}


#ifndef DEBUG
CARLA_DECLARE_NON_COPY_STRUCT(ExternalMidiNote) CARLA_DECLARE_NON_COPY_STRUCT(ExternalMidiNote)
#else
CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(ExternalMidiNote)
#endif
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -763,21 +774,37 @@ struct CarlaPluginProtectedData {
} }
} }


// -------------------------------------------------------------------
// Post-poned events

void postponeRtEvent(const PluginPostRtEventType type, const int32_t value1, const int32_t value2, const float value3)
{
PluginPostRtEvent event;
event.type = type;
event.value1 = value1;
event.value2 = value2;
event.value3 = value3;

postRtEvents.appendRT(event);
}

// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Library functions, see CarlaPlugin.cpp // Library functions, see CarlaPlugin.cpp


bool libOpen(const char* const filename);
bool uiLibOpen(const char* const filename);
bool libClose();
bool uiLibClose();
bool libOpen(const char* const filename);
bool libClose();
void* libSymbol(const char* const symbol); void* libSymbol(const char* const symbol);

bool uiLibOpen(const char* const filename);
bool uiLibClose();
void* uiLibSymbol(const char* const symbol); void* uiLibSymbol(const char* const symbol);

const char* libError(const char* const filename); const char* libError(const char* const filename);


// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Settings functions, see CarlaPlugin.cpp // Settings functions, see CarlaPlugin.cpp


void saveSetting(const unsigned int option, const bool yesNo);
void saveSetting(const unsigned int option, const bool yesNo);
unsigned int loadSettings(const unsigned int options, const unsigned int availOptions); unsigned int loadSettings(const unsigned int options, const unsigned int availOptions);


// ------------------------------------------------------------------- // -------------------------------------------------------------------


+ 8
- 0
source/includes/ladspa_rdf.hpp View File

@@ -18,6 +18,8 @@
#ifndef LADSPA_RDF_HPP_INCLUDED #ifndef LADSPA_RDF_HPP_INCLUDED
#define LADSPA_RDF_HPP_INCLUDED #define LADSPA_RDF_HPP_INCLUDED


#include "CarlaJuceUtils.hpp"

// Base Types // Base Types
typedef float LADSPA_Data; typedef float LADSPA_Data;
typedef int LADSPA_Property; typedef int LADSPA_Property;
@@ -132,6 +134,8 @@ struct LADSPA_RDF_ScalePoint {
Label = nullptr; Label = nullptr;
} }
} }

CARLA_DECLARE_NON_COPY_STRUCT(LADSPA_RDF_ScalePoint)
}; };


// Port // Port
@@ -167,6 +171,8 @@ struct LADSPA_RDF_Port {
ScalePoints = nullptr; ScalePoints = nullptr;
} }
} }

CARLA_DECLARE_NON_COPY_STRUCT(LADSPA_RDF_Port)
}; };


// Plugin Descriptor // Plugin Descriptor
@@ -205,6 +211,8 @@ struct LADSPA_RDF_Descriptor {
Ports = nullptr; Ports = nullptr;
} }
} }

CARLA_DECLARE_NON_COPY_STRUCT(LADSPA_RDF_Descriptor)
}; };


#endif // LADSPA_RDF_HPP_INCLUDED #endif // LADSPA_RDF_HPP_INCLUDED

+ 16
- 0
source/includes/lv2_rdf.hpp View File

@@ -18,6 +18,8 @@
#ifndef LV2_RDF_HPP_INCLUDED #ifndef LV2_RDF_HPP_INCLUDED
#define LV2_RDF_HPP_INCLUDED #define LV2_RDF_HPP_INCLUDED


#include "CarlaJuceUtils.hpp"

#ifdef CARLA_PROPER_CPP11_SUPPORT #ifdef CARLA_PROPER_CPP11_SUPPORT
# include <cstdint> # include <cstdint>
#else #else
@@ -347,6 +349,8 @@ struct LV2_RDF_PortUnit {
Symbol = nullptr; Symbol = nullptr;
} }
} }

CARLA_DECLARE_NON_COPY_STRUCT(LV2_RDF_PortUnit)
}; };


// Port Scale Point // Port Scale Point
@@ -366,6 +370,8 @@ struct LV2_RDF_PortScalePoint {
Label = nullptr; Label = nullptr;
} }
} }

CARLA_DECLARE_NON_COPY_STRUCT(LV2_RDF_PortScalePoint)
}; };


// Port // Port
@@ -410,6 +416,8 @@ struct LV2_RDF_Port {
ScalePoints = nullptr; ScalePoints = nullptr;
} }
} }

CARLA_DECLARE_NON_COPY_STRUCT(LV2_RDF_Port)
}; };


// Preset // Preset
@@ -434,6 +442,8 @@ struct LV2_RDF_Preset {
Label = nullptr; Label = nullptr;
} }
} }

CARLA_DECLARE_NON_COPY_STRUCT(LV2_RDF_Preset)
}; };


// Feature // Feature
@@ -453,6 +463,8 @@ struct LV2_RDF_Feature {
URI = nullptr; URI = nullptr;
} }
} }

CARLA_DECLARE_NON_COPY_STRUCT(LV2_RDF_Feature)
}; };


// UI // UI
@@ -506,6 +518,8 @@ struct LV2_RDF_UI {
Extensions = nullptr; Extensions = nullptr;
} }
} }

CARLA_DECLARE_NON_COPY_STRUCT(LV2_RDF_UI)
}; };


// Plugin Descriptor // Plugin Descriptor
@@ -621,6 +635,8 @@ struct LV2_RDF_Descriptor {
UIs = nullptr; UIs = nullptr;
} }
} }

CARLA_DECLARE_NON_COPY_STRUCT(LV2_RDF_Descriptor)
}; };


#endif // LV2_RDF_HPP_INCLUDED #endif // LV2_RDF_HPP_INCLUDED

+ 12
- 10
source/tests/ANSI.cpp View File

@@ -18,9 +18,17 @@
#undef NDEBUG #undef NDEBUG
#define DEBUG #define DEBUG


// includes
// includes (part1)
#include "CarlaDefines.hpp" #include "CarlaDefines.hpp"
#include "CarlaMIDI.h" #include "CarlaMIDI.h"

// Carla common utils
#include "CarlaUtils.hpp"

// Carla misc utils imported from Juce source code
#include "CarlaJuceUtils.hpp"

// includes (part2)
#include "ladspa_rdf.hpp" #include "ladspa_rdf.hpp"
#include "lv2_rdf.hpp" #include "lv2_rdf.hpp"


@@ -30,12 +38,6 @@
// Carla Native Plugin API // Carla Native Plugin API
#include "CarlaNative.h" #include "CarlaNative.h"


// Carla common utils
#include "CarlaUtils.hpp"

// Carla misc utils imported from Juce source code
#include "CarlaJuceUtils.hpp"

// Carla Native Plugin API (C++) // Carla Native Plugin API (C++)
#include "CarlaNative.hpp" #include "CarlaNative.hpp"


@@ -45,7 +47,9 @@
// Carla Plugin API // Carla Plugin API
#include "CarlaPlugin.hpp" #include "CarlaPlugin.hpp"


// #include "CarlaEngine.hpp"
// Carla Engine API
#include "CarlaEngine.hpp"

//#include "standalone/CarlaStandalone.cpp" //#include "standalone/CarlaStandalone.cpp"


// #include "CarlaMutex.hpp" // #include "CarlaMutex.hpp"
@@ -74,7 +78,6 @@ int main()
LADSPA_RDF_ScalePoint a; LADSPA_RDF_ScalePoint a;
LADSPA_RDF_Port b; LADSPA_RDF_Port b;
LADSPA_RDF_Descriptor c; LADSPA_RDF_Descriptor c;
a=a;b=b;c=c;
} }


// lv2 rdf // lv2 rdf
@@ -88,7 +91,6 @@ int main()
LV2_RDF_Feature g; LV2_RDF_Feature g;
LV2_RDF_UI h; LV2_RDF_UI h;
LV2_RDF_Descriptor i; LV2_RDF_Descriptor i;
a=a;b=b;c=c;d=d;e=e;f=f;g=g;h=h;i=i;
} }


// Carla Backend API // Carla Backend API


+ 1
- 1
source/utils/CarlaLibUtils.hpp View File

@@ -76,7 +76,7 @@ const char* lib_error(const char* const filename)
CARLA_ASSERT(filename != nullptr); CARLA_ASSERT(filename != nullptr);


#ifdef CARLA_OS_WIN #ifdef CARLA_OS_WIN
static char libError[2048];
static char libError[2048+1];
//carla_fill<char>(libError, 2048, '\0'); //carla_fill<char>(libError, 2048, '\0');


LPVOID winErrorString; LPVOID winErrorString;


+ 1
- 1
source/utils/CarlaLv2Utils.hpp View File

@@ -404,7 +404,7 @@ public:
} }


private: private:
bool needInit;
bool fNeedsInit;


CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Lv2WorldClass) CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Lv2WorldClass)
}; };


+ 1
- 1
source/utils/CarlaOscUtils.hpp View File

@@ -60,7 +60,7 @@ struct CarlaOscData {
} }
} }


CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(CarlaOscData)
CARLA_DECLARE_NON_COPY_STRUCT(CarlaOscData)
}; };


// ------------------------------------------------- // -------------------------------------------------


+ 16
- 22
source/utils/CarlaStateUtils.hpp View File

@@ -208,7 +208,7 @@ struct SaveState {
customData.clear(); customData.clear();
} }


CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(SaveState)
CARLA_DECLARE_NON_COPY_STRUCT(SaveState)
}; };


// ------------------------------------------------- // -------------------------------------------------
@@ -225,7 +225,7 @@ QString xmlSafeString(const QString& string, const bool toXml)
} }


static inline static inline
const char* xmlSafeStringChar(const QString& string, const bool toXml)
const char* xmlSafeStringCharDup(const QString& string, const bool toXml)
{ {
return carla_strdup(xmlSafeString(string, toXml).toUtf8().constData()); return carla_strdup(xmlSafeString(string, toXml).toUtf8().constData());
} }
@@ -233,13 +233,12 @@ const char* xmlSafeStringChar(const QString& string, const bool toXml)
// ------------------------------------------------- // -------------------------------------------------


static inline static inline
const SaveState& getSaveStateDictFromXML(const QDomNode& xmlNode)
void fillSaveStateFromXmlNode(SaveState& saveState, const QDomNode& xmlNode)
{ {
static SaveState saveState;
saveState.reset(); saveState.reset();


if (xmlNode.isNull()) if (xmlNode.isNull())
return saveState;
return;


QDomNode node(xmlNode.firstChild()); QDomNode node(xmlNode.firstChild());


@@ -258,13 +257,13 @@ const SaveState& getSaveStateDictFromXML(const QDomNode& xmlNode)
const QString text(xmlInfo.toElement().text().trimmed()); const QString text(xmlInfo.toElement().text().trimmed());


if (tag.compare("Type", Qt::CaseInsensitive) == 0) if (tag.compare("Type", Qt::CaseInsensitive) == 0)
saveState.type = xmlSafeStringChar(text, false);
saveState.type = xmlSafeStringCharDup(text, false);
else if (tag.compare("Name", Qt::CaseInsensitive) == 0) else if (tag.compare("Name", Qt::CaseInsensitive) == 0)
saveState.name = xmlSafeStringChar(text, false);
saveState.name = xmlSafeStringCharDup(text, false);
else if (tag.compare("Label", Qt::CaseInsensitive) == 0 || tag.compare("URI", Qt::CaseInsensitive) == 0) else if (tag.compare("Label", Qt::CaseInsensitive) == 0 || tag.compare("URI", Qt::CaseInsensitive) == 0)
saveState.label = xmlSafeStringChar(text, false);
saveState.label = xmlSafeStringCharDup(text, false);
else if (tag.compare("Binary", Qt::CaseInsensitive) == 0) else if (tag.compare("Binary", Qt::CaseInsensitive) == 0)
saveState.binary = xmlSafeStringChar(text, false);
saveState.binary = xmlSafeStringCharDup(text, false);
else if (tag.compare("UniqueID", Qt::CaseInsensitive) == 0) else if (tag.compare("UniqueID", Qt::CaseInsensitive) == 0)
{ {
bool ok; bool ok;
@@ -345,7 +344,7 @@ const SaveState& getSaveStateDictFromXML(const QDomNode& xmlNode)
} }
else if (tag.compare("CurrentProgramName", Qt::CaseInsensitive) == 0) else if (tag.compare("CurrentProgramName", Qt::CaseInsensitive) == 0)
{ {
saveState.currentProgramName = xmlSafeStringChar(text, false);
saveState.currentProgramName = xmlSafeStringCharDup(text, false);
} }


// ---------------------------------------------- // ----------------------------------------------
@@ -388,11 +387,11 @@ const SaveState& getSaveStateDictFromXML(const QDomNode& xmlNode)
} }
else if (pTag.compare("Name", Qt::CaseInsensitive) == 0) else if (pTag.compare("Name", Qt::CaseInsensitive) == 0)
{ {
stateParameter->name = xmlSafeStringChar(pText, false);
stateParameter->name = xmlSafeStringCharDup(pText, false);
} }
else if (pTag.compare("Symbol", Qt::CaseInsensitive) == 0) else if (pTag.compare("Symbol", Qt::CaseInsensitive) == 0)
{ {
stateParameter->symbol = xmlSafeStringChar(pText, false);
stateParameter->symbol = xmlSafeStringCharDup(pText, false);
} }
else if (pTag.compare("Value", Qt::CaseInsensitive) == 0) else if (pTag.compare("Value", Qt::CaseInsensitive) == 0)
{ {
@@ -436,11 +435,11 @@ const SaveState& getSaveStateDictFromXML(const QDomNode& xmlNode)
const QString cText(xmlSubData.toElement().text().trimmed()); const QString cText(xmlSubData.toElement().text().trimmed());


if (cTag.compare("Type", Qt::CaseInsensitive) == 0) if (cTag.compare("Type", Qt::CaseInsensitive) == 0)
stateCustomData->type = xmlSafeStringChar(cText, false);
stateCustomData->type = xmlSafeStringCharDup(cText, false);
else if (cTag.compare("Key", Qt::CaseInsensitive) == 0) else if (cTag.compare("Key", Qt::CaseInsensitive) == 0)
stateCustomData->key = xmlSafeStringChar(cText, false);
stateCustomData->key = xmlSafeStringCharDup(cText, false);
else if (cTag.compare("Value", Qt::CaseInsensitive) == 0) else if (cTag.compare("Value", Qt::CaseInsensitive) == 0)
stateCustomData->value = xmlSafeStringChar(cText, false);
stateCustomData->value = xmlSafeStringCharDup(cText, false);


xmlSubData = xmlSubData.nextSibling(); xmlSubData = xmlSubData.nextSibling();
} }
@@ -453,7 +452,7 @@ const SaveState& getSaveStateDictFromXML(const QDomNode& xmlNode)


else if (tag.compare("Chunk", Qt::CaseInsensitive) == 0) else if (tag.compare("Chunk", Qt::CaseInsensitive) == 0)
{ {
saveState.chunk = xmlSafeStringChar(text, false);
saveState.chunk = xmlSafeStringCharDup(text, false);
} }


// ---------------------------------------------- // ----------------------------------------------
@@ -466,16 +465,13 @@ const SaveState& getSaveStateDictFromXML(const QDomNode& xmlNode)


node = node.nextSibling(); node = node.nextSibling();
} }

return saveState;
} }


// ------------------------------------------------- // -------------------------------------------------


static inline static inline
const QString& getXMLFromSaveState(const SaveState& saveState)
void fillXmlStringFromSaveState(QString& content, const SaveState& saveState)
{ {
static QString content;
content.clear(); content.clear();


{ {
@@ -632,8 +628,6 @@ const QString& getXMLFromSaveState(const SaveState& saveState)
} }


content += " </Data>\n"; content += " </Data>\n";

return content;
} }


// ------------------------------------------------- // -------------------------------------------------


+ 12
- 6
source/utils/CarlaString.hpp View File

@@ -49,7 +49,8 @@ public:


explicit CarlaString(const int value) explicit CarlaString(const int value)
{ {
char strBuf[0xff] = { '\0' };
char strBuf[0xff+1];
carla_fill<char>(strBuf, 0xff+1, '\0');
std::snprintf(strBuf, 0xff, "%d", value); std::snprintf(strBuf, 0xff, "%d", value);


_init(); _init();
@@ -58,7 +59,8 @@ public:


explicit CarlaString(const unsigned int value, const bool hexadecimal = false) explicit CarlaString(const unsigned int value, const bool hexadecimal = false)
{ {
char strBuf[0xff] = { '\0' };
char strBuf[0xff+1];
carla_fill<char>(strBuf, 0xff+1, '\0');
std::snprintf(strBuf, 0xff, hexadecimal ? "0x%x" : "%u", value); std::snprintf(strBuf, 0xff, hexadecimal ? "0x%x" : "%u", value);


_init(); _init();
@@ -67,7 +69,8 @@ public:


explicit CarlaString(const long int value) explicit CarlaString(const long int value)
{ {
char strBuf[0xff] = { '\0' };
char strBuf[0xff+1];
carla_fill<char>(strBuf, 0xff+1, '\0');
std::snprintf(strBuf, 0xff, "%ld", value); std::snprintf(strBuf, 0xff, "%ld", value);


_init(); _init();
@@ -76,7 +79,8 @@ public:


explicit CarlaString(const unsigned long int value, const bool hexadecimal = false) explicit CarlaString(const unsigned long int value, const bool hexadecimal = false)
{ {
char strBuf[0xff] = { '\0' };
char strBuf[0xff+1];
carla_fill<char>(strBuf, 0xff+1, '\0');
std::snprintf(strBuf, 0xff, hexadecimal ? "0x%lx" : "%lu", value); std::snprintf(strBuf, 0xff, hexadecimal ? "0x%lx" : "%lu", value);


_init(); _init();
@@ -85,7 +89,8 @@ public:


explicit CarlaString(const float value) explicit CarlaString(const float value)
{ {
char strBuf[0xff] = { '\0' };
char strBuf[0xff+1];
carla_fill<char>(strBuf, 0xff+1, '\0');
std::snprintf(strBuf, 0xff, "%f", value); std::snprintf(strBuf, 0xff, "%f", value);


_init(); _init();
@@ -94,7 +99,8 @@ public:


explicit CarlaString(const double value) explicit CarlaString(const double value)
{ {
char strBuf[0xff] = { '\0' };
char strBuf[0xff+1];
carla_fill<char>(strBuf, 0xff+1, '\0');
std::snprintf(strBuf, 0xff, "%g", value); std::snprintf(strBuf, 0xff, "%g", value);


_init(); _init();


Loading…
Cancel
Save