Browse Source

More work&cleanup for plugin bridges

tags/1.9.4
falkTX 10 years ago
parent
commit
76d70ba4d1
13 changed files with 185 additions and 192 deletions
  1. +60
    -0
      source/backend/engine/CarlaEngineBridge.cpp
  2. +32
    -30
      source/backend/engine/CarlaEngineOsc.cpp
  3. +4
    -5
      source/backend/engine/CarlaEngineOsc.hpp
  4. +23
    -18
      source/backend/plugin/BridgePlugin.cpp
  5. +0
    -1
      source/backend/plugin/CarlaPlugin.cpp
  6. +2
    -0
      source/backend/plugin/Lv2Plugin.cpp
  7. +6
    -2
      source/bridges/CarlaBridgeClient.cpp
  8. +3
    -4
      source/bridges/CarlaBridgeClient.hpp
  9. +20
    -35
      source/bridges/CarlaBridgeOsc.cpp
  10. +11
    -19
      source/bridges/CarlaBridgeOsc.hpp
  11. +2
    -57
      source/bridges/CarlaBridgePlugin.cpp
  12. +2
    -2
      source/bridges/CarlaBridgeUI-LV2.cpp
  13. +20
    -19
      source/utils/CarlaBridgeUtils.hpp

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

@@ -463,6 +463,50 @@ public:
break; break;
} }


case kPluginBridgeOpcodePrepareForSave: {
carla_prepare_for_save(0);

for (uint32_t i=0, count=carla_get_custom_data_count(0); i<count; ++i)
{
const CarlaBackend::CustomData* const cdata(carla_get_custom_data(0, i));
CARLA_SAFE_ASSERT_CONTINUE(cdata != nullptr);

oscSend_bridge_set_custom_data(cdata->type, cdata->key, cdata->value);
}

//if (fPlugin->getOptionsEnabled() & CarlaBackend::PLUGIN_OPTION_USE_CHUNKS)
{
//if (const char* const chunkData = carla_get_chunk_data(0))
{
#if 0
QString filePath;
filePath = QDir::tempPath();
#ifdef Q_OS_WIN
filePath += "\\.CarlaChunk_";
#else
filePath += "/.CarlaChunk_";
#endif
filePath += fPlugin->getName();

QFile file(filePath);

if (file.open(QIODevice::WriteOnly))
{
QByteArray chunk((const char*)data, dataSize);
file.write(chunk);
file.close();
fEngine->oscSend_bridge_set_chunk_data(filePath.toUtf8().constData());
}
#endif
}
}

carla_stdout("-----------------------------------------------------, got prepare for save");

oscSend_bridge_configure(CARLA_BRIDGE_MSG_SAVED, "");
break;
}

case kPluginBridgeOpcodeMidiEvent: { case kPluginBridgeOpcodeMidiEvent: {
const int64_t time(fShmControl.readLong()); const int64_t time(fShmControl.readLong());
const int32_t size(fShmControl.readInt()); const int32_t size(fShmControl.readInt());
@@ -543,10 +587,26 @@ public:
break; break;
} }


case kPluginBridgeOpcodeShowUI:
carla_stdout("-----------------------------------------------------, got SHOW UI");

carla_show_custom_ui(0, true);
break;

case kPluginBridgeOpcodeHideUI:
carla_stdout("-----------------------------------------------------, got HIDE UI");

carla_show_custom_ui(0, false);
break;

case kPluginBridgeOpcodeQuit: case kPluginBridgeOpcodeQuit:
signalThreadShouldExit(); signalThreadShouldExit();
fIsRunning = false; fIsRunning = false;
break; break;

default:
carla_stderr2("Unhandled Plugin opcode %i", opcode);
break;
} }
} }




+ 32
- 30
source/backend/engine/CarlaEngineOsc.cpp View File

@@ -279,12 +279,17 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons
return 0; return 0;
} }


// Common OSC methods (DSSI and bridge UIs)
// Common OSC methods (all bridges)
if (std::strcmp(method, "update") == 0) if (std::strcmp(method, "update") == 0)
{ {
const lo_address source(lo_message_get_source(msg)); const lo_address source(lo_message_get_source(msg));
return handleMsgUpdate(plugin, argc, argv, types, source); return handleMsgUpdate(plugin, argc, argv, types, source);
} }
if (std::strcmp(method, "exiting") == 0)
return handleMsgExiting(plugin);

#ifndef BUILD_BRIDGE
// Common OSC methods (DSSI and bridge UIs)
if (std::strcmp(method, "configure") == 0) if (std::strcmp(method, "configure") == 0)
return handleMsgConfigure(plugin, argc, argv, types); return handleMsgConfigure(plugin, argc, argv, types);
if (std::strcmp(method, "control") == 0) if (std::strcmp(method, "control") == 0)
@@ -293,10 +298,7 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons
return handleMsgProgram(plugin, argc, argv, types); return handleMsgProgram(plugin, argc, argv, types);
if (std::strcmp(method, "midi") == 0) if (std::strcmp(method, "midi") == 0)
return handleMsgMidi(plugin, argc, argv, types); return handleMsgMidi(plugin, argc, argv, types);
if (std::strcmp(method, "exiting") == 0)
return handleMsgExiting(plugin);


#ifndef BUILD_BRIDGE
// Internal methods // Internal methods
if (std::strcmp(method, "set_active") == 0) if (std::strcmp(method, "set_active") == 0)
return handleMsgSetActive(plugin, argc, argv, types); return handleMsgSetActive(plugin, argc, argv, types);
@@ -379,13 +381,13 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons
if (std::strcmp(bmethod, "error") == 0) if (std::strcmp(bmethod, "error") == 0)
return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeError, argc, argv, types); return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeError, argc, argv, types);
} }
#endif


// Plugin-specific methods // Plugin-specific methods
if (std::strcmp(method, "lv2_atom_transfer") == 0) if (std::strcmp(method, "lv2_atom_transfer") == 0)
return handleMsgLv2AtomTransfer(plugin, argc, argv, types); return handleMsgLv2AtomTransfer(plugin, argc, argv, types);
if (std::strcmp(method, "lv2_urid_map") == 0) if (std::strcmp(method, "lv2_urid_map") == 0)
return handleMsgLv2UridMap(plugin, argc, argv, types); return handleMsgLv2UridMap(plugin, argc, argv, types);
#endif


carla_stderr("CarlaEngineOsc::handleMessage() - unsupported OSC method '%s'", method); carla_stderr("CarlaEngineOsc::handleMessage() - unsupported OSC method '%s'", method);
return 1; return 1;
@@ -393,6 +395,30 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons


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


int CarlaEngineOsc::handleMsgUpdate(CARLA_ENGINE_OSC_HANDLE_ARGS2, const lo_address source)
{
carla_debug("CarlaEngineOsc::handleMsgUpdate()");
CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "s");

const char* const url = (const char*)&argv[0]->s;

plugin->updateOscData(source, url);
return 0;
}

int CarlaEngineOsc::handleMsgExiting(CARLA_ENGINE_OSC_HANDLE_ARGS1)
{
carla_debug("CarlaEngineOsc::handleMsgExiting()");

// TODO - check for non-UIs (dssi-vst) and set to -1 instead
fEngine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, plugin->getId(), 0, 0, 0.0f, nullptr);

plugin->showCustomUI(false);
return 0;
}

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

#ifndef BUILD_BRIDGE #ifndef BUILD_BRIDGE
int CarlaEngineOsc::handleMsgRegister(const bool isTCP, const int argc, const lo_arg* const* const argv, const char* const types, const lo_address source) int CarlaEngineOsc::handleMsgRegister(const bool isTCP, const int argc, const lo_arg* const* const argv, const char* const types, const lo_address source)
{ {
@@ -449,21 +475,9 @@ int CarlaEngineOsc::handleMsgUnregister()
fControlData.clear(); fControlData.clear();
return 0; return 0;
} }
#endif


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


int CarlaEngineOsc::handleMsgUpdate(CARLA_ENGINE_OSC_HANDLE_ARGS2, const lo_address source)
{
carla_debug("CarlaEngineOsc::handleMsgUpdate()");
CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "s");

const char* const url = (const char*)&argv[0]->s;

plugin->updateOscData(source, url);
return 0;
}

int CarlaEngineOsc::handleMsgConfigure(CARLA_ENGINE_OSC_HANDLE_ARGS2) int CarlaEngineOsc::handleMsgConfigure(CARLA_ENGINE_OSC_HANDLE_ARGS2)
{ {
carla_debug("CarlaEngineOsc::handleMsgConfigure()"); carla_debug("CarlaEngineOsc::handleMsgConfigure()");
@@ -569,20 +583,8 @@ int CarlaEngineOsc::handleMsgMidi(CARLA_ENGINE_OSC_HANDLE_ARGS2)
#endif #endif
} }


int CarlaEngineOsc::handleMsgExiting(CARLA_ENGINE_OSC_HANDLE_ARGS1)
{
carla_debug("CarlaEngineOsc::handleMsgExiting()");

// TODO - check for non-UIs (dssi-vst) and set to -1 instead
fEngine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, plugin->getId(), 0, 0, 0.0f, nullptr);

plugin->showCustomUI(false);
return 0;
}

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


#ifndef BUILD_BRIDGE
int CarlaEngineOsc::handleMsgSetActive(CARLA_ENGINE_OSC_HANDLE_ARGS2) int CarlaEngineOsc::handleMsgSetActive(CARLA_ENGINE_OSC_HANDLE_ARGS2)
{ {
carla_debug("CarlaEngineOsc::handleMsgSetActive()"); carla_debug("CarlaEngineOsc::handleMsgSetActive()");
@@ -750,7 +752,7 @@ int CarlaEngineOsc::handleMsgNoteOff(CARLA_ENGINE_OSC_HANDLE_ARGS2)
plugin->sendMidiSingleNote(static_cast<uint8_t>(channel), static_cast<uint8_t>(note), 0, true, false, true); plugin->sendMidiSingleNote(static_cast<uint8_t>(channel), static_cast<uint8_t>(note), 0, true, false, true);
return 0; return 0;
} }
#endif
#endif // ! BUILD_BRIDGE


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




+ 4
- 5
source/backend/engine/CarlaEngineOsc.hpp View File

@@ -108,19 +108,18 @@ private:


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


int handleMsgUpdate(CARLA_ENGINE_OSC_HANDLE_ARGS2, const lo_address source);
int handleMsgExiting(CARLA_ENGINE_OSC_HANDLE_ARGS1);

#ifndef BUILD_BRIDGE #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 handleMsgRegister(const bool isTCP, const int argc, const lo_arg* const* const argv, const char* const types, const lo_address source);
int handleMsgUnregister(); int handleMsgUnregister();
#endif


int handleMsgUpdate(CARLA_ENGINE_OSC_HANDLE_ARGS2, const lo_address source);
int handleMsgConfigure(CARLA_ENGINE_OSC_HANDLE_ARGS2); int handleMsgConfigure(CARLA_ENGINE_OSC_HANDLE_ARGS2);
int handleMsgControl(CARLA_ENGINE_OSC_HANDLE_ARGS2); int handleMsgControl(CARLA_ENGINE_OSC_HANDLE_ARGS2);
int handleMsgProgram(CARLA_ENGINE_OSC_HANDLE_ARGS2); int handleMsgProgram(CARLA_ENGINE_OSC_HANDLE_ARGS2);
int handleMsgMidi(CARLA_ENGINE_OSC_HANDLE_ARGS2); int handleMsgMidi(CARLA_ENGINE_OSC_HANDLE_ARGS2);
int handleMsgExiting(CARLA_ENGINE_OSC_HANDLE_ARGS1);


#ifndef BUILD_BRIDGE
int handleMsgSetActive(CARLA_ENGINE_OSC_HANDLE_ARGS2); int handleMsgSetActive(CARLA_ENGINE_OSC_HANDLE_ARGS2);
int handleMsgSetDryWet(CARLA_ENGINE_OSC_HANDLE_ARGS2); int handleMsgSetDryWet(CARLA_ENGINE_OSC_HANDLE_ARGS2);
int handleMsgSetVolume(CARLA_ENGINE_OSC_HANDLE_ARGS2); int handleMsgSetVolume(CARLA_ENGINE_OSC_HANDLE_ARGS2);
@@ -134,10 +133,10 @@ private:
int handleMsgSetMidiProgram(CARLA_ENGINE_OSC_HANDLE_ARGS2); int handleMsgSetMidiProgram(CARLA_ENGINE_OSC_HANDLE_ARGS2);
int handleMsgNoteOn(CARLA_ENGINE_OSC_HANDLE_ARGS2); int handleMsgNoteOn(CARLA_ENGINE_OSC_HANDLE_ARGS2);
int handleMsgNoteOff(CARLA_ENGINE_OSC_HANDLE_ARGS2); int handleMsgNoteOff(CARLA_ENGINE_OSC_HANDLE_ARGS2);
#endif


int handleMsgLv2AtomTransfer(CARLA_ENGINE_OSC_HANDLE_ARGS2); int handleMsgLv2AtomTransfer(CARLA_ENGINE_OSC_HANDLE_ARGS2);
int handleMsgLv2UridMap(CARLA_ENGINE_OSC_HANDLE_ARGS2); int handleMsgLv2UridMap(CARLA_ENGINE_OSC_HANDLE_ARGS2);
#endif


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




+ 23
- 18
source/backend/plugin/BridgePlugin.cpp View File

@@ -347,12 +347,6 @@ public:
fShmControl.waitForServer(3); fShmControl.waitForServer(3);
} }


if (pData->osc.data.target != nullptr)
{
osc_send_hide(pData->osc.data);
osc_send_quit(pData->osc.data);
}

pData->osc.data.clear(); pData->osc.data.clear();
pData->osc.thread.stopThread(3000); pData->osc.thread.stopThread(3000);


@@ -490,22 +484,30 @@ public:


