From b0035be5c98a8ec3782fabdf1684063b731abc7c Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 26 Mar 2015 15:16:07 +0100 Subject: [PATCH] Don't call engine->idle if engine is plugin; Give plugin hosts idle --- source/backend/engine/CarlaEngineNative.cpp | 8 ++++++++ source/backend/plugin/CarlaPluginBridge.cpp | 7 ++++++- source/backend/plugin/CarlaPluginNative.cpp | 3 +++ source/includes/CarlaNative.h | 3 ++- source/plugin/carla-lv2.cpp | 1 + source/plugin/carla-vst.cpp | 21 +++++++++++++++++++-- 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index 747683c31..1a3ae8417 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -700,6 +700,14 @@ protected: return "Plugin"; } + void callback(const EngineCallbackOpcode action, const uint pluginId, const int value1, const int value2, const float value3, const char* const valueStr) noexcept override + { + CarlaEngine::callback(action, pluginId, value1, value2, value3, valueStr); + + if (action == ENGINE_CALLBACK_IDLE) + pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_HOST_IDLE, 0, 0, nullptr, 0.0f); + } + // ------------------------------------------------------------------- const char* renamePlugin(const uint id, const char* const newName) override diff --git a/source/backend/plugin/CarlaPluginBridge.cpp b/source/backend/plugin/CarlaPluginBridge.cpp index 99aac7638..e78c57f07 100644 --- a/source/backend/plugin/CarlaPluginBridge.cpp +++ b/source/backend/plugin/CarlaPluginBridge.cpp @@ -2531,10 +2531,15 @@ public: #endif sFirstInit = false; + const bool needsEngineIdle = pData->engine->getType() != kEngineTypePlugin; + for (; Time::currentTimeMillis() < fLastPongTime + timeoutEnd && fBridgeThread.isThreadRunning();) { pData->engine->callback(ENGINE_CALLBACK_IDLE, 0, 0, 0, 0.0f, nullptr); - pData->engine->idle(); + + if (needsEngineIdle) + pData->engine->idle(); + idle(); if (fInitiated) diff --git a/source/backend/plugin/CarlaPluginNative.cpp b/source/backend/plugin/CarlaPluginNative.cpp index 4a94df012..b66c79ccf 100644 --- a/source/backend/plugin/CarlaPluginNative.cpp +++ b/source/backend/plugin/CarlaPluginNative.cpp @@ -2219,6 +2219,9 @@ protected: pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, -1, 0, 0.0f, nullptr); fIsUiVisible = false; break; + case NATIVE_HOST_OPCODE_HOST_IDLE: + pData->engine->callback(ENGINE_CALLBACK_IDLE, 0, 0, 0, 0.0f, nullptr); + break; } return ret; diff --git a/source/includes/CarlaNative.h b/source/includes/CarlaNative.h index bcbbbf1b5..4b92d00d5 100644 --- a/source/includes/CarlaNative.h +++ b/source/includes/CarlaNative.h @@ -103,7 +103,8 @@ typedef enum { NATIVE_HOST_OPCODE_RELOAD_PARAMETERS = 3, /** nothing */ NATIVE_HOST_OPCODE_RELOAD_MIDI_PROGRAMS = 4, /** nothing */ NATIVE_HOST_OPCODE_RELOAD_ALL = 5, /** nothing */ - NATIVE_HOST_OPCODE_UI_UNAVAILABLE = 6 /** nothing */ + NATIVE_HOST_OPCODE_UI_UNAVAILABLE = 6, /** nothing */ + NATIVE_HOST_OPCODE_HOST_IDLE = 7 /** nothing */ } NativeHostDispatcherOpcode; /* ------------------------------------------------------------------------------------------------------------ diff --git a/source/plugin/carla-lv2.cpp b/source/plugin/carla-lv2.cpp index 5faaaf59d..99967ca79 100644 --- a/source/plugin/carla-lv2.cpp +++ b/source/plugin/carla-lv2.cpp @@ -897,6 +897,7 @@ protected: case NATIVE_HOST_OPCODE_RELOAD_PARAMETERS: case NATIVE_HOST_OPCODE_RELOAD_MIDI_PROGRAMS: case NATIVE_HOST_OPCODE_RELOAD_ALL: + case NATIVE_HOST_OPCODE_HOST_IDLE: // nothing break; case NATIVE_HOST_OPCODE_UI_UNAVAILABLE: diff --git a/source/plugin/carla-vst.cpp b/source/plugin/carla-vst.cpp index 5206e5c45..decd9e96f 100644 --- a/source/plugin/carla-vst.cpp +++ b/source/plugin/carla-vst.cpp @@ -512,10 +512,27 @@ protected: intptr_t handleDispatcher(const NativeHostDispatcherOpcode opcode, const int32_t index, const intptr_t value, void* const ptr, const float opt) { carla_debug("NativePlugin::handleDispatcher(%i, %i, " P_INTPTR ", %p, %f)", opcode, index, value, ptr, opt); - return 0; + + switch (opcode) + { + case NATIVE_HOST_OPCODE_NULL: + case NATIVE_HOST_OPCODE_UPDATE_PARAMETER: + case NATIVE_HOST_OPCODE_UPDATE_MIDI_PROGRAM: + case NATIVE_HOST_OPCODE_RELOAD_PARAMETERS: + case NATIVE_HOST_OPCODE_RELOAD_MIDI_PROGRAMS: + case NATIVE_HOST_OPCODE_RELOAD_ALL: + case NATIVE_HOST_OPCODE_UI_UNAVAILABLE: + break; + + case NATIVE_HOST_OPCODE_HOST_IDLE: + fAudioMaster(fEffect, audioMasterIdle, 0, 0, nullptr, 0.0f); + break; + } // unused for now - (void)opcode; (void)index; (void)value; (void)ptr; (void)opt; + return 0; + + (void)index; (void)value; (void)ptr; (void)opt; } private: