Browse Source

Carla: Rework OSC to support both UDP & TCP (DSSI UIs need UDP)

tags/v0.9.0
falkTX 13 years ago
parent
commit
51c45f33e3
16 changed files with 109 additions and 73 deletions
  1. +1
    -1
      c++/carla-backend/carla_backend_standalone.cpp
  2. +1
    -1
      c++/carla-backend/carla_bridge.cpp
  3. +10
    -5
      c++/carla-backend/carla_engine.cpp
  4. +3
    -2
      c++/carla-backend/carla_engine.h
  5. +2
    -2
      c++/carla-backend/carla_native.cpp
  6. +40
    -27
      c++/carla-backend/carla_osc.cpp
  7. +16
    -9
      c++/carla-backend/carla_osc.h
  8. +12
    -4
      c++/carla-backend/carla_plugin.h
  9. +11
    -9
      c++/carla-backend/carla_threads.cpp
  10. +2
    -2
      c++/carla-backend/dssi.cpp
  11. +2
    -2
      c++/carla-backend/fluidsynth.cpp
  12. +1
    -1
      c++/carla-backend/ladspa.cpp
  13. +2
    -2
      c++/carla-backend/linuxsampler.cpp
  14. +2
    -2
      c++/carla-backend/lv2.cpp
  15. +2
    -2
      c++/carla-backend/vst.cpp
  16. +2
    -2
      c++/carla-bridge/carla_bridge_osc.cpp

+ 1
- 1
c++/carla-backend/carla_backend_standalone.cpp View File

@@ -1239,7 +1239,7 @@ const char* get_host_osc_url()
{
qDebug("CarlaBackendStandalone::get_host_osc_url()");

return carlaEngine->getOscServerPath();
return carlaEngine->getOscServerPathTCP();
}

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


+ 1
- 1
c++/carla-backend/carla_bridge.cpp View File

@@ -1016,7 +1016,7 @@ CarlaPlugin* CarlaPlugin::newBridge(const initializer& init, BinaryType btype, P
}

//plugin->reload();
plugin->registerToOsc();
plugin->registerToOscControl();

return plugin;
}


+ 10
- 5
c++/carla-backend/carla_engine.cpp View File

@@ -108,7 +108,7 @@ bool CarlaEngine::init(const char* const clientName)

#ifndef BUILD_BRIDGE
m_osc.init(clientName);
m_oscData = m_osc.getControllerData();
m_oscData = m_osc.getControlData();

carla_setprocname(clientName);
#endif
@@ -539,19 +539,24 @@ void CarlaEngine::midiUnlock()
// -----------------------------------------------------------------------
// OSC Stuff

bool CarlaEngine::isOscControllerRegisted() const
bool CarlaEngine::isOscControlRegisted() const
{
#ifndef BUILD_BRIDGE
return m_osc.isControllerRegistered();
return m_osc.isControlRegistered();
#else
return bool(m_oscData);
#endif
}

#ifndef BUILD_BRIDGE
const char* CarlaEngine::getOscServerPath() const
const char* CarlaEngine::getOscServerPathTCP() const
{
return m_osc.getServerPath();
return m_osc.getServerPathTCP();
}

const char* CarlaEngine::getOscServerPathUDP() const
{
return m_osc.getServerPathUDP();
}
#else
void CarlaEngine::setOscBridgeData(const CarlaOscData* const oscData)


+ 3
- 2
c++/carla-backend/carla_engine.h View File

@@ -260,10 +260,11 @@ public:
// -------------------------------------------------------------------
// OSC Stuff

bool isOscControllerRegisted() const;
bool isOscControlRegisted() const;

#ifndef BUILD_BRIDGE
const char* getOscServerPath() const;
const char* getOscServerPathTCP() const;
const char* getOscServerPathUDP() const;
#else
void setOscBridgeData(const CarlaOscData* const oscData);
#endif


+ 2
- 2
c++/carla-backend/carla_native.cpp View File

@@ -795,7 +795,7 @@ public:

#ifndef BUILD_BRIDGE
// Update OSC Names
if (x_engine->isOscControllerRegisted())
if (x_engine->isOscControlRegisted())
{
x_engine->osc_send_control_set_midi_program_count(m_id, midiprog.count);

@@ -1663,7 +1663,7 @@ CarlaPlugin* CarlaPlugin::newNative(const initializer& init)
}
}

plugin->registerToOsc();
plugin->registerToOscControl();

return plugin;
}


+ 40
- 27
c++/carla-backend/carla_osc.cpp View File

@@ -31,11 +31,13 @@ CarlaOsc::CarlaOsc(CarlaEngine* const engine_) :
Q_ASSERT(engine);
qDebug("CarlaOsc::CarlaOsc(%p)", engine_);

m_serverPath = nullptr;
m_serverThread = nullptr;
m_controllerData.path = nullptr;
m_controllerData.source = nullptr;
m_controllerData.target = nullptr;
m_serverPathTCP = nullptr;
m_serverPathUDP = nullptr;
m_serverThreadTCP = nullptr;
m_serverThreadUDP = nullptr;
m_controlData.path = nullptr;
m_controlData.source = nullptr;
m_controlData.target = nullptr;

m_name = nullptr;
m_name_len = 0;
@@ -56,16 +58,23 @@ void CarlaOsc::init(const char* const name)
m_name_len = strlen(name);

// create new OSC thread
m_serverThread = lo_server_thread_new_with_proto(nullptr, LO_TCP, osc_error_handler);
m_serverThreadTCP = lo_server_thread_new_with_proto(nullptr, LO_TCP, osc_error_handler);
m_serverThreadUDP = lo_server_thread_new_with_proto(nullptr, LO_UDP, osc_error_handler);

// get our full OSC server path
char* const threadPath = lo_server_thread_get_url(m_serverThread);
m_serverPath = strdup(QString("%1%2").arg(threadPath).arg(name).toUtf8().constData());
free(threadPath);
char* const threadPathTCP = lo_server_thread_get_url(m_serverThreadTCP);
m_serverPathTCP = strdup(QString("%1%2").arg(threadPathTCP).arg(name).toUtf8().constData());
free(threadPathTCP);

char* const threadPathUDP = lo_server_thread_get_url(m_serverThreadUDP);
m_serverPathUDP = strdup(QString("%1%2").arg(threadPathUDP).arg(name).toUtf8().constData());
free(threadPathUDP);

// register message handler and start OSC thread
lo_server_thread_add_method(m_serverThread, nullptr, nullptr, osc_message_handler, this);
lo_server_thread_start(m_serverThread);
lo_server_thread_add_method(m_serverThreadTCP, nullptr, nullptr, osc_message_handler, this);
lo_server_thread_add_method(m_serverThreadUDP, nullptr, nullptr, osc_message_handler, this);
lo_server_thread_start(m_serverThreadTCP);
lo_server_thread_start(m_serverThreadUDP);
}

void CarlaOsc::close()
@@ -73,14 +82,19 @@ void CarlaOsc::close()
Q_ASSERT(m_name);
qDebug("CarlaOsc::close()");

osc_clear_data(&m_controllerData);
osc_clear_data(&m_controlData);

lo_server_thread_stop(m_serverThread);
lo_server_thread_del_method(m_serverThread, nullptr, nullptr);
lo_server_thread_free(m_serverThread);
lo_server_thread_stop(m_serverThreadTCP);
lo_server_thread_stop(m_serverThreadUDP);
lo_server_thread_del_method(m_serverThreadTCP, nullptr, nullptr);
lo_server_thread_del_method(m_serverThreadUDP, nullptr, nullptr);
lo_server_thread_free(m_serverThreadTCP);
lo_server_thread_free(m_serverThreadUDP);

free((void*)m_serverPath);
m_serverPath = nullptr;
free((void*)m_serverPathTCP);
free((void*)m_serverPathUDP);
m_serverPathTCP = nullptr;
m_serverPathUDP = nullptr;

free((void*)m_name);
m_name = nullptr;
@@ -95,9 +109,8 @@ int CarlaOsc::handleMessage(const char* const path, const int argc, const lo_arg
if (! QString(path).contains("put_peak_value"))
qDebug("CarlaOsc::handleMessage(%s, %i, %p, %s, %p)", path, argc, argv, types, msg);
#endif
qWarning("CarlaOsc::handleMessage(%s, %i, %p, %s, %p)", path, argc, argv, types, msg);

Q_ASSERT(m_serverThread);
Q_ASSERT(m_serverThreadTCP || m_serverPathUDP);
Q_ASSERT(path);

// Initial path check
@@ -258,9 +271,9 @@ int CarlaOsc::handleMsgRegister(const int argc, const lo_arg* const* const argv,
qDebug("CarlaOsc::handleMsgRegister()");
CARLA_OSC_CHECK_OSC_TYPES(1, "s");

if (m_controllerData.path)
if (m_controlData.path)
{
qWarning("CarlaOsc::handleMsgRegister() - OSC backend already registered to %s", m_controllerData.path);
qWarning("CarlaOsc::handleMsgRegister() - OSC backend already registered to %s", m_controlData.path);
return 1;
}

@@ -272,12 +285,12 @@ int CarlaOsc::handleMsgRegister(const int argc, const lo_arg* const* const argv,

host = lo_address_get_hostname(source);
port = lo_address_get_port(source);
m_controllerData.source = lo_address_new_with_proto(LO_TCP, host, port);
m_controlData.source = lo_address_new_with_proto(LO_TCP, host, port);

host = lo_url_get_hostname(url);
port = lo_url_get_port(url);
m_controllerData.path = lo_url_get_path(url);
m_controllerData.target = lo_address_new_with_proto(LO_TCP, host, port);
m_controlData.path = lo_url_get_path(url);
m_controlData.target = lo_address_new_with_proto(LO_TCP, host, port);

free((void*)host);
free((void*)port);
@@ -288,7 +301,7 @@ int CarlaOsc::handleMsgRegister(const int argc, const lo_arg* const* const argv,
CarlaPlugin* const plugin = engine->getPluginUnchecked(i);

if (plugin && plugin->enabled())
plugin->registerToOsc();
plugin->registerToOscControl();
}

return 0;
@@ -298,13 +311,13 @@ int CarlaOsc::handleMsgUnregister()
{
qDebug("CarlaOsc::handleMsgUnregister()");

if (! m_controllerData.path)
if (! m_controlData.path)
{
qWarning("CarlaOsc::handleMsgUnregister() - OSC backend is not registered yet");
return 1;
}

osc_clear_data(&m_controllerData);
osc_clear_data(&m_controlData);
return 0;
}



+ 16
- 9
c++/carla-backend/carla_osc.h View File

@@ -60,27 +60,34 @@ public:

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

bool isControllerRegistered() const
bool isControlRegistered() const
{
return bool(m_controllerData.target);
return bool(m_controlData.target);
}

const CarlaOscData* getControllerData() const
const CarlaOscData* getControlData() const
{
return &m_controllerData;
return &m_controlData;
}

const char* getServerPath() const
const char* getServerPathTCP() const
{
return m_serverPath;
return m_serverPathTCP;
}

const char* getServerPathUDP() const
{
return m_serverPathUDP;
}

private:
CarlaEngine* const engine;

const char* m_serverPath;
lo_server_thread m_serverThread;
CarlaOscData m_controllerData;
const char* m_serverPathTCP;
const char* m_serverPathUDP;
lo_server_thread m_serverThreadTCP;
lo_server_thread m_serverThreadUDP;
CarlaOscData m_controlData; // for carla-control

const char* m_name;
size_t m_name_len;


+ 12
- 4
c++/carla-backend/carla_plugin.h View File

@@ -1408,9 +1408,9 @@ public:
/*!
* Register this plugin to the engine's OSC controller.
*/
void registerToOsc()
void registerToOscControl()
{
if (! x_engine->isOscControllerRegisted())
if (! x_engine->isOscControlRegisted())
return;

#ifndef BUILD_BRIDGE
@@ -1547,12 +1547,20 @@ public:

host = lo_address_get_hostname(source);
port = lo_address_get_port(source);
osc.data.source = lo_address_new(host, port);

if (m_type == PLUGIN_DSSI)
osc.data.source = lo_address_new_with_proto(LO_UDP, host, port);
else
osc.data.source = lo_address_new_with_proto(LO_TCP, host, port);

host = lo_url_get_hostname(url);
port = lo_url_get_port(url);
osc.data.path = lo_url_get_path(url);
osc.data.target = lo_address_new(host, port);

if (m_type == PLUGIN_DSSI)
osc.data.target = lo_address_new_with_proto(LO_UDP, host, port);
else
osc.data.target = lo_address_new_with_proto(LO_TCP, host, port);

free((void*)host);
free((void*)port);


+ 11
- 9
c++/carla-backend/carla_threads.cpp View File

@@ -64,7 +64,7 @@ void CarlaCheckThread::run()

using namespace CarlaBackend;

bool oscControllerRegisted, usesSingleThread;
bool oscControlRegisted, usesSingleThread;
unsigned short id, maxPluginNumber = CarlaEngine::maxPluginNumber();
double value;

@@ -73,7 +73,7 @@ void CarlaCheckThread::run()
while (engine->isRunning() && ! m_stopNow)
{
const ScopedLocker m(this);
oscControllerRegisted = engine->isOscControllerRegisted();
oscControlRegisted = engine->isOscControlRegisted();

for (unsigned short i=0; i < maxPluginNumber; i++)
{
@@ -93,7 +93,7 @@ void CarlaCheckThread::run()
// -------------------------------------------------------
// Update parameter outputs

if (oscControllerRegisted || ! usesSingleThread)
if (oscControlRegisted || ! usesSingleThread)
{
for (uint32_t i=0; i < plugin->parameterCount(); i++)
{
@@ -106,12 +106,14 @@ void CarlaCheckThread::run()
plugin->uiParameterChange(i, value);

// Update OSC control client
if (oscControllerRegisted)
if (oscControlRegisted)
{
#ifdef BUILD_BRIDGE
engine->osc_send_bridge_set_parameter_value(i, value);
#else
engine->osc_send_control_set_parameter_value(id, i, value);
#endif
}
}
}
}
@@ -119,7 +121,7 @@ void CarlaCheckThread::run()
// -------------------------------------------------------
// Update OSC control client

if (oscControllerRegisted)
if (oscControlRegisted)
{
// Peak values
if (plugin->audioInCount() > 0)
@@ -211,21 +213,21 @@ void CarlaPluginThread::run()
switch (mode)
{
case PLUGIN_THREAD_DSSI_GUI:
/* osc_url */ arguments << QString("%1/%2").arg(engine->getOscServerPath()).arg(plugin->id());
/* osc_url */ arguments << QString("%1/%2").arg(engine->getOscServerPathUDP()).arg(plugin->id());
/* filename */ arguments << plugin->filename();
/* label */ arguments << m_label;
/* ui-title */ arguments << QString("%1 (GUI)").arg(plugin->name());
break;

case PLUGIN_THREAD_LV2_GUI:
/* osc_url */ arguments << QString("%1/%2").arg(engine->getOscServerPath()).arg(plugin->id());
/* osc_url */ arguments << QString("%1/%2").arg(engine->getOscServerPathTCP()).arg(plugin->id());
/* URI */ arguments << m_label;
/* ui-URI */ arguments << m_data1;
/* ui-title */ arguments << QString("%1 (GUI)").arg(plugin->name());
break;

case PLUGIN_THREAD_VST_GUI:
/* osc_url */ arguments << QString("%1/%2").arg(engine->getOscServerPath()).arg(plugin->id());
/* osc_url */ arguments << QString("%1/%2").arg(engine->getOscServerPathTCP()).arg(plugin->id());
/* filename */ arguments << plugin->filename();
/* ui-title */ arguments << QString("%1 (GUI)").arg(plugin->name());
break;
@@ -237,7 +239,7 @@ void CarlaPluginThread::run()
if (! name)
name = "(none)";

/* osc_url */ arguments << QString("%1/%2").arg(engine->getOscServerPath()).arg(plugin->id());
/* osc_url */ arguments << QString("%1/%2").arg(engine->getOscServerPathTCP()).arg(plugin->id());
/* stype */ arguments << m_data1;
/* filename */ arguments << plugin->filename();
/* name */ arguments << name;


+ 2
- 2
c++/carla-backend/dssi.cpp View File

@@ -748,7 +748,7 @@ public:

#ifndef BUILD_BRIDGE
// Update OSC Names
if (x_engine->isOscControllerRegisted())
if (x_engine->isOscControlRegisted())
{
x_engine->osc_send_control_set_midi_program_count(m_id, midiprog.count);

@@ -1564,7 +1564,7 @@ CarlaPlugin* CarlaPlugin::newDSSI(const initializer& init, const void* const ext
}
#endif

plugin->registerToOsc();
plugin->registerToOscControl();

return plugin;
#else


+ 2
- 2
c++/carla-backend/fluidsynth.cpp View File

@@ -784,7 +784,7 @@ public:

#ifndef BUILD_BRIDGE
// Update OSC Names
if (x_engine->isOscControllerRegisted())
if (x_engine->isOscControlRegisted())
{
x_engine->osc_send_control_set_midi_program_count(m_id, midiprog.count);

@@ -1353,7 +1353,7 @@ CarlaPlugin* CarlaPlugin::newSF2(const initializer& init)
}

plugin->reload();
plugin->registerToOsc();
plugin->registerToOscControl();

return plugin;
#else


+ 1
- 1
c++/carla-backend/ladspa.cpp View File

@@ -1172,7 +1172,7 @@ CarlaPlugin* CarlaPlugin::newLADSPA(const initializer& init, const void* const e
}
#endif

plugin->registerToOsc();
plugin->registerToOscControl();

return plugin;
#else


+ 2
- 2
c++/carla-backend/linuxsampler.cpp View File

@@ -252,7 +252,7 @@ public:

#ifndef BUILD_BRIDGE
// Update OSC Names
if (x_engine->isOscControllerRegisted())
if (x_engine->isOscControlRegisted())
{
x_engine->osc_send_control_set_midi_program_count(m_id, midiprog.count);

@@ -608,7 +608,7 @@ CarlaPlugin* LinuxSamplerPlugin::newLinuxSampler(const initializer& init, bool i
}

plugin->reload();
plugin->registerToOsc();
plugin->registerToOscControl();

return plugin;
}


+ 2
- 2
c++/carla-backend/lv2.cpp View File

@@ -1775,7 +1775,7 @@ public:

#ifndef BUILD_BRIDGE
// Update OSC Names
if (x_engine->isOscControllerRegisted())
if (x_engine->isOscControlRegisted())
{
x_engine->osc_send_control_set_midi_program_count(m_id, midiprog.count);

@@ -4515,7 +4515,7 @@ CarlaPlugin* CarlaPlugin::newLV2(const initializer& init)
}
#endif

plugin->registerToOsc();
plugin->registerToOscControl();
plugin->updateUi();

return plugin;


+ 2
- 2
c++/carla-backend/vst.cpp View File

@@ -757,7 +757,7 @@ public:

#ifndef BUILD_BRIDGE
// Update OSC Names
if (x_engine->isOscControllerRegisted())
if (x_engine->isOscControlRegisted())
{
x_engine->osc_send_control_set_program_count(m_id, prog.count);

@@ -2314,7 +2314,7 @@ CarlaPlugin* CarlaPlugin::newVST(const initializer& init)
}
#endif

plugin->registerToOsc();
plugin->registerToOscControl();

return plugin;
#else


+ 2
- 2
c++/carla-bridge/carla_bridge_osc.cpp View File

@@ -72,7 +72,7 @@ bool CarlaBridgeOsc::init(const char* const url)
char* port = lo_url_get_port(url);

m_controlData.path = lo_url_get_path(url);
m_controlData.target = lo_address_new(host, port);
m_controlData.target = lo_address_new_with_proto(LO_TCP, host, port);

free(host);
free(port);
@@ -84,7 +84,7 @@ bool CarlaBridgeOsc::init(const char* const url)
}

// create new OSC thread
m_serverThread = lo_server_thread_new(nullptr, osc_error_handler);
m_serverThread = lo_server_thread_new_with_proto(nullptr, LO_TCP, osc_error_handler);

// get our full OSC server path
char* const threadPath = lo_server_thread_get_url(m_serverThread);


Loading…
Cancel
Save