Fixes high cpu usage with gtk2-suil hoststags/1.9.7b
| @@ -64,7 +64,7 @@ class CarlaEngineNativeUI : public CarlaExternalUI | |||||
| public: | public: | ||||
| CarlaEngineNativeUI(CarlaEngine* const engine) | CarlaEngineNativeUI(CarlaEngine* const engine) | ||||
| : fEngine(engine), | : fEngine(engine), | ||||
| fIsReady(false) | |||||
| fRemoteWinId(0) | |||||
| { | { | ||||
| carla_debug("CarlaEngineNativeUI::CarlaEngineNativeUI(%p)", engine); | carla_debug("CarlaEngineNativeUI::CarlaEngineNativeUI(%p)", engine); | ||||
| } | } | ||||
| @@ -76,7 +76,12 @@ public: | |||||
| bool isReady() const noexcept | bool isReady() const noexcept | ||||
| { | { | ||||
| return fIsReady; | |||||
| return fRemoteWinId != 0; | |||||
| } | |||||
| intptr_t getRemoteWinId() const noexcept | |||||
| { | |||||
| return fRemoteWinId; | |||||
| } | } | ||||
| protected: | protected: | ||||
| @@ -544,7 +549,11 @@ protected: | |||||
| } | } | ||||
| else if (std::strcmp(msg, "ready") == 0) | else if (std::strcmp(msg, "ready") == 0) | ||||
| { | { | ||||
| fIsReady = true; | |||||
| uint64_t winId; | |||||
| CARLA_SAFE_ASSERT_RETURN(readNextLineAsULong(winId), true); | |||||
| fRemoteWinId = static_cast<intptr_t>(winId); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -565,7 +574,7 @@ protected: | |||||
| private: | private: | ||||
| CarlaEngine* const fEngine; | CarlaEngine* const fEngine; | ||||
| bool fIsReady; | |||||
| intptr_t fRemoteWinId; | |||||
| void _updateParamValues(CarlaPlugin* const plugin, const uint32_t pluginId) const noexcept | void _updateParamValues(CarlaPlugin* const plugin, const uint32_t pluginId) const noexcept | ||||
| { | { | ||||
| @@ -1521,10 +1530,13 @@ protected: | |||||
| if (fWaitForReadyMsg) | if (fWaitForReadyMsg) | ||||
| { | { | ||||
| carla_stdout("Using Carla plugin embedded in Tracktion, waiting for it to be ready..."); | |||||
| carla_stdout("Using Carla plugin embedded, waiting for it to be ready..."); | |||||
| for (; fUiServer.isPipeRunning() && ! fUiServer.isReady();) | for (; fUiServer.isPipeRunning() && ! fUiServer.isReady();) | ||||
| { | |||||
| carla_msleep(25); | |||||
| fUiServer.idlePipe(); | fUiServer.idlePipe(); | ||||
| } | |||||
| carla_stdout("Done!"); | carla_stdout("Done!"); | ||||
| } | } | ||||
| @@ -1784,7 +1796,10 @@ public: | |||||
| { | { | ||||
| case NATIVE_PLUGIN_OPCODE_NULL: | case NATIVE_PLUGIN_OPCODE_NULL: | ||||
| if (static_cast<uint32_t>(index) == 0xDEADF00D && static_cast<uintptr_t>(value) == 0xC0C0B00B) | if (static_cast<uint32_t>(index) == 0xDEADF00D && static_cast<uintptr_t>(value) == 0xC0C0B00B) | ||||
| { | |||||
| handlePtr->fWaitForReadyMsg = true; | handlePtr->fWaitForReadyMsg = true; | ||||
| return handlePtr->fUiServer.getRemoteWinId(); | |||||
| } | |||||
| return 0; | return 0; | ||||
| case NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED: | case NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED: | ||||
| CARLA_SAFE_ASSERT_RETURN(value > 0, 0); | CARLA_SAFE_ASSERT_RETURN(value > 0, 0); | ||||
| @@ -485,7 +485,7 @@ class CarlaEmbedW(QEmbedWidget): | |||||
| self.addWidget(self.gui.centralWidget()) | self.addWidget(self.gui.centralWidget()) | ||||
| self.finalSetup(self.gui, winId) | self.finalSetup(self.gui, winId) | ||||
| self.gui.send(["ready"]) | |||||
| self.gui.send(["ready", int(self.winId())]) | |||||
| def addShortcutActions(self, actions): | def addShortcutActions(self, actions): | ||||
| for action in actions: | for action in actions: | ||||
| @@ -821,9 +821,8 @@ public: | |||||
| if (isEmbed) | if (isEmbed) | ||||
| { | { | ||||
| fUI.isVisible = true; | |||||
| intptr_t parentId = 0; | intptr_t parentId = 0; | ||||
| const LV2UI_Resize* uiResize = nullptr; | |||||
| for (int i=0; features[i] != nullptr; ++i) | for (int i=0; features[i] != nullptr; ++i) | ||||
| { | { | ||||
| @@ -833,20 +832,40 @@ public: | |||||
| } | } | ||||
| else if (std::strcmp(features[i]->URI, LV2_UI__resize) == 0) | else if (std::strcmp(features[i]->URI, LV2_UI__resize) == 0) | ||||
| { | { | ||||
| const LV2UI_Resize* const uiResize((const LV2UI_Resize*)features[i]->data); | |||||
| uiResize->ui_resize(uiResize->handle, 740, 512); | |||||
| uiResize = (const LV2UI_Resize*)features[i]->data; | |||||
| } | } | ||||
| } | } | ||||
| char strBuf[0xff+1]; | |||||
| strBuf[0xff] = '\0'; | |||||
| std::snprintf(strBuf, 0xff, P_INTPTR, parentId); | |||||
| // ----------------------------------------------------------- | |||||
| // see if the host can really embed the UI | |||||
| carla_setenv("CARLA_PLUGIN_EMBED_WINID", strBuf); | |||||
| if (parentId != 0) | |||||
| { | |||||
| // wait for remote side to be ready | |||||
| fDescriptor->dispatcher(fHandle, NATIVE_PLUGIN_OPCODE_NULL, (int32_t)0xDEADF00D, 0xC0C0B00B, nullptr, 0.0f); | |||||
| fDescriptor->ui_show(fHandle, true); | |||||
| if (uiResize && uiResize->ui_resize != nullptr) | |||||
| uiResize->ui_resize(uiResize->handle, 740, 512); | |||||
| fHost.uiName = carla_strdup(fDescriptor->name); | |||||
| fUI.isVisible = true; | |||||
| char strBuf[0xff+1]; | |||||
| strBuf[0xff] = '\0'; | |||||
| std::snprintf(strBuf, 0xff, P_INTPTR, parentId); | |||||
| carla_setenv("CARLA_PLUGIN_EMBED_WINID", "0"); | |||||
| carla_setenv("CARLA_PLUGIN_EMBED_WINID", strBuf); | |||||
| fDescriptor->ui_show(fHandle, true); | |||||
| carla_setenv("CARLA_PLUGIN_EMBED_WINID", "0"); | |||||
| const intptr_t winId(fDescriptor->dispatcher(fHandle, NATIVE_PLUGIN_OPCODE_NULL, (int32_t)0xDEADF00D, 0xC0C0B00B, nullptr, 0.0f)); | |||||
| CARLA_SAFE_ASSERT_RETURN(winId != 0,); | |||||
| *widget = (LV2UI_Widget)winId; | |||||
| return; | |||||
| } | |||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -972,8 +991,6 @@ protected: | |||||
| void handleUiShow() | void handleUiShow() | ||||
| { | { | ||||
| CARLA_SAFE_ASSERT_RETURN(! fUI.isEmbed,); | |||||
| if (fDescriptor->ui_show != nullptr) | if (fDescriptor->ui_show != nullptr) | ||||
| fDescriptor->ui_show(fHandle, true); | fDescriptor->ui_show(fHandle, true); | ||||