Browse Source

OSC control now waits for responses from server

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.1-rc1
falkTX 6 years ago
parent
commit
94d30f085b
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 178 additions and 158 deletions
  1. +1
    -0
      source/backend/engine/CarlaEngineOsc.hpp
  2. +121
    -103
      source/backend/engine/CarlaEngineOscHandlers.cpp
  3. +9
    -49
      source/backend/engine/CarlaEngineOscSend.cpp
  4. +47
    -6
      source/frontend/carla_control.py

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

@@ -105,6 +105,7 @@ public:
void sendPluginCustomData(const CarlaPlugin* const plugin, const uint32_t index) const noexcept;
void sendPluginInternalParameterValues(const CarlaPlugin* const plugin) const noexcept;
void sendPing() const noexcept;
void sendResponse(const int messageId, const char* const error) const noexcept;
void sendExit() const noexcept;

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


+ 121
- 103
source/backend/engine/CarlaEngineOscHandlers.cpp View File

@@ -284,6 +284,7 @@ int CarlaEngineOsc::handleMsgControl(const char* const method,
carla_debug("CarlaEngineOsc::handleMsgControl()");
CARLA_SAFE_ASSERT_RETURN(method != nullptr && method[0] != '\0', 0);
CARLA_SAFE_ASSERT_RETURN(types != nullptr, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'i', 0);

if (fControlDataTCP.owner == nullptr)
{
@@ -291,230 +292,247 @@ int CarlaEngineOsc::handleMsgControl(const char* const method,
return 0;
}

const int32_t messageId = argv[0]->i;
bool ok;

#define CARLA_SAFE_ASSERT_RETURN_OSC_ERR(cond) \
if (! (cond)) { carla_safe_assert(#cond, __FILE__, __LINE__); sendResponse(messageId, #cond); return 0; }

/**/ if (std::strcmp(method, "clear_engine_xruns") == 0)
{
ok = true;
fEngine->clearXruns();
}
else if (std::strcmp(method, "cancel_engine_action") == 0)
{
ok = true;
fEngine->setActionCanceled(true);
}
else if (std::strcmp(method, "patchbay_connect") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 5, argc, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[1] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[2] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[3] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[4] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(argc == 6);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[1] == 'i');
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[2] == 'i');
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[3] == 'i');
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[4] == 'i');
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[5] == 'i');

const bool ext = argv[0]->i != 0;
const bool external = argv[1]->i != 0;

const int32_t i1 = argv[1]->i;
CARLA_SAFE_ASSERT_RETURN(i1 >= 0, 0);
const int32_t groupA = argv[2]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(groupA >= 0);

const int32_t i2 = argv[2]->i;
CARLA_SAFE_ASSERT_RETURN(i2 >= 0, 0);
const int32_t portA = argv[3]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(portA >= 0);

const int32_t i3 = argv[3]->i;
CARLA_SAFE_ASSERT_RETURN(i3 >= 0, 0);
const int32_t groupB = argv[4]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(groupB >= 0);

const int32_t i4 = argv[4]->i;
CARLA_SAFE_ASSERT_RETURN(i4 >= 0, 0);
const int32_t portB = argv[5]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(portB >= 0);

fEngine->patchbayConnect(ext,
static_cast<uint32_t>(i1),
static_cast<uint32_t>(i2),
static_cast<uint32_t>(i3),
static_cast<uint32_t>(i4));
ok = fEngine->patchbayConnect(external,
static_cast<uint32_t>(groupA),
static_cast<uint32_t>(portA),
static_cast<uint32_t>(groupB),
static_cast<uint32_t>(portB));
}
else if (std::strcmp(method, "patchbay_disconnect") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 2, argc, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[1] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(argc == 3);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[1] == 'i');
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[2] == 'i');

const bool ext = argv[0]->i != 0;
const bool external = argv[1]->i != 0;

const int32_t id = argv[1]->i;
CARLA_SAFE_ASSERT_RETURN(id >= 0, 0);
const int32_t connectionId = argv[2]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(connectionId >= 0);