void prepareForSave() override void prepareForSave() override
{ {
#if 0
m_saved = false;
osc_send_configure(&osc.data, CARLA_BRIDGE_MSG_SAVE_NOW, "");
fSaved = false;

{
const CarlaMutexLocker _cml(fShmControl.lock);

fShmControl.writeOpcode(kPluginBridgeOpcodePrepareForSave);
fShmControl.commitWrite();
}

carla_stdout("BridgePlugin::prepareForSave() - sent, now waiting...");


for (int i=0; i < 200; ++i) for (int i=0; i < 200; ++i)
{ {
if (m_saved)
if (fSaved)
break; break;
carla_msleep(50);
carla_msleep(30);
pData->engine->callback(ENGINE_CALLBACK_IDLE, 0, 0, 0, 0.0f, nullptr);
pData->engine->idle();
} }


if (! m_saved)
if (! fSaved)
carla_stderr("BridgePlugin::prepareForSave() - Timeout while requesting save state"); carla_stderr("BridgePlugin::prepareForSave() - Timeout while requesting save state");
else else
carla_debug("BridgePlugin::prepareForSave() - success!");
#endif
carla_stdout("BridgePlugin::prepareForSave() - success!");
} }


// ------------------------------------------------------------------- // -------------------------------------------------------------------
@@ -618,17 +620,20 @@ public:


void showCustomUI(const bool yesNo) override void showCustomUI(const bool yesNo) override
{ {
if (yesNo)
{ {
osc_send_show(pData->osc.data);
const CarlaMutexLocker _cml(fShmControl.lock);


fShmControl.writeOpcode(yesNo ? kPluginBridgeOpcodeShowUI : kPluginBridgeOpcodeHideUI);
fShmControl.commitWrite();
}

if (yesNo)
{
pData->tryTransient(); pData->tryTransient();
} }
else else
{ {
pData->transientTryCounter = 0; pData->transientTryCounter = 0;

osc_send_hide(pData->osc.data);
} }
} }




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

@@ -490,7 +490,6 @@ const StateSave& CarlaPlugin::getStateSave()
pData->stateSave.label = carla_strdup(strBuf); pData->stateSave.label = carla_strdup(strBuf);
pData->stateSave.uniqueId = getUniqueId(); pData->stateSave.uniqueId = getUniqueId();
pData->stateSave.options = pData->options; pData->stateSave.options = pData->options;
carla_stdout("Options: 0x%x | 0x%x", pData->options, pData->stateSave.options);


if (pData->filename != nullptr) if (pData->filename != nullptr)
pData->stateSave.binary = carla_strdup(pData->filename); pData->stateSave.binary = carla_strdup(pData->filename);


+ 2
- 0
source/backend/plugin/Lv2Plugin.cpp View File

@@ -5780,6 +5780,7 @@ private:


#define lv2PluginPtr ((Lv2Plugin*)plugin) #define lv2PluginPtr ((Lv2Plugin*)plugin)


#ifndef BUILD_BRIDGE
int CarlaEngineOsc::handleMsgLv2AtomTransfer(CARLA_ENGINE_OSC_HANDLE_ARGS2) int CarlaEngineOsc::handleMsgLv2AtomTransfer(CARLA_ENGINE_OSC_HANDLE_ARGS2)
{ {
CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "is"); CARLA_ENGINE_OSC_CHECK_OSC_TYPES(2, "is");
@@ -5811,6 +5812,7 @@ int CarlaEngineOsc::handleMsgLv2UridMap(CARLA_ENGINE_OSC_HANDLE_ARGS2)
lv2PluginPtr->handleUridMap(static_cast<LV2_URID>(urid), uri); lv2PluginPtr->handleUridMap(static_cast<LV2_URID>(urid), uri);
return 0; return 0;
} }
#endif


#undef lv2PluginPtr #undef lv2PluginPtr




+ 6
- 2
source/bridges/CarlaBridgeClient.cpp View File

@@ -154,6 +154,8 @@ void CarlaBridgeClient::sendOscUpdate() const
osc_send_update(fOscData, fOsc.getServerPath()); osc_send_update(fOscData, fOsc.getServerPath());
} }


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

#ifdef BUILD_BRIDGE_PLUGIN #ifdef BUILD_BRIDGE_PLUGIN
void CarlaBridgeClient::sendOscBridgeUpdate() const void CarlaBridgeClient::sendOscBridgeUpdate() const
{ {
@@ -174,6 +176,7 @@ void CarlaBridgeClient::sendOscBridgeError(const char* const error) const


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


#ifdef BUILD_BRIDGE_UI
void CarlaBridgeClient::sendOscConfigure(const char* const key, const char* const value) const void CarlaBridgeClient::sendOscConfigure(const char* const key, const char* const value) const
{ {
carla_debug("CarlaBridgeClient::sendOscConfigure(\"%s\", \"%s\")", key, value); carla_debug("CarlaBridgeClient::sendOscConfigure(\"%s\", \"%s\")", key, value);
@@ -242,7 +245,6 @@ void CarlaBridgeClient::sendOscLv2UridMap(const uint32_t urid, const char* const


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


#ifdef BUILD_BRIDGE_UI
void* CarlaBridgeClient::getContainerId() void* CarlaBridgeClient::getContainerId()
{ {
carla_debug("CarlaBridgeClient::getContainerId()"); carla_debug("CarlaBridgeClient::getContainerId()");
@@ -285,6 +287,8 @@ const char* CarlaBridgeClient::uiLibError()


return lib_error(fUI.filename); return lib_error(fUI.filename);
} }
#endif
#endif // BUILD_BRIDGE_UI

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


CARLA_BRIDGE_END_NAMESPACE CARLA_BRIDGE_END_NAMESPACE

+ 3
- 4
source/bridges/CarlaBridgeClient.hpp View File

@@ -86,6 +86,7 @@ public:
// --------------------------------------------------------------------- // ---------------------------------------------------------------------


protected: protected:
#ifdef BUILD_BRIDGE_UI
void sendOscConfigure(const char* const key, const char* const value) const; void sendOscConfigure(const char* const key, const char* const value) const;
void sendOscControl(const int32_t index, const float value) const; void sendOscControl(const int32_t index, const float value) const;
void sendOscProgram(const uint32_t index) const; void sendOscProgram(const uint32_t index) const;
@@ -93,14 +94,13 @@ protected:
void sendOscMidi(const uint8_t midiBuf[4]) const; void sendOscMidi(const uint8_t midiBuf[4]) const;
void sendOscExiting() const; void sendOscExiting() const;


#ifdef BRIDGE_LV2
# ifdef BRIDGE_LV2
void sendOscLv2AtomTransfer(const int32_t portIndex, const char* const atomBuf) const; void sendOscLv2AtomTransfer(const int32_t portIndex, const char* const atomBuf) const;
void sendOscLv2UridMap(const uint32_t urid, const char* const uri) const; void sendOscLv2UridMap(const uint32_t urid, const char* const uri) const;
#endif
# endif


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


#ifdef BUILD_BRIDGE_UI
void* getContainerId(); void* getContainerId();
bool uiLibOpen(const char* const filename); bool uiLibOpen(const char* const filename);
bool uiLibClose(); bool uiLibClose();
@@ -155,7 +155,6 @@ private:
} fUI; } fUI;
#else #else
friend class CarlaPluginClient; friend class CarlaPluginClient;
friend class JackBridgeClient;
#endif #endif


CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaBridgeClient) CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaBridgeClient)


+ 20
- 35
source/bridges/CarlaBridgeOsc.cpp View File

@@ -20,10 +20,6 @@


CARLA_BRIDGE_START_NAMESPACE CARLA_BRIDGE_START_NAMESPACE


#if 0
} // Fix editor indentation
#endif

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


