commit a0f9667cc65f0f05e1ec0e8ee9ee764f26c3aa87
parent 34154b473e92d38c086f3534e32716619f437369
Author: falkTX <falktx@falktx.com>
Date: Thu, 26 Aug 2021 12:41:38 +0100
Start tests with mpv
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
4 files changed, 70 insertions(+), 11 deletions(-)
diff --git a/distrho/extra/ExternalWindow.hpp b/distrho/extra/ExternalWindow.hpp
@@ -122,7 +122,6 @@ public:
return ext.inUse ? ext.isQuitting : pData.isQuitting;
}
-#if DISTRHO_PLUGIN_HAS_EMBED_UI
/**
Get the "native" window handle.
This can be reimplemented in order to pass the native window to hosts that can use such informaton.
@@ -139,7 +138,6 @@ public:
{
return 0;
}
-#endif
/**
Grab the keyboard input focus.
diff --git a/examples/ExternalUI/DistrhoPluginInfo.h b/examples/ExternalUI/DistrhoPluginInfo.h
@@ -22,7 +22,7 @@
#define DISTRHO_PLUGIN_URI "http://distrho.sf.net/examples/ExternalUI"
#define DISTRHO_PLUGIN_HAS_UI 1
-#define DISTRHO_PLUGIN_HAS_EMBED_UI 0
+#define DISTRHO_PLUGIN_HAS_EMBED_UI 1
#define DISTRHO_PLUGIN_HAS_EXTERNAL_UI 1
#define DISTRHO_PLUGIN_IS_RT_SAFE 1
#define DISTRHO_PLUGIN_NUM_INPUTS 1
diff --git a/examples/ExternalUI/ExternalExampleUI.cpp b/examples/ExternalUI/ExternalExampleUI.cpp
@@ -19,14 +19,20 @@
#include "DistrhoUI.hpp"
+#define MPV_TEST
+// #define KDE_FIFO_TEST
+
+#ifdef KDE_FIFO_TEST
// Extra includes for current path and fifo stuff
#include <dlfcn.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
+#endif
START_NAMESPACE_DISTRHO
+#ifdef KDE_FIFO_TEST
// TODO: generate a random, not-yet-existing, filename
const char* const kFifoFilename = "/tmp/dpf-fifo-test";
@@ -58,6 +64,7 @@ writeRetry(int fd, const void* src, size_t size)
return error;
}
+#endif
// -----------------------------------------------------------------------------------------------------------
@@ -66,10 +73,13 @@ class ExternalExampleUI : public UI
public:
ExternalExampleUI()
: UI(405, 256),
+#ifdef KDE_FIFO_TEST
fFifo(-1),
- fValue(0.0f),
- fExternalScript(getNextBundlePath())
+ fExternalScript(getNextBundlePath()),
+#endif
+ fValue(0.0f)
{
+#ifdef KDE_FIFO_TEST
if (fExternalScript.isEmpty())
{
fExternalScript = getCurrentPluginFilename();
@@ -78,6 +88,15 @@ public:
fExternalScript += "/ExternalLauncher.sh";
d_stdout("External script = %s", fExternalScript.buffer());
+#endif
+ if (isVisible() || isEmbed())
+ visibilityChanged(true);
+ }
+
+ ~ExternalExampleUI()
+ {
+ if (isEmbed())
+ terminateAndWaitForExternalProcess();
}
protected:
@@ -95,6 +114,7 @@ protected:
fValue = value;
+#ifdef KDE_FIFO_TEST
if (fFifo == -1)
return;
@@ -104,6 +124,7 @@ protected:
std::snprintf(valueStr, 23, "%i\n", static_cast<int>(value + 0.5f));
DISTRHO_SAFE_ASSERT(writeRetry(fFifo, valueStr, 24) == sizeof(valueStr));
+#endif
}
/* --------------------------------------------------------------------------------------------------------
@@ -114,18 +135,21 @@ protected:
*/
void uiIdle() override
{
+#ifdef KDE_FIFO_TEST
if (fFifo == -1)
return;
writeRetry(fFifo, "idle\n", 5);
+#endif
}
/**
Manage external process and IPC when UI is requested to be visible.
*/
- void setVisible(const bool yesNo) override
+ void visibilityChanged(const bool visible) override
{
- if (yesNo)
+#ifdef KDE_FIFO_TEST
+ if (visible)
{
DISTRHO_SAFE_ASSERT_RETURN(fileExists(fExternalScript),);
@@ -167,21 +191,57 @@ protected:
unlink(kFifoFilename);
terminateAndWaitForExternalProcess();
}
+#endif
+#ifdef MPV_TEST
+ if (visible)
+ {
+ const char* const file = "/home/falktx/Videos/HD/"; // TODO make this a state file?
- UI::setVisible(yesNo);
+ if (isEmbed())
+ {
+ char winIdStr[64];
+ snprintf(winIdStr, sizeof(winIdStr), "--wid=%lu", getParentWindowHandle());
+ const char* args[] = {
+ "mpv",
+ "--ao=jack",
+ winIdStr,
+ file,
+ nullptr
+ };
+ unsetenv("LD_LIBRARY_PATH");
+ startExternalProcess(args);
+ }
+ else
+ {
+ const char* args[] = {
+ "mpv",
+ "--ao=jack",
+ file,
+ nullptr
+ };
+ startExternalProcess(args);
+ }
+ }
+ else
+ {
+ terminateAndWaitForExternalProcess();
+ }
+#endif
}
// -------------------------------------------------------------------------------------------------------
private:
+#ifdef KDE_FIFO_TEST
// IPC Stuff
int fFifo;
- // Current value, cached for when UI becomes visible
- float fValue;
-
// Path to external ui script
String fExternalScript;
+#endif
+
+ // Current value, cached for when UI becomes visible
+ float fValue;
/**
Set our UI class as non-copyable and add a leak detector just in case.
diff --git a/examples/ExternalUI/Makefile b/examples/ExternalUI/Makefile
@@ -34,6 +34,7 @@ endif
TARGETS += jack
TARGETS += dssi
TARGETS += lv2_sep
+TARGETS += vst2
all: $(TARGETS)