@@ -230,9 +230,9 @@ struct CARLA_API EngineEvent { | |||
* Engine options. | |||
*/ | |||
struct CARLA_API EngineOptions { | |||
EngineProcessMode processMode; | |||
EngineProcessMode processMode; | |||
EngineTransportMode transportMode; | |||
const char* transportExtra; | |||
const char* transportExtra; | |||
bool forceStereo; | |||
bool preferPluginBridges; | |||
@@ -620,18 +620,14 @@ protected: | |||
#endif | |||
}; | |||
// ----------------------------------------------------------------------- | |||
/*! | |||
* Carla Engine Meta CV port. | |||
* Carla Engine Meta CV Port. | |||
* FIXME needs a better name... | |||
*/ | |||
class CARLA_API CarlaEngineCVSourcePorts | |||
{ | |||
protected: | |||
/*! | |||
* The constructor, protected. | |||
*/ | |||
CarlaEngineCVSourcePorts(); | |||
public: | |||
/*! | |||
* The destructor. | |||
@@ -662,9 +658,15 @@ public: | |||
#ifndef DOXYGEN | |||
protected: | |||
/** @internal */ | |||
struct ProtectedData; | |||
ProtectedData* const pData; | |||
/*! | |||
* The constructor, protected. | |||
*/ | |||
CarlaEngineCVSourcePorts(); | |||
CARLA_DECLARE_NON_COPY_CLASS(CarlaEngineCVSourcePorts) | |||
#endif | |||
}; | |||
@@ -672,7 +674,7 @@ protected: | |||
// ----------------------------------------------------------------------- | |||
/*! | |||
* Carla Engine client. | |||
* Carla Engine Client. | |||
* Each plugin requires one client from the engine (created via CarlaEngine::addClient()). | |||
* @note This is a virtual class, some engine types provide custom functionality. | |||
*/ | |||
@@ -764,9 +766,7 @@ public: | |||
#ifndef DOXYGEN | |||
protected: | |||
/*! | |||
* Internal data, for CarlaEngineClient subclasses only. | |||
*/ | |||
/** @internal */ | |||
struct ProtectedData; | |||
ProtectedData* const pData; | |||
@@ -379,7 +379,14 @@ void CarlaEngine::idle() noexcept | |||
CarlaEngineClient* CarlaEngine::addClient(CarlaPlugin* const plugin) | |||
{ | |||
return new CarlaEngineClient2(*this, pData->graph, plugin); | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
return new CarlaEngineClientForStandalone(*this, pData->graph, plugin); | |||
#else | |||
return new CarlaEngineClientForBridge(*this); | |||
// unused | |||
(void)plugin; | |||
#endif | |||
} | |||
float CarlaEngine::getDSPLoad() const noexcept | |||
@@ -19,7 +19,7 @@ | |||
# error This file should not be compiled if not building bridge | |||
#endif | |||
#include "CarlaEngineInternal.hpp" | |||
#include "CarlaEngineClient.hpp" | |||
#include "CarlaPlugin.hpp" | |||
#include "CarlaBackendUtils.hpp" | |||
@@ -62,12 +62,18 @@ struct LatencyChangedCallback { | |||
virtual void latencyChanged(const uint32_t samples) noexcept = 0; | |||
}; | |||
class CarlaEngineBridgeClient : public CarlaEngineClient | |||
class CarlaEngineBridgeClient : public CarlaEngineClientForSubclassing | |||
{ | |||
public: | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
CarlaEngineBridgeClient(const CarlaEngine& engine, EngineInternalGraph& egraph, CarlaPlugin* const plugin, LatencyChangedCallback* const cb) | |||
: CarlaEngineClientForSubclassing(engine, egraph, plugin), | |||
fLatencyCallback(cb) {} | |||
#else | |||
CarlaEngineBridgeClient(const CarlaEngine& engine, LatencyChangedCallback* const cb) | |||
: CarlaEngineClient(engine), | |||
: CarlaEngineClientForSubclassing(engine), | |||
fLatencyCallback(cb) {} | |||
#endif | |||
protected: | |||
void setLatency(const uint32_t samples) noexcept override | |||
@@ -287,9 +293,13 @@ public: | |||
fShmNonRtServerControl.commitWrite(); | |||
} | |||
CarlaEngineClient* addClient(CarlaPlugin* const) override | |||
CarlaEngineClient* addClient(CarlaPlugin* const plugin) override | |||
{ | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
return new CarlaEngineBridgeClient(*this, pData->graph, plugin, this); | |||
#else | |||
return new CarlaEngineBridgeClient(*this, this); | |||
#endif | |||
} | |||
void idle() noexcept override | |||
@@ -22,24 +22,8 @@ | |||
CARLA_BACKEND_START_NAMESPACE | |||
CarlaEngineClient2::CarlaEngineClient2(const CarlaEngine& engine, EngineInternalGraph& egraph, CarlaPlugin* const plugin) | |||
: CarlaEngineClient(new ProtectedData(engine, egraph, plugin)) | |||
{ | |||
} | |||
CarlaEngineClient2::~CarlaEngineClient2() | |||
{ | |||
} | |||
PatchbayGraph* CarlaEngineClient2::getPatchbayGraph() const noexcept | |||
{ | |||
return pData->egraph.getPatchbayGraph(); | |||
} | |||
CarlaPlugin* CarlaEngineClient2::getPlugin() const noexcept | |||
{ | |||
return pData->plugin; | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine Client | |||
CarlaEngineClient::CarlaEngineClient(ProtectedData* const p) | |||
: pData(p) | |||
@@ -49,10 +33,7 @@ CarlaEngineClient::CarlaEngineClient(ProtectedData* const p) | |||
CarlaEngineClient::~CarlaEngineClient() noexcept | |||
{ | |||
CARLA_SAFE_ASSERT(! pData->active); | |||
carla_debug("CarlaEngineClient::~CarlaEngineClient()"); | |||
delete pData; | |||
} | |||
void CarlaEngineClient::activate() noexcept | |||
@@ -289,11 +270,6 @@ void CarlaEngineClient::_clearPorts() | |||
pData->eventOutList.clear(); | |||
} | |||
// void* CarlaEngineClient::_getNode() const noexcept | |||
// { | |||
// return pData->node; | |||
// } | |||
// ----------------------------------------------------------------------- | |||
CARLA_BACKEND_END_NAMESPACE |
@@ -19,35 +19,14 @@ | |||
#define CARLA_ENGINE_CLIENT_HPP_INCLUDED | |||
#include "CarlaEngine.hpp" | |||
#include "CarlaEngineInternal.hpp" | |||
#include "CarlaEnginePorts.hpp" | |||
#include "CarlaStringList.hpp" | |||
CARLA_BACKEND_START_NAMESPACE | |||
class EngineInternalGraph; | |||
class PatchbayGraph; | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine Meta CV port | |||
class CarlaEngineCVSourcePorts2 : public CarlaEngineCVSourcePorts | |||
{ | |||
public: | |||
CarlaEngineCVSourcePorts2() : CarlaEngineCVSourcePorts() {} | |||
~CarlaEngineCVSourcePorts2() override {} | |||
void setGraphAndPlugin(PatchbayGraph* const graph, CarlaPlugin* const plugin) noexcept | |||
{ | |||
pData->graph = graph; | |||
pData->plugin = plugin; | |||
} | |||
}; | |||
#endif | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine client (Abstract) | |||
// Carla Engine Client Protected Data | |||
struct CarlaEngineClient::ProtectedData { | |||
const CarlaEngine& engine; | |||
@@ -56,7 +35,7 @@ struct CarlaEngineClient::ProtectedData { | |||
uint32_t latency; | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
CarlaEngineCVSourcePorts2 cvSourcePorts; | |||
CarlaEngineCVSourcePortsForStandalone cvSourcePorts; | |||
EngineInternalGraph& egraph; | |||
CarlaPlugin* const plugin; | |||
#endif | |||
@@ -68,7 +47,11 @@ struct CarlaEngineClient::ProtectedData { | |||
CarlaStringList eventInList; | |||
CarlaStringList eventOutList; | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
ProtectedData(const CarlaEngine& eng, EngineInternalGraph& eg, CarlaPlugin* const p) noexcept | |||
#else | |||
ProtectedData(const CarlaEngine& eng) noexcept | |||
#endif | |||
: engine(eng), | |||
active(false), | |||
latency(0), | |||
@@ -91,17 +74,50 @@ struct CarlaEngineClient::ProtectedData { | |||
}; | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine Client | |||
class CarlaEngineClient2 : public CarlaEngineClient | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
class CarlaEngineClientForStandalone : public CarlaEngineClient | |||
{ | |||
public: | |||
CarlaEngineClient2(const CarlaEngine& engine, EngineInternalGraph& egraph, CarlaPlugin* const plugin); | |||
virtual ~CarlaEngineClient2() override; | |||
CarlaEngineClientForStandalone(const CarlaEngine& engine, EngineInternalGraph& egraph, CarlaPlugin* const plugin) | |||
: CarlaEngineClient(new ProtectedData(engine, egraph, plugin)) {} | |||
~CarlaEngineClientForStandalone() override | |||
{ | |||
delete pData; | |||
} | |||
protected: | |||
PatchbayGraph* getPatchbayGraph() const noexcept; | |||
CarlaPlugin* getPlugin() const noexcept; | |||
inline PatchbayGraph* getPatchbayGraph() const noexcept | |||
{ | |||
return pData->egraph.getPatchbayGraph(); | |||
} | |||
inline CarlaPlugin* getPlugin() const noexcept | |||
{ | |||
return pData->plugin; | |||
} | |||
CARLA_DECLARE_NON_COPY_CLASS(CarlaEngineClientForStandalone) | |||
}; | |||
typedef CarlaEngineClientForStandalone CarlaEngineClientForSubclassing; | |||
#else | |||
class CarlaEngineClientForBridge : public CarlaEngineClient | |||
{ | |||
public: | |||
CarlaEngineClientForBridge(const CarlaEngine& engine) | |||
: CarlaEngineClient(new ProtectedData(engine)) {} | |||
~CarlaEngineClientForBridge() override | |||
{ | |||
delete pData; | |||
} | |||
CARLA_DECLARE_NON_COPY_CLASS(CarlaEngineClientForBridge) | |||
}; | |||
typedef CarlaEngineClientForBridge CarlaEngineClientForSubclassing; | |||
#endif | |||
// ----------------------------------------------------------------------- | |||
@@ -211,31 +211,6 @@ struct EnginePluginData { | |||
float peaks[4]; | |||
}; | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
// ----------------------------------------------------------------------- | |||
// CarlaEngineEventPortProtectedData | |||
struct CarlaEngineEventCV { | |||
CarlaEngineCVPort* cvPort; | |||
uint32_t indexOffset; | |||
float previousValue; | |||
}; | |||
struct CarlaEngineCVSourcePorts::ProtectedData { | |||
CarlaRecursiveMutex rmutex; | |||
EngineEvent* buffer; | |||
water::Array<CarlaEngineEventCV> cvs; | |||
PatchbayGraph* graph; | |||
CarlaPlugin* plugin; | |||
ProtectedData(); | |||
~ProtectedData(); | |||
CARLA_DECLARE_NON_COPY_STRUCT(ProtectedData) | |||
}; | |||
#endif | |||
// ----------------------------------------------------------------------- | |||
// CarlaEngineProtectedData | |||
@@ -523,12 +523,17 @@ public: | |||
// ----------------------------------------------------------------------- | |||
// Jack Engine client | |||
class CarlaEngineJackClient : public CarlaEngineClient2, | |||
class CarlaEngineJackClient : public CarlaEngineClientForSubclassing, | |||
private JackPortDeletionCallback | |||
{ | |||
public: | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
CarlaEngineJackClient(const CarlaEngine& engine, EngineInternalGraph& egraph, CarlaPlugin* const plugin, jack_client_t* const jackClient) | |||
: CarlaEngineClient2(engine, egraph, plugin), | |||
: CarlaEngineClientForSubclassing(engine, egraph, plugin), | |||
#else | |||
CarlaEngineJackClient(const CarlaEngine& engine, jack_client_t* const jackClient) | |||
: CarlaEngineClientForSubclassing(engine), | |||
#endif | |||
fJackClient(jackClient), | |||
fUseClient(engine.getProccessMode() == ENGINE_PROCESS_MODE_SINGLE_CLIENT || engine.getProccessMode() == ENGINE_PROCESS_MODE_MULTIPLE_CLIENTS), | |||
fAudioPorts(), | |||
@@ -1445,7 +1450,11 @@ public: | |||
#endif | |||
} | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
return new CarlaEngineJackClient(*this, pData->graph, plugin, client); | |||
#else | |||
return new CarlaEngineJackClient(*this, client); | |||
#endif | |||
} | |||
#ifndef BUILD_BRIDGE | |||
@@ -15,7 +15,7 @@ | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#include "CarlaEngineInternal.hpp" | |||
#include "CarlaEnginePorts.hpp" | |||
#include "CarlaEngineGraph.hpp" | |||
#include "CarlaEngineUtils.hpp" | |||
#include "CarlaMathUtils.hpp" | |||
@@ -327,35 +327,6 @@ bool CarlaEngineEventPort::writeMidiEvent(const uint32_t time, const uint8_t cha | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine Meta CV port | |||
CarlaEngineCVSourcePorts::ProtectedData::ProtectedData() | |||
: rmutex(), | |||
buffer(nullptr), | |||
cvs(), | |||
graph(nullptr), | |||
plugin(nullptr) | |||
{ | |||
} | |||
CarlaEngineCVSourcePorts::ProtectedData::~ProtectedData() | |||
{ | |||
const CarlaRecursiveMutexLocker crml(rmutex); | |||
carla_stdout("CarlaEngineCVSourcePorts::ProtectedData::~ProtectedData size %i", cvs.size()); | |||
/* | |||
for (int i = cvs.size(); --i >= 0;) | |||
delete cvs[i].cvPort; | |||
*/ | |||
cvs.clear(); | |||
if (buffer != nullptr) | |||
{ | |||
delete[] buffer; | |||
buffer = nullptr; | |||
} | |||
} | |||
CarlaEngineCVSourcePorts::CarlaEngineCVSourcePorts() | |||
: pData(new ProtectedData()) | |||
{ | |||
@@ -382,7 +353,7 @@ bool CarlaEngineCVSourcePorts::addCVSource(CarlaEngineCVPort* const port, const | |||
return false; | |||
if (pData->graph != nullptr && pData->plugin != nullptr) | |||
pData->graph->reconfigureForCV(pData->plugin, pData->cvs.size()-1, true); | |||
pData->graph->reconfigureForCV(pData->plugin, static_cast<uint>(pData->cvs.size()-1), true); | |||
/* | |||
if (pData->buffer == nullptr) | |||
@@ -407,7 +378,7 @@ bool CarlaEngineCVSourcePorts::removeCVSource(const uint32_t portIndexOffset) | |||
if (ecv.indexOffset == portIndexOffset) | |||
{ | |||
if (pData->graph != nullptr && pData->plugin != nullptr) | |||
pData->graph->reconfigureForCV(pData->plugin, i, false); | |||
pData->graph->reconfigureForCV(pData->plugin, static_cast<uint>(i), false); | |||
carla_stdout("found cv source to remove %u", portIndexOffset); | |||
delete ecv.cvPort; | |||
@@ -0,0 +1,96 @@ | |||
/* | |||
* Carla Plugin Host | |||
* Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
* published by the Free Software Foundation; either version 2 of | |||
* the License, or any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* 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 doc/GPL.txt file. | |||
*/ | |||
#ifndef CARLA_ENGINE_PORTS_HPP_INCLUDED | |||
#define CARLA_ENGINE_PORTS_HPP_INCLUDED | |||
#include "CarlaEngine.hpp" | |||
#include "CarlaEngineInternal.hpp" | |||
CARLA_BACKEND_START_NAMESPACE | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine Meta CV Port Protected Data | |||
struct CarlaEngineEventCV { | |||
CarlaEngineCVPort* cvPort; | |||
uint32_t indexOffset; | |||
float previousValue; | |||
}; | |||
struct CarlaEngineCVSourcePorts::ProtectedData { | |||
CarlaRecursiveMutex rmutex; | |||
EngineEvent* buffer; | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
PatchbayGraph* graph; | |||
CarlaPlugin* plugin; | |||
#endif | |||
water::Array<CarlaEngineEventCV> cvs; | |||
ProtectedData() noexcept | |||
: rmutex(), | |||
buffer(nullptr), | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
graph(nullptr), | |||
plugin(nullptr), | |||
#endif | |||
cvs() {} | |||
~ProtectedData() | |||
{ | |||
{ | |||
const CarlaRecursiveMutexLocker crml(rmutex); | |||
for (int i = cvs.size(); --i >= 0;) | |||
delete cvs[i].cvPort; | |||
cvs.clear(); | |||
} | |||
if (buffer != nullptr) | |||
{ | |||
delete[] buffer; | |||
buffer = nullptr; | |||
} | |||
} | |||
CARLA_DECLARE_NON_COPY_STRUCT(ProtectedData) | |||
}; | |||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | |||
// ----------------------------------------------------------------------- | |||
// Carla Engine Meta CV Port | |||
class CarlaEngineCVSourcePortsForStandalone : public CarlaEngineCVSourcePorts | |||
{ | |||
public: | |||
CarlaEngineCVSourcePortsForStandalone() : CarlaEngineCVSourcePorts() {} | |||
~CarlaEngineCVSourcePortsForStandalone() override {} | |||
inline void setGraphAndPlugin(PatchbayGraph* const graph, CarlaPlugin* const plugin) noexcept | |||
{ | |||
pData->graph = graph; | |||
pData->plugin = plugin; | |||
} | |||
}; | |||
#endif | |||
// ----------------------------------------------------------------------- | |||
CARLA_BACKEND_END_NAMESPACE | |||
#endif // CARLA_ENGINE_PORTS_HPP_INCLUDED |