From dc146bb5ad4bc14276d0a988478a39ebce4cfe61 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 2 Feb 2014 10:56:50 +0000 Subject: [PATCH] Fix jack engine for grouping canvas clients to plugin ids --- source/backend/CarlaBackend.h | 5 +- source/backend/engine/CarlaEngineJack.cpp | 69 ++++++----------------- source/carla | 2 +- source/carla_backend.py | 5 +- source/carla_host.py | 6 +- source/carla_patchbay.py | 6 +- source/utils/CarlaBackendUtils.hpp | 4 +- 7 files changed, 33 insertions(+), 64 deletions(-) diff --git a/source/backend/CarlaBackend.h b/source/backend/CarlaBackend.h index 8e549e804..4a3896295 100644 --- a/source/backend/CarlaBackend.h +++ b/source/backend/CarlaBackend.h @@ -804,12 +804,13 @@ typedef enum { ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 21, /*! - * A patchbay client icon has changed. + * A patchbay client data has changed. * @param pluginId Client Id * @param value1 New icon + * @param value2 New plugin Id (-1 if not a plugin) * @see PatchbayIcon */ - ENGINE_CALLBACK_PATCHBAY_CLIENT_ICON_CHANGED = 22, + ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED = 22, /*! * A patchbay port has been added. diff --git a/source/backend/engine/CarlaEngineJack.cpp b/source/backend/engine/CarlaEngineJack.cpp index 433f618a2..fb871c1c0 100644 --- a/source/backend/engine/CarlaEngineJack.cpp +++ b/source/backend/engine/CarlaEngineJack.cpp @@ -490,7 +490,7 @@ public: fUsedGroupNames.clear(); fUsedPortNames.clear(); fUsedConnections.clear(); - fNewPlugins.clear(); + fNewGroups.clear(); #endif } @@ -567,7 +567,7 @@ public: fUsedGroupNames.clear(); fUsedPortNames.clear(); fUsedConnections.clear(); - fNewPlugins.clear(); + fNewGroups.clear(); fClient = jackbridge_client_open(clientName, JackNullOption, nullptr); @@ -576,9 +576,6 @@ public: pData->bufferSize = jackbridge_get_buffer_size(fClient); pData->sampleRate = jackbridge_get_sample_rate(fClient); - //jackbridge_custom_publish_data(fClient, URI_CANVAS_ICON, "carla", 6); - //jackbridge_custom_set_data_appearance_callback(fClient, carla_jack_custom_appearance_callback, this); - jackbridge_set_buffer_size_callback(fClient, carla_jack_bufsize_callback, this); jackbridge_set_sample_rate_callback(fClient, carla_jack_srate_callback, this); jackbridge_set_freewheel_callback(fClient, carla_jack_freewheel_callback, this); @@ -663,58 +660,37 @@ public: fUsedGroupNames.clear(); fUsedPortNames.clear(); fUsedConnections.clear(); - fNewPlugins.clear(); + fNewGroups.clear(); return false; #endif } -#if 0 //ndef BUILD_BRIDGE void idle() override { CarlaEngine::idle(); - if (fGroupIconsChanged.count() == 0) - return; - - static bool checkIcons = false; - - if (! checkIcons) - { - checkIcons = true; // check them next time + if (fNewGroups.count() == 0) return; - } - - checkIcons = false; - - void* data; - size_t dataSize; - List groupIconsCopy; - fGroupIconsChanged.spliceAppend(groupIconsCopy, true); + LinkedList newPlugins; + fNewGroups.spliceInsert(newPlugins, true); - for (List::Itenerator it = groupIconsCopy.begin(); it.valid(); it.next()) + for (LinkedList::Itenerator it = newPlugins.begin(); it.valid(); it.next()) { - const int& groupId(*it); + const int groupId(it.getValue()); const char* const groupName(getGroupName(groupId)); + CARLA_SAFE_ASSERT_CONTINUE(groupId > 0 && groupName != nullptr && groupName[0] != '\0'); - data = nullptr; - dataSize = 0; + int pluginId = -1; + PatchbayIcon icon = PATCHBAY_ICON_PLUGIN; - if (jackbridge_custom_get_data(fClient, groupName, URI_CANVAS_ICON, &data, &dataSize) && data != nullptr && dataSize != 0) - { - const char* const icon((const char*)data); - CARLA_ASSERT(std::strlen(icon)+1 == dataSize); - - callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_ICON_CHANGED, 0, groupId, 0, 0.0f, icon); - - jackbridge_free(data); - } + if (findPluginIdAndIcon(groupName, pluginId, icon)) + callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED, static_cast(groupId), icon, pluginId, 0.0f, nullptr); } - groupIconsCopy.clear(); + newPlugins.clear(); } -#endif bool isRunning() const noexcept override { @@ -742,7 +718,6 @@ public: CarlaEngineClient* addClient(CarlaPlugin* const plugin) override { - //const char* const iconName(plugin->getIconName()); jack_client_t* client = nullptr; #ifdef BUILD_BRIDGE @@ -753,8 +728,6 @@ public: pData->bufferSize = jackbridge_get_buffer_size(client); pData->sampleRate = jackbridge_get_sample_rate(client); - //jackbridge_custom_publish_data(client, URI_CANVAS_ICON, iconName, std::strlen(iconName)+1); - jackbridge_set_buffer_size_callback(client, carla_jack_bufsize_callback, this); jackbridge_set_sample_rate_callback(client, carla_jack_srate_callback, this); jackbridge_set_freewheel_callback(client, carla_jack_freewheel_callback, this); @@ -772,8 +745,6 @@ public: CARLA_SAFE_ASSERT_RETURN(client != nullptr, nullptr); - //jackbridge_custom_publish_data(client, URI_CANVAS_ICON, iconName, std::strlen(iconName)+1); - //jackbridge_set_latency_callback(client, carla_jack_latency_callback_plugin, plugin); jackbridge_set_process_callback(client, carla_jack_process_callback_plugin, plugin); } @@ -822,9 +793,6 @@ public: if (jack_client_t* const jclient = jackbridge_client_open(name, JackNullOption, nullptr)) { - //const char* const iconName(plugin->getIconName()); - //jackbridge_custom_publish_data(jclient, URI_CANVAS_ICON, iconName, std::strlen(iconName)+1); - // close old client plugin->setEnabled(false); @@ -931,7 +899,7 @@ public: fUsedGroupNames.clear(); fUsedPortNames.clear(); fUsedConnections.clear(); - fNewPlugins.clear(); + fNewGroups.clear(); initJackPatchbay(jackbridge_get_client_name(fClient)); @@ -1334,12 +1302,11 @@ protected: groupNameToId.setData(groupId, groupName); fUsedGroupNames.append(groupNameToId); - int pluginId = -1; PatchbayIcon icon = (jackPortFlags & JackPortIsPhysical) ? PATCHBAY_ICON_HARDWARE : PATCHBAY_ICON_APPLICATION; - findPluginIdAndIcon(groupName.getBuffer(), pluginId, icon); + callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED, static_cast(groupId), icon, -1, 0.0f, groupName); - callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED, static_cast(groupId), icon, pluginId, 0.0f, groupName); + fNewGroups.append(groupId); } bool portIsInput = (jackPortFlags & JackPortIsInput); @@ -1641,7 +1608,7 @@ private: LinkedList fUsedGroupNames; LinkedList fUsedPortNames; LinkedList fUsedConnections; - LinkedList fNewPlugins; + LinkedList fNewGroups; int getGroupId(const char* const name) { diff --git a/source/carla b/source/carla index cac755eb6..be7f97169 100755 --- a/source/carla +++ b/source/carla @@ -84,7 +84,7 @@ class CarlaMultiW(QTabWidget): parent.PatchbayClientAddedCallback.connect(self.fPatchbay.slot_handlePatchbayClientAddedCallback) parent.PatchbayClientRemovedCallback.connect(self.fPatchbay.slot_handlePatchbayClientRemovedCallback) parent.PatchbayClientRenamedCallback.connect(self.fPatchbay.slot_handlePatchbayClientRenamedCallback) - parent.PatchbayClientIconChangedCallback.connect(self.fPatchbay.slot_handlePatchbayClientIconChangedCallback) + parent.PatchbayClientDataChangedCallback.connect(self.fPatchbay.slot_handlePatchbayClientDataChangedCallback) parent.PatchbayPortAddedCallback.connect(self.fPatchbay.slot_handlePatchbayPortAddedCallback) parent.PatchbayPortRemovedCallback.connect(self.fPatchbay.slot_handlePatchbayPortRemovedCallback) parent.PatchbayPortRenamedCallback.connect(self.fPatchbay.slot_handlePatchbayPortRenamedCallback) diff --git a/source/carla_backend.py b/source/carla_backend.py index cad4a0f0c..f24a5dcf2 100644 --- a/source/carla_backend.py +++ b/source/carla_backend.py @@ -573,11 +573,12 @@ ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED = 20 # @param valueStr New client name ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED = 21 -# A patchbay client icon has changed. +# A patchbay client data has changed. # @param pluginId Client Id # @param value1 New icon +# @param value2 New plugin Id (-1 if not a plugin) # @see PatchbayIcon -ENGINE_CALLBACK_PATCHBAY_CLIENT_ICON_CHANGED = 22 +ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED = 22 # A patchbay port has been added. # @param pluginId Client Id diff --git a/source/carla_host.py b/source/carla_host.py index d90d40bac..45a85a590 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -124,7 +124,7 @@ class HostWindow(QMainWindow): PatchbayClientAddedCallback = pyqtSignal(int, int, str) PatchbayClientRemovedCallback = pyqtSignal(int) PatchbayClientRenamedCallback = pyqtSignal(int, str) - PatchbayClientIconChangedCallback = pyqtSignal(int, int) + PatchbayClientDataChangedCallback = pyqtSignal(int, int, int) PatchbayPortAddedCallback = pyqtSignal(int, int, int, str) PatchbayPortRemovedCallback = pyqtSignal(int, int) PatchbayPortRenamedCallback = pyqtSignal(int, int, str) @@ -1178,8 +1178,8 @@ def engineCallback(ptr, action, pluginId, value1, value2, value3, valueStr): Carla.gui.PatchbayClientRemovedCallback.emit(pluginId) elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED: Carla.gui.PatchbayClientRenamedCallback.emit(pluginId, valueStr) - elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_ICON_CHANGED: - Carla.gui.PatchbayClientIconChangedCallback.emit(pluginId, value1) + elif action == ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED: + Carla.gui.PatchbayClientDataChangedCallback.emit(pluginId, value1, value2) elif action == ENGINE_CALLBACK_PATCHBAY_PORT_ADDED: Carla.gui.PatchbayPortAddedCallback.emit(pluginId, value1, value2, valueStr) elif action == ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED: diff --git a/source/carla_patchbay.py b/source/carla_patchbay.py index 2743b0fb2..f90d73ea0 100644 --- a/source/carla_patchbay.py +++ b/source/carla_patchbay.py @@ -133,7 +133,7 @@ class CarlaPatchbayW(QGraphicsView): parent.PatchbayClientAddedCallback.connect(self.slot_handlePatchbayClientAddedCallback) parent.PatchbayClientRemovedCallback.connect(self.slot_handlePatchbayClientRemovedCallback) parent.PatchbayClientRenamedCallback.connect(self.slot_handlePatchbayClientRenamedCallback) - parent.PatchbayClientIconChangedCallback.connect(self.slot_handlePatchbayClientIconChangedCallback) + parent.PatchbayClientDataChangedCallback.connect(self.slot_handlePatchbayClientDataChangedCallback) parent.PatchbayPortAddedCallback.connect(self.slot_handlePatchbayPortAddedCallback) parent.PatchbayPortRemovedCallback.connect(self.slot_handlePatchbayPortRemovedCallback) parent.PatchbayPortRenamedCallback.connect(self.slot_handlePatchbayPortRenamedCallback) @@ -640,8 +640,8 @@ class CarlaPatchbayW(QGraphicsView): patchcanvas.renameGroup(clientId, newClientName) QTimer.singleShot(0, self.fMiniCanvasPreview.update) - @pyqtSlot(int, int) - def slot_handlePatchbayClientIconChangedCallback(self, clientId, clientIcon): + @pyqtSlot(int, int, int) + def slot_handlePatchbayClientDataChangedCallback(self, clientId, clientIcon, pluginId): pcIcon = patchcanvas.ICON_APPLICATION if clientIcon == PATCHBAY_ICON_PLUGIN: diff --git a/source/utils/CarlaBackendUtils.hpp b/source/utils/CarlaBackendUtils.hpp index 8a2ceb06d..a130982fd 100644 --- a/source/utils/CarlaBackendUtils.hpp +++ b/source/utils/CarlaBackendUtils.hpp @@ -241,8 +241,8 @@ const char* EngineCallbackOpcode2Str(const EngineCallbackOpcode opcode) noexcept return "ENGINE_CALLBACK_PATCHBAY_CLIENT_REMOVED"; case ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED: return "ENGINE_CALLBACK_PATCHBAY_CLIENT_RENAMED"; - case ENGINE_CALLBACK_PATCHBAY_CLIENT_ICON_CHANGED: - return "ENGINE_CALLBACK_PATCHBAY_CLIENT_ICON_CHANGED"; + case ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED: + return "ENGINE_CALLBACK_PATCHBAY_CLIENT_DATA_CHANGED"; case ENGINE_CALLBACK_PATCHBAY_PORT_ADDED: return "ENGINE_CALLBACK_PATCHBAY_PORT_ADDED"; case ENGINE_CALLBACK_PATCHBAY_PORT_REMOVED: