Browse Source

Misc changes

tags/v0.9.0
falkTX 12 years ago
parent
commit
e6342a100d
10 changed files with 160 additions and 114 deletions
  1. +6
    -0
      c++/carla-bridge/carla_bridge_client.hpp
  2. +1
    -0
      c++/carla-bridge/carla_bridge_osc.cpp
  3. +15
    -18
      c++/carla-bridge/carla_bridge_osc.hpp
  4. +4
    -4
      c++/carla-bridge/carla_bridge_plugin.cpp
  5. +10
    -0
      c++/carla-engine/carla_engine.cpp
  6. +10
    -0
      c++/carla-engine/carla_engine.hpp
  7. +4
    -0
      c++/carla-engine/carla_engine.pro
  8. +91
    -86
      c++/carla-engine/carla_engine_osc.cpp
  9. +18
    -6
      c++/carla-engine/carla_engine_osc.hpp
  10. +1
    -0
      c++/carla-utils/carla_utils.hpp

+ 6
- 0
c++/carla-bridge/carla_bridge_client.hpp View File

@@ -22,6 +22,12 @@

#include <QtCore/QMutex>

#ifdef BUILD_BRIDGE_PLUGIN
namespace CarlaBackend {
class CarlaEngine;
}
#endif

CARLA_BRIDGE_START_NAMESPACE

#if 0


+ 1
- 0
c++/carla-bridge/carla_bridge_osc.cpp View File

@@ -54,6 +54,7 @@ bool CarlaBridgeOsc::init(const char* const url)
CARLA_ASSERT(! m_name);
CARLA_ASSERT(! m_server);
CARLA_ASSERT(! m_serverPath);
CARLA_ASSERT(m_nameSize == 0);
CARLA_ASSERT(url);

if (! url)


+ 15
- 18
c++/carla-bridge/carla_bridge_osc.hpp View File

@@ -81,8 +81,21 @@ public:

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

protected:
private:
CarlaBridgeClient* const client;

char* m_name;
size_t m_nameSize;

lo_server m_server;
char* m_serverPath;

CarlaOscData m_controlData;

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

int handleMessage(const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg);

int handleMsgConfigure(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgControl(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS);
@@ -99,22 +112,6 @@ protected:

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

protected:
CarlaBridgeClient* const client;

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

private:
char* m_name;
size_t m_nameSize;

lo_server m_server;
char* m_serverPath;

CarlaOscData m_controlData;

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

static void osc_error_handler(const int num, const char* const msg, const char* const path)
{
qWarning("CarlaBridgeOsc::osc_error_handler(%i, \"%s\", \"%s\")", num, msg, path);
@@ -125,7 +122,7 @@ private:
CARLA_ASSERT(user_data);
if (CarlaBridgeOsc* const _this_ = (CarlaBridgeOsc*)user_data)
return _this_->handleMessage(path, argc, argv, types, msg);
return -1;
return 1;
}
};



+ 4
- 4
c++/carla-bridge/carla_bridge_plugin.cpp View File

@@ -225,15 +225,15 @@ private:

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

class BridgePluginClient : public CarlaToolkit,
public CarlaClient,
class BridgePluginClient : public CarlaBridgeToolkit,
public CarlaBridgeClient,
public BridgePluginGUI::Callback,
public QApplication
{
public:
BridgePluginClient()
: CarlaToolkit("carla-bridge-plugin"),
CarlaClient(this),
: CarlaBridgeToolkit("carla-bridge-plugin"),
CarlaBridgeClient("ui title"),
QApplication(qargc, qargv, true)
{
qDebug("BridgePluginClient::BridgePluginClient()");


+ 10
- 0
c++/carla-engine/carla_engine.cpp View File

@@ -1182,6 +1182,11 @@ void CarlaEngine::processLock()
m_procLock.lock();
}

void CarlaEngine::processTryLock()
{
m_procLock.tryLock();
}

void CarlaEngine::processUnlock()
{
m_procLock.unlock();
@@ -1192,6 +1197,11 @@ void CarlaEngine::midiLock()
m_midiLock.lock();
}

void CarlaEngine::midiTryLock()
{
m_midiLock.tryLock();
}

void CarlaEngine::midiUnlock()
{
m_midiLock.unlock();


+ 10
- 0
c++/carla-engine/carla_engine.hpp View File

@@ -736,6 +736,11 @@ public:
*/
void processLock();

/*!
* Try Lock processing.
*/
void processTryLock();

/*!
* Unlock processing.
*/
@@ -746,6 +751,11 @@ public:
*/
void midiLock();

/*!
* Try Lock MIDI.
*/
void midiTryLock();

/*!
* Unlock MIDI.
*/


+ 4
- 0
c++/carla-engine/carla_engine.pro View File

@@ -52,6 +52,10 @@ INCLUDEPATH = . \
../carla-plugin \
../carla-utils

# FIXME
INCLUDEPATH += \
/opt/kxstudio/include

# JACK
INCLUDEPATH += ../carla-jackbridge



+ 91
- 86
c++/carla-engine/carla_engine_osc.cpp View File

@@ -22,39 +22,25 @@ CARLA_BACKEND_START_NAMESPACE

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

void osc_error_handlerTCP(const int num, const char* const msg, const char* const path)
{
qCritical("CarlaEngineOsc::osc_error_handlerTCP(%i, \"%s\", \"%s\")", num, msg, path);
}

void osc_error_handlerUDP(const int num, const char* const msg, const char* const path)
{
qCritical("CarlaEngineOsc::osc_error_handlerUDP(%i, \"%s\", \"%s\")", num, msg, path);
}

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

CarlaEngineOsc::CarlaEngineOsc(CarlaEngine* const engine_)
: engine(engine_)
{
qDebug("CarlaEngineOsc::CarlaEngineOsc(%p)", engine);
CARLA_ASSERT(engine);

m_serverTCP = nullptr;
m_serverUDP = nullptr;
#ifndef BUILD_BRIDGE
m_controlData.path = nullptr;
m_controlData.source = nullptr;
m_controlData.target = nullptr;
#endif

m_name = nullptr;
m_nameSize = 0;

m_serverTCP = nullptr;
m_serverUDP = nullptr;
}

CarlaEngineOsc::~CarlaEngineOsc()
{
qDebug("CarlaEngineOsc::~CarlaEngineOsc()");
CARLA_ASSERT(! m_name);
CARLA_ASSERT(! m_serverTCP);
CARLA_ASSERT(! m_serverUDP);
}

// -----------------------------------------------------------------------
@@ -62,37 +48,40 @@ CarlaEngineOsc::~CarlaEngineOsc()
void CarlaEngineOsc::init(const char* const name)
{
qDebug("CarlaEngineOsc::init(\"%s\")", name);
CARLA_ASSERT(! m_name);
CARLA_ASSERT(! m_serverTCP);
CARLA_ASSERT(! m_serverUDP);
CARLA_ASSERT(m_nameSize == 0);
CARLA_ASSERT(m_serverPathTCP.isEmpty());
CARLA_ASSERT(m_serverPathUDP.isEmpty());
CARLA_ASSERT(m_nameSize == 0);
CARLA_ASSERT(name);

m_name = strdup(name ? name : "");
m_nameSize = strlen(m_name);

// create new OSC severs
m_serverTCP = lo_server_new_with_proto(nullptr, LO_TCP, osc_error_handlerTCP);
m_serverUDP = lo_server_new_with_proto(nullptr, LO_UDP, osc_error_handlerUDP);

if (m_serverTCP)
{
// get our full OSC servers path
char* const serverPathTCP = lo_server_get_url(m_serverTCP);
m_serverPathTCP = serverPathTCP;
m_serverPathTCP += m_name;
free(serverPathTCP);
if (char* const serverPathTCP = lo_server_get_url(m_serverTCP))
{
m_serverPathTCP = serverPathTCP;
m_serverPathTCP += m_name;
free(serverPathTCP);
}

lo_server_add_method(m_serverTCP, nullptr, nullptr, osc_message_handler, this);
}

if (m_serverUDP)
{
char* const serverPathUDP = lo_server_get_url(m_serverUDP);
m_serverPathUDP = serverPathUDP;
m_serverPathUDP += m_name;
free(serverPathUDP);
if (char* const serverPathUDP = lo_server_get_url(m_serverUDP))
{
m_serverPathUDP = serverPathUDP;
m_serverPathUDP += m_name;
free(serverPathUDP);
}

lo_server_add_method(m_serverUDP, nullptr, nullptr, osc_message_handler, this);
}
@@ -114,15 +103,19 @@ void CarlaEngineOsc::idle()
void CarlaEngineOsc::close()
{
qDebug("CarlaEngineOsc::close()");
CARLA_ASSERT(m_name);
CARLA_ASSERT(m_serverTCP);
CARLA_ASSERT(m_serverUDP);
CARLA_ASSERT(m_serverPathTCP.isNotEmpty());
CARLA_ASSERT(m_serverPathUDP.isNotEmpty());
CARLA_ASSERT(m_name);

#ifndef BUILD_BRIDGE
m_controlData.free();
#endif
m_nameSize = 0;

if (m_name)
{
free(m_name);
m_name = nullptr;
}

if (m_serverTCP)
{
@@ -141,9 +134,9 @@ void CarlaEngineOsc::close()
m_serverPathTCP.clear();
m_serverPathUDP.clear();

free(m_name);
m_name = nullptr;
m_nameSize = 0;
#ifndef BUILD_BRIDGE
m_controlData.free();
#endif
}

// -----------------------------------------------------------------------
@@ -154,13 +147,22 @@ int CarlaEngineOsc::handleMessage(const char* const path, const int argc, const
if (! QString(path).endsWith("peak"))
qDebug("CarlaEngineOsc::handleMessage(%s, %i, %p, %s, %p)", path, argc, argv, types, msg);
#endif
CARLA_ASSERT(m_name);
CARLA_ASSERT(m_serverTCP || m_serverUDP);
CARLA_ASSERT(m_serverPathTCP.isNotEmpty() || m_serverPathUDP.isNotEmpty());
CARLA_ASSERT(m_name);
CARLA_ASSERT(path);

if (! (m_name && path))
if (! path)
{
qCritical("CarlaEngineOsc::handleMessage() - got invalid path");
return 1;
}

if (! m_name)
{
qCritical("CarlaEngineOsc::handleMessage(\"%s\", ...) - received message but client is offline", path);
return 1;
}

#ifndef BUILD_BRIDGE
// Initial path check
@@ -207,112 +209,115 @@ int CarlaEngineOsc::handleMessage(const char* const path, const int argc, const
}

// Get method from path, "/Carla/i/method"
const int offset = (pluginId >= 10) ? 4 : 3;
const int offset = (pluginId >= 10) ? 5 : 4;
char method[32] = { 0 };
memcpy(method, path + (m_nameSize + offset), carla_minU(strlen(path), 32));
strncpy(method, path + (m_nameSize + offset), 31);

if (method[0] == 0 || method[0] != '/' || strlen(method) < 5)
if (method[0] == '\0')
{
qWarning("CarlaEngineOsc::handleMessage(\"%s\", ...) - received message without method", path);
return 1;
}

// Common OSC methods (DSSI and internal UIs)
if (strcmp(method, "/update") == 0)
if (strcmp(method, "update") == 0)
{
const lo_address source = lo_message_get_source(msg);
return handleMsgUpdate(plugin, argc, argv, types, source);
}
if (strcmp(method, "/configure") == 0)
if (strcmp(method, "configure") == 0)
return handleMsgConfigure(plugin, argc, argv, types);
if (strcmp(method, "/control") == 0)
if (strcmp(method, "control") == 0)
return handleMsgControl(plugin, argc, argv, types);
if (strcmp(method, "/program") == 0)
if (strcmp(method, "program") == 0)
return handleMsgProgram(plugin, argc, argv, types);
if (strcmp(method, "/midi") == 0)
if (strcmp(method, "midi") == 0)
return handleMsgMidi(plugin, argc, argv, types);
if (strcmp(method, "/exiting") == 0)
if (strcmp(method, "exiting") == 0)
return handleMsgExiting(plugin);

#ifndef BUILD_BRIDGE
// Internal methods
if (strcmp(method, "/set_active") == 0)
if (strcmp(method, "set_active") == 0)
return handleMsgSetActive(plugin, argc, argv, types);
if (strcmp(method, "/set_drywet") == 0)
if (strcmp(method, "set_drywet") == 0)
return handleMsgSetDryWet(plugin, argc, argv, types);
if (strcmp(method, "/set_volume") == 0)
if (strcmp(method, "set_volume") == 0)
return handleMsgSetVolume(plugin, argc, argv, types);
if (strcmp(method, "/set_balance_left") == 0)
if (strcmp(method, "set_balance_left") == 0)
return handleMsgSetBalanceLeft(plugin, argc, argv, types);
if (strcmp(method, "/set_balance_right") == 0)
if (strcmp(method, "set_balance_right") == 0)
return handleMsgSetBalanceRight(plugin, argc, argv, types);
if (strcmp(method, "/set_parameter_value") == 0)
if (strcmp(method, "set_parameter_value") == 0)
return handleMsgSetParameterValue(plugin, argc, argv, types);
if (strcmp(method, "/set_parameter_midi_cc") == 0)
if (strcmp(method, "set_parameter_midi_cc") == 0)
return handleMsgSetParameterMidiCC(plugin, argc, argv, types);
if (strcmp(method, "/set_parameter_midi_channel") == 0)
if (strcmp(method, "set_parameter_midi_channel") == 0)
return handleMsgSetParameterMidiChannel(plugin, argc, argv, types);
if (strcmp(method, "/set_program") == 0)
if (strcmp(method, "set_program") == 0)
return handleMsgSetProgram(plugin, argc, argv, types);
if (strcmp(method, "/set_midi_program") == 0)
if (strcmp(method, "set_midi_program") == 0)
return handleMsgSetMidiProgram(plugin, argc, argv, types);
if (strcmp(method, "/note_on") == 0)
if (strcmp(method, "note_on") == 0)
return handleMsgNoteOn(plugin, argc, argv, types);
if (strcmp(method, "/note_off") == 0)
if (strcmp(method, "note_off") == 0)
return handleMsgNoteOff(plugin, argc, argv, types);

// Plugin Bridges
if ((plugin->hints() & PLUGIN_IS_BRIDGE) > 0 && strlen(method) > 12 && strncmp(method, "/bridge_", 8) == 0)
if ((plugin->hints() & PLUGIN_IS_BRIDGE) > 0 && strlen(method) > 11 && strncmp(method, "bridge_", 7) == 0)
{
if (strcmp(method+8, "set_inpeak") == 0)
if (strcmp(method+7, "set_inpeak") == 0)
return handleMsgBridgeSetInPeak(plugin, argc, argv, types);
if (strcmp(method+8, "set_outpeak") == 0)
if (strcmp(method+7, "set_outpeak") == 0)
return handleMsgBridgeSetOutPeak(plugin, argc, argv, types);
if (strcmp(method+8, "audio_count") == 0)
if (strcmp(method+7, "audio_count") == 0)
return plugin->setOscBridgeInfo(PluginBridgeAudioCount, argc, argv, types);
if (strcmp(method+8, "midi_count") == 0)
if (strcmp(method+7, "midi_count") == 0)
return plugin->setOscBridgeInfo(PluginBridgeMidiCount, argc, argv, types);
if (strcmp(method+8, "parameter_count") == 0)
if (strcmp(method+7, "parameter_count") == 0)
return plugin->setOscBridgeInfo(PluginBridgeParameterCount, argc, argv, types);
if (strcmp(method+8, "program_count") == 0)
if (strcmp(method+7, "program_count") == 0)
return plugin->setOscBridgeInfo(PluginBridgeProgramCount, argc, argv, types);
if (strcmp(method+8, "midi_program_count") == 0)
if (strcmp(method+7, "midi_program_count") == 0)
return plugin->setOscBridgeInfo(PluginBridgeMidiProgramCount, argc, argv, types);
if (strcmp(method+8, "plugin_info") == 0)
if (strcmp(method+7, "plugin_info") == 0)
return plugin->setOscBridgeInfo(PluginBridgePluginInfo, argc, argv, types);
if (strcmp(method+8, "parameter_info") == 0)
if (strcmp(method+7, "parameter_info") == 0)
return plugin->setOscBridgeInfo(PluginBridgeParameterInfo, argc, argv, types);
if (strcmp(method+8, "parameter_data") == 0)
if (strcmp(method+7, "parameter_data") == 0)
return plugin->setOscBridgeInfo(PluginBridgeParameterData, argc, argv, types);
if (strcmp(method+8, "parameter_ranges") == 0)
if (strcmp(method+7, "parameter_ranges") == 0)
return plugin->setOscBridgeInfo(PluginBridgeParameterRanges, argc, argv, types);
if (strcmp(method+8, "program_info") == 0)
if (strcmp(method+7, "program_info") == 0)
return plugin->setOscBridgeInfo(PluginBridgeProgramInfo, argc, argv, types);
if (strcmp(method+8, "midi_program_info") == 0)
if (strcmp(method+7, "midi_program_info") == 0)
return plugin->setOscBridgeInfo(PluginBridgeMidiProgramInfo, argc, argv, types);
if (strcmp(method+8, "configure") == 0)
if (strcmp(method+7, "configure") == 0)
return plugin->setOscBridgeInfo(PluginBridgeConfigure, argc, argv, types);
if (strcmp(method+8, "set_parameter_value") == 0)
if (strcmp(method+7, "set_parameter_value") == 0)
return plugin->setOscBridgeInfo(PluginBridgeSetParameterValue, argc, argv, types);
if (strcmp(method+8, "set_default_value") == 0)
if (strcmp(method+7, "set_default_value") == 0)
return plugin->setOscBridgeInfo(PluginBridgeSetDefaultValue, argc, argv, types);
if (strcmp(method+8, "set_program") == 0)
if (strcmp(method+7, "set_program") == 0)
return plugin->setOscBridgeInfo(PluginBridgeSetProgram, argc, argv, types);
if (strcmp(method+8, "set_midi_program") == 0)
if (strcmp(method+7, "set_midi_program") == 0)
return plugin->setOscBridgeInfo(PluginBridgeSetMidiProgram, argc, argv, types);
if (strcmp(method+8, "set_custom_data") == 0)
if (strcmp(method+7, "set_custom_data") == 0)
return plugin->setOscBridgeInfo(PluginBridgeSetCustomData, argc, argv, types);
if (strcmp(method+8, "set_chunk_data") == 0)
if (strcmp(method+7, "set_chunk_data") == 0)
return plugin->setOscBridgeInfo(PluginBridgeSetChunkData, argc, argv, types);
if (strcmp(method+8, "update") == 0)
if (strcmp(method+7, "update") == 0)
return plugin->setOscBridgeInfo(PluginBridgeUpdateNow, argc, argv, types);
if (strcmp(method+8, "error") == 0)
if (strcmp(method+7, "error") == 0)
return plugin->setOscBridgeInfo(PluginBridgeError, argc, argv, types);
}
#endif

// Plugin-specific methods
#ifdef WANT_LV2
if (strcmp(method, "/lv2_atom_transfer") == 0)
if (strcmp(method, "lv2_atom_transfer") == 0)
return handleMsgLv2AtomTransfer(plugin, argc, argv, types);
if (strcmp(method, "/lv2_event_transfer") == 0)
if (strcmp(method, "lv2_event_transfer") == 0)
return handleMsgLv2EventTransfer(plugin, argc, argv, types);
#endif



+ 18
- 6
c++/carla-engine/carla_engine_osc.hpp View File

@@ -92,17 +92,18 @@ public:
private:
CarlaEngine* const engine;

char* m_name;
size_t m_nameSize;

lo_server m_serverTCP;
lo_server m_serverUDP;
CarlaString m_serverPathTCP;
CarlaString m_serverPathUDP;

#ifndef BUILD_BRIDGE
CarlaOscData m_controlData; // for carla-control
#endif

char* m_name;
size_t m_nameSize;

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

int handleMessage(const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg);
@@ -142,13 +143,24 @@ private:
int handleMsgLv2EventTransfer(CARLA_ENGINE_OSC_HANDLE_ARGS2);
#endif

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

static void osc_error_handlerTCP(const int num, const char* const msg, const char* const path)
{
qWarning("CarlaEngineOsc::osc_error_handlerTCP(%i, \"%s\", \"%s\")", num, msg, path);
}

static void osc_error_handlerUDP(const int num, const char* const msg, const char* const path)
{
qWarning("CarlaEngineOsc::osc_error_handlerUDP(%i, \"%s\", \"%s\")", num, msg, path);
}

static int osc_message_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg, void* const userData)
{
CARLA_ASSERT(userData);
CarlaEngineOsc* const _this_ = (CarlaEngineOsc*)userData;
return _this_->handleMessage(path, argc, argv, types, msg);
if (CarlaEngineOsc* const _this_ = (CarlaEngineOsc*)userData)
return _this_->handleMessage(path, argc, argv, types, msg);
return 1;
}
};



+ 1
- 0
c++/carla-utils/carla_utils.hpp View File

@@ -278,6 +278,7 @@ public:
if (::strcmp(buffer, "") == 0)
return;

::free(buffer);
buffer = ::strdup("");
}



Loading…
Cancel
Save