From 59955b16aa2677122825c6b1a00837eb841a51f2 Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 8 Feb 2019 00:32:31 +0100 Subject: [PATCH] Small fixes to libjack Signed-off-by: falkTX --- source/backend/plugin/CarlaPluginJack.cpp | 9 --------- source/libjack/libjack.hpp | 6 ++---- source/libjack/libjack_port-searching.cpp | 14 ++++++++------ source/libjack/libjack_ports.cpp | 17 +++++++++-------- 4 files changed, 19 insertions(+), 27 deletions(-) diff --git a/source/backend/plugin/CarlaPluginJack.cpp b/source/backend/plugin/CarlaPluginJack.cpp index dce42db92..dbd666a24 100644 --- a/source/backend/plugin/CarlaPluginJack.cpp +++ b/source/backend/plugin/CarlaPluginJack.cpp @@ -114,13 +114,6 @@ public: return (uintptr_t)fProcess->getPID(); } - void sendTerminate() const noexcept - { - CARLA_SAFE_ASSERT_RETURN(fProcess != nullptr,); - - fProcess->terminate(); - } - #ifdef HAVE_LIBLO void nsmSave(const char* const setupLabel) { @@ -487,8 +480,6 @@ public: fShmNonRtClientControl.writeOpcode(kPluginBridgeNonRtClientQuit); fShmNonRtClientControl.commitWrite(); - fBridgeThread.sendTerminate(); - if (! fTimedOut) waitForClient("stopping", 3000); } diff --git a/source/libjack/libjack.hpp b/source/libjack/libjack.hpp index 12b8e6fa5..2397b67fd 100644 --- a/source/libjack/libjack.hpp +++ b/source/libjack/libjack.hpp @@ -96,8 +96,8 @@ struct JackMidiPortBuffer { }; struct JackPortState { - char* name; - char* fullname; + const char* name; + const char* fullname; void* buffer; uint index; uint flags; @@ -144,8 +144,6 @@ struct JackPortState { ~JackPortState() { - std::free(name); - std::free(fullname); } CARLA_DECLARE_NON_COPY_STRUCT(JackPortState) diff --git a/source/libjack/libjack_port-searching.cpp b/source/libjack/libjack_port-searching.cpp index c9b227fca..d6cf765cb 100644 --- a/source/libjack/libjack_port-searching.cpp +++ b/source/libjack/libjack_port-searching.cpp @@ -120,17 +120,19 @@ jack_port_t* jack_port_by_name(jack_client_t* client, const char* name) /* isSystem */ true, /* isConnected */ false ); + static CarlaString rname, rfullname; const JackServerState& jserver(jclient->server); const int commonFlags = JackPortIsPhysical|JackPortIsTerminal; - std::free(retPort.fullname); - retPort.fullname = strdup(name); + rfullname = name; name += 7; - std::free(retPort.name); - retPort.name = strdup(name); + rname = name; + + retPort.name = rname.buffer(); + retPort.fullname = rfullname.buffer(); /**/ if (std::strncmp(name, "capture_", 8) == 0) { @@ -161,7 +163,7 @@ jack_port_t* jack_port_by_name(jack_client_t* client, const char* name) name += 13; const int index = std::atoi(name)-1; - CARLA_SAFE_ASSERT_RETURN(index >= 0 && index < jserver.numAudioIns, nullptr); + CARLA_SAFE_ASSERT_RETURN(index >= 0 && index < jserver.numMidiIns, nullptr); retPort.index = index; retPort.flags = commonFlags|JackPortIsOutput; @@ -173,7 +175,7 @@ jack_port_t* jack_port_by_name(jack_client_t* client, const char* name) name += 14; const int index = std::atoi(name)-1; - CARLA_SAFE_ASSERT_RETURN(index >= 0 && index < jserver.numAudioOuts, nullptr); + CARLA_SAFE_ASSERT_RETURN(index >= 0 && index < jserver.numMidiOuts, nullptr); retPort.index = (jserver.numAudioIns) + index; retPort.flags = commonFlags|JackPortIsInput; diff --git a/source/libjack/libjack_ports.cpp b/source/libjack/libjack_ports.cpp index 361eaa32e..28f0f8a52 100644 --- a/source/libjack/libjack_ports.cpp +++ b/source/libjack/libjack_ports.cpp @@ -344,22 +344,23 @@ int jack_port_rename(jack_client_t* client, jack_port_t *port, const char *port_ CARLA_SAFE_ASSERT_RETURN(jport != nullptr, EINVAL); CARLA_SAFE_ASSERT_RETURN(! jport->isSystem, EINVAL); + static CarlaString rname, rfullname; + // TODO: verify uniqueness - char* const name = strdup(port_name); - CARLA_SAFE_ASSERT_RETURN(name != nullptr, ENOMEM); + rname = port_name; + CARLA_SAFE_ASSERT_RETURN(rname.isNotEmpty(), ENOMEM); char* const fullname = (char*)std::malloc(STR_MAX); - CARLA_SAFE_ASSERT_RETURN(name != nullptr, ENOMEM); - - std::free(jport->name); - jport->name = strdup(port_name); + CARLA_SAFE_ASSERT_RETURN(fullname != nullptr, ENOMEM); std::snprintf(fullname, STR_MAX, "%s:%s", jclient->name, port_name); fullname[STR_MAX-1] = '\0'; - std::free(jport->fullname); - jport->fullname = fullname; + jport->name = rname.buffer(); + jport->fullname = rfullname.buffer(); + + std::free(fullname); // TODO: port rename callback