fEngine->patchbayDisconnect(ext, static_cast<uint32_t>(id));
ok = fEngine->patchbayDisconnect(external, static_cast<uint32_t>(connectionId));
}
else if (std::strcmp(method, "patchbay_refresh") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 1, argc, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(argc == 2);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[1] == 'i');

const bool ext = argv[0]->i != 0;
fEngine->patchbayRefresh(false, true, ext);
const bool external = argv[1]->i != 0;

ok = fEngine->patchbayRefresh(false, true, external);
}
else if (std::strcmp(method, "transport_play") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 0, argc, 0);
ok = true;
fEngine->transportPlay();
}
else if (std::strcmp(method, "transport_pause") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 0, argc, 0);
ok = true;
fEngine->transportPause();
}
else if (std::strcmp(method, "transport_bpm") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 1, argc, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'f', 0);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(argc == 2);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[1] == 'f');

const double f = argv[0]->f;
CARLA_SAFE_ASSERT_RETURN(f >= 0.0, 0);
const double bpm = argv[1]->f;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(bpm >= 0.0);

fEngine->transportBPM(f);
ok = true;
fEngine->transportBPM(bpm);
}
else if (std::strcmp(method, "transport_relocate") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 1, argc, 0);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(argc == 2);

uint64_t frame;

/**/ if (types[0] == 'i')
/**/ if (types[1] == 'i')
{
const int32_t i = argv[0]->i;
CARLA_SAFE_ASSERT_RETURN(i >= 0, 0);
const int32_t i = argv[1]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(i >= 0);
frame = static_cast<uint64_t>(i);
}
else if (types[0] == 'h')
else if (types[1] == 'h')
{
const int64_t h = argv[0]->h;
CARLA_SAFE_ASSERT_RETURN(h >= 0, 0);
const int64_t h = argv[1]->h;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(h >= 0);
frame = static_cast<uint64_t>(h);
}
else
{
carla_stderr2("Wrong OSC type used for '%s'", method);
sendResponse(messageId, "Wrong OSC type");
return 0;
}

ok = true;
fEngine->transportRelocate(frame);
}
else if (std::strcmp(method, "add_plugin") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 7, argc, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[1] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[2] == 's', 0);
CARLA_SAFE_ASSERT_RETURN(types[3] == 's', 0);
CARLA_SAFE_ASSERT_RETURN(types[4] == 's', 0);
CARLA_SAFE_ASSERT_RETURN(types[6] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(argc == 8);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[1] == 'i');
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[2] == 'i');
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[3] == 's');
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[4] == 's');
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[5] == 's');
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[7] == 'i');

const int32_t btype = argv[0]->i;
CARLA_SAFE_ASSERT_RETURN(btype >= 0, 0);
const int32_t btype = argv[1]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(btype >= 0);

const int32_t ptype = argv[1]->i;
CARLA_SAFE_ASSERT_RETURN(ptype >= 0, 0);
const int32_t ptype = argv[2]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(ptype >= 0);

const char* filename = &argv[2]->s;
const char* filename = &argv[3]->s;

if (filename != nullptr && std::strcmp(filename, "(null)") == 0)
filename = nullptr;

const char* name = &argv[3]->s;
const char* name = &argv[4]->s;

if (name != nullptr && std::strcmp(name, "(null)") == 0)
name = nullptr;

const char* const label = &argv[4]->s;
CARLA_SAFE_ASSERT_RETURN(label != nullptr && label[0] != '\0', 0);
const char* const label = &argv[5]->s;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(label != nullptr && label[0] != '\0');

int64_t uniqueId;

/**/ if (types[5] == 'i')
/**/ if (types[6] == 'i')
{
uniqueId = argv[5]->i;
uniqueId = argv[6]->i;
}
else if (types[5] == 'h')
else if (types[6] == 'h')
{
uniqueId = argv[5]->h;
uniqueId = argv[6]->h;
}
else
{
carla_stderr2("Wrong OSC type used for '%s' uniqueId", method);
sendResponse(messageId, "Wrong OSC type");
return 0;
}

