Browse Source

More plugin-bridge work

tags/1.9.6
falkTX 10 years ago
parent
commit
503314968f
10 changed files with 313 additions and 349 deletions
  1. +1
    -13
      source/backend/CarlaEngine.hpp
  2. +1
    -13
      source/backend/engine/CarlaEngine.cpp
  3. +0
    -7
      source/backend/engine/CarlaEngineBridge.cpp
  4. +1
    -1
      source/backend/engine/CarlaEngineOsc.hpp
  5. +4
    -3
      source/backend/engine/CarlaEngineThread.cpp
  6. +1
    -1
      source/backend/plugin/CarlaPlugin.cpp
  7. +295
    -230
      source/backend/plugin/CarlaPluginBridge.cpp
  8. +0
    -6
      source/backend/plugin/CarlaPluginDSSI.cpp
  9. +10
    -72
      source/bridges-plugin/CarlaBridgePlugin.cpp
  10. +0
    -3
      source/utils/CarlaBridgeUtils.hpp

+ 1
- 13
source/backend/CarlaEngine.hpp View File

@@ -1006,12 +1006,7 @@ public:
// -------------------------------------------------------------------
// OSC Stuff

#ifdef BUILD_BRIDGE
/*!
* Check if OSC bridge is registered.
*/
bool isOscBridgeRegistered() const noexcept;
#else
#ifndef BUILD_BRIDGE
/*!
* Check if OSC controller is registered.
*/
@@ -1033,13 +1028,6 @@ public:
*/
const char* getOscServerPathUDP() const noexcept;

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

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



+ 1
- 13
source/backend/engine/CarlaEngine.cpp View File

@@ -1420,12 +1420,7 @@ void CarlaEngine::setOption(const EngineOption option, const int value, const ch
// -----------------------------------------------------------------------
// OSC Stuff

#ifdef BUILD_BRIDGE
bool CarlaEngine::isOscBridgeRegistered() const noexcept
{
return (pData->oscData != nullptr);
}
#else
#ifndef BUILD_BRIDGE
bool CarlaEngine::isOscControlRegistered() const noexcept
{
return pData->osc.isControlRegistered();
@@ -1447,13 +1442,6 @@ const char* CarlaEngine::getOscServerPathUDP() const noexcept
return pData->osc.getServerPathUDP();
}

#ifdef BUILD_BRIDGE
void CarlaEngine::setOscBridgeData(CarlaOscData* const oscData) const noexcept
{
pData->oscData = oscData;
}
#endif

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



+ 0
- 7
source/backend/engine/CarlaEngineBridge.cpp View File

@@ -788,13 +788,6 @@ protected:
break;
}

case kPluginBridgeRtClientSetCVPool: {
const uint64_t poolSize(fShmRtClientControl.readULong());
CARLA_SAFE_ASSERT_BREAK(poolSize > 0);
//fShmCVPool.data = (float*)jackbridge_shm_map(fShmCVPool.shm, static_cast<size_t>(poolSize));
break;
}