CarlaBridgeOsc::CarlaBridgeOsc(CarlaBridgeClient* const client) CarlaBridgeOsc::CarlaBridgeOsc(CarlaBridgeClient* const client)
@@ -160,42 +156,28 @@ int CarlaBridgeOsc::handleMessage(const char* const path, const int argc, const
if (std::strcmp(method, "quit") == 0) if (std::strcmp(method, "quit") == 0)
return handleMsgQuit(); return handleMsgQuit();


#ifdef BRIDGE_LV2
// LV2 methods
if (std::strcmp(method, "lv2_atom_transfer") == 0)
return handleMsgLv2AtomTransfer(argc, argv, types);
if (std::strcmp(method, "lv2_urid_map") == 0)
return handleMsgLv2UridMap(argc, argv, types);
#endif

#ifdef BUILD_BRIDGE_UI #ifdef BUILD_BRIDGE_UI
// UI methods // UI methods
if (std::strcmp(method, "configure") == 0) if (std::strcmp(method, "configure") == 0)
return handleMsgConfigure(argc, argv, types);
return handleMsgUiConfigure(argc, argv, types);
if (std::strcmp(method, "control") == 0) if (std::strcmp(method, "control") == 0)
return handleMsgControl(argc, argv, types);
return handleMsgUiControl(argc, argv, types);
if (std::strcmp(method, "program") == 0) if (std::strcmp(method, "program") == 0)
return handleMsgProgram(argc, argv, types);
return handleMsgUiProgram(argc, argv, types);
if (std::strcmp(method, "midi-program") == 0) if (std::strcmp(method, "midi-program") == 0)
return handleMsgMidiProgram(argc, argv, types);
return handleMsgUiMidiProgram(argc, argv, types);
if (std::strcmp(method, "midi") == 0) if (std::strcmp(method, "midi") == 0)
return handleMsgMidi(argc, argv, types);
return handleMsgUiMidi(argc, argv, types);
if (std::strcmp(method, "sample-rate") == 0) if (std::strcmp(method, "sample-rate") == 0)
return 0; // unused return 0; // unused
#endif


#if defined(BUILD_BRIDGE_PLUGIN) && ! defined(BRIDGE_JACK)
// Plugin methods
if (std::strcmp(method, "plugin_save_now") == 0)
return handleMsgPluginSaveNow();
if (std::strcmp(method, "plugin_set_parameter_midi_channel") == 0)
return handleMsgPluginSetParameterMidiChannel(argc, argv, types);
if (std::strcmp(method, "plugin_set_parameter_midi_cc") == 0)
return handleMsgPluginSetParameterMidiCC(argc, argv, types);
if (std::strcmp(method, "plugin_set_chunk") == 0)
return handleMsgPluginSetChunk(argc, argv, types);
if (std::strcmp(method, "plugin_set_custom_data") == 0)
return handleMsgPluginSetCustomData(argc, argv, types);
# ifdef BRIDGE_LV2
// LV2 methods
if (std::strcmp(method, "lv2_atom_transfer") == 0)
return handleMsgLv2UiAtomTransfer(argc, argv, types);
if (std::strcmp(method, "lv2_urid_map") == 0)
return handleMsgLv2UiUridMap(argc, argv, types);
# endif
#endif #endif


carla_stderr("CarlaBridgeOsc::handleMessage(\"%s\", ...) - received unsupported OSC method '%s'", path, method); carla_stderr("CarlaBridgeOsc::handleMessage(\"%s\", ...) - received unsupported OSC method '%s'", path, method);
@@ -233,7 +215,7 @@ int CarlaBridgeOsc::handleMsgQuit()
return 0; return 0;
} }


int CarlaBridgeOsc::handleMsgConfigure(CARLA_BRIDGE_OSC_HANDLE_ARGS)
int CarlaBridgeOsc::handleMsgUiConfigure(CARLA_BRIDGE_OSC_HANDLE_ARGS)
{ {
CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "ss"); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "ss");
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1); CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1);
@@ -246,7 +228,7 @@ int CarlaBridgeOsc::handleMsgConfigure(CARLA_BRIDGE_OSC_HANDLE_ARGS)
(void)argv; (void)argv;
} }


int CarlaBridgeOsc::handleMsgControl(CARLA_BRIDGE_OSC_HANDLE_ARGS)
int CarlaBridgeOsc::handleMsgUiControl(CARLA_BRIDGE_OSC_HANDLE_ARGS)
{ {
CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "if"); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "if");
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1); CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1);
@@ -262,7 +244,7 @@ int CarlaBridgeOsc::handleMsgControl(CARLA_BRIDGE_OSC_HANDLE_ARGS)
return 0; return 0;
} }


int CarlaBridgeOsc::handleMsgProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS)
int CarlaBridgeOsc::handleMsgUiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS)
{ {
CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(1, "i"); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(1, "i");
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1); CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1);
@@ -277,7 +259,7 @@ int CarlaBridgeOsc::handleMsgProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS)
return 0; return 0;
} }


int CarlaBridgeOsc::handleMsgMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS)
int CarlaBridgeOsc::handleMsgUiMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS)
{ {
CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "ii"); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "ii");
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1); CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1);
@@ -294,7 +276,7 @@ int CarlaBridgeOsc::handleMsgMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS)
return 0; return 0;
} }


int CarlaBridgeOsc::handleMsgMidi(CARLA_BRIDGE_OSC_HANDLE_ARGS)
int CarlaBridgeOsc::handleMsgUiMidi(CARLA_BRIDGE_OSC_HANDLE_ARGS)
{ {
CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(1, "m"); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(1, "m");
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1); CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1);
@@ -329,6 +311,9 @@ int CarlaBridgeOsc::handleMsgMidi(CARLA_BRIDGE_OSC_HANDLE_ARGS)


return 0; return 0;
} }

#endif // BUILD_BRIDGE_UI #endif // BUILD_BRIDGE_UI


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

CARLA_BRIDGE_END_NAMESPACE CARLA_BRIDGE_END_NAMESPACE

+ 11
- 19
source/bridges/CarlaBridgeOsc.hpp View File

@@ -94,29 +94,21 @@ private:


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