const int32_t options = argv[6]->i;
CARLA_SAFE_ASSERT_RETURN(options >= 0, 0);
const int32_t options = argv[7]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(options >= 0);

fEngine->addPlugin(static_cast<BinaryType>(btype),
static_cast<PluginType>(ptype),
filename, name, label, uniqueId, nullptr, static_cast<uint32_t>(options));
ok = fEngine->addPlugin(static_cast<BinaryType>(btype),
static_cast<PluginType>(ptype),
filename, name, label, uniqueId, nullptr, static_cast<uint32_t>(options));
}
else if (std::strcmp(method, "remove_plugin") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 1, argc, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(argc == 2);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[1] == 'i');

const int32_t i = argv[0]->i;
CARLA_SAFE_ASSERT_RETURN(i >= 0, 0);
const int32_t id = argv[1]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(id >= 0);

fEngine->removePlugin(static_cast<uint32_t>(i));
ok = fEngine->removePlugin(static_cast<uint32_t>(id));
}
else if (std::strcmp(method, "remove_all_plugins") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 0, argc, 0);

fEngine->removeAllPlugins();
ok = fEngine->removeAllPlugins();
}
else if (std::strcmp(method, "rename_plugin") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 2, argc, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[1] == 's', 0);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(argc == 3);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[1] == 'i');
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[2] == 's');

const int32_t i = argv[0]->i;
CARLA_SAFE_ASSERT_RETURN(i >= 0, 0);
const int32_t id = argv[1]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(id >= 0);

const char* const s = &argv[1]->s;
CARLA_SAFE_ASSERT_RETURN(s != nullptr && s[0] != '\0', 0);
const char* const newName = &argv[2]->s;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(newName != nullptr && newName[0] != '\0');

fEngine->renamePlugin(static_cast<uint32_t>(i), s);
ok = fEngine->renamePlugin(static_cast<uint32_t>(id), newName);
}
else if (std::strcmp(method, "clone_plugin") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 1, argc, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(argc == 2);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[1] == 'i');

const int32_t i = argv[0]->i;
CARLA_SAFE_ASSERT_RETURN(i >= 0, 0);
const int32_t id = argv[1]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(id >= 0);

fEngine->clonePlugin(static_cast<uint32_t>(i));
ok = fEngine->clonePlugin(static_cast<uint32_t>(id));
}
else if (std::strcmp(method, "replace_plugin") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 1, argc, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(argc == 2);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[1] == 'i');

const int32_t i = argv[0]->i;
CARLA_SAFE_ASSERT_RETURN(i >= 0, 0);
const int32_t id = argv[1]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(id >= 0);

fEngine->replacePlugin(static_cast<uint32_t>(i));
ok = fEngine->replacePlugin(static_cast<uint32_t>(id));
}
else if (std::strcmp(method, "switch_plugins") == 0)
{
CARLA_SAFE_ASSERT_INT_RETURN(argc == 2, argc, 0);
CARLA_SAFE_ASSERT_RETURN(types[0] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN(types[1] == 'i', 0);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(argc == 3);
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[1] == 'i');
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(types[2] == 'i');

const int32_t i0 = argv[0]->i;
CARLA_SAFE_ASSERT_RETURN(i0 >= 0, 0);
const int32_t idA = argv[1]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(idA >= 0);

const int32_t i1 = argv[1]->i;
CARLA_SAFE_ASSERT_RETURN(i1 >= 0, 0);
const int32_t idB = argv[2]->i;
CARLA_SAFE_ASSERT_RETURN_OSC_ERR(idB >= 0);

fEngine->switchPlugins(static_cast<uint32_t>(i0), static_cast<uint32_t>(i1));
ok = fEngine->switchPlugins(static_cast<uint32_t>(idA), static_cast<uint32_t>(idB));
}
else
{
carla_stderr2("Unhandled OSC control for '%s'", method);
sendResponse(messageId, "Unhandled OSC control method");
return 0;
}

