Skip to content

Commit

Permalink
Fix OSC control unregister
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Sep 15, 2024
1 parent 9235ca8 commit 7d3b067
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion source/backend/engine/CarlaEngineOsc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class CarlaEngineOsc
int argc, const lo_arg* const* argv, const char* types, lo_message msg);

int handleMsgRegister(bool isTCP, int argc, const lo_arg* const* argv, const char* types, lo_address source);
int handleMsgUnregister(bool isTCP, int argc, const lo_arg* const* argv, const char* types);
int handleMsgUnregister(bool isTCP, int argc, const lo_arg* const* argv, const char* types, lo_address source);
int handleMsgControl(const char* method,
int argc, const lo_arg* const* argv, const char* types);

Expand Down
25 changes: 18 additions & 7 deletions source/backend/engine/CarlaEngineOscHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path,
return handleMsgRegister(isTCP, argc, argv, types, source);

if (std::strcmp(path, "/unregister") == 0)
return handleMsgUnregister(isTCP, argc, argv, types);
return handleMsgUnregister(isTCP, argc, argv, types, source);

if (std::strncmp(path, "/ctrl/", 6) == 0)
{
Expand Down Expand Up @@ -284,7 +284,8 @@ int CarlaEngineOsc::handleMsgRegister(const bool isTCP,
}

int CarlaEngineOsc::handleMsgUnregister(const bool isTCP,
const int argc, const lo_arg* const* const argv, const char* const types)
const int argc, const lo_arg* const* const argv, const char* const types,
const lo_address source)
{
carla_debug("CarlaEngineOsc::handleMsgUnregister()");
CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "s");
Expand All @@ -297,16 +298,26 @@ int CarlaEngineOsc::handleMsgUnregister(const bool isTCP,
return 0;
}

const char* const url = &argv[0]->s;
const char* const url = &argv[0]->s;
const char* const host = lo_address_get_hostname(source);
const char* const path = lo_url_get_path(url);

if (std::strcmp(oscData.owner, host) != 0)
{
carla_stderr("OSC backend unregister failed, current owner host %s does not match requested %s",
oscData.owner, host);
return 0;
}

if (std::strcmp(oscData.owner, url) == 0)
if (std::strcmp(oscData.path, path) != 0)
{
carla_stdout("OSC client %s unregistered", url);
oscData.clear();
carla_stderr("OSC backend unregister failed, current owner path %s does not match requested %s",
oscData.path, path);
return 0;
}

carla_stderr("OSC backend unregister failed, current owner %s does not match requested %s", oscData.owner, url);
carla_stdout("OSC client %s unregistered", url);
oscData.clear();
return 0;
}

Expand Down

0 comments on commit 7d3b067

Please sign in to comment.