#ifdef BUILD_BRIDGE_UI
int handleMsgConfigure(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgControl(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgMidi(CARLA_BRIDGE_OSC_HANDLE_ARGS);
#endif

int handleMsgShow(); int handleMsgShow();
int handleMsgHide(); int handleMsgHide();
int handleMsgQuit(); int handleMsgQuit();


#ifdef BRIDGE_LV2
int handleMsgLv2AtomTransfer(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgLv2UridMap(CARLA_BRIDGE_OSC_HANDLE_ARGS);
#endif
#ifdef BUILD_BRIDGE_PLUGIN
int handleMsgPluginSaveNow();
int handleMsgPluginSetParameterMidiChannel(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgPluginSetParameterMidiCC(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgPluginSetCustomData(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgPluginSetChunk(CARLA_BRIDGE_OSC_HANDLE_ARGS);
#ifdef BUILD_BRIDGE_UI
int handleMsgUiConfigure(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgUiControl(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgUiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgUiMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgUiMidi(CARLA_BRIDGE_OSC_HANDLE_ARGS);
# ifdef BRIDGE_LV2
int handleMsgLv2UiAtomTransfer(CARLA_BRIDGE_OSC_HANDLE_ARGS);
int handleMsgLv2UiUridMap(CARLA_BRIDGE_OSC_HANDLE_ARGS);
# endif
#endif #endif


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


+ 2
- 57
source/bridges/CarlaBridgePlugin.cpp View File

@@ -254,54 +254,6 @@ public:
} }


// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// plugin management

void prepareForSave()
{
CARLA_SAFE_ASSERT_RETURN(fEngine != nullptr,);
carla_debug("CarlaPluginClient::prepareForSave()");

carla_prepare_for_save(0);

for (uint32_t i=0, count=carla_get_custom_data_count(0); i<count; ++i)
{
const CarlaBackend::CustomData* const cdata(carla_get_custom_data(0, i));
CARLA_SAFE_ASSERT_CONTINUE(cdata != nullptr);

fEngine->oscSend_bridge_set_custom_data(cdata->type, cdata->key, cdata->value);
}

//if (fPlugin->getOptionsEnabled() & CarlaBackend::PLUGIN_OPTION_USE_CHUNKS)
{
//if (const char* const chunkData = carla_get_chunk_data(0))
{
#if 0
QString filePath;
filePath = QDir::tempPath();
#ifdef Q_OS_WIN
filePath += "\\.CarlaChunk_";
#else
filePath += "/.CarlaChunk_";
#endif
filePath += fPlugin->getName();

QFile file(filePath);

if (file.open(QIODevice::WriteOnly))
{
QByteArray chunk((const char*)data, dataSize);
file.write(chunk);
file.close();
fEngine->oscSend_bridge_set_chunk_data(filePath.toUtf8().constData());
}
#endif
}
}

fEngine->oscSend_bridge_configure(CARLA_BRIDGE_MSG_SAVED, "");
}

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


protected: protected:
void handleCallback(const EngineCallbackOpcode action, const int value1, const int value2, const float value3, const char* const valueStr) void handleCallback(const EngineCallbackOpcode action, const int value1, const int value2, const float value3, const char* const valueStr)
@@ -386,17 +338,9 @@ int CarlaBridgeOsc::handleMsgQuit()
return 0; return 0;
} }


#if 0
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------


int CarlaBridgeOsc::handleMsgPluginSaveNow()
{
CARLA_SAFE_ASSERT_RETURN(fClient != nullptr, 1);
carla_debug("CarlaBridgeOsc::handleMsgPluginSaveNow()");

((CarlaPluginClient*)fClient)->prepareForSave();
return 0;
}

int CarlaBridgeOsc::handleMsgPluginSetParameterMidiChannel(CARLA_BRIDGE_OSC_HANDLE_ARGS) int CarlaBridgeOsc::handleMsgPluginSetParameterMidiChannel(CARLA_BRIDGE_OSC_HANDLE_ARGS)
{ {
CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "ii"); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "ii");
@@ -474,6 +418,7 @@ int CarlaBridgeOsc::handleMsgPluginSetChunk(CARLA_BRIDGE_OSC_HANDLE_ARGS)
carla_set_chunk_data(0, chunkData.toRawUTF8()); carla_set_chunk_data(0, chunkData.toRawUTF8());
return 0; return 0;
} }
#endif


CARLA_BRIDGE_END_NAMESPACE CARLA_BRIDGE_END_NAMESPACE




+ 2
- 2
source/bridges/CarlaBridgeUI-LV2.cpp View File

@@ -1156,7 +1156,7 @@ private:


#define lv2ClientPtr ((CarlaLv2Client*)fClient) #define lv2ClientPtr ((CarlaLv2Client*)fClient)


int CarlaBridgeOsc::handleMsgLv2AtomTransfer(CARLA_BRIDGE_OSC_HANDLE_ARGS)
int CarlaBridgeOsc::handleMsgLv2UiAtomTransfer(CARLA_BRIDGE_OSC_HANDLE_ARGS)
{ {
CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "is"); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "is");
carla_debug("CarlaBridgeOsc::handleMsgLv2AtomTransfer()"); carla_debug("CarlaBridgeOsc::handleMsgLv2AtomTransfer()");
@@ -1178,7 +1178,7 @@ int CarlaBridgeOsc::handleMsgLv2AtomTransfer(CARLA_BRIDGE_OSC_HANDLE_ARGS)
return 0; return 0;
} }


int CarlaBridgeOsc::handleMsgLv2UridMap(CARLA_BRIDGE_OSC_HANDLE_ARGS)
int CarlaBridgeOsc::handleMsgLv2UiUridMap(CARLA_BRIDGE_OSC_HANDLE_ARGS)
{ {
CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "is"); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "is");
carla_debug("CarlaBridgeOsc::handleMsgLv2UridMap()"); carla_debug("CarlaBridgeOsc::handleMsgLv2UridMap()");


+ 20
- 19
source/utils/CarlaBridgeUtils.hpp View File

@@ -50,27 +50,28 @@ enum PluginBridgeInfoType {
}; };


enum PluginBridgeOpcode { enum PluginBridgeOpcode {
kPluginBridgeOpcodeNull = 0,
kPluginBridgeOpcodeSetAudioPool = 1, // long
kPluginBridgeOpcodeSetBufferSize = 2, // int
kPluginBridgeOpcodeSetSampleRate = 3, // float
kPluginBridgeOpcodeSetParameterRt = 4, // int, float
kPluginBridgeOpcodeSetParameterNonRt = 5, // int, float
kPluginBridgeOpcodeSetProgram = 6, // int
kPluginBridgeOpcodeSetMidiProgram = 7, // int
kPluginBridgeOpcodeMidiEvent = 8, // long, int, char[] (long = timeFrame, int = size max 4)
kPluginBridgeOpcodeProcess = 9,
kPluginBridgeOpcodeQuit = 10
kPluginBridgeOpcodeNull = 0,
kPluginBridgeOpcodeSetAudioPool = 1, // long
kPluginBridgeOpcodeSetBufferSize = 2, // int
kPluginBridgeOpcodeSetSampleRate = 3, // float
kPluginBridgeOpcodeSetParameterRt = 4, // int, float
kPluginBridgeOpcodeSetParameterNonRt = 5, // int, float
kPluginBridgeOpcodeSetParameterMidiChannel = 6, // int, float
kPluginBridgeOpcodeSetParameterMidiCC = 7, // int, float
kPluginBridgeOpcodeSetProgram = 8, // int
kPluginBridgeOpcodeSetMidiProgram = 9, // int
kPluginBridgeOpcodeSetCustomData = 10, // str, str, str
kPluginBridgeOpcodeSetChunkFile = 11, // str
kPluginBridgeOpcodePrepareForSave = 12,
kPluginBridgeOpcodeMidiEvent = 13, // long, int, char[] (long = timeFrame, int = size max 4)
kPluginBridgeOpcodeProcess = 14,
kPluginBridgeOpcodeShowUI = 15,
kPluginBridgeOpcodeHideUI = 16,
kPluginBridgeOpcodeQuit = 17
}; };


const char* const CARLA_BRIDGE_MSG_HIDE_GUI = "CarlaBridgeHideGUI"; //!< Plugin -> Host call, tells host GUI is now hidden
const char* const CARLA_BRIDGE_MSG_SAVED = "CarlaBridgeSaved"; //!< Plugin -> Host call, tells host state is saved
#if 0
const char* const CARLA_BRIDGE_MSG_SAVE_NOW = "CarlaBridgeSaveNow"; //!< Host -> Plugin call, tells plugin to save state now
const char* const CARLA_BRIDGE_MSG_SET_CHUNK = "CarlaBridgeSetChunk"; //!< Host -> Plugin call, tells plugin to set chunk in file \a value
const char* const CARLA_BRIDGE_MSG_SET_CUSTOM = "CarlaBridgeSetCustom"; //!< Host -> Plugin call, tells plugin to set a custom data set using \a value ("type·key·rvalue").
//If \a type is 'chunk' or 'binary' \a rvalue refers to chunk file.
#endif
const char* const CARLA_BRIDGE_MSG_HIDE_GUI = "CarlaBridgeHideGUI"; //!< Plugin -> Host call, tells host GUI is now hidden
const char* const CARLA_BRIDGE_MSG_SAVED = "CarlaBridgeSaved"; //!< Plugin -> Host call, tells host state is saved


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




Loading…
Cancel
Save