Browse Source

Start tests with mpv

Signed-off-by: falkTX <falktx@falktx.com>
pull/314/head
falkTX 3 years ago
parent
commit
a0f9667cc6
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 70 additions and 11 deletions
  1. +0
    -2
      distrho/extra/ExternalWindow.hpp
  2. +1
    -1
      examples/ExternalUI/DistrhoPluginInfo.h
  3. +68
    -8
      examples/ExternalUI/ExternalExampleUI.cpp
  4. +1
    -0
      examples/ExternalUI/Makefile

+ 0
- 2
distrho/extra/ExternalWindow.hpp View File

@@ -122,7 +122,6 @@ public:
return ext.inUse ? ext.isQuitting : pData.isQuitting; return ext.inUse ? ext.isQuitting : pData.isQuitting;
} }


#if DISTRHO_PLUGIN_HAS_EMBED_UI
/** /**
Get the "native" window handle. Get the "native" window handle.
This can be reimplemented in order to pass the native window to hosts that can use such informaton. 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; return 0;
} }
#endif


/** /**
Grab the keyboard input focus. Grab the keyboard input focus.


+ 1
- 1
examples/ExternalUI/DistrhoPluginInfo.h View File

@@ -22,7 +22,7 @@
#define DISTRHO_PLUGIN_URI "http://distrho.sf.net/examples/ExternalUI" #define DISTRHO_PLUGIN_URI "http://distrho.sf.net/examples/ExternalUI"


#define DISTRHO_PLUGIN_HAS_UI 1 #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_HAS_EXTERNAL_UI 1
#define DISTRHO_PLUGIN_IS_RT_SAFE 1 #define DISTRHO_PLUGIN_IS_RT_SAFE 1
#define DISTRHO_PLUGIN_NUM_INPUTS 1 #define DISTRHO_PLUGIN_NUM_INPUTS 1


+ 68
- 8
examples/ExternalUI/ExternalExampleUI.cpp View File

@@ -19,14 +19,20 @@


#include "DistrhoUI.hpp" #include "DistrhoUI.hpp"


#define MPV_TEST
// #define KDE_FIFO_TEST

#ifdef KDE_FIFO_TEST
// Extra includes for current path and fifo stuff // Extra includes for current path and fifo stuff
#include <dlfcn.h> #include <dlfcn.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#endif


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


#ifdef KDE_FIFO_TEST
// TODO: generate a random, not-yet-existing, filename // TODO: generate a random, not-yet-existing, filename
const char* const kFifoFilename = "/tmp/dpf-fifo-test"; const char* const kFifoFilename = "/tmp/dpf-fifo-test";


@@ -58,6 +64,7 @@ writeRetry(int fd, const void* src, size_t size)


return error; return error;
} }
#endif


// ----------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------


@@ -66,10 +73,13 @@ class ExternalExampleUI : public UI
public: public:
ExternalExampleUI() ExternalExampleUI()
: UI(405, 256), : UI(405, 256),
#ifdef KDE_FIFO_TEST
fFifo(-1), fFifo(-1),
fValue(0.0f),
fExternalScript(getNextBundlePath())
fExternalScript(getNextBundlePath()),
#endif
fValue(0.0f)
{ {
#ifdef KDE_FIFO_TEST
if (fExternalScript.isEmpty()) if (fExternalScript.isEmpty())
{ {
fExternalScript = getCurrentPluginFilename(); fExternalScript = getCurrentPluginFilename();
@@ -78,6 +88,15 @@ public:


fExternalScript += "/ExternalLauncher.sh"; fExternalScript += "/ExternalLauncher.sh";
d_stdout("External script = %s", fExternalScript.buffer()); d_stdout("External script = %s", fExternalScript.buffer());
#endif
if (isVisible() || isEmbed())
visibilityChanged(true);
}

~ExternalExampleUI()
{
if (isEmbed())
terminateAndWaitForExternalProcess();
} }


protected: protected:
@@ -95,6 +114,7 @@ protected:


fValue = value; fValue = value;


#ifdef KDE_FIFO_TEST
if (fFifo == -1) if (fFifo == -1)
return; return;


@@ -104,6 +124,7 @@ protected:
std::snprintf(valueStr, 23, "%i\n", static_cast<int>(value + 0.5f)); std::snprintf(valueStr, 23, "%i\n", static_cast<int>(value + 0.5f));


DISTRHO_SAFE_ASSERT(writeRetry(fFifo, valueStr, 24) == sizeof(valueStr)); DISTRHO_SAFE_ASSERT(writeRetry(fFifo, valueStr, 24) == sizeof(valueStr));
#endif
} }


/* -------------------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------------------
@@ -114,18 +135,21 @@ protected:
*/ */
void uiIdle() override void uiIdle() override
{ {
#ifdef KDE_FIFO_TEST
if (fFifo == -1) if (fFifo == -1)
return; return;


writeRetry(fFifo, "idle\n", 5); writeRetry(fFifo, "idle\n", 5);
#endif
} }


/** /**
Manage external process and IPC when UI is requested to be visible. 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),); DISTRHO_SAFE_ASSERT_RETURN(fileExists(fExternalScript),);


@@ -167,21 +191,57 @@ protected:
unlink(kFifoFilename); unlink(kFifoFilename);
terminateAndWaitForExternalProcess(); 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: private:
#ifdef KDE_FIFO_TEST
// IPC Stuff // IPC Stuff
int fFifo; int fFifo;


// Current value, cached for when UI becomes visible
float fValue;

// Path to external ui script // Path to external ui script
String fExternalScript; 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. Set our UI class as non-copyable and add a leak detector just in case.


+ 1
- 0
examples/ExternalUI/Makefile View File

@@ -34,6 +34,7 @@ endif
TARGETS += jack TARGETS += jack
TARGETS += dssi TARGETS += dssi
TARGETS += lv2_sep TARGETS += lv2_sep
TARGETS += vst2


all: $(TARGETS) all: $(TARGETS)




Loading…
Cancel
Save