commit 370af7f263dd39cd926eb6f88ae0d10d74a59cf7
parent 9f4fcf9dda1076aec061e740de3f33ca90fa495a
Author: falkTX <falktx@falktx.com>
Date: Sat, 16 Mar 2024 22:05:31 +0100
Preparations for a future DISTRHO_PLUGIN_WANT_WEBVIEW
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
7 files changed, 71 insertions(+), 16 deletions(-)
diff --git a/Makefile.plugins.mk b/Makefile.plugins.mk
@@ -250,6 +250,10 @@ HAVE_DGL = false
endif
endif
+ifeq ($(HAVE_DGL)$(LINUX)$(USING_WEBVIEW),truetruetrue)
+DGL_LIB_SHARED = $(shell $(CC) -print-file-name=Scrt1.o)
+endif
+
DGL_LIBS += $(DGL_SYSTEM_LIBS) -lm
# TODO split dsp and ui object build flags
@@ -545,9 +549,9 @@ lv2_dsp: $(lv2_dsp)
lv2_sep: $(lv2_dsp) $(lv2_ui)
ifeq ($(HAVE_DGL),true)
-$(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB)
+$(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB) $(DGL_LIB_SHARED)
else
-$(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o
+$(lv2): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o
endif
-@mkdir -p $(shell dirname $@)
@echo "Creating LV2 plugin for $(NAME)"
@@ -558,7 +562,7 @@ $(lv2_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o
@echo "Creating LV2 plugin library for $(NAME)"
$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(EXTRA_LIBS) $(EXTRA_DSP_LIBS) $(SHARED) $(SYMBOLS_LV2DSP) -o $@
-$(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB)
+$(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB) $(DGL_LIB_SHARED)
-@mkdir -p $(shell dirname $@)
@echo "Creating LV2 plugin UI for $(NAME)"
$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(EXTRA_LIBS) $(EXTRA_UI_LIBS) $(DGL_LIBS) $(SHARED) $(SYMBOLS_LV2UI) -o $@
@@ -663,7 +667,7 @@ modgui:
vst2 vst: $(vst2) $(vst2files)
ifeq ($(HAVE_DGL),true)
-$(vst2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST2.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST2.cpp.o $(DGL_LIB)
+$(vst2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST2.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST2.cpp.o $(DGL_LIB) $(DGL_LIB_SHARED)
else
$(vst2): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_VST2.cpp.o
endif
@@ -677,7 +681,7 @@ endif
vst3: $(vst3) $(vst3files)
ifeq ($(HAVE_DGL),true)
-$(vst3): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST3.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST3.cpp.o $(DGL_LIB)
+$(vst3): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST3.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST3.cpp.o $(DGL_LIB) $(DGL_LIB_SHARED)
else
$(vst3): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_VST3.cpp.o
endif
@@ -699,7 +703,7 @@ endif
clap: $(clap) $(clapfiles)
ifeq ($(HAVE_DGL),true)
-$(clap): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_CLAP.cpp.o $(BUILD_DIR)/DistrhoUIMain_CLAP.cpp.o $(DGL_LIB)
+$(clap): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_CLAP.cpp.o $(BUILD_DIR)/DistrhoUIMain_CLAP.cpp.o $(DGL_LIB) $(DGL_LIB_SHARED)
else
$(clap): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_CLAP.cpp.o
endif
@@ -739,7 +743,7 @@ endif
shared: $(shared)
ifeq ($(HAVE_DGL),true)
-$(shared): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_SHARED.cpp.o $(BUILD_DIR)/DistrhoUIMain_SHARED.cpp.o $(DGL_LIB)
+$(shared): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_SHARED.cpp.o $(BUILD_DIR)/DistrhoUIMain_SHARED.cpp.o $(DGL_LIB) $(DGL_LIB_SHARED)
else
$(shared): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_SHARED.cpp.o
endif
diff --git a/distrho/DistrhoUtils.hpp b/distrho/DistrhoUtils.hpp
@@ -366,13 +366,15 @@ int32_t d_roundToInt(const T& value)
/** @} */
/* --------------------------------------------------------------------------------------------------------------------
- * math functions */
+ * other stuff */
#ifndef DONT_SET_USING_DISTRHO_NAMESPACE
- // If your code uses a lot of DISTRHO classes, then this will obviously save you
- // a lot of typing, but can be disabled by setting DONT_SET_USING_DISTRHO_NAMESPACE.
- namespace DISTRHO_NAMESPACE {}
- using namespace DISTRHO_NAMESPACE;
+/**
+ If your code uses a lot of DISTRHO classes, then this will obviously save you a lot of typing,
+ but can be disabled by setting DONT_SET_USING_DISTRHO_NAMESPACE.
+ */
+namespace DISTRHO_NAMESPACE {}
+using namespace DISTRHO_NAMESPACE;
#endif
#endif // DISTRHO_UTILS_HPP_INCLUDED
diff --git a/distrho/src/DistrhoPluginChecks.h b/distrho/src/DistrhoPluginChecks.h
@@ -94,6 +94,10 @@
# define DISTRHO_PLUGIN_WANT_TIMEPOS 0
#endif
+#ifndef DISTRHO_PLUGIN_WANT_WEBVIEW
+# define DISTRHO_PLUGIN_WANT_WEBVIEW 0
+#endif
+
#ifndef DISTRHO_UI_FILE_BROWSER
# if defined(DGL_FILE_BROWSER_DISABLED) || DISTRHO_PLUGIN_HAS_EXTERNAL_UI
# define DISTRHO_UI_FILE_BROWSER 0
@@ -257,6 +261,17 @@ static_assert(sizeof(STRINGIFY(DISTRHO_PLUGIN_UNIQUE_ID)) == 5, "The macro DISTR
# error DISTRHO_UI_IS_STANDALONE must not be defined
#endif
+#ifdef DPF_USING_LD_LINUX_WEBVIEW
+# error DPF_USING_LD_LINUX_WEBVIEW must not be defined
+#endif
+
+// --------------------------------------------------------------------------------------------------------------------
+// Set DPF_USING_LD_LINUX_WEBVIEW for internal use
+
+#if DISTRHO_PLUGIN_WANT_WEBVIEW && defined(__linux__)
+# define DPF_USING_LD_LINUX_WEBVIEW
+#endif
+
// --------------------------------------------------------------------------------------------------------------------
#endif // DISTRHO_PLUGIN_CHECKS_H_INCLUDED
diff --git a/distrho/src/DistrhoPluginJACK.cpp b/distrho/src/DistrhoPluginJACK.cpp
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
- * Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
+ * Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -86,6 +86,10 @@ static const writeMidiFunc writeMidiCallback = nullptr;
static const requestParameterValueChangeFunc requestParameterValueChangeCallback = nullptr;
#endif
+#ifdef DPF_USING_LD_LINUX_WEBVIEW
+int dpf_webview_start(int argc, char* argv[]);
+#endif
+
// -----------------------------------------------------------------------
static volatile bool gCloseSignalReceived = false;
@@ -996,6 +1000,11 @@ int main(int argc, char* argv[])
}
#endif
+ #ifdef DPF_USING_LD_LINUX_WEBVIEW
+ if (argc >= 2 && std::strcmp(argv[1], "dpf-ld-linux-webview") == 0)
+ return dpf_webview_start(argc - 1, argv + 1);
+ #endif
+
if (argc == 2 && std::strcmp(argv[1], "selftest") == 0)
{
#ifdef DPF_RUNTIME_TESTING
diff --git a/distrho/src/DistrhoPluginVST2.cpp b/distrho/src/DistrhoPluginVST2.cpp
@@ -1720,13 +1720,17 @@ const vst_effect* VSTPluginMain(const vst_host_callback audioMaster)
return effect;
}
-#if !(defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WASM) || defined(DISTRHO_OS_WINDOWS))
+#if !(defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WASM) || defined(DISTRHO_OS_WINDOWS) || DISTRHO_PLUGIN_WANT_WEBVIEW)
DISTRHO_PLUGIN_EXPORT
const vst_effect* VSTPluginMainCompat(vst_host_callback) asm ("main");
DISTRHO_PLUGIN_EXPORT
const vst_effect* VSTPluginMainCompat(const vst_host_callback audioMaster)
{
+ // protect main symbol against running as executable
+ if (reinterpret_cast<uintptr_t>(audioMaster) < 0xff)
+ return nullptr;
+
return VSTPluginMain(audioMaster);
}
#endif
diff --git a/distrho/src/DistrhoUIDSSI.cpp b/distrho/src/DistrhoUIDSSI.cpp
@@ -38,6 +38,10 @@ static constexpr const setSizeFunc setSizeCallback = nullptr;
// unsupported in DSSI
static constexpr const fileRequestFunc fileRequestCallback = nullptr;
+#ifdef DPF_USING_LD_LINUX_WEBVIEW
+int dpf_webview_start(int argc, char* argv[]);
+#endif
+
// --------------------------------------------------------------------------------------------------------------------
@@ -387,6 +391,11 @@ int main(int argc, char* argv[])
{
USE_NAMESPACE_DISTRHO
+ #ifdef DPF_USING_LD_LINUX_WEBVIEW
+ if (argc >= 2 && std::strcmp(argv[1], "dpf-ld-linux-webview") == 0)
+ return dpf_webview_start(argc - 1, argv + 1);
+ #endif
+
// dummy test mode
if (argc == 1)
{
diff --git a/distrho/src/DistrhoUtils.cpp b/distrho/src/DistrhoUtils.cpp
@@ -49,7 +49,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID)
START_NAMESPACE_DISTRHO
-// -----------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------------------------------
const char* getBinaryFilename()
{
@@ -165,6 +165,18 @@ bool requestBufferSizeChange(uint) { return false; }
bool requestMIDI() { return false; }
#endif
-// -----------------------------------------------------------------------
+/* define webview start */
+#ifdef DPF_USING_LD_LINUX_WEBVIEW
+int dpf_webview_start(int argc, char* argv[]);
+#endif
+
+// --------------------------------------------------------------------------------------------------------------------
END_NAMESPACE_DISTRHO
+
+#if defined(DPF_USING_LD_LINUX_WEBVIEW) && !DISTRHO_IS_STANDALONE
+int main(int argc, char* argv[])
+{
+ return DISTRHO_NAMESPACE::dpf_webview_start(argc, argv);
+}
+#endif