Browse Source

Merge 49c5d16cc9 into 1d8dcb5aab

pull/2011/merge
Asahi Lina GitHub 2 weeks ago
parent
commit
421c7f8278
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
3 changed files with 43 additions and 38 deletions
  1. +39
    -36
      source/backend/engine/CarlaEngineOscHandlers.cpp
  2. +2
    -1
      source/frontend/C++/carla_widgets.cpp
  3. +2
    -1
      source/frontend/dialogs/aboutdialog.cpp

+ 39
- 36
source/backend/engine/CarlaEngineOscHandlers.cpp View File

@@ -87,7 +87,8 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path,
{ {
bytesAfterName = fName.length(); bytesAfterName = fName.length();


if (std::strlen(path) <= bytesAfterName || std::strncmp(path+1, fName, bytesAfterName) != 0)
if (std::strlen(path) <= bytesAfterName || std::strncmp(path+1, fName, bytesAfterName) != 0 ||
path[bytesAfterName+1] != '/')
{ {
carla_stderr("CarlaEngineOsc::handleMessage() - message not for this client -> '%s' != '/%s/'", carla_stderr("CarlaEngineOsc::handleMessage() - message not for this client -> '%s' != '/%s/'",
path, fName.buffer()); path, fName.buffer());
@@ -99,63 +100,65 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path,


// Get plugin id from path, "/carla/23/method" -> 23 // Get plugin id from path, "/carla/23/method" -> 23
uint pluginId = 0; uint pluginId = 0;
std::size_t offset;


if (! std::isdigit(path[bytesAfterName+1]))
const char* const pluginPath = &path[bytesAfterName+1];
std::size_t pluginLen;
if (const char* const slash = std::strchr(pluginPath, '/'))
{ {
carla_stderr("CarlaEngineOsc::handleMessage() - invalid message '%s'", path);
pluginLen = slash - pluginPath;
}
else
{
carla_stderr("CarlaEngineOsc::handleMessage() - message '%s' is invalid", path);
return 1; return 1;
} }


if (std::isdigit(path[bytesAfterName+2]))
{
if (std::isdigit(path[bytesAfterName+4]))
{
carla_stderr2("CarlaEngineOsc::handleMessage() - invalid plugin id, over 999? (value: \"%s\")",
path+bytesAfterName);
return 1;
}
else if (std::isdigit(path[bytesAfterName+3]))
CarlaPluginPtr plugin = nullptr;
bool isNumeric = true;
for (std::size_t i = 0; i < pluginLen; i++) {
if (! std::isdigit(pluginPath[i]))
{ {
// 3 digits, /xyz/method
offset = 5;
pluginId += uint(path[bytesAfterName+1]-'0')*100;
pluginId += uint(path[bytesAfterName+2]-'0')*10;
pluginId += uint(path[bytesAfterName+3]-'0');
isNumeric = false;
break;
} }
else
}
if (pluginLen <= 4 && isNumeric)
{
pluginId = atoi(pluginPath);

if (pluginId > fEngine->getCurrentPluginCount())
{ {
// 2 digits, /xy/method
offset = 4;
pluginId += uint(path[bytesAfterName+1]-'0')*10;
pluginId += uint(path[bytesAfterName+2]-'0');
carla_stderr("CarlaEngineOsc::handleMessage() - failed to get plugin, wrong id '%i'", pluginId);
return 0;
} }

// Get plugin
plugin = fEngine->getPluginUnchecked(pluginId);

} }
else else
{ {
// single digit, /x/method
offset = 3;
pluginId += uint(path[bytesAfterName+1]-'0');
}
for (pluginId = 0; pluginId < fEngine->getCurrentPluginCount(); pluginId++)
{
plugin = fEngine->getPluginUnchecked(pluginId);


if (pluginId > fEngine->getCurrentPluginCount())
{
carla_stderr("CarlaEngineOsc::handleMessage() - failed to get plugin, wrong id '%i'", pluginId);
return 0;
}
if (strlen(plugin->getName()) == pluginLen && !strncmp(plugin->getName(), pluginPath, pluginLen)) {
break;
}


// Get plugin
const CarlaPluginPtr plugin = fEngine->getPluginUnchecked(pluginId);
plugin = nullptr;
}
}


if (plugin == nullptr || plugin->getId() != pluginId) if (plugin == nullptr || plugin->getId() != pluginId)
{ {
carla_stderr("CarlaEngineOsc::handleMessage() - invalid plugin id '%i', probably has been removed (path: '%s')", pluginId, path);
carla_stderr("CarlaEngineOsc::handleMessage() - plugin not found, probably has been removed (path: '%s')", path);
return 0; return 0;
} }


// Get method from path, "/Carla/i/method" -> "method" // Get method from path, "/Carla/i/method" -> "method"
char method[48]; char method[48];
std::strncpy(method, path + (bytesAfterName + offset), 47);
std::strncpy(method, &pluginPath[pluginLen + 1], 47);
method[47] = '\0'; method[47] = '\0';


if (method[0] == '\0') if (method[0] == '\0')


+ 2
- 1
source/frontend/C++/carla_widgets.cpp View File

@@ -118,7 +118,8 @@ struct CarlaAboutW::PrivateData {
"</table>"); "</table>");


ui.l_example->setText("/Carla/2/set_parameter_value 5 1.0"); ui.l_example->setText("/Carla/2/set_parameter_value 5 1.0");
ui.l_example_help->setText("<i>(as in this example, \"2\" is the plugin number and \"5\" the parameter)</i>");
ui.l_example_help->setText("<i>(In this example, \"2\" is the plugin number and \"5\" the parameter.<br>"
"Plugins can also be referenced by their name.)</i>");


ui.l_ladspa->setText(tr("Everything! (Including LRDF)")); ui.l_ladspa->setText(tr("Everything! (Including LRDF)"));
ui.l_dssi->setText(tr("Everything! (Including CustomData/Chunks)")); ui.l_dssi->setText(tr("Everything! (Including CustomData/Chunks)"));


+ 2
- 1
source/frontend/dialogs/aboutdialog.cpp View File

@@ -74,7 +74,8 @@ AboutDialog::AboutDialog(QWidget* const parent,
"</table>"); "</table>");


ui.l_example->setText("/Carla/2/set_parameter_value 5 1.0"); ui.l_example->setText("/Carla/2/set_parameter_value 5 1.0");
ui.l_example_help->setText("<i>(as in this example, \"2\" is the plugin number and \"5\" the parameter)</i>");
ui.l_example_help->setText("<i>(In this example, \"2\" is the plugin number and \"5\" the parameter.<br>"
"Plugins can also be referenced by their name.)</i>");


ui.l_ladspa->setText(tr("Everything! (Including LRDF)")); ui.l_ladspa->setText(tr("Everything! (Including LRDF)"));
ui.l_dssi->setText(tr("Everything! (Including CustomData/Chunks)")); ui.l_dssi->setText(tr("Everything! (Including CustomData/Chunks)"));


Loading…
Cancel
Save