diff --git a/source/backend/CarlaEngine.hpp b/source/backend/CarlaEngine.hpp index 6abb42d5d..e8844eaa6 100644 --- a/source/backend/CarlaEngine.hpp +++ b/source/backend/CarlaEngine.hpp @@ -234,9 +234,9 @@ struct EngineOptions { unsigned int oscUiTimeout; bool jackAutoConnect; - bool jackTimeMaster; #ifdef WANT_RTAUDIO + unsigned int rtaudioNumberPeriods; unsigned int rtaudioBufferSize; unsigned int rtaudioSampleRate; CarlaString rtaudioDevice; @@ -285,9 +285,9 @@ struct EngineOptions { maxParameters(MAX_DEFAULT_PARAMETERS), oscUiTimeout(4000), jackAutoConnect(false), - jackTimeMaster(false), # ifdef WANT_RTAUDIO - rtaudioBufferSize(1024), + rtaudioNumberPeriods(0), + rtaudioBufferSize(512), rtaudioSampleRate(44100), # endif resourceDir() {} @@ -1134,11 +1134,11 @@ protected: void offlineModeChanged(const bool isOffline); /*! - * Run any RT pending events.\n + * Run any pending RT events.\n * Must always be called at the end of audio processing. * \note RT call */ - void runRtPendingEvents(); + void runPendingRtEvents(); /*! * Set a plugin (stereo) peak values. diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index f878df1f5..974146de2 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -27,21 +27,6 @@ #include #include -// ------------------------------------------------------------------------------------------------------------------- -// Register native engine plugin - -#ifndef BUILD_BRIDGE -# include "CarlaNative.h" - -void carla_register_native_plugin_carla() -{ - CARLA_BACKEND_USE_NAMESPACE - CarlaEngine::registerNativePlugin(); -} -#endif - -// ------------------------------------------------------------------------------------------------------------------- - CARLA_BACKEND_START_NAMESPACE // ------------------------------------------------------------------------------------------------------------------- @@ -68,8 +53,8 @@ void registerEnginePlugin(CarlaEngine* const engine, const unsigned int id, Carl // Carla Engine port (Abstract) CarlaEnginePort::CarlaEnginePort(const bool isInput, const ProcessMode processMode) - : kIsInput(isInput), - kProcessMode(processMode) + : fIsInput(isInput), + fProcessMode(processMode) { carla_debug("CarlaEnginePort::CarlaEnginePort(%s, %s)", bool2str(isInput), ProcessMode2Str(processMode)); } @@ -88,7 +73,7 @@ CarlaEngineAudioPort::CarlaEngineAudioPort(const bool isInput, const ProcessMode { carla_debug("CarlaEngineAudioPort::CarlaEngineAudioPort(%s, %s)", bool2str(isInput), ProcessMode2Str(processMode)); - if (kProcessMode == PROCESS_MODE_PATCHBAY) + if (fProcessMode == PROCESS_MODE_PATCHBAY) fBuffer = new float[PATCHBAY_BUFFER_SIZE]; } @@ -96,7 +81,7 @@ CarlaEngineAudioPort::~CarlaEngineAudioPort() { carla_debug("CarlaEngineAudioPort::~CarlaEngineAudioPort()"); - if (kProcessMode == PROCESS_MODE_PATCHBAY) + if (fProcessMode == PROCESS_MODE_PATCHBAY) { CARLA_ASSERT(fBuffer != nullptr); @@ -110,7 +95,7 @@ CarlaEngineAudioPort::~CarlaEngineAudioPort() void CarlaEngineAudioPort::initBuffer(CarlaEngine* const) { - if (kProcessMode == PROCESS_MODE_PATCHBAY && ! kIsInput) + if (fProcessMode == PROCESS_MODE_PATCHBAY && ! fIsInput) carla_zeroFloat(fBuffer, PATCHBAY_BUFFER_SIZE); } @@ -147,7 +132,7 @@ void CarlaEngineCVPort::initBuffer(CarlaEngine* const engine) void CarlaEngineCVPort::writeBuffer(const uint32_t, const uint32_t) { - CARLA_ASSERT(! kIsInput); + CARLA_ASSERT(! fIsInput); } void CarlaEngineCVPort::setBufferSize(const uint32_t bufferSize) @@ -173,7 +158,7 @@ CarlaEngineEventPort::CarlaEngineEventPort(const bool isInput, const ProcessMode { carla_debug("CarlaEngineEventPort::CarlaEngineEventPort(%s, %s)", bool2str(isInput), ProcessMode2Str(processMode)); - if (kProcessMode == PROCESS_MODE_PATCHBAY) + if (fProcessMode == PROCESS_MODE_PATCHBAY) pBuffer = new EngineEvent[INTERNAL_EVENT_COUNT]; } @@ -181,7 +166,7 @@ CarlaEngineEventPort::~CarlaEngineEventPort() { carla_debug("CarlaEngineEventPort::~CarlaEngineEventPort()"); - if (kProcessMode == PROCESS_MODE_PATCHBAY) + if (fProcessMode == PROCESS_MODE_PATCHBAY) { CARLA_ASSERT(pBuffer != nullptr); @@ -200,24 +185,24 @@ void CarlaEngineEventPort::initBuffer(CarlaEngine* const engine) if (engine == nullptr) return; - if (kProcessMode == PROCESS_MODE_CONTINUOUS_RACK || kProcessMode == PROCESS_MODE_BRIDGE) - pBuffer = engine->getInternalEventBuffer(kIsInput); + if (fProcessMode == PROCESS_MODE_CONTINUOUS_RACK || fProcessMode == PROCESS_MODE_BRIDGE) + pBuffer = engine->getInternalEventBuffer(fIsInput); - else if (kProcessMode == PROCESS_MODE_PATCHBAY && ! kIsInput) + else if (fProcessMode == PROCESS_MODE_PATCHBAY && ! fIsInput) carla_zeroStruct(pBuffer, INTERNAL_EVENT_COUNT); } uint32_t CarlaEngineEventPort::getEventCount() const { - CARLA_ASSERT(kIsInput); + CARLA_ASSERT(fIsInput); CARLA_ASSERT(pBuffer != nullptr); - CARLA_ASSERT(kProcessMode != PROCESS_MODE_SINGLE_CLIENT && kProcessMode != PROCESS_MODE_MULTIPLE_CLIENTS); + CARLA_ASSERT(fProcessMode != PROCESS_MODE_SINGLE_CLIENT && fProcessMode != PROCESS_MODE_MULTIPLE_CLIENTS); - if (! kIsInput) + if (! fIsInput) return 0; if (pBuffer == nullptr) return 0; - if (kProcessMode == PROCESS_MODE_SINGLE_CLIENT || kProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS) + if (fProcessMode == PROCESS_MODE_SINGLE_CLIENT || fProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS) return 0; for (uint32_t i=0; i < INTERNAL_EVENT_COUNT; ++i) @@ -232,16 +217,16 @@ uint32_t CarlaEngineEventPort::getEventCount() const const EngineEvent& CarlaEngineEventPort::getEvent(const uint32_t index) { - CARLA_ASSERT(kIsInput); + CARLA_ASSERT(fIsInput); CARLA_ASSERT(pBuffer != nullptr); - CARLA_ASSERT(kProcessMode != PROCESS_MODE_SINGLE_CLIENT && kProcessMode != PROCESS_MODE_MULTIPLE_CLIENTS); + CARLA_ASSERT(fProcessMode != PROCESS_MODE_SINGLE_CLIENT && fProcessMode != PROCESS_MODE_MULTIPLE_CLIENTS); CARLA_ASSERT(index < INTERNAL_EVENT_COUNT); - if (! kIsInput) + if (! fIsInput) return kFallbackEngineEvent; if (pBuffer == nullptr) return kFallbackEngineEvent; - if (kProcessMode == PROCESS_MODE_SINGLE_CLIENT || kProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS) + if (fProcessMode == PROCESS_MODE_SINGLE_CLIENT || fProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS) return kFallbackEngineEvent; if (index >= INTERNAL_EVENT_COUNT) return kFallbackEngineEvent; @@ -251,18 +236,18 @@ const EngineEvent& CarlaEngineEventPort::getEvent(const uint32_t index) void CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t channel, const EngineControlEventType type, const uint16_t param, const float value) { - CARLA_ASSERT(! kIsInput); + CARLA_ASSERT(! fIsInput); CARLA_ASSERT(pBuffer != nullptr); - CARLA_ASSERT(kProcessMode != PROCESS_MODE_SINGLE_CLIENT && kProcessMode != PROCESS_MODE_MULTIPLE_CLIENTS); + CARLA_ASSERT(fProcessMode != PROCESS_MODE_SINGLE_CLIENT && fProcessMode != PROCESS_MODE_MULTIPLE_CLIENTS); CARLA_ASSERT(type != kEngineControlEventTypeNull); CARLA_ASSERT(channel < MAX_MIDI_CHANNELS); CARLA_SAFE_ASSERT(value >= 0.0f && value <= 1.0f); - if (kIsInput) + if (fIsInput) return; if (pBuffer == nullptr) return; - if (kProcessMode == PROCESS_MODE_SINGLE_CLIENT || kProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS) + if (fProcessMode == PROCESS_MODE_SINGLE_CLIENT || fProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS) return; if (type == kEngineControlEventTypeNull) return; @@ -293,18 +278,18 @@ void CarlaEngineEventPort::writeControlEvent(const uint32_t time, const uint8_t void CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t channel, const uint8_t port, const uint8_t* const data, const uint8_t size) { - CARLA_ASSERT(! kIsInput); + CARLA_ASSERT(! fIsInput); CARLA_ASSERT(pBuffer != nullptr); - CARLA_ASSERT(kProcessMode != PROCESS_MODE_SINGLE_CLIENT && kProcessMode != PROCESS_MODE_MULTIPLE_CLIENTS); + CARLA_ASSERT(fProcessMode != PROCESS_MODE_SINGLE_CLIENT && fProcessMode != PROCESS_MODE_MULTIPLE_CLIENTS); CARLA_ASSERT(channel < MAX_MIDI_CHANNELS); CARLA_ASSERT(data != nullptr); CARLA_ASSERT(size != 0 && size <= 4); - if (kIsInput) + if (fIsInput) return; if (pBuffer == nullptr) return; - if (kProcessMode == PROCESS_MODE_SINGLE_CLIENT || kProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS) + if (fProcessMode == PROCESS_MODE_SINGLE_CLIENT || fProcessMode == PROCESS_MODE_MULTIPLE_CLIENTS) return; if (channel >= MAX_MIDI_CHANNELS) return; @@ -339,7 +324,7 @@ void CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t cha // Carla Engine client (Abstract) CarlaEngineClient::CarlaEngineClient(const CarlaEngine& engine) - : kEngine(engine), + : fEngine(engine), fActive(false), fLatency(0) { @@ -401,11 +386,11 @@ CarlaEnginePort* CarlaEngineClient::addPort(const EnginePortType portType, const case kEnginePortTypeNull: break; case kEnginePortTypeAudio: - return new CarlaEngineAudioPort(isInput, kEngine.getProccessMode()); + return new CarlaEngineAudioPort(isInput, fEngine.getProccessMode()); case kEnginePortTypeCV: - return new CarlaEngineCVPort(isInput, kEngine.getProccessMode(), kEngine.getBufferSize()); + return new CarlaEngineCVPort(isInput, fEngine.getProccessMode(), fEngine.getBufferSize()); case kEnginePortTypeEvent: - return new CarlaEngineEventPort(isInput, kEngine.getProccessMode()); + return new CarlaEngineEventPort(isInput, fEngine.getProccessMode()); } carla_stderr("CarlaEngineClient::addPort(%i, \"%s\", %s) - invalid type", portType, name, bool2str(isInput)); @@ -418,7 +403,7 @@ CarlaEnginePort* CarlaEngineClient::addPort(const EnginePortType portType, const CarlaEngine::CarlaEngine() : fBufferSize(0), fSampleRate(0.0), - kData(new CarlaEngineProtectedData(this)) + pData(new CarlaEngineProtectedData(this)) { carla_debug("CarlaEngine::CarlaEngine()"); } @@ -427,7 +412,7 @@ CarlaEngine::~CarlaEngine() { carla_debug("CarlaEngine::~CarlaEngine()"); - delete kData; + delete pData; } // ----------------------------------------------------------------------- @@ -563,22 +548,22 @@ CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName) // ----------------------------------------------------------------------- // Maximum values -unsigned int CarlaEngine::maxClientNameSize() const +unsigned int CarlaEngine::getMaxClientNameSize() const noexcept { return STR_MAX/2; } -unsigned int CarlaEngine::maxPortNameSize() const +unsigned int CarlaEngine::getMaxPortNameSize() const noexcept { return STR_MAX; } -unsigned int CarlaEngine::currentPluginCount() const +unsigned int CarlaEngine::getCurrentPluginCount() const noexcept { return pData->curPluginCount; } -unsigned int CarlaEngine::maxPluginNumber() const +unsigned int CarlaEngine::getMaxPluginNumber() const noexcept { return pData->maxPluginNumber; } @@ -641,7 +626,7 @@ bool CarlaEngine::init(const char* const clientName) pData->oscData = pData->osc.getControlData(); #endif - if (type() != kEngineTypePlugin) + if (getType() != kEngineTypePlugin) carla_setprocname(clientName); pData->nextAction.ready(); @@ -662,7 +647,7 @@ bool CarlaEngine::close() pData->nextAction.ready(); #ifndef BUILD_BRIDGE - osc_send_control_exit(); + oscSend_control_exit(); #endif pData->osc.close(); pData->oscData = nullptr; @@ -705,7 +690,7 @@ void CarlaEngine::idle() { CarlaPlugin* const plugin(pData->plugins[i].plugin); - if (plugin != nullptr && plugin->enabled()) + if (plugin != nullptr && plugin->isEnabled()) plugin->idleGui(); } } @@ -817,7 +802,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons break; case PLUGIN_VST3: - plugin = CarlaPlugin::newVST3(init); + //plugin = CarlaPlugin::newVST3(init); break; case PLUGIN_GIG: @@ -847,7 +832,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons ++pData->curPluginCount; - callback(CALLBACK_PLUGIN_ADDED, id, 0, 0, 0.0f, plugin->name()); + callback(CALLBACK_PLUGIN_ADDED, id, 0, 0, 0.0f, plugin->getName()); return true; } @@ -873,16 +858,16 @@ bool CarlaEngine::removePlugin(const unsigned int id) return false; } - CARLA_ASSERT(plugin->id() == id); + CARLA_ASSERT(plugin->getId() == id); pData->thread.stopNow(); const bool lockWait(isRunning() && fOptions.processMode != PROCESS_MODE_MULTIPLE_CLIENTS); - const CarlaEngineProtectedData::ScopedPluginAction spa(kData, kEnginePostActionRemovePlugin, id, 0, lockWait); + const CarlaEngineProtectedData::ScopedPluginAction spa(pData, kEnginePostActionRemovePlugin, id, 0, lockWait); #ifndef BUILD_BRIDGE if (isOscControlRegistered()) - osc_send_control_remove_plugin(id); + oscSend_control_remove_plugin(id); #endif delete plugin; @@ -906,7 +891,7 @@ void CarlaEngine::removeAllPlugins() pData->thread.stopNow(); const bool lockWait(isRunning()); - const CarlaEngineProtectedData::ScopedPluginAction spa(kData, kEnginePostActionZeroCount, 0, 0, lockWait); + const CarlaEngineProtectedData::ScopedPluginAction spa(pData, kEnginePostActionZeroCount, 0, 0, lockWait); for (unsigned int i=0; i < pData->maxPluginNumber; ++i) { @@ -953,7 +938,7 @@ const char* CarlaEngine::renamePlugin(const unsigned int id, const char* const n return nullptr; } - CARLA_ASSERT(plugin->id() == id); + CARLA_ASSERT(plugin->getId() == id); if (const char* const name = getUniquePluginName(newName)) { @@ -986,7 +971,7 @@ bool CarlaEngine::clonePlugin(const unsigned int id) return false; } - CARLA_ASSERT(plugin->id() == id); + CARLA_ASSERT(plugin->getId() == id); char label[STR_MAX+1] = { '\0' }; plugin->getLabel(label); @@ -994,13 +979,13 @@ bool CarlaEngine::clonePlugin(const unsigned int id) BinaryType binaryType = BINARY_NATIVE; #ifndef BUILD_BRIDGE - if (plugin->hints() & PLUGIN_IS_BRIDGE) + if (plugin->getHints() & PLUGIN_IS_BRIDGE) binaryType = CarlaPluginGetBridgeBinaryType(plugin); #endif const unsigned int pluginCountBefore(pData->curPluginCount); - if (! addPlugin(binaryType, plugin->type(), plugin->filename(), plugin->name(), label, plugin->getExtraStuff())) + if (! addPlugin(binaryType, plugin->getType(), plugin->getFilename(), plugin->getName(), label, plugin->getExtraStuff())) return false; CARLA_ASSERT(pluginCountBefore+1 == pData->curPluginCount); @@ -1044,11 +1029,11 @@ bool CarlaEngine::switchPlugins(const unsigned int idA, const unsigned int idB) pData->thread.stopNow(); const bool lockWait(isRunning() && fOptions.processMode != PROCESS_MODE_MULTIPLE_CLIENTS); - const CarlaEngineProtectedData::ScopedPluginAction spa(kData, kEnginePostActionSwitchPlugins, idA, idB, lockWait); + const CarlaEngineProtectedData::ScopedPluginAction spa(pData, kEnginePostActionSwitchPlugins, idA, idB, lockWait); #ifndef BUILD_BRIDGE // TODO //if (isOscControlRegistered()) - // osc_send_control_switch_plugins(idA, idB); + // oscSend_control_switch_plugins(idA, idB); #endif if (isRunning() && ! pData->aboutToClose) @@ -1071,7 +1056,7 @@ CarlaPlugin* CarlaEngine::getPlugin(const unsigned int id) const return nullptr; } -CarlaPlugin* CarlaEngine::getPluginUnchecked(const unsigned int id) const +CarlaPlugin* CarlaEngine::getPluginUnchecked(const unsigned int id) const noexcept { return pData->plugins[id].plugin; } @@ -1107,7 +1092,7 @@ const char* CarlaEngine::getUniquePluginName(const char* const name) break; // Check if unique name doesn't exist - if (const char* const pluginName = pData->plugins[i].plugin->name()) + if (const char* const pluginName = pData->plugins[i].plugin->getName()) { if (sname != pluginName) continue; @@ -1337,7 +1322,9 @@ bool CarlaEngine::loadProject(const char* const filename) { if (isPreset || node.toElement().tagName() == "Plugin") { - const SaveState& saveState(getSaveStateDictFromXML(isPreset ? xmlNode : node)); + SaveState saveState; + fillSaveStateFromXmlNode(saveState, isPreset ? xmlNode : node); + CARLA_ASSERT(saveState.type != nullptr); if (saveState.type == nullptr) @@ -1396,7 +1383,7 @@ bool CarlaEngine::saveProject(const char* const filename) { CarlaPlugin* const plugin = pData->plugins[i].plugin; - if (plugin != nullptr && plugin->enabled()) + if (plugin != nullptr && plugin->isEnabled()) { if (! firstPlugin) out << "\n"; @@ -1406,8 +1393,11 @@ bool CarlaEngine::saveProject(const char* const filename) if (*strBuf != 0) out << QString(" \n").arg(xmlSafeString(strBuf, true)); + QString content; + fillXmlStringFromSaveState(content, plugin->getSaveState()); + out << " \n"; - out << getXMLFromSaveState(plugin->getSaveState()); + out << content; out << " \n"; firstPlugin = false; @@ -1574,13 +1564,6 @@ void CarlaEngine::setOption(const OptionsType option, const int value, const cha fOptions.forceStereo = (value != 0); break; -#ifdef WANT_DSSI - case OPTION_USE_DSSI_VST_CHUNKS: - CARLA_ENGINE_SET_OPTION_RUNNING_CHECK - fOptions.useDssiVstChunks = (value != 0); - break; -#endif - case OPTION_PREFER_PLUGIN_BRIDGES: CARLA_ENGINE_SET_OPTION_RUNNING_CHECK fOptions.preferPluginBridges = (value != 0); @@ -1591,7 +1574,14 @@ void CarlaEngine::setOption(const OptionsType option, const int value, const cha fOptions.preferUiBridges = (value != 0); break; - case OPTION_OSC_UI_TIMEOUT: +#ifdef WANT_DSSI + case OPTION_USE_DSSI_VST_CHUNKS: + CARLA_ENGINE_SET_OPTION_RUNNING_CHECK + fOptions.useDssiVstChunks = (value != 0); + break; +#endif + + case OPTION_UI_BRIDGES_TIMEOUT: CARLA_ENGINE_SET_OPTION_RUNNING_CHECK fOptions.oscUiTimeout = static_cast(value); break; @@ -1601,12 +1591,12 @@ void CarlaEngine::setOption(const OptionsType option, const int value, const cha fOptions.jackAutoConnect = (value != 0); break; - case OPTION_JACK_TIMEMASTER: +#ifdef WANT_RTAUDIO + case OPTION_RTAUDIO_NUMBER_PERIODS: CARLA_ENGINE_SET_OPTION_RUNNING_CHECK - fOptions.jackTimeMaster = (value != 0); + fOptions.rtaudioNumberPeriods = static_cast(value); break; -#ifdef WANT_RTAUDIO case OPTION_RTAUDIO_BUFFER_SIZE: CARLA_ENGINE_SET_OPTION_RUNNING_CHECK fOptions.rtaudioBufferSize = static_cast(value); @@ -1731,7 +1721,7 @@ void CarlaEngine::bufferSizeChanged(const uint32_t newBufferSize) { CarlaPlugin* const plugin(pData->plugins[i].plugin); - if (plugin != nullptr && plugin->enabled()) + if (plugin != nullptr && plugin->isEnabled()) plugin->bufferSizeChanged(newBufferSize); } @@ -1746,7 +1736,7 @@ void CarlaEngine::sampleRateChanged(const double newSampleRate) { CarlaPlugin* const plugin(pData->plugins[i].plugin); - if (plugin != nullptr && plugin->enabled()) + if (plugin != nullptr && plugin->isEnabled()) plugin->sampleRateChanged(newSampleRate); } @@ -1761,15 +1751,13 @@ void CarlaEngine::offlineModeChanged(const bool isOffline) { CarlaPlugin* const plugin(pData->plugins[i].plugin); - if (plugin != nullptr && plugin->enabled()) + if (plugin != nullptr && plugin->isEnabled()) plugin->offlineModeChanged(isOffline); } } -void CarlaEngine::proccessPendingEvents() +void CarlaEngine::runPendingRtEvents() { - //carla_stderr("proccessPendingEvents(%i)", pData->nextAction.opcode); - pData->doNextPluginAction(true); if (pData->time.playing) @@ -1787,7 +1775,7 @@ void CarlaEngine::proccessPendingEvents() } } -void CarlaEngine::setPeaks(const unsigned int pluginId, float const inPeaks[2], float const outPeaks[2]) noexcept +void CarlaEngine::setPluginPeaks(const unsigned int pluginId, float const inPeaks[2], float const outPeaks[2]) noexcept { pData->plugins[pluginId].insPeak[0] = inPeaks[0]; pData->plugins[pluginId].insPeak[1] = inPeaks[1]; @@ -1824,7 +1812,7 @@ void CarlaEngine::processRack(float* inBuf[2], float* outBuf[2], const uint32_t { CarlaPlugin* const plugin = pData->plugins[i].plugin; - if (plugin == nullptr || ! plugin->enabled() || ! plugin->tryLock()) + if (plugin == nullptr || ! plugin->isEnabled() || ! plugin->tryLock()) continue; if (processed) @@ -1908,12 +1896,12 @@ void CarlaEngine::processPatchbay(float** inBuf, float** outBuf, const uint32_t // Carla Engine OSC stuff #ifndef BUILD_BRIDGE -void CarlaEngine::osc_send_control_add_plugin_start(const int32_t pluginId, const char* const pluginName) +void CarlaEngine::oscSend_control_add_plugin_start(const int32_t pluginId, const char* const pluginName) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); CARLA_ASSERT(pluginName != nullptr); - carla_debug("CarlaEngine::osc_send_control_add_plugin_start(%i, \"%s\")", pluginId, pluginName); + carla_debug("CarlaEngine::oscSend_control_add_plugin_start(%i, \"%s\")", pluginId, pluginName); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -1924,11 +1912,11 @@ void CarlaEngine::osc_send_control_add_plugin_start(const int32_t pluginId, cons } } -void CarlaEngine::osc_send_control_add_plugin_end(const int32_t pluginId) +void CarlaEngine::oscSend_control_add_plugin_end(const int32_t pluginId) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); - carla_debug("CarlaEngine::osc_send_control_add_plugin_end(%i)", pluginId); + carla_debug("CarlaEngine::oscSend_control_add_plugin_end(%i)", pluginId); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -1939,11 +1927,11 @@ void CarlaEngine::osc_send_control_add_plugin_end(const int32_t pluginId) } } -void CarlaEngine::osc_send_control_remove_plugin(const int32_t pluginId) +void CarlaEngine::oscSend_control_remove_plugin(const int32_t pluginId) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->curPluginCount)); - carla_debug("CarlaEngine::osc_send_control_remove_plugin(%i)", pluginId); + carla_debug("CarlaEngine::oscSend_control_remove_plugin(%i)", pluginId); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -1954,7 +1942,7 @@ void CarlaEngine::osc_send_control_remove_plugin(const int32_t pluginId) } } -void CarlaEngine::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 CarlaEngine::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) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); @@ -1963,7 +1951,7 @@ void CarlaEngine::osc_send_control_set_plugin_data(const int32_t pluginId, const CARLA_ASSERT(label != nullptr); CARLA_ASSERT(maker != nullptr); CARLA_ASSERT(copyright != nullptr); - carla_debug("CarlaEngine::osc_send_control_set_plugin_data(%i, %i, %i, %i, \"%s\", \"%s\", \"%s\", \"%s\", " P_INT64 ")", pluginId, type, category, hints, realName, label, maker, copyright, uniqueId); + carla_debug("CarlaEngine::oscSend_control_set_plugin_data(%i, %i, %i, %i, \"%s\", \"%s\", \"%s\", \"%s\", " P_INT64 ")", pluginId, type, category, hints, realName, label, maker, copyright, uniqueId); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -1974,11 +1962,11 @@ void CarlaEngine::osc_send_control_set_plugin_data(const int32_t pluginId, const } } -void CarlaEngine::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 CarlaEngine::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) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); - carla_debug("CarlaEngine::osc_send_control_set_plugin_ports(%i, %i, %i, %i, %i, %i, %i, %i)", pluginId, audioIns, audioOuts, midiIns, midiOuts, cIns, cOuts, cTotals); + carla_debug("CarlaEngine::oscSend_control_set_plugin_ports(%i, %i, %i, %i, %i, %i, %i, %i)", pluginId, audioIns, audioOuts, midiIns, midiOuts, cIns, cOuts, cTotals); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -1989,7 +1977,7 @@ void CarlaEngine::osc_send_control_set_plugin_ports(const int32_t pluginId, cons } } -void CarlaEngine::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 CarlaEngine::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) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); @@ -1997,7 +1985,7 @@ void CarlaEngine::osc_send_control_set_parameter_data(const int32_t pluginId, co CARLA_ASSERT(type != PARAMETER_UNKNOWN); CARLA_ASSERT(name != nullptr); CARLA_ASSERT(label != nullptr); - carla_debug("CarlaEngine::osc_send_control_set_parameter_data(%i, %i, %i, %i, \"%s\", \"%s\", %f)", pluginId, index, type, hints, name, label, current); + carla_debug("CarlaEngine::oscSend_control_set_parameter_data(%i, %i, %i, %i, \"%s\", \"%s\", %f)", pluginId, index, type, hints, name, label, current); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2008,13 +1996,13 @@ void CarlaEngine::osc_send_control_set_parameter_data(const int32_t pluginId, co } } -void CarlaEngine::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 CarlaEngine::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) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); CARLA_ASSERT(index >= 0); CARLA_ASSERT(min < max); - carla_debug("CarlaEngine::osc_send_control_set_parameter_ranges(%i, %i, %f, %f, %f, %f, %f, %f)", pluginId, index, min, max, def, step, stepSmall, stepLarge); + carla_debug("CarlaEngine::oscSend_control_set_parameter_ranges(%i, %i, %f, %f, %f, %f, %f, %f)", pluginId, index, min, max, def, step, stepSmall, stepLarge); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2025,12 +2013,12 @@ void CarlaEngine::osc_send_control_set_parameter_ranges(const int32_t pluginId, } } -void CarlaEngine::osc_send_control_set_parameter_midi_cc(const int32_t pluginId, const int32_t index, const int32_t cc) +void CarlaEngine::oscSend_control_set_parameter_midi_cc(const int32_t pluginId, const int32_t index, const int32_t cc) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); CARLA_ASSERT(index >= 0); - carla_debug("CarlaEngine::osc_send_control_set_parameter_midi_cc(%i, %i, %i)", pluginId, index, cc); + carla_debug("CarlaEngine::oscSend_control_set_parameter_midi_cc(%i, %i, %i)", pluginId, index, cc); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2041,13 +2029,13 @@ void CarlaEngine::osc_send_control_set_parameter_midi_cc(const int32_t pluginId, } } -void CarlaEngine::osc_send_control_set_parameter_midi_channel(const int32_t pluginId, const int32_t index, const int32_t channel) +void CarlaEngine::oscSend_control_set_parameter_midi_channel(const int32_t pluginId, const int32_t index, const int32_t channel) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); CARLA_ASSERT(index >= 0); CARLA_ASSERT(channel >= 0 && channel < 16); - carla_debug("CarlaEngine::osc_send_control_set_parameter_midi_channel(%i, %i, %i)", pluginId, index, channel); + carla_debug("CarlaEngine::oscSend_control_set_parameter_midi_channel(%i, %i, %i)", pluginId, index, channel); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2058,15 +2046,15 @@ void CarlaEngine::osc_send_control_set_parameter_midi_channel(const int32_t plug } } -void CarlaEngine::osc_send_control_set_parameter_value(const int32_t pluginId, const int32_t index, const float value) +void CarlaEngine::oscSend_control_set_parameter_value(const int32_t pluginId, const int32_t index, const float value) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); #if DEBUG if (index < 0) - carla_debug("CarlaEngine::osc_send_control_set_parameter_value(%i, %s, %f)", pluginId, InternalParametersIndex2Str((InternalParametersIndex)index), value); + carla_debug("CarlaEngine::oscSend_control_set_parameter_value(%i, %s, %f)", pluginId, InternalParametersIndex2Str((InternalParametersIndex)index), value); else - carla_debug("CarlaEngine::osc_send_control_set_parameter_value(%i, %i, %f)", pluginId, index, value); + carla_debug("CarlaEngine::oscSend_control_set_parameter_value(%i, %i, %f)", pluginId, index, value); #endif if (pData->oscData != nullptr && pData->oscData->target != nullptr) @@ -2078,12 +2066,12 @@ void CarlaEngine::osc_send_control_set_parameter_value(const int32_t pluginId, c } } -void CarlaEngine::osc_send_control_set_default_value(const int32_t pluginId, const int32_t index, const float value) +void CarlaEngine::oscSend_control_set_default_value(const int32_t pluginId, const int32_t index, const float value) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); CARLA_ASSERT(index >= 0); - carla_debug("CarlaEngine::osc_send_control_set_default_value(%i, %i, %f)", pluginId, index, value); + carla_debug("CarlaEngine::oscSend_control_set_default_value(%i, %i, %f)", pluginId, index, value); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2094,11 +2082,11 @@ void CarlaEngine::osc_send_control_set_default_value(const int32_t pluginId, con } } -void CarlaEngine::osc_send_control_set_program(const int32_t pluginId, const int32_t index) +void CarlaEngine::oscSend_control_set_program(const int32_t pluginId, const int32_t index) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); - carla_debug("CarlaEngine::osc_send_control_set_program(%i, %i)", pluginId, index); + carla_debug("CarlaEngine::oscSend_control_set_program(%i, %i)", pluginId, index); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2109,12 +2097,12 @@ void CarlaEngine::osc_send_control_set_program(const int32_t pluginId, const int } } -void CarlaEngine::osc_send_control_set_program_count(const int32_t pluginId, const int32_t count) +void CarlaEngine::oscSend_control_set_program_count(const int32_t pluginId, const int32_t count) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); CARLA_ASSERT(count >= 0); - carla_debug("CarlaEngine::osc_send_control_set_program_count(%i, %i)", pluginId, count); + carla_debug("CarlaEngine::oscSend_control_set_program_count(%i, %i)", pluginId, count); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2125,13 +2113,13 @@ void CarlaEngine::osc_send_control_set_program_count(const int32_t pluginId, con } } -void CarlaEngine::osc_send_control_set_program_name(const int32_t pluginId, const int32_t index, const char* const name) +void CarlaEngine::oscSend_control_set_program_name(const int32_t pluginId, const int32_t index, const char* const name) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); CARLA_ASSERT(index >= 0); CARLA_ASSERT(name != nullptr); - carla_debug("CarlaEngine::osc_send_control_set_program_name(%i, %i, \"%s\")", pluginId, index, name); + carla_debug("CarlaEngine::oscSend_control_set_program_name(%i, %i, \"%s\")", pluginId, index, name); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2142,11 +2130,11 @@ void CarlaEngine::osc_send_control_set_program_name(const int32_t pluginId, cons } } -void CarlaEngine::osc_send_control_set_midi_program(const int32_t pluginId, const int32_t index) +void CarlaEngine::oscSend_control_set_midi_program(const int32_t pluginId, const int32_t index) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); - carla_debug("CarlaEngine::osc_send_control_set_midi_program(%i, %i)", pluginId, index); + carla_debug("CarlaEngine::oscSend_control_set_midi_program(%i, %i)", pluginId, index); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2157,12 +2145,12 @@ void CarlaEngine::osc_send_control_set_midi_program(const int32_t pluginId, cons } } -void CarlaEngine::osc_send_control_set_midi_program_count(const int32_t pluginId, const int32_t count) +void CarlaEngine::oscSend_control_set_midi_program_count(const int32_t pluginId, const int32_t count) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); CARLA_ASSERT(count >= 0); - carla_debug("CarlaEngine::osc_send_control_set_midi_program_count(%i, %i)", pluginId, count); + carla_debug("CarlaEngine::oscSend_control_set_midi_program_count(%i, %i)", pluginId, count); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2173,7 +2161,7 @@ void CarlaEngine::osc_send_control_set_midi_program_count(const int32_t pluginId } } -void CarlaEngine::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 CarlaEngine::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) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->maxPluginNumber)); @@ -2181,7 +2169,7 @@ void CarlaEngine::osc_send_control_set_midi_program_data(const int32_t pluginId, CARLA_ASSERT(bank >= 0); CARLA_ASSERT(program >= 0); CARLA_ASSERT(name != nullptr); - carla_debug("CarlaEngine::osc_send_control_set_midi_program_data(%i, %i, %i, %i, \"%s\")", pluginId, index, bank, program, name); + carla_debug("CarlaEngine::oscSend_control_set_midi_program_data(%i, %i, %i, %i, \"%s\")", pluginId, index, bank, program, name); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2192,14 +2180,14 @@ void CarlaEngine::osc_send_control_set_midi_program_data(const int32_t pluginId, } } -void CarlaEngine::osc_send_control_note_on(const int32_t pluginId, const int32_t channel, const int32_t note, const int32_t velo) +void CarlaEngine::oscSend_control_note_on(const int32_t pluginId, const int32_t channel, const int32_t note, const int32_t velo) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->curPluginCount)); CARLA_ASSERT(channel >= 0 && channel < MAX_MIDI_CHANNELS); CARLA_ASSERT(note >= 0 && note < MAX_MIDI_NOTE); CARLA_ASSERT(velo > 0 && velo < MAX_MIDI_VALUE); - carla_debug("CarlaEngine::osc_send_control_note_on(%i, %i, %i, %i)", pluginId, channel, note, velo); + carla_debug("CarlaEngine::oscSend_control_note_on(%i, %i, %i, %i)", pluginId, channel, note, velo); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2210,13 +2198,13 @@ void CarlaEngine::osc_send_control_note_on(const int32_t pluginId, const int32_t } } -void CarlaEngine::osc_send_control_note_off(const int32_t pluginId, const int32_t channel, const int32_t note) +void CarlaEngine::oscSend_control_note_off(const int32_t pluginId, const int32_t channel, const int32_t note) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->curPluginCount)); CARLA_ASSERT(channel >= 0 && channel < MAX_MIDI_CHANNELS); CARLA_ASSERT(note >= 0 && note < MAX_MIDI_NOTE); - carla_debug("CarlaEngine::osc_send_control_note_off(%i, %i, %i)", pluginId, channel, note); + carla_debug("CarlaEngine::oscSend_control_note_off(%i, %i, %i)", pluginId, channel, note); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2227,26 +2215,26 @@ void CarlaEngine::osc_send_control_note_off(const int32_t pluginId, const int32_ } } -void CarlaEngine::osc_send_control_set_peaks(const int32_t pluginId) +void CarlaEngine::oscSend_control_set_peaks(const int32_t pluginId) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(pluginId >= 0 && pluginId < static_cast(pData->curPluginCount)); - const EnginePluginData& pData = pData->plugins[pluginId]; + const EnginePluginData& epData(pData->plugins[pluginId]); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { char targetPath[std::strlen(pData->oscData->path)+22]; std::strcpy(targetPath, pData->oscData->path); std::strcat(targetPath, "/set_peaks"); - lo_send(pData->oscData->target, targetPath, "iffff", pluginId, pData.insPeak[0], pData.insPeak[1], pData.outsPeak[0], pData.outsPeak[1]); + lo_send(pData->oscData->target, targetPath, "iffff", pluginId, epData.insPeak[0], epData.insPeak[1], epData.outsPeak[0], epData.outsPeak[1]); } } -void CarlaEngine::osc_send_control_exit() +void CarlaEngine::oscSend_control_exit() { CARLA_ASSERT(pData->oscData != nullptr); - carla_debug("CarlaEngine::osc_send_control_exit()"); + carla_debug("CarlaEngine::oscSend_control_exit()"); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2257,11 +2245,11 @@ void CarlaEngine::osc_send_control_exit() } } #else -void CarlaEngine::osc_send_bridge_audio_count(const int32_t ins, const int32_t outs, const int32_t total) +void CarlaEngine::oscSend_bridge_audio_count(const int32_t ins, const int32_t outs, const int32_t total) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(total >= 0 && total >= ins + outs); - carla_debug("CarlaEngine::osc_send_bridge_audio_count(%i, %i, %i)", ins, outs, total); + carla_debug("CarlaEngine::oscSend_bridge_audio_count(%i, %i, %i)", ins, outs, total); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2272,11 +2260,11 @@ void CarlaEngine::osc_send_bridge_audio_count(const int32_t ins, const int32_t o } } -void CarlaEngine::osc_send_bridge_midi_count(const int32_t ins, const int32_t outs, const int32_t total) +void CarlaEngine::oscSend_bridge_midi_count(const int32_t ins, const int32_t outs, const int32_t total) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(total >= 0 && total >= ins + outs); - carla_debug("CarlaEngine::osc_send_bridge_midi_count(%i, %i, %i)", ins, outs, total); + carla_debug("CarlaEngine::oscSend_bridge_midi_count(%i, %i, %i)", ins, outs, total); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2287,11 +2275,11 @@ void CarlaEngine::osc_send_bridge_midi_count(const int32_t ins, const int32_t ou } } -void CarlaEngine::osc_send_bridge_parameter_count(const int32_t ins, const int32_t outs, const int32_t total) +void CarlaEngine::oscSend_bridge_parameter_count(const int32_t ins, const int32_t outs, const int32_t total) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(total >= 0 && total >= ins + outs); - carla_debug("CarlaEngine::osc_send_bridge_parameter_count(%i, %i, %i)", ins, outs, total); + carla_debug("CarlaEngine::oscSend_bridge_parameter_count(%i, %i, %i)", ins, outs, total); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2302,11 +2290,11 @@ void CarlaEngine::osc_send_bridge_parameter_count(const int32_t ins, const int32 } } -void CarlaEngine::osc_send_bridge_program_count(const int32_t count) +void CarlaEngine::oscSend_bridge_program_count(const int32_t count) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(count >= 0); - carla_debug("CarlaEngine::osc_send_bridge_program_count(%i)", count); + carla_debug("CarlaEngine::oscSend_bridge_program_count(%i)", count); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2317,11 +2305,11 @@ void CarlaEngine::osc_send_bridge_program_count(const int32_t count) } } -void CarlaEngine::osc_send_bridge_midi_program_count(const int32_t count) +void CarlaEngine::oscSend_bridge_midi_program_count(const int32_t count) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(count >= 0); - carla_debug("CarlaEngine::osc_send_bridge_midi_program_count(%i)", count); + carla_debug("CarlaEngine::oscSend_bridge_midi_program_count(%i)", count); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2332,14 +2320,14 @@ void CarlaEngine::osc_send_bridge_midi_program_count(const int32_t count) } } -void CarlaEngine::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 CarlaEngine::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) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(name != nullptr); CARLA_ASSERT(label != nullptr); CARLA_ASSERT(maker != nullptr); CARLA_ASSERT(copyright != nullptr); - carla_debug("CarlaEngine::osc_send_bridge_plugin_info(%i, %i, \"%s\", \"%s\", \"%s\", \"%s\", " P_INT64 ")", category, hints, name, label, maker, copyright, uniqueId); + carla_debug("CarlaEngine::oscSend_bridge_plugin_info(%i, %i, \"%s\", \"%s\", \"%s\", \"%s\", " P_INT64 ")", category, hints, name, label, maker, copyright, uniqueId); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2350,12 +2338,12 @@ void CarlaEngine::osc_send_bridge_plugin_info(const int32_t category, const int3 } } -void CarlaEngine::osc_send_bridge_parameter_info(const int32_t index, const char* const name, const char* const unit) +void CarlaEngine::oscSend_bridge_parameter_info(const int32_t index, const char* const name, const char* const unit) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(name != nullptr); CARLA_ASSERT(unit != nullptr); - carla_debug("CarlaEngine::osc_send_bridge_parameter_info(%i, \"%s\", \"%s\")", index, name, unit); + carla_debug("CarlaEngine::oscSend_bridge_parameter_info(%i, \"%s\", \"%s\")", index, name, unit); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2366,10 +2354,10 @@ void CarlaEngine::osc_send_bridge_parameter_info(const int32_t index, const char } } -void CarlaEngine::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 CarlaEngine::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) { CARLA_ASSERT(pData->oscData != nullptr); - carla_debug("CarlaEngine::osc_send_bridge_parameter_data(%i, %i, %i, %i, %i, %i)", index, type, rindex, hints, midiChannel, midiCC); + carla_debug("CarlaEngine::oscSend_bridge_parameter_data(%i, %i, %i, %i, %i, %i)", index, type, rindex, hints, midiChannel, midiCC); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2380,10 +2368,10 @@ void CarlaEngine::osc_send_bridge_parameter_data(const int32_t index, const int3 } } -void CarlaEngine::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 CarlaEngine::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) { CARLA_ASSERT(pData->oscData != nullptr); - carla_debug("CarlaEngine::osc_send_bridge_parameter_ranges(%i, %f, %f, %f, %f, %f, %f)", index, def, min, max, step, stepSmall, stepLarge); + carla_debug("CarlaEngine::oscSend_bridge_parameter_ranges(%i, %f, %f, %f, %f, %f, %f)", index, def, min, max, step, stepSmall, stepLarge); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2394,10 +2382,10 @@ void CarlaEngine::osc_send_bridge_parameter_ranges(const int32_t index, const fl } } -void CarlaEngine::osc_send_bridge_program_info(const int32_t index, const char* const name) +void CarlaEngine::oscSend_bridge_program_info(const int32_t index, const char* const name) { CARLA_ASSERT(pData->oscData != nullptr); - carla_debug("CarlaEngine::osc_send_bridge_program_info(%i, \"%s\")", index, name); + carla_debug("CarlaEngine::oscSend_bridge_program_info(%i, \"%s\")", index, name); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2408,10 +2396,10 @@ void CarlaEngine::osc_send_bridge_program_info(const int32_t index, const char* } } -void CarlaEngine::osc_send_bridge_midi_program_info(const int32_t index, const int32_t bank, const int32_t program, const char* const label) +void CarlaEngine::oscSend_bridge_midi_program_info(const int32_t index, const int32_t bank, const int32_t program, const char* const label) { CARLA_ASSERT(pData->oscData != nullptr); - carla_debug("CarlaEngine::osc_send_bridge_midi_program_info(%i, %i, %i, \"%s\")", index, bank, program, label); + carla_debug("CarlaEngine::oscSend_bridge_midi_program_info(%i, %i, %i, \"%s\")", index, bank, program, label); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2422,12 +2410,12 @@ void CarlaEngine::osc_send_bridge_midi_program_info(const int32_t index, const i } } -void CarlaEngine::osc_send_bridge_configure(const char* const key, const char* const value) +void CarlaEngine::oscSend_bridge_configure(const char* const key, const char* const value) { CARLA_ASSERT(pData->oscData != nullptr); CARLA_ASSERT(key != nullptr); CARLA_ASSERT(value != nullptr); - carla_debug("CarlaEngine::osc_send_bridge_configure(\"%s\", \"%s\")", key, value); + carla_debug("CarlaEngine::oscSend_bridge_configure(\"%s\", \"%s\")", key, value); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2438,10 +2426,10 @@ void CarlaEngine::osc_send_bridge_configure(const char* const key, const char* c } } -void CarlaEngine::osc_send_bridge_set_parameter_value(const int32_t index, const float value) +void CarlaEngine::oscSend_bridge_set_parameter_value(const int32_t index, const float value) { CARLA_ASSERT(pData->oscData != nullptr); - carla_debug("CarlaEngine::osc_send_bridge_set_parameter_value(%i, %f)", index, value); + carla_debug("CarlaEngine::oscSend_bridge_set_parameter_value(%i, %f)", index, value); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2452,10 +2440,10 @@ void CarlaEngine::osc_send_bridge_set_parameter_value(const int32_t index, const } } -void CarlaEngine::osc_send_bridge_set_default_value(const int32_t index, const float value) +void CarlaEngine::oscSend_bridge_set_default_value(const int32_t index, const float value) { CARLA_ASSERT(pData->oscData != nullptr); - carla_debug("CarlaEngine::osc_send_bridge_set_default_value(%i, %f)", index, value); + carla_debug("CarlaEngine::oscSend_bridge_set_default_value(%i, %f)", index, value); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2466,10 +2454,10 @@ void CarlaEngine::osc_send_bridge_set_default_value(const int32_t index, const f } } -void CarlaEngine::osc_send_bridge_set_program(const int32_t index) +void CarlaEngine::oscSend_bridge_set_program(const int32_t index) { CARLA_ASSERT(pData->oscData != nullptr); - carla_debug("CarlaEngine::osc_send_bridge_set_program(%i)", index); + carla_debug("CarlaEngine::oscSend_bridge_set_program(%i)", index); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2480,10 +2468,10 @@ void CarlaEngine::osc_send_bridge_set_program(const int32_t index) } } -void CarlaEngine::osc_send_bridge_set_midi_program(const int32_t index) +void CarlaEngine::oscSend_bridge_set_midi_program(const int32_t index) { CARLA_ASSERT(pData->oscData != nullptr); - carla_debug("CarlaEngine::osc_send_bridge_set_midi_program(%i)", index); + carla_debug("CarlaEngine::oscSend_bridge_set_midi_program(%i)", index); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2494,10 +2482,10 @@ void CarlaEngine::osc_send_bridge_set_midi_program(const int32_t index) } } -void CarlaEngine::osc_send_bridge_set_custom_data(const char* const type, const char* const key, const char* const value) +void CarlaEngine::oscSend_bridge_set_custom_data(const char* const type, const char* const key, const char* const value) { CARLA_ASSERT(pData->oscData != nullptr); - carla_debug("CarlaEngine::osc_send_bridge_set_custom_data(\"%s\", \"%s\", \"%s\")", type, key, value); + carla_debug("CarlaEngine::oscSend_bridge_set_custom_data(\"%s\", \"%s\", \"%s\")", type, key, value); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { @@ -2508,10 +2496,10 @@ void CarlaEngine::osc_send_bridge_set_custom_data(const char* const type, const } } -void CarlaEngine::osc_send_bridge_set_chunk_data(const char* const chunkFile) +void CarlaEngine::oscSend_bridge_set_chunk_data(const char* const chunkFile) { CARLA_ASSERT(pData->oscData != nullptr); - carla_debug("CarlaEngine::osc_send_bridge_set_chunk_data(\"%s\")", chunkFile); + carla_debug("CarlaEngine::oscSend_bridge_set_chunk_data(\"%s\")", chunkFile); if (pData->oscData != nullptr && pData->oscData->target != nullptr) { diff --git a/source/backend/engine/CarlaEngineInternal.hpp b/source/backend/engine/CarlaEngineInternal.hpp index ce10cffb2..94f64e86a 100644 --- a/source/backend/engine/CarlaEngineInternal.hpp +++ b/source/backend/engine/CarlaEngineInternal.hpp @@ -222,10 +222,10 @@ struct CarlaEngineProtectedData { #ifndef BUILD_BRIDGE static void registerEnginePlugin(CarlaEngine* const engine, const unsigned int id, CarlaPlugin* const plugin) { - CARLA_ASSERT(id == engine->kData->curPluginCount); + CARLA_ASSERT(id == engine->pData->curPluginCount); - if (id == engine->kData->curPluginCount) - engine->kData->plugins[id].plugin = plugin; + if (id == engine->pData->curPluginCount) + engine->pData->plugins[id].plugin = plugin; } #endif @@ -316,36 +316,36 @@ struct CarlaEngineProtectedData { { public: ScopedPluginAction(CarlaEngineProtectedData* const data, const EnginePostAction action, const unsigned int pluginId, const unsigned int value, const bool lockWait) - : kData(data) + : fData(data) { - kData->nextAction.mutex.lock(); + fData->nextAction.mutex.lock(); - CARLA_ASSERT(kData->nextAction.opcode == kEnginePostActionNull); + CARLA_ASSERT(fData->nextAction.opcode == kEnginePostActionNull); - kData->nextAction.opcode = action; - kData->nextAction.pluginId = pluginId; - kData->nextAction.value = value; + fData->nextAction.opcode = action; + fData->nextAction.pluginId = pluginId; + fData->nextAction.value = value; if (lockWait) { // block wait for unlock on proccessing side carla_stdout("ScopedPluginAction(%i) - blocking START", pluginId); - kData->nextAction.mutex.lock(); + fData->nextAction.mutex.lock(); carla_stdout("ScopedPluginAction(%i) - blocking DONE", pluginId); } else { - kData->doNextPluginAction(false); + fData->doNextPluginAction(false); } } ~ScopedPluginAction() { - kData->nextAction.mutex.unlock(); + fData->nextAction.mutex.unlock(); } private: - CarlaEngineProtectedData* const kData; + CarlaEngineProtectedData* const fData; }; }; diff --git a/source/backend/plugin/CarlaPluginThread.cpp b/source/backend/plugin/CarlaPluginThread.cpp index ae3ce9c74..45105177e 100644 --- a/source/backend/plugin/CarlaPluginThread.cpp +++ b/source/backend/plugin/CarlaPluginThread.cpp @@ -64,7 +64,7 @@ CarlaPluginThread::~CarlaPluginThread() } } -void CarlaPluginThread::setMode(const CarlaPluginThread::Mode mode) +void CarlaPluginThread::setMode(const CarlaPluginThread::Mode mode) noexcept { fMode = mode; } diff --git a/source/backend/plugin/CarlaPluginThread.hpp b/source/backend/plugin/CarlaPluginThread.hpp index d76b6516b..f23da989b 100644 --- a/source/backend/plugin/CarlaPluginThread.hpp +++ b/source/backend/plugin/CarlaPluginThread.hpp @@ -12,11 +12,11 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * For a full copy of the GNU General Public License see the GPL.txt file + * For a full copy of the GNU General Public License see the doc/GPL.txt file. */ -#ifndef __CARLA_PLUGIN_THREAD_HPP__ -#define __CARLA_PLUGIN_THREAD_HPP__ +#ifndef CARLA_PLUGIN_THREAD_HPP_INCLUDED +#define CARLA_PLUGIN_THREAD_HPP_INCLUDED #include "CarlaBackend.hpp" #include "CarlaString.hpp" @@ -41,15 +41,15 @@ public: CarlaPluginThread(CarlaEngine* const engine, CarlaPlugin* const plugin, const Mode mode = PLUGIN_THREAD_NULL); ~CarlaPluginThread(); - void setMode(const CarlaPluginThread::Mode mode); + void setMode(const CarlaPluginThread::Mode mode) noexcept; void setOscData(const char* const binary, const char* const label, const char* const extra1="", const char* const extra2=""); protected: void run(); private: - CarlaEngine* const kEngine; - CarlaPlugin* const kPlugin; + CarlaEngine* const fEngine; + CarlaPlugin* const fPlugin; Mode fMode; CarlaString fBinary; @@ -58,9 +58,10 @@ private: CarlaString fExtra2; QProcess* fProcess; + CARLA_PREVENT_HEAP_ALLOCATION CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaPluginThread) }; CARLA_BACKEND_END_NAMESPACE -#endif // __CARLA_PLUGIN_THREAD_HPP__ +#endif // CARLA_PLUGIN_THREAD_HPP_INCLUDED diff --git a/source/libs/rtmempool/list.h b/source/libs/rtmempool/list.h index f3b68a157..90b4cdf9a 100644 --- a/source/libs/rtmempool/list.h +++ b/source/libs/rtmempool/list.h @@ -21,8 +21,8 @@ * *****************************************************************************/ -#ifndef __LINUX_LIST_H__ -#define __LINUX_LIST_H__ +#ifndef LINUX_LIST_H_INCLUDED +#define LINUX_LIST_H_INCLUDED /* This file is from Linux Kernel (include/linux/list.h) * and modified by removing hardware prefetching of list items @@ -300,7 +300,7 @@ static inline void list_splice_tail_init(struct list_head *list, struct list_hea * @type: the type of the struct this is embedded in. * @member: the name of the list_struct within the struct. */ -#if defined(__GNUC__) && ! defined(QTCREATOR_TEST) +#if defined(__GNUC__) && ! (defined(BUILD_ANSI_TEST) || defined(QTCREATOR_TEST)) # define list_entry(ptr, type, member) \ container_of(ptr, type, member) #else @@ -452,4 +452,4 @@ static inline void list_splice_tail_init(struct list_head *list, struct list_hea &pos->member != (head); \ pos = n, n = list_entry(n->member.prev, typeof(*n), member)) -#endif // __LINUX_LIST_H__ +#endif // LINUX_LIST_H_INCLUDED diff --git a/source/tests/ANSI.cpp b/source/tests/ANSI.cpp index 09a706891..f2b0aa405 100644 --- a/source/tests/ANSI.cpp +++ b/source/tests/ANSI.cpp @@ -53,31 +53,33 @@ // Carla Standalone API #include "CarlaStandalone.hpp" -// // Carla Plugin Thread -// #include "CarlaPluginThread.hpp" -// -// #include "CarlaBackendUtils.hpp" -// #include "CarlaOscUtils.hpp" -// #include "CarlaMutex.hpp" -// #include "RtList.hpp" -// -// // Carla Plugin +// Carla Plugin Thread +#include "CarlaPluginThread.hpp" + +// Carla Backend utils +#include "CarlaBackendUtils.hpp" + +// Carla OSC utils +#include "CarlaOscUtils.hpp" + +// Carla Mutex +#include "CarlaMutex.hpp" + +// RT List +#include "RtList.hpp" + +// Carla Plugin // #include "CarlaPluginInternal.hpp" //#include "standalone/CarlaStandalone.cpp" -// #include "CarlaMutex.hpp" - -// #include "CarlaBackendUtils.hpp" // #include "CarlaBridgeUtils.hpp" // #include "CarlaLadspaUtils.hpp" // #include "CarlaLibUtils.hpp" // #include "CarlaLv2Utils.hpp" -// #include "CarlaOscUtils.hpp" // #include "CarlaShmUtils.hpp" // #include "CarlaStateUtils.hpp" // #include "CarlaVstUtils.hpp" -// #include "RtList.hpp" int safe_assert_return_test(bool test) { @@ -434,5 +436,39 @@ int main() c = new PluginDescriptorClassTest(&a); } + // Carla Backend utils + { + class TestClass { public: int i; char pad[50]; }; + + TestClass a, b, c; + uintptr_t ad = CarlaBackend::getAddressFromPointer(&a); + uintptr_t bd = CarlaBackend::getAddressFromPointer(&b); + uintptr_t cd = CarlaBackend::getAddressFromPointer(&c); + assert(bd > ad); + assert(cd > bd); + + TestClass* ap = CarlaBackend::getPointerFromAddress(ad); + TestClass* bp = CarlaBackend::getPointerFromAddress(bd); + TestClass* cp = CarlaBackend::getPointerFromAddress(cd); + assert(ap == &a); + assert(bp == &b); + assert(cp == &c); + + ap->i = 4; + bp->i = 5; + cp->i = 6; + assert(a.i == 4); + assert(b.i == 5); + assert(c.i == 6); + } + + // Carla Mutex + { + CarlaMutex m; + m.tryLock(); + m.unlock(); + const CarlaMutex::ScopedLocker sl(m); + } + return 0; } diff --git a/source/tests/Makefile b/source/tests/Makefile index 8c73ff263..4c89df12b 100644 --- a/source/tests/Makefile +++ b/source/tests/Makefile @@ -8,11 +8,11 @@ include ../Makefile.mk # -------------------------------------------------------------- -BUILD_CXX_FLAGS += -I../backend -I../includes -I../libs -I../theme -I../utils +BUILD_CXX_FLAGS += -I../backend -I../backend/plugin -I../includes -I../libs -I../theme -I../utils BUILD_CXX_FLAGS += -DWANT_NATIVE -DWANT_LADSPA -DWANT_DSSI -DWANT_LV2 -DWANT_VST -DWANT_FLUIDSYNTH -DWANT_LINUXSAMPLER BUILD_CXX_FLAGS += -DWANT_RTAUDIO -DWANT_OPENGL -DWANT_AUDIOFILE -DWANT_MIDIFILE -DWANT_ZYNADDSUBFX -DWANT_ZYNADDSUBFX_UI # BUILD_CXX_FLAGS += -isystem ../libs/juce -# BUILD_CXX_FLAGS += -isystem /usr/include/qt4 +BUILD_CXX_FLAGS += -isystem /usr/include/qt4 # BUILD_CXX_FLAGS += -isystem ../backend/engine/rtaudio-4.0.11 # BUILD_CXX_FLAGS += -I/opt/mingw32/include diff --git a/source/utils/CarlaBackendUtils.hpp b/source/utils/CarlaBackendUtils.hpp index fec60edd1..7c1cfc55f 100644 --- a/source/utils/CarlaBackendUtils.hpp +++ b/source/utils/CarlaBackendUtils.hpp @@ -12,21 +12,21 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * For a full copy of the GNU General Public License see the GPL.txt file + * For a full copy of the GNU General Public License see the doc/GPL.txt file. */ -#ifndef __CARLA_BACKEND_UTILS_HPP__ -#define __CARLA_BACKEND_UTILS_HPP__ +#ifndef CARLA_BACKEND_UTILS_HPP_INCLUDED +#define CARLA_BACKEND_UTILS_HPP_INCLUDED #include "CarlaBackend.hpp" #include "CarlaString.hpp" CARLA_BACKEND_START_NAMESPACE -// ------------------------------------------------- +// ----------------------------------------------------------------------- static inline -const char* PluginOption2Str(const unsigned int& option) +const char* PluginOption2Str(const unsigned int option) { switch (option) { @@ -54,10 +54,8 @@ const char* PluginOption2Str(const unsigned int& option) return nullptr; } -// ------------------------------------------------- - static inline -const char* BinaryType2Str(const BinaryType& type) +const char* BinaryType2Str(const BinaryType type) { switch (type) { @@ -80,7 +78,7 @@ const char* BinaryType2Str(const BinaryType& type) } static inline -const char* PluginType2Str(const PluginType& type) +const char* PluginType2Str(const PluginType type) { switch (type) { @@ -111,7 +109,7 @@ const char* PluginType2Str(const PluginType& type) } static inline -const char* PluginCategory2Str(const PluginCategory& category) +const char* PluginCategory2Str(const PluginCategory category) { switch (category) { @@ -140,7 +138,7 @@ const char* PluginCategory2Str(const PluginCategory& category) } static inline -const char* ParameterType2Str(const ParameterType& type) +const char* ParameterType2Str(const ParameterType type) { switch (type) { @@ -167,7 +165,7 @@ const char* ParameterType2Str(const ParameterType& type) } static inline -const char* InternalParametersIndex2Str(const InternalParametersIndex& index) +const char* InternalParametersIndex2Str(const InternalParametersIndex index) { switch (index) { @@ -196,7 +194,7 @@ const char* InternalParametersIndex2Str(const InternalParametersIndex& index) } static inline -const char* OptionsType2Str(const OptionsType& type) +const char* OptionsType2Str(const OptionsType type) { switch (type) { @@ -218,15 +216,15 @@ const char* OptionsType2Str(const OptionsType& type) #endif case OPTION_MAX_PARAMETERS: return "OPTION_MAX_PARAMETERS"; - case OPTION_OSC_UI_TIMEOUT: - return "OPTION_OSC_UI_TIMEOUT"; + case OPTION_UI_BRIDGES_TIMEOUT: + return "OPTION_UI_BRIDGES_TIMEOUT"; case OPTION_JACK_AUTOCONNECT: return "OPTION_JACK_AUTOCONNECT"; - case OPTION_JACK_TIMEMASTER: - return "OPTION_JACK_TIMEMASTER"; #ifdef WANT_RTAUDIO + case OPTION_RTAUDIO_NUMBER_PERIODS: + return "OPTION_RTAUDIO_NUMBER_PERIODS"; case OPTION_RTAUDIO_BUFFER_SIZE: - return "OPTION_RTAUDIO_BUFFER_SIZE:"; + return "OPTION_RTAUDIO_BUFFER_SIZE"; case OPTION_RTAUDIO_SAMPLE_RATE: return "OPTION_RTAUDIO_SAMPLE_RATE"; case OPTION_RTAUDIO_DEVICE: @@ -277,7 +275,7 @@ const char* OptionsType2Str(const OptionsType& type) } static inline -const char* CallbackType2Str(const CallbackType& type) +const char* CallbackType2Str(const CallbackType type) { switch (type) { @@ -360,7 +358,7 @@ const char* CallbackType2Str(const CallbackType& type) } static inline -const char* ProcessMode2Str(const ProcessMode& mode) +const char* ProcessMode2Str(const ProcessMode mode) { switch (mode) { @@ -381,7 +379,7 @@ const char* ProcessMode2Str(const ProcessMode& mode) } static inline -const char* TransportMode2Str(const TransportMode& mode) +const char* TransportMode2Str(const TransportMode mode) { switch (mode) { @@ -399,30 +397,31 @@ const char* TransportMode2Str(const TransportMode& mode) return nullptr; } -// ------------------------------------------------- +// ----------------------------------------------------------------------- static inline uintptr_t getAddressFromPointer(void* ptr) { CARLA_ASSERT(ptr != nullptr); - uintptr_t* addr = (uintptr_t*)&ptr; + uintptr_t* const addr((uintptr_t*)&ptr); return *addr; } +template static inline -void* getPointerFromAddress(uintptr_t& addr) +T* getPointerFromAddress(uintptr_t& addr) { CARLA_ASSERT(addr != 0); - uintptr_t** const ptr = (uintptr_t**)&addr; + T** const ptr((T**)&addr); return *ptr; } -// ------------------------------------------------- +// ----------------------------------------------------------------------- static inline -const char* getPluginTypeAsString(const PluginType& type) +const char* getPluginTypeAsString(const PluginType type) { carla_debug("CarlaBackend::getPluginTypeAsString(%s)", PluginType2Str(type)); @@ -491,7 +490,7 @@ PluginType getPluginTypeFromString(const char* const stype) return PLUGIN_NONE; } -// ------------------------------------------------- +// ----------------------------------------------------------------------- static inline PluginCategory getPluginCategoryFromName(const char* const name) @@ -577,4 +576,4 @@ PluginCategory getPluginCategoryFromName(const char* const name) CARLA_BACKEND_END_NAMESPACE -#endif // __CARLA_BACKEND_UTILS_HPP__ +#endif // CARLA_BACKEND_UTILS_HPP_INCLUDED diff --git a/source/utils/CarlaBridgeUtils.hpp b/source/utils/CarlaBridgeUtils.hpp index b54301ca2..004d3702a 100644 --- a/source/utils/CarlaBridgeUtils.hpp +++ b/source/utils/CarlaBridgeUtils.hpp @@ -21,7 +21,7 @@ #include "CarlaRingBuffer.hpp" -// ------------------------------------------------- +// ----------------------------------------------------------------------- enum PluginBridgeInfoType { kPluginBridgeAudioCount = 0, @@ -68,7 +68,7 @@ const char* const CARLA_BRIDGE_MSG_SET_CUSTOM = "CarlaBridgeSetCustom"; //!< Hos //If \a type is 'chunk' or 'binary' \a rvalue refers to chunk file. #endif -// ------------------------------------------------- +// ----------------------------------------------------------------------- struct BridgeShmControl { // 32 and 64-bit binaries align semaphores differently. @@ -86,7 +86,7 @@ struct BridgeShmControl { CARLA_DECLARE_NON_COPY_STRUCT(BridgeShmControl) }; -// ------------------------------------------------- +// ----------------------------------------------------------------------- static inline const char* PluginBridgeInfoType2str(const PluginBridgeInfoType type) @@ -170,6 +170,4 @@ const char* PluginBridgeOpcode2str(const PluginBridgeOpcode opcode) return nullptr; } -// ------------------------------------------------- - #endif // __CARLA_BRIDGE_UTILS_HPP__ diff --git a/source/utils/CarlaLadspaUtils.hpp b/source/utils/CarlaLadspaUtils.hpp index f76b12e8a..1f02ebe34 100644 --- a/source/utils/CarlaLadspaUtils.hpp +++ b/source/utils/CarlaLadspaUtils.hpp @@ -25,7 +25,7 @@ #include -// ------------------------------------------------- +// ----------------------------------------------------------------------- // Copy RDF object static inline @@ -87,7 +87,7 @@ const LADSPA_RDF_Descriptor* ladspa_rdf_dup(const LADSPA_RDF_Descriptor* const o return newDescriptor; } -// ------------------------------------------------- +// ----------------------------------------------------------------------- // Check if 2 ports match types static inline @@ -104,7 +104,7 @@ bool is_ladspa_port_good(const LADSPA_PortDescriptor port1, const LADSPA_PortDes return true; } -// ------------------------------------------------- +// ----------------------------------------------------------------------- // Check if rdf data matches descriptor static inline @@ -137,7 +137,7 @@ bool is_ladspa_rdf_descriptor_valid(const LADSPA_RDF_Descriptor* const rdfDescri return true; } -// ------------------------------------------------- +// ----------------------------------------------------------------------- // Get default control port value static inline @@ -205,6 +205,4 @@ LADSPA_Data get_default_ladspa_port_value(const LADSPA_PortRangeHintDescriptor h return def; } -// ------------------------------------------------- - #endif // __CARLA_LADSPA_UTILS_HPP__ diff --git a/source/utils/CarlaLibUtils.hpp b/source/utils/CarlaLibUtils.hpp index 39527d141..4a8b4ef22 100644 --- a/source/utils/CarlaLibUtils.hpp +++ b/source/utils/CarlaLibUtils.hpp @@ -24,7 +24,7 @@ # include #endif -// ------------------------------------------------- +// ----------------------------------------------------------------------- // library related calls static inline @@ -95,6 +95,4 @@ const char* lib_error(const char* const filename) #endif } -// ------------------------------------------------- - #endif // __CARLA_LIB_UTILS_HPP__ diff --git a/source/utils/CarlaLogThread.hpp b/source/utils/CarlaLogThread.hpp index be8c99c11..7e676856e 100644 --- a/source/utils/CarlaLogThread.hpp +++ b/source/utils/CarlaLogThread.hpp @@ -26,7 +26,7 @@ CARLA_BACKEND_START_NAMESPACE -// ------------------------------------------------------------------------------------------------------------------- +// ----------------------------------------------------------------------- // Log thread class LogThread : public QThread diff --git a/source/utils/CarlaLv2Utils.hpp b/source/utils/CarlaLv2Utils.hpp index 035478a1d..a74e2a3b0 100644 --- a/source/utils/CarlaLv2Utils.hpp +++ b/source/utils/CarlaLv2Utils.hpp @@ -64,7 +64,7 @@ #include #include -// ------------------------------------------------- +// ----------------------------------------------------------------------- // Define namespaces and missing prefixes #define NS_dct "http://purl.org/dc/terms/" @@ -82,7 +82,7 @@ #define LV2_UI__idle LV2_UI_PREFIX "idle" #define LV2_UI__makeResident LV2_UI_PREFIX "makeResident" -// ------------------------------------------------- +// ----------------------------------------------------------------------- // Non-void versions #define LV2NV_ATOM_CONTENTS(type, atom) \ diff --git a/source/utils/CarlaMutex.hpp b/source/utils/CarlaMutex.hpp index 963da3a76..bf62242ce 100644 --- a/source/utils/CarlaMutex.hpp +++ b/source/utils/CarlaMutex.hpp @@ -12,23 +12,17 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * For a full copy of the GNU General Public License see the GPL.txt file + * For a full copy of the GNU General Public License see the doc/GPL.txt file. */ -#ifndef __CARLA_MUTEX_HPP__ -#define __CARLA_MUTEX_HPP__ +#ifndef CARLA_MUTEX_HPP_INCLUDED +#define CARLA_MUTEX_HPP_INCLUDED #include "CarlaJuceUtils.hpp" -// #define CPP11_MUTEX +#include -#ifdef CPP11_MUTEX -# include -#else -# include -#endif - -// ------------------------------------------------- +// ----------------------------------------------------------------------- // CarlaMutex class class CarlaMutex @@ -37,48 +31,32 @@ public: CarlaMutex() : fTryLockWasCalled(false) { -#ifndef CPP11_MUTEX pthread_mutex_init(&pmutex, nullptr); -#endif } ~CarlaMutex() { -#ifndef CPP11_MUTEX pthread_mutex_destroy(&pmutex); -#endif } void lock() { -#ifdef CPP11_MUTEX - cmutex.lock(); -#else pthread_mutex_lock(&pmutex); -#endif } bool tryLock() { fTryLockWasCalled = true; -#ifdef CPP11_MUTEX - return cmutex.try_lock(); -#else return (pthread_mutex_trylock(&pmutex) == 0); -#endif } - void unlock(const bool resetTryLock) + void unlock(/*const bool resetTryLock*/) { - if (resetTryLock) - fTryLockWasCalled = false; + //if (resetTryLock) + // fTryLockWasCalled = false; -#ifdef CPP11_MUTEX - cmutex.unlock(); -#else pthread_mutex_unlock(&pmutex); -#endif } bool wasTryLockCalled() @@ -110,17 +88,11 @@ public: }; private: -#ifdef CPP11_MUTEX - std::mutex cmutex; -#else pthread_mutex_t pmutex; -#endif bool fTryLockWasCalled; CARLA_PREVENT_HEAP_ALLOCATION CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaMutex) }; -// ------------------------------------------------- - -#endif // __CARLA_MUTEX_HPP__ +#endif // CARLA_MUTEX_HPP_INCLUDED diff --git a/source/utils/CarlaOscUtils.hpp b/source/utils/CarlaOscUtils.hpp index 0e44581e1..bcb887f0c 100644 --- a/source/utils/CarlaOscUtils.hpp +++ b/source/utils/CarlaOscUtils.hpp @@ -12,24 +12,24 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * For a full copy of the GNU General Public License see the GPL.txt file + * For a full copy of the GNU General Public License see the doc/GPL.txt file. */ -#ifndef __CARLA_OSC_UTILS_HPP__ -#define __CARLA_OSC_UTILS_HPP__ +#ifndef CARLA_OSC_UTILS_HPP_INCLUDED +#define CARLA_OSC_UTILS_HPP_INCLUDED #include "CarlaJuceUtils.hpp" #include -// ------------------------------------------------- +// ----------------------------------------------------------------------- struct CarlaOscData { const char* path; lo_address source; lo_address target; - CarlaOscData() + CarlaOscData() noexcept : path(nullptr), source(nullptr), target(nullptr) {} @@ -63,290 +63,288 @@ struct CarlaOscData { CARLA_DECLARE_NON_COPY_STRUCT(CarlaOscData) }; -// ------------------------------------------------- +// ----------------------------------------------------------------------- static inline -void osc_send_configure(const CarlaOscData* const oscData, const char* const key, const char* const value) +void osc_send_configure(const CarlaOscData& oscData, const char* const key, const char* const value) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); + CARLA_ASSERT(oscData.path != nullptr); CARLA_ASSERT(key != nullptr); CARLA_ASSERT(value != nullptr); - carla_debug("osc_send_configure(path:\"%s\", \"%s\", \"%s\")", oscData->path, key, value); + carla_debug("osc_send_configure(path:\"%s\", \"%s\", \"%s\")", oscData.path, key, value); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr && key != nullptr && value != nullptr) + if (oscData.path != nullptr && oscData.target != nullptr && key != nullptr && value != nullptr) { - char targetPath[std::strlen(oscData->path)+11]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+11]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/configure"); - lo_send(oscData->target, targetPath, "ss", key, value); + lo_send(oscData.target, targetPath, "ss", key, value); } } static inline -void osc_send_control(const CarlaOscData* const oscData, const int32_t index, const float value) +void osc_send_control(const CarlaOscData& oscData, const int32_t index, const float value) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); + CARLA_ASSERT(oscData.path != nullptr); CARLA_ASSERT(index != -1); // -1 == PARAMETER_NULL - carla_debug("osc_send_control(path:\"%s\", %i, %f)", oscData->path, index, value); + carla_debug("osc_send_control(path:\"%s\", %i, %f)", oscData.path, index, value); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr && index != -1) + if (oscData.path != nullptr && oscData.target != nullptr && index != -1) { - char targetPath[std::strlen(oscData->path)+9]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+9]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/control"); - lo_send(oscData->target, targetPath, "if", index, value); + lo_send(oscData.target, targetPath, "if", index, value); } } static inline -void osc_send_program(const CarlaOscData* const oscData, const int32_t index) +void osc_send_program(const CarlaOscData& oscData, const int32_t index) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); + CARLA_ASSERT(oscData.path != nullptr); CARLA_ASSERT(index >= 0); - carla_debug("osc_send_program(path:\"%s\", %i)", oscData->path, index); + carla_debug("osc_send_program(path:\"%s\", %i)", oscData.path, index); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr && index >= 0) + if (oscData.path != nullptr && oscData.target != nullptr && index >= 0) { - char targetPath[std::strlen(oscData->path)+9]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+9]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/program"); - lo_send(oscData->target, targetPath, "i", index); + lo_send(oscData.target, targetPath, "i", index); } } static inline -void osc_send_program(const CarlaOscData* const oscData, const int32_t bank, const int32_t program) +void osc_send_program(const CarlaOscData& oscData, const int32_t bank, const int32_t program) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); + CARLA_ASSERT(oscData.path != nullptr); CARLA_ASSERT(program >= 0); CARLA_ASSERT(bank >= 0); - carla_debug("osc_send_program(path:\"%s\", %i, %i)", oscData->path, bank, program); + carla_debug("osc_send_program(path:\"%s\", %i, %i)", oscData.path, bank, program); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr && bank >= 0 && program >= 0) + if (oscData.path != nullptr && oscData.target != nullptr && bank >= 0 && program >= 0) { - char targetPath[std::strlen(oscData->path)+9]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+9]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/program"); - lo_send(oscData->target, targetPath, "ii", bank, program); + lo_send(oscData.target, targetPath, "ii", bank, program); } } static inline -void osc_send_midi_program(const CarlaOscData* const oscData, const int32_t index) +void osc_send_midi_program(const CarlaOscData& oscData, const int32_t index) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); + CARLA_ASSERT(oscData.path != nullptr); CARLA_ASSERT(index >= 0); - carla_debug("osc_send_midi_program(path:\"%s\", %i)", oscData->path, index); + carla_debug("osc_send_midi_program(path:\"%s\", %i)", oscData.path, index); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr && index >= 0) + if (oscData.path != nullptr && oscData.target != nullptr && index >= 0) { - char targetPath[std::strlen(oscData->path)+14]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+14]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/midi-program"); - lo_send(oscData->target, targetPath, "i", index); + lo_send(oscData.target, targetPath, "i", index); } } static inline -void osc_send_midi_program(const CarlaOscData* const oscData, const int32_t bank, const int32_t program) +void osc_send_midi_program(const CarlaOscData& oscData, const int32_t bank, const int32_t program) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); + CARLA_ASSERT(oscData.path != nullptr); CARLA_ASSERT(program >= 0); CARLA_ASSERT(bank >= 0); - carla_debug("osc_send_midi_program(path:\"%s\", %i, %i)", oscData->path, bank, program); + carla_debug("osc_send_midi_program(path:\"%s\", %i, %i)", oscData.path, bank, program); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr && bank >= 0 && program >= 0) + if (oscData.path != nullptr && oscData.target != nullptr && bank >= 0 && program >= 0) { - char targetPath[std::strlen(oscData->path)+14]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+14]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/midi-program"); - lo_send(oscData->target, targetPath, "ii", bank, program); + lo_send(oscData.target, targetPath, "ii", bank, program); } } static inline -void osc_send_midi(const CarlaOscData* const oscData, const uint8_t buf[4]) +void osc_send_midi(const CarlaOscData& oscData, const uint8_t buf[4]) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); + CARLA_ASSERT(oscData.path != nullptr); CARLA_ASSERT(buf[0] == 0); CARLA_ASSERT(buf[1] != 0); - carla_debug("osc_send_midi(path:\"%s\", 0x%X, %03u, %03u)", oscData->path, buf[1], buf[2], buf[3]); + carla_debug("osc_send_midi(path:\"%s\", [0x%X, %03u, %03u])", oscData.path, buf[1], buf[2], buf[3]); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr && buf[0] == 0 && buf[1] != 0) + if (oscData.path != nullptr && oscData.target != nullptr && buf[0] == 0 && buf[1] != 0) { - char targetPath[std::strlen(oscData->path)+6]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+6]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/midi"); - lo_send(oscData->target, targetPath, "m", buf); + lo_send(oscData.target, targetPath, "m", buf); } } static inline -void osc_send_sample_rate(const CarlaOscData* const oscData, const float sampleRate) +void osc_send_sample_rate(const CarlaOscData& oscData, const float sampleRate) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); + CARLA_ASSERT(oscData.path != nullptr); CARLA_ASSERT(sampleRate > 0.0f); - carla_debug("osc_send_sample_rate(path:\"%s\", %f)", oscData->path, sampleRate); + carla_debug("osc_send_sample_rate(path:\"%s\", %f)", oscData.path, sampleRate); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr && sampleRate > 0.0f) + if (oscData.path != nullptr && oscData.target != nullptr && sampleRate > 0.0f) { - char targetPath[std::strlen(oscData->path)+13]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+13]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/sample-rate"); - lo_send(oscData->target, targetPath, "f", sampleRate); + lo_send(oscData.target, targetPath, "f", sampleRate); } } #ifdef BUILD_BRIDGE static inline -void osc_send_update(const CarlaOscData* const oscData, const char* const url) +void osc_send_update(const CarlaOscData& oscData, const char* const url) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); + CARLA_ASSERT(oscData.path != nullptr); CARLA_ASSERT(url != nullptr); - carla_debug("osc_send_update(path:\"%s\", \"%s\")", oscData->path, url); + carla_debug("osc_send_update(path:\"%s\", \"%s\")", oscData.path, url); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr && url != nullptr) + if (oscData.path != nullptr && oscData.target != nullptr && url != nullptr) { - char targetPath[std::strlen(oscData->path)+8]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+8]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/update"); - lo_send(oscData->target, targetPath, "s", url); + lo_send(oscData.target, targetPath, "s", url); } } static inline -void osc_send_exiting(const CarlaOscData* const oscData) +void osc_send_exiting(const CarlaOscData& oscData) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); - carla_debug("osc_send_exiting(path:\"%s\")", oscData->path); + CARLA_ASSERT(oscData.path != nullptr); + carla_debug("osc_send_exiting(path:\"%s\")", oscData.path); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr) + if (oscData.path != nullptr && oscData.target != nullptr) { - char targetPath[std::strlen(oscData->path)+9]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+9]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/exiting"); - lo_send(oscData->target, targetPath, ""); + lo_send(oscData.target, targetPath, ""); } } #endif static inline -void osc_send_show(const CarlaOscData* const oscData) +void osc_send_show(const CarlaOscData& oscData) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); - carla_debug("osc_send_show(path:\"%s\")", oscData->path); + CARLA_ASSERT(oscData.path != nullptr); + carla_debug("osc_send_show(path:\"%s\")", oscData.path); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr) + if (oscData.path != nullptr && oscData.target != nullptr) { - char targetPath[std::strlen(oscData->path)+6]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+6]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/show"); - lo_send(oscData->target, targetPath, ""); + lo_send(oscData.target, targetPath, ""); } } static inline -void osc_send_hide(const CarlaOscData* const oscData) +void osc_send_hide(const CarlaOscData& oscData) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); - carla_debug("osc_send_hide(path:\"%s\")", oscData->path); + CARLA_ASSERT(oscData.path != nullptr); + carla_debug("osc_send_hide(path:\"%s\")", oscData.path); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr) + if (oscData.path != nullptr && oscData.target != nullptr) { - char targetPath[std::strlen(oscData->path)+6]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+6]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/hide"); - lo_send(oscData->target, targetPath, ""); + lo_send(oscData.target, targetPath, ""); } } static inline -void osc_send_quit(const CarlaOscData* const oscData) +void osc_send_quit(const CarlaOscData& oscData) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); - carla_debug("osc_send_quit(path:\"%s\")", oscData->path); + CARLA_ASSERT(oscData.path != nullptr); + carla_debug("osc_send_quit(path:\"%s\")", oscData.path); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr) + if (oscData.path != nullptr && oscData.target != nullptr) { - char targetPath[std::strlen(oscData->path)+6]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+6]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/quit"); - lo_send(oscData->target, targetPath, ""); + lo_send(oscData.target, targetPath, ""); } } -// ------------------------------------------------- +// ----------------------------------------------------------------------- #ifdef BUILD_BRIDGE_PLUGIN static inline -void osc_send_bridge_update(const CarlaOscData* const oscData, const char* const url) +void osc_send_bridge_update(const CarlaOscData& oscData, const char* const url) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); + CARLA_ASSERT(oscData.path != nullptr); CARLA_ASSERT(url != nullptr); - carla_debug("osc_send_bridge_update(path:\"%s\", \"%s\")", oscData->path, url); + carla_debug("osc_send_bridge_update(path:\"%s\", \"%s\")", oscData.path, url); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr && url != nullptr) + if (oscData.path != nullptr && oscData.target != nullptr && url != nullptr) { - char targetPath[std::strlen(oscData->path)+15]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+15]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/bridge_update"); - lo_send(oscData->target, targetPath, "s", url); + lo_send(oscData.target, targetPath, "s", url); } } static inline -void osc_send_bridge_error(const CarlaOscData* const oscData, const char* const error) +void osc_send_bridge_error(const CarlaOscData& oscData, const char* const error) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); + CARLA_ASSERT(oscData.path != nullptr); CARLA_ASSERT(error != nullptr); - carla_debug("osc_send_bridge_error(path:\"%s\", \"%s\")", oscData->path, error); + carla_debug("osc_send_bridge_error(path:\"%s\", \"%s\")", oscData.path, error); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr && error != nullptr) + if (oscData.path != nullptr && oscData.target != nullptr && error != nullptr) { - char targetPath[std::strlen(oscData->path)+14]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+14]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/bridge_error"); - lo_send(oscData->target, targetPath, "s", error); + lo_send(oscData.target, targetPath, "s", error); } } #endif #if defined(BRIDGE_LV2) || defined(WANT_LV2) static inline -void osc_send_lv2_atom_transfer(const CarlaOscData* const oscData, const int32_t portIndex, const char* const atomBuf) +void osc_send_lv2_atom_transfer(const CarlaOscData& oscData, const int32_t portIndex, const char* const atomBuf) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); + CARLA_ASSERT(oscData.path != nullptr); CARLA_ASSERT(portIndex >= 0); CARLA_ASSERT(atomBuf != nullptr); - carla_debug("osc_send_lv2_atom_transfer(path:\"%s\", %i, )", oscData->path, portIndex, atomBuf); + carla_debug("osc_send_lv2_atom_transfer(path:\"%s\", %i, )", oscData.path, portIndex, atomBuf); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr && portIndex >= 0 && atomBuf != nullptr) + if (oscData.path != nullptr && oscData.target != nullptr && portIndex >= 0 && atomBuf != nullptr) { - char targetPath[std::strlen(oscData->path)+19]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+19]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/lv2_atom_transfer"); - lo_send(oscData->target, targetPath, "is", portIndex, atomBuf); + lo_send(oscData.target, targetPath, "is", portIndex, atomBuf); } } static inline -void osc_send_lv2_urid_map(const CarlaOscData* const oscData, const uint32_t urid, const char* const uri) +void osc_send_lv2_urid_map(const CarlaOscData& oscData, const uint32_t urid, const char* const uri) { - CARLA_ASSERT(oscData != nullptr && oscData->path != nullptr); + CARLA_ASSERT(oscData.path != nullptr); CARLA_ASSERT(urid > 0); CARLA_ASSERT(uri != nullptr); - carla_debug("osc_send_lv2_urid_map(path:\"%s\", %i, \"%s\")", oscData->path, urid, uri); + carla_debug("osc_send_lv2_urid_map(path:\"%s\", %i, \"%s\")", oscData.path, urid, uri); - if (oscData != nullptr && oscData->path != nullptr && oscData->target != nullptr && urid > 0 && uri != nullptr) + if (oscData.path != nullptr && oscData.target != nullptr && urid > 0 && uri != nullptr) { - char targetPath[std::strlen(oscData->path)+14]; - std::strcpy(targetPath, oscData->path); + char targetPath[std::strlen(oscData.path)+14]; + std::strcpy(targetPath, oscData.path); std::strcat(targetPath, "/lv2_urid_map"); - lo_send(oscData->target, targetPath, "is", urid, uri); + lo_send(oscData.target, targetPath, "is", urid, uri); } } #endif -// ------------------------------------------------- - -#endif // __CARLA_OSC_UTILS_HPP__ +#endif // CARLA_OSC_UTILS_HPP_INCLUDED diff --git a/source/utils/CarlaRingBuffer.hpp b/source/utils/CarlaRingBuffer.hpp index 45fa6de7d..7d47c6cc0 100644 --- a/source/utils/CarlaRingBuffer.hpp +++ b/source/utils/CarlaRingBuffer.hpp @@ -23,7 +23,7 @@ #define RING_BUFFER_SIZE 2048 -// ------------------------------------------------- +// ----------------------------------------------------------------------- // RingBuffer struct struct RingBuffer { @@ -34,7 +34,7 @@ struct RingBuffer { CARLA_DECLARE_NON_COPY_STRUCT(RingBuffer) }; -// ------------------------------------------------- +// ----------------------------------------------------------------------- // RingBufferControl class class RingBufferControl diff --git a/source/utils/CarlaShmUtils.hpp b/source/utils/CarlaShmUtils.hpp index 7817d4929..4afcb1636 100644 --- a/source/utils/CarlaShmUtils.hpp +++ b/source/utils/CarlaShmUtils.hpp @@ -28,7 +28,7 @@ struct shm_t { HANDLE shm; HANDLE map; }; typedef int shm_t; #endif -// ------------------------------------------------- +// ----------------------------------------------------------------------- // shared memory calls static inline diff --git a/source/utils/CarlaStateUtils.hpp b/source/utils/CarlaStateUtils.hpp index c46fd3fd8..60de38e7a 100644 --- a/source/utils/CarlaStateUtils.hpp +++ b/source/utils/CarlaStateUtils.hpp @@ -26,7 +26,7 @@ CARLA_BACKEND_START_NAMESPACE -// ------------------------------------------------- +// ----------------------------------------------------------------------- struct StateParameter { uint32_t index; diff --git a/source/utils/CarlaString.hpp b/source/utils/CarlaString.hpp index dedb6252d..c39fec372 100644 --- a/source/utils/CarlaString.hpp +++ b/source/utils/CarlaString.hpp @@ -299,11 +299,10 @@ public: } } -#ifndef BUILD_ANSI_TEST - // Using '+=' and '-=' temporarily converts char into int - void toLower() noexcept { +#ifndef BUILD_ANSI_TEST + // Using '+=' temporarily converts char into int static const char kCharDiff('a' - 'A'); for (size_t i=0; i < fBufferLen; ++i) @@ -311,10 +310,13 @@ public: if (fBuffer[i] >= 'A' && fBuffer[i] <= 'Z') fBuffer[i] += kCharDiff; } +#endif } void toUpper() noexcept { +#ifndef BUILD_ANSI_TEST + // Using '-=' temporarily converts char into int static const char kCharDiff('a' - 'A'); for (size_t i=0; i < fBufferLen; ++i) @@ -322,8 +324,8 @@ public: if (fBuffer[i] >= 'a' && fBuffer[i] <= 'z') fBuffer[i] -= kCharDiff; } - } #endif + } // ------------------------------------------------------------------- // public operators diff --git a/source/utils/CarlaUtils.hpp b/source/utils/CarlaUtils.hpp index 314130525..bb41217c1 100644 --- a/source/utils/CarlaUtils.hpp +++ b/source/utils/CarlaUtils.hpp @@ -131,7 +131,7 @@ void carla_assert_int2(const char* const assertion, const char* const file, cons static inline void carla_sleep(const unsigned int secs) { - CARLA_ASSERT(secs > 0); + CARLA_SAFE_ASSERT_RETURN(secs > 0,); #ifdef CARLA_OS_WIN Sleep(secs * 1000); @@ -143,7 +143,7 @@ void carla_sleep(const unsigned int secs) static inline void carla_msleep(const unsigned int msecs) { - CARLA_ASSERT(msecs > 0); + CARLA_SAFE_ASSERT_RETURN(msecs > 0,); #ifdef CARLA_OS_WIN Sleep(msecs); @@ -158,8 +158,8 @@ void carla_msleep(const unsigned int msecs) static inline void carla_setenv(const char* const key, const char* const value) { - CARLA_ASSERT(key != nullptr); - CARLA_ASSERT(value != nullptr); + CARLA_SAFE_ASSERT_RETURN(key != nullptr,); + CARLA_SAFE_ASSERT_RETURN(value != nullptr,); #ifdef CARLA_OS_WIN SetEnvironmentVariableA(key, value); @@ -174,7 +174,7 @@ void carla_setenv(const char* const key, const char* const value) static inline void carla_setprocname(const char* const name) { - CARLA_ASSERT(name != nullptr); + CARLA_SAFE_ASSERT_RETURN(name != nullptr,); #if defined(CARLA_OS_HAIKU) if ((thread_id this_thread = find_thread(nullptr)) != B_NAME_NOT_FOUND) @@ -199,7 +199,7 @@ void carla_setprocname(const char* const name) static inline const char* carla_strdup(const char* const strBuf) { - CARLA_ASSERT(strBuf != nullptr); + CARLA_SAFE_ASSERT(strBuf != nullptr); const size_t bufferLen = (strBuf != nullptr) ? std::strlen(strBuf) : 0; char* const buffer = new char[bufferLen+1]; @@ -241,7 +241,7 @@ template static inline const T& carla_fixValue(const T& min, const T& max, const T& value) { - CARLA_ASSERT(max > min); + CARLA_SAFE_ASSERT_RETURN(max > min, max); if (value <= min) return min; @@ -254,12 +254,9 @@ template static inline void carla_add(T* dataDst, T* dataSrc, const size_t size) { - CARLA_ASSERT(dataDst != nullptr); - CARLA_ASSERT(dataSrc != nullptr); - CARLA_ASSERT(size != 0); - - if (dataDst == nullptr || dataSrc == nullptr || size == 0) - return; + CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,); + CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,); + CARLA_SAFE_ASSERT_RETURN(size != 0,); for (size_t i=0; i < size; ++i) *dataDst++ += *dataSrc++; @@ -269,12 +266,9 @@ template static inline void carla_add(T* dataDst, const T* dataSrc, const size_t size) { - CARLA_ASSERT(dataDst != nullptr); - CARLA_ASSERT(dataSrc != nullptr); - CARLA_ASSERT(size != 0); - - if (dataDst == nullptr || dataSrc == nullptr || size == 0) - return; + CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,); + CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,); + CARLA_SAFE_ASSERT_RETURN(size != 0,); for (size_t i=0; i < size; ++i) *dataDst++ += *dataSrc++; @@ -284,12 +278,9 @@ template static inline void carla_copy(T* dataDst, T* dataSrc, const size_t size) { - CARLA_ASSERT(dataDst != nullptr); - CARLA_ASSERT(dataSrc != nullptr); - CARLA_ASSERT(size != 0); - - if (dataDst == nullptr || dataSrc == nullptr || size == 0) - return; + CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,); + CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,); + CARLA_SAFE_ASSERT_RETURN(size != 0,); for (size_t i=0; i < size; ++i) *dataDst++ = *dataSrc++; @@ -299,12 +290,9 @@ template static inline void carla_copy(T* dataDst, const T* dataSrc, const size_t size) { - CARLA_ASSERT(dataDst != nullptr); - CARLA_ASSERT(dataSrc != nullptr); - CARLA_ASSERT(size != 0); - - if (dataDst == nullptr || dataSrc == nullptr || size == 0) - return; + CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,); + CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,); + CARLA_SAFE_ASSERT_RETURN(size != 0,); for (size_t i=0; i < size; ++i) *dataDst++ = *dataSrc++; @@ -314,11 +302,8 @@ template static inline void carla_fill(T* data, const size_t size, const T v) { - CARLA_ASSERT(data != nullptr); - CARLA_ASSERT(size != 0); - - if (data == nullptr || size == 0) - return; + CARLA_SAFE_ASSERT_RETURN(data != nullptr,); + CARLA_SAFE_ASSERT_RETURN(size != 0,); for (size_t i=0; i < size; ++i) *data++ = v; @@ -339,9 +324,9 @@ void carla_addFloat(float* const dataDst, float* const dataSrc, const size_t siz static inline void carla_copyDouble(double* const dataDst, double* const dataSrc, const size_t size) { - CARLA_ASSERT(dataDst != nullptr); - CARLA_ASSERT(dataSrc != nullptr); - CARLA_ASSERT(size > 0); + CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,); + CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,); + CARLA_SAFE_ASSERT_RETURN(size > 0,); std::memcpy(dataDst, dataSrc, size*sizeof(double)); } @@ -349,9 +334,9 @@ void carla_copyDouble(double* const dataDst, double* const dataSrc, const size_t static inline void carla_copyFloat(float* const dataDst, float* const dataSrc, const size_t size) { - CARLA_ASSERT(dataDst != nullptr); - CARLA_ASSERT(dataSrc != nullptr); - CARLA_ASSERT(size > 0); + CARLA_SAFE_ASSERT_RETURN(dataDst != nullptr,); + CARLA_SAFE_ASSERT_RETURN(dataSrc != nullptr,); + CARLA_SAFE_ASSERT_RETURN(size > 0,); std::memcpy(dataDst, dataSrc, size*sizeof(float)); } @@ -388,11 +373,8 @@ inline float static inline void carla_zeroMem(void* const memory, const size_t numBytes) { - CARLA_ASSERT(memory != nullptr); - CARLA_ASSERT(numBytes != 0); - - if (memory == nullptr || numBytes == 0) - return; + CARLA_SAFE_ASSERT_RETURN(memory != nullptr,); + CARLA_SAFE_ASSERT_RETURN(numBytes != 0,); std::memset(memory, 0, numBytes); } @@ -408,8 +390,8 @@ template static inline void carla_zeroStruct(T* const structure, const size_t count) { - CARLA_ASSERT(structure != nullptr); - CARLA_ASSERT(count >= 1); + CARLA_SAFE_ASSERT_RETURN(structure != nullptr,); + CARLA_SAFE_ASSERT_RETURN(count != 0,); std::memset(structure, 0, sizeof(T)*count); } diff --git a/source/utils/Lv2AtomQueue.hpp b/source/utils/Lv2AtomQueue.hpp index 96ae384c8..c8ffac0e6 100644 --- a/source/utils/Lv2AtomQueue.hpp +++ b/source/utils/Lv2AtomQueue.hpp @@ -21,6 +21,8 @@ #include "CarlaLv2Utils.hpp" #include "CarlaMutex.hpp" +// ----------------------------------------------------------------------- + class Lv2AtomQueue { public: diff --git a/source/utils/RtList.hpp b/source/utils/RtList.hpp index b90ddcb41..7d1cab23c 100644 --- a/source/utils/RtList.hpp +++ b/source/utils/RtList.hpp @@ -12,11 +12,11 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * For a full copy of the GNU General Public License see the GPL.txt file + * For a full copy of the GNU General Public License see the doc/GPL.txt file. */ -#ifndef __RT_LIST_HPP__ -#define __RT_LIST_HPP__ +#ifndef RT_LIST_HPP_INCLUDED +#define RT_LIST_HPP_INCLUDED #include "CarlaUtils.hpp" @@ -137,7 +137,7 @@ public: { if (Data* const data = _allocate()) { - std::memcpy(&data->value, &value, sizeof(T)); + data->value = value; list_add_tail(&data->siblings, &fQueue); ++fCount; return true; @@ -150,7 +150,7 @@ public: { if (Data* const data = _allocate()) { - std::memcpy(&data->value, &value, sizeof(T)); + data->value = value; list_add_tail(&data->siblings, it.fEntry->next); ++fCount; return true; @@ -163,7 +163,7 @@ public: { if (Data* const data = _allocate()) { - std::memcpy(&data->value, &value, sizeof(T)); + data->value = value; list_add(&data->siblings, &fQueue); ++fCount; return true; @@ -176,7 +176,7 @@ public: { if (Data* const data = _allocate()) { - std::memcpy(&data->value, &value, sizeof(T)); + data->value = value; list_add(&data->siblings, it.fEntry->prev); ++fCount; return true; @@ -461,7 +461,7 @@ public: { if (typename List::Data* const data = _allocate_sleepy()) { - std::memcpy(&data->value, &value, sizeof(T)); + data->value = value; list_add_tail(&data->siblings, &this->fQueue); ++this->fCount; } @@ -471,7 +471,7 @@ public: { if (typename List::Data* const data = _allocate_sleepy()) { - std::memcpy(&data->value, &value, sizeof(T)); + data->value = value; list_add(&data->siblings, &this->fQueue); ++this->fCount; } @@ -584,6 +584,4 @@ private: LIST_DECLARATIONS(NonRtListNew) }; -// ----------------------------------------------------------------------- - -#endif // __RT_LIST_HPP__ +#endif // RT_LIST_HPP_INCLUDED