#undef CARLA_SAFE_ASSERT_RETURN_OSC_ERR

sendResponse(messageId, ok ? "" : fEngine->getLastError());
return 0;
}



+ 9
- 49
source/backend/engine/CarlaEngineOscSend.cpp View File

@@ -271,69 +271,29 @@ void CarlaEngineOsc::sendPluginInternalParameterValues(const CarlaPlugin* const
);
}

#if 0
void CarlaEngineOsc::sendset_program_count(const uint pluginId, const uint32_t count) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);
carla_debug("CarlaEngineOsc::sendset_program_count(%i, %i)", pluginId, count);

char targetPath[std::strlen(fControlDataTCP.path)+19];
std::strcpy(targetPath, fControlDataTCP.path);
std::strcat(targetPath, "/set_program_count");
try_lo_send(fControlDataTCP.target, targetPath, "ii", static_cast<int32_t>(pluginId), static_cast<int32_t>(count));
}

void CarlaEngineOsc::sendset_midi_program_count(const uint pluginId, const uint32_t count) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);
carla_debug("CarlaEngineOsc::sendset_midi_program_count(%i, %i)", pluginId, count);

char targetPath[std::strlen(fControlDataTCP.path)+24];
std::strcpy(targetPath, fControlDataTCP.path);
std::strcat(targetPath, "/set_midi_program_count");
try_lo_send(fControlDataTCP.target, targetPath, "ii", static_cast<int32_t>(pluginId), static_cast<int32_t>(count));
}

void CarlaEngineOsc::sendset_program_name(const uint pluginId, const uint32_t index, const char* const name) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
carla_debug("CarlaEngineOsc::sendset_program_name(%i, %i, \"%s\")", pluginId, index, name);

char targetPath[std::strlen(fControlDataTCP.path)+18];
std::strcpy(targetPath, fControlDataTCP.path);
std::strcat(targetPath, "/set_program_name");
try_lo_send(fControlDataTCP.target, targetPath, "iis", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), name);
}
// -----------------------------------------------------------------------

void CarlaEngineOsc::sendset_midi_program_data(const uint pluginId, const uint32_t index, const uint32_t bank, const uint32_t program, const char* const name) const noexcept
void CarlaEngineOsc::sendPing() const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(name != nullptr,);
carla_debug("CarlaEngineOsc::sendset_midi_program_data(%i, %i, %i, %i, \"%s\")", pluginId, index, bank, program, name);

char targetPath[std::strlen(fControlDataTCP.path)+23];
char targetPath[std::strlen(fControlDataTCP.path)+6];
std::strcpy(targetPath, fControlDataTCP.path);
std::strcat(targetPath, "/set_midi_program_data");
try_lo_send(fControlDataTCP.target, targetPath, "iiiis", static_cast<int32_t>(pluginId), static_cast<int32_t>(index), static_cast<int32_t>(bank), static_cast<int32_t>(program), name);
std::strcat(targetPath, "/ping");
try_lo_send(fControlDataTCP.target, targetPath, "");
}
#endif

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

void CarlaEngineOsc::sendPing() const noexcept
void CarlaEngineOsc::sendResponse(const int messageId, const char* const error) const noexcept
{
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.path != nullptr && fControlDataTCP.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(fControlDataTCP.target != nullptr,);
carla_debug("CarlaEngineOsc::sendExit()");

char targetPath[std::strlen(fControlDataTCP.path)+6];
std::strcpy(targetPath, fControlDataTCP.path);
std::strcat(targetPath, "/ping");
try_lo_send(fControlDataTCP.target, targetPath, "");
std::strcat(targetPath, "/resp");
try_lo_send(fControlDataTCP.target, targetPath, "is", messageId, error);
}

void CarlaEngineOsc::sendExit() const noexcept


+ 47
- 6
source/frontend/carla_control.py View File

@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

# Carla Backend code (OSC stuff)
# Copyright (C) 2011-2015 Filipe Coelho <falktx@falktx.com>
# 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
@@ -16,6 +16,11 @@
#
# For a full copy of the GNU General Public License see the doc/GPL.txt file.

# ----------------------------------------------------------------------------------------------------------------------
# Imports (Global)

from PyQt5.QtCore import QEventLoop

# ------------------------------------------------------------------------------------------------------------
# Imports (Custom)

@@ -51,6 +56,10 @@ class CarlaHostOSC(CarlaHostQtPlugin):
self.lo_target_tcp_name = ""
self.lo_target_udp_name = ""

self.lastMessageId = 1
self.pendingMessages = []
self.responses = {}

# -------------------------------------------------------------------

def printAndReturnError(self, error):
@@ -97,6 +106,7 @@ class CarlaHostOSC(CarlaHostQtPlugin):
#"save_plugin_state",
):
path = "/ctrl/" + method
needResp = True

elif method in (#"set_option",
"set_active",
@@ -118,10 +128,12 @@ class CarlaHostOSC(CarlaHostQtPlugin):
#"randomize_parameters",
):
pluginId = lines.pop(0)
needResp = False
path = "/%s/%i/%s" % (self.lo_target_tcp_name, pluginId, method)

elif method == "send_midi_note":
pluginId = lines.pop(0)
needResp = False
channel, note, velocity = lines

if velocity:
@@ -133,11 +145,35 @@ class CarlaHostOSC(CarlaHostQtPlugin):
else:
return self.printAndReturnError("invalid method '%s'" % method)

if len(self.pendingMessages) != 0:
return self.printAndReturnError("A previous operation is still pending, please wait")

args = [int(line) if isinstance(line, bool) else line for line in lines]
#print(path, args)

lo_send(self.lo_target_tcp, path, *args)
return True
if not needResp:
lo_send(self.lo_target_tcp, path, *args)
return True

messageId = self.lastMessageId
self.lastMessageId += 1
self.pendingMessages.append(messageId)

lo_send(self.lo_target_tcp, path, messageId, *args)

while messageId in self.pendingMessages:
QApplication.processEvents(QEventLoop.AllEvents, 100)

error = self.responses.pop(messageId)

if not error:
return True

self.fLastError = error
return False

def sendMsgAndSetError(self, lines):
return self.sendMsg(lines)

# -------------------------------------------------------------------

@@ -166,7 +202,7 @@ class CarlaControlServerTCP(Server):
Server.__init__(self, proto=LO_TCP)

if False:
host = CarlaHostPlugin()
host = CarlaHostOSC()

self.host = host

@@ -308,6 +344,13 @@ class CarlaControlServerTCP(Server):
self.host._set_internalValue(pluginId, PARAMETER_PANNING, pan)
self.host._set_internalValue(pluginId, PARAMETER_CTRL_CHANNEL, ctrlChan)

@make_method('/ctrl/resp', 'is')
def carla_resp(self, path, args):
self.fReceivedMsgs = True
messageId, error = args
self.host.responses[messageId] = error
self.host.pendingMessages.remove(messageId)

@make_method('/ctrl/exit', '')
def carla_exit(self, path, args):
self.fReceivedMsgs = True
@@ -411,12 +454,10 @@ class HostWindowOSC(HostWindow):
lo_target_tcp = Address(self.fOscAddressTCP)
lo_server_tcp = CarlaControlServerTCP(self.host)
lo_send(lo_target_tcp, "/register", lo_server_tcp.getFullURL())
print(lo_server_tcp.getFullURL())

lo_target_udp = Address(self.fOscAddressUDP)
lo_server_udp = CarlaControlServerUDP(self.host)
lo_send(lo_target_udp, "/register", lo_server_udp.getFullURL())
print(lo_server_udp.getFullURL())

except AddressError as e:
err = e


Loading…
Cancel
Save