Signed-off-by: falkTX <falktx@falktx.com>tags/v2.4.2
@@ -1096,9 +1096,27 @@ public: | |||||
plugin->showCustomUI(false); | plugin->showCustomUI(false); | ||||
break; | break; | ||||
case kPluginBridgeNonRtClientEmbedUI: { | |||||
const uint64_t winId = fShmNonRtClientControl.readULong(); | |||||
uint64_t resp = 0; | |||||
if (plugin->isEnabled()) | |||||
resp = reinterpret_cast<uint64_t>(plugin->embedCustomUI(reinterpret_cast<void*>(winId))); | |||||
if (resp == 0) | |||||
resp = 1; | |||||
const CarlaMutexLocker _cml(fShmNonRtServerControl.mutex); | |||||
fShmNonRtServerControl.writeOpcode(kPluginBridgeNonRtServerEmbedUI); | |||||
fShmNonRtServerControl.writeULong(reinterpret_cast<uint64_t>(resp)); | |||||
fShmNonRtServerControl.commitWrite(); | |||||
break; | |||||
} | |||||
case kPluginBridgeNonRtClientUiParameterChange: { | case kPluginBridgeNonRtClientUiParameterChange: { | ||||
const uint32_t index(fShmNonRtClientControl.readUInt()); | |||||
const float value(fShmNonRtClientControl.readFloat()); | |||||
const uint32_t index = fShmNonRtClientControl.readUInt(); | |||||
const float value = fShmNonRtClientControl.readFloat(); | |||||
if (plugin->isEnabled()) | if (plugin->isEnabled()) | ||||
plugin->uiParameterChange(index, value); | plugin->uiParameterChange(index, value); | ||||
@@ -420,6 +420,7 @@ public: | |||||
fTimedError(false), | fTimedError(false), | ||||
fBufferSize(engine->getBufferSize()), | fBufferSize(engine->getBufferSize()), | ||||
fProcWaitTime(0), | fProcWaitTime(0), | ||||
fPendingEmbedCustomUI(0), | |||||
fBridgeBinary(), | fBridgeBinary(), | ||||
fBridgeThread(engine, this), | fBridgeThread(engine, this), | ||||
fShmAudioPool(), | fShmAudioPool(), | ||||
@@ -1036,6 +1037,44 @@ public: | |||||
#endif | #endif | ||||
} | } | ||||
void* embedCustomUI(void* const ptr) override | |||||
{ | |||||
if (fBridgeVersion < 9) | |||||
return nullptr; | |||||
fPendingEmbedCustomUI = 0; | |||||
{ | |||||
const CarlaMutexLocker _cml(fShmNonRtClientControl.mutex); | |||||
fShmNonRtClientControl.writeOpcode(kPluginBridgeNonRtClientEmbedUI); | |||||
fShmNonRtClientControl.writeULong(reinterpret_cast<uint64_t>(ptr)); | |||||
fShmNonRtClientControl.commitWrite(); | |||||
} | |||||
const uint32_t timeoutEnd = Time::getMillisecondCounter() + 15*1000; // 15 secs | |||||
const bool needsEngineIdle = pData->engine->getType() != kEngineTypePlugin; | |||||
for (; Time::getMillisecondCounter() < timeoutEnd && fBridgeThread.isThreadRunning();) | |||||
{ | |||||
pData->engine->callback(true, true, ENGINE_CALLBACK_IDLE, 0, 0, 0, 0, 0.0f, nullptr); | |||||
if (needsEngineIdle) | |||||
pData->engine->idle(); | |||||
if (fPendingEmbedCustomUI != 0) | |||||
{ | |||||
if (fPendingEmbedCustomUI == 1) | |||||
fPendingEmbedCustomUI = 0; | |||||
break; | |||||
} | |||||
carla_msleep(20); | |||||
} | |||||
return reinterpret_cast<void*>(fPendingEmbedCustomUI); | |||||
} | |||||
void idle() override | void idle() override | ||||
{ | { | ||||
if (fBridgeThread.isThreadRunning()) | if (fBridgeThread.isThreadRunning()) | ||||
@@ -2093,6 +2132,9 @@ public: | |||||
pData->hints = hints | PLUGIN_IS_BRIDGE; | pData->hints = hints | PLUGIN_IS_BRIDGE; | ||||
pData->options = optionEn; | pData->options = optionEn; | ||||
if (fBridgeVersion < 9) | |||||
pData->hints &= ~PLUGIN_HAS_CUSTOM_EMBED_UI; | |||||
fInfo.category = static_cast<PluginCategory>(category); | fInfo.category = static_cast<PluginCategory>(category); | ||||
fInfo.optionsAvailable = optionAv; | fInfo.optionsAvailable = optionAv; | ||||
} break; | } break; | ||||
@@ -2520,6 +2562,10 @@ public: | |||||
fSaved = true; | fSaved = true; | ||||
break; | break; | ||||
case kPluginBridgeNonRtServerEmbedUI: | |||||
fPendingEmbedCustomUI = fShmNonRtServerControl.readULong(); | |||||
break; | |||||
case kPluginBridgeNonRtServerUiClosed: | case kPluginBridgeNonRtServerUiClosed: | ||||
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH | ||||
pData->transientTryCounter = 0; | pData->transientTryCounter = 0; | ||||
@@ -2792,6 +2838,7 @@ private: | |||||
bool fTimedError; | bool fTimedError; | ||||
uint fBufferSize; | uint fBufferSize; | ||||
uint fProcWaitTime; | uint fProcWaitTime; | ||||
uint64_t fPendingEmbedCustomUI; | |||||
CarlaString fBridgeBinary; | CarlaString fBridgeBinary; | ||||
CarlaPluginBridgeThread fBridgeThread; | CarlaPluginBridgeThread fBridgeThread; | ||||
@@ -1533,6 +1533,7 @@ public: | |||||
case kPluginBridgeNonRtServerMidiProgramData: | case kPluginBridgeNonRtServerMidiProgramData: | ||||
case kPluginBridgeNonRtServerSetCustomData: | case kPluginBridgeNonRtServerSetCustomData: | ||||
case kPluginBridgeNonRtServerVersion: | case kPluginBridgeNonRtServerVersion: | ||||
case kPluginBridgeNonRtServerEmbedUI: | |||||
break; | break; | ||||
case kPluginBridgeNonRtServerSetChunkDataFile: | case kPluginBridgeNonRtServerSetChunkDataFile: | ||||
@@ -1009,6 +1009,7 @@ public: | |||||
#endif | #endif | ||||
{ | { | ||||
pData->hints |= PLUGIN_HAS_CUSTOM_UI; | pData->hints |= PLUGIN_HAS_CUSTOM_UI; | ||||
pData->hints |= PLUGIN_HAS_CUSTOM_EMBED_UI; | |||||
} | } | ||||
pData->hints |= PLUGIN_NEEDS_UI_MAIN_THREAD; | pData->hints |= PLUGIN_NEEDS_UI_MAIN_THREAD; | ||||
@@ -24,7 +24,7 @@ | |||||
#define CARLA_PLUGIN_BRIDGE_API_VERSION_MINIMUM 6 | #define CARLA_PLUGIN_BRIDGE_API_VERSION_MINIMUM 6 | ||||
// current API version, bumped when something is added | // current API version, bumped when something is added | ||||
#define CARLA_PLUGIN_BRIDGE_API_VERSION_CURRENT 8 | |||||
#define CARLA_PLUGIN_BRIDGE_API_VERSION_CURRENT 9 | |||||
// ------------------------------------------------------------------------------------------------------------------- | // ------------------------------------------------------------------------------------------------------------------- | ||||
@@ -79,6 +79,8 @@ enum PluginBridgeNonRtClientOpcode { | |||||
kPluginBridgeNonRtClientSetOptions, // uint | kPluginBridgeNonRtClientSetOptions, // uint | ||||
// stuff added in API 8 | // stuff added in API 8 | ||||
kPluginBridgeNonRtClientSetWindowTitle, // uint/size, str[] | kPluginBridgeNonRtClientSetWindowTitle, // uint/size, str[] | ||||
// stuff added in API 9 | |||||
kPluginBridgeNonRtClientEmbedUI, // ulong | |||||
}; | }; | ||||
// Client sends these to server during non-RT | // Client sends these to server during non-RT | ||||
@@ -114,7 +116,9 @@ enum PluginBridgeNonRtServerOpcode { | |||||
kPluginBridgeNonRtServerUiClosed, | kPluginBridgeNonRtServerUiClosed, | ||||
kPluginBridgeNonRtServerError, // uint/size, str[] | kPluginBridgeNonRtServerError, // uint/size, str[] | ||||
// stuff added in API 7 | // stuff added in API 7 | ||||
kPluginBridgeNonRtServerVersion // uint | |||||
kPluginBridgeNonRtServerVersion, // uint | |||||
// stuff added in API 9 | |||||
kPluginBridgeNonRtServerEmbedUI, // ulong | |||||
}; | }; | ||||
// used for kPluginBridgeNonRtServerPortName | // used for kPluginBridgeNonRtServerPortName | ||||
@@ -127,6 +127,8 @@ const char* PluginBridgeNonRtClientOpcode2str(const PluginBridgeNonRtClientOpcod | |||||
return "kPluginBridgeNonRtClientSetOptions"; | return "kPluginBridgeNonRtClientSetOptions"; | ||||
case kPluginBridgeNonRtClientSetWindowTitle: | case kPluginBridgeNonRtClientSetWindowTitle: | ||||
return "kPluginBridgeNonRtClientSetWindowTitle"; | return "kPluginBridgeNonRtClientSetWindowTitle"; | ||||
case kPluginBridgeNonRtClientEmbedUI: | |||||
return "kPluginBridgeNonRtClientEmbedUI"; | |||||
} | } | ||||
carla_stderr("CarlaBackend::PluginBridgeNonRtClientOpcode2str(%i) - invalid opcode", opcode); | carla_stderr("CarlaBackend::PluginBridgeNonRtClientOpcode2str(%i) - invalid opcode", opcode); | ||||
@@ -200,6 +202,8 @@ const char* PluginBridgeNonRtServerOpcode2str(const PluginBridgeNonRtServerOpcod | |||||
return "kPluginBridgeNonRtServerError"; | return "kPluginBridgeNonRtServerError"; | ||||
case kPluginBridgeNonRtServerVersion: | case kPluginBridgeNonRtServerVersion: | ||||
return "kPluginBridgeNonRtServerVersion"; | return "kPluginBridgeNonRtServerVersion"; | ||||
case kPluginBridgeNonRtServerEmbedUI: | |||||
return "kPluginBridgeNonRtServerEmbedUI"; | |||||
} | } | ||||
carla_stderr("CarlaBackend::PluginBridgeNonRtServerOpcode2str%i) - invalid opcode", opcode); | carla_stderr("CarlaBackend::PluginBridgeNonRtServerOpcode2str%i) - invalid opcode", opcode); | ||||