case kPluginBridgeRtClientControlEventParameter: {
const uint32_t time(fShmRtClientControl.readUInt());
const uint8_t channel(fShmRtClientControl.readByte());


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

@@ -110,6 +110,7 @@ private:
#ifndef BUILD_BRIDGE
int handleMsgRegister(const bool isTCP, const int argc, const lo_arg* const* const argv, const char* const types, const lo_address source);
int handleMsgUnregister();
#endif

// Internal methods
int handleMsgSetActive(CARLA_ENGINE_OSC_HANDLE_ARGS);
@@ -125,7 +126,6 @@ private:
int handleMsgSetMidiProgram(CARLA_ENGINE_OSC_HANDLE_ARGS);
int handleMsgNoteOn(CARLA_ENGINE_OSC_HANDLE_ARGS);
int handleMsgNoteOff(CARLA_ENGINE_OSC_HANDLE_ARGS);
#endif

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



+ 4
- 3
source/backend/engine/CarlaEngineThread.cpp View File

@@ -47,12 +47,13 @@ void CarlaEngineThread::run() noexcept

bool needsSingleThread, needsUiUpdates, oscRegisted;
float value;
#ifdef BUILD_BRIDGE
oscRegisted = false;
#endif

for (; kEngine->isRunning() && ! shouldThreadExit();)
{
#ifdef BUILD_BRIDGE
oscRegisted = kEngine->isOscBridgeRegistered();
#else
#ifndef BUILD_BRIDGE
oscRegisted = kEngine->isOscControlRegistered();
#endif



+ 1
- 1
source/backend/plugin/CarlaPlugin.cpp View File

@@ -1431,7 +1431,7 @@ void CarlaPlugin::clearBuffers() noexcept
void CarlaPlugin::registerToOscClient() noexcept
{
#ifdef BUILD_BRIDGE
if (! pData->engine->isOscBridgeRegistered())
return;
#else
if (! pData->engine->isOscControlRegistered())
#endif


+ 295
- 230
source/backend/plugin/CarlaPluginBridge.cpp
File diff suppressed because it is too large
View File


+ 0
- 6
source/backend/plugin/CarlaPluginDSSI.cpp View File

@@ -130,12 +130,6 @@ public:

StringArray arguments;

#ifndef CARLA_OS_WIN
// start with "wine" if needed
if (fBinary.endsWith(".exe"))
arguments.add("wine");
#endif

// binary
arguments.add(fBinary.buffer());



+ 10
- 72
source/bridges-plugin/CarlaBridgePlugin.cpp View File

@@ -205,57 +205,7 @@ public:

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

void oscInit(const char* const url)
{
fOscServerThread = lo_server_thread_new_with_proto(nullptr, LO_UDP, osc_error_handler);

CARLA_SAFE_ASSERT_RETURN(fOscServerThread != nullptr,)

{
char* const host = lo_url_get_hostname(url);
char* const port = lo_url_get_port(url);
fOscControlData.path = carla_strdup_free(lo_url_get_path(url));
fOscControlData.target = lo_address_new_with_proto(LO_UDP, host, port);

std::free(host);
std::free(port);
}

if (char* const tmpServerPath = lo_server_thread_get_url(fOscServerThread))
{
std::srand((uint)(uintptr_t)this);
std::srand((uint)(uintptr_t)&url);

CarlaString oscName("plug-" + CarlaString(std::rand() % 99999));

fOscServerPath = tmpServerPath;
fOscServerPath += oscName;
std::free(tmpServerPath);
}

lo_server_thread_start(fOscServerThread);

fEngine->setOscBridgeData(&fOscControlData);
}

void oscClose()
{
lo_server_thread_stop(fOscServerThread);

fEngine->setOscBridgeData(nullptr);

if (fOscServerThread != nullptr)
{
lo_server_thread_free(fOscServerThread);
fOscServerThread = nullptr;
}

fOscControlData.clear();
fOscServerPath.clear();
}

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

/*
void sendOscUpdate() const noexcept
{
if (fOscControlData.target != nullptr)
@@ -273,6 +223,7 @@ public:
if (fOscControlData.target != nullptr)
osc_send_bridge_error(fOscControlData, error);
}
*/

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

@@ -377,9 +328,9 @@ int main(int argc, char* argv[])
// ---------------------------------------------------------------------
// Check argument count

if (argc != 5)
if (argc != 4 && argc != 5)
{
carla_stdout("usage: %s <type> <filename> <label> <uniqueId>", argv[0]);
carla_stdout("usage: %s <type> <filename> <label> [uniqueId]", argv[0]);
return 1;
}

@@ -389,7 +340,7 @@ int main(int argc, char* argv[])
const char* const stype = argv[1];
const char* const filename = argv[2];
const char* label = argv[3];
const int64_t uniqueId = static_cast<int64_t>(std::atoll(argv[4]));
const int64_t uniqueId = (argc == 5) ? static_cast<int64_t>(std::atoll(argv[4])) : 0;

// ---------------------------------------------------------------------
// Check plugin type
@@ -413,10 +364,9 @@ int main(int argc, char* argv[])
// ---------------------------------------------------------------------
// Setup options

const char* const oscUrl(std::getenv("ENGINE_BRIDGE_OSC_URL"));
const char* const shmIds(std::getenv("ENGINE_BRIDGE_SHM_IDS"));

const bool useBridge = (shmIds != nullptr && oscUrl != nullptr);
const bool useBridge = (shmIds != nullptr);

// ---------------------------------------------------------------------
// Setup bridge ids
@@ -479,12 +429,6 @@ int main(int argc, char* argv[])
return 1;
}

// ---------------------------------------------------------------------
// Init OSC

if (useBridge)
bridge.oscInit(oscUrl);

// ---------------------------------------------------------------------
// Listen for ctrl+c or sigint/sigterm events

@@ -501,8 +445,8 @@ int main(int argc, char* argv[])

if (useBridge)
{
bridge.sendOscUpdate();
bridge.sendOscBridgeUpdate();
//bridge.sendOscUpdate();
//bridge.sendOscBridgeUpdate();
}
else
{
@@ -524,15 +468,9 @@ int main(int argc, char* argv[])
const char* const lastError(carla_get_last_error());
carla_stderr("Plugin failed to load, error was:\n%s", lastError);

if (useBridge)
bridge.sendOscBridgeError(lastError);
//if (useBridge)
// bridge.sendOscBridgeError(lastError);
}

// ---------------------------------------------------------------------
// Close OSC

if (useBridge)
bridge.oscClose();

return ret;
}

+ 0
- 3
source/utils/CarlaBridgeUtils.hpp View File

@@ -26,7 +26,6 @@
enum PluginBridgeRtClientOpcode {
kPluginBridgeRtClientNull = 0,
kPluginBridgeRtClientSetAudioPool, // ulong/ptr
kPluginBridgeRtClientSetCVPool, // ulong/ptr
kPluginBridgeRtClientControlEventParameter, // uint/frame, byte/chan, ushort, float
kPluginBridgeRtClientControlEventMidiBank, // uint/frame, byte/chan, ushort
kPluginBridgeRtClientControlEventMidiProgram, // uint/frame, byte/chan, ushort
@@ -156,8 +155,6 @@ const char* PluginBridgeRtClientOpcode2str(const PluginBridgeRtClientOpcode opco
return "kPluginBridgeRtClientNull";
case kPluginBridgeRtClientSetAudioPool:
return "kPluginBridgeRtClientSetAudioPool";
case kPluginBridgeRtClientSetCVPool:
return "kPluginBridgeRtClientSetCVPool";
case kPluginBridgeRtClientControlEventParameter:
return "kPluginBridgeRtClientControlEventParameter";
case kPluginBridgeRtClientControlEventMidiBank:


Loading…
Cancel
Save