Cleanup, fix MOD builds

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-12-30 17:37:52 +00:00
parent 4ab933a073
commit 6aedd9d2f3
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
5 changed files with 46 additions and 27 deletions

View file

@ -66,7 +66,7 @@ static const constexpr uint kCardinalStateCount = kCardinalStateBaseCount;
extern const std::string CARDINAL_VERSION; extern const std::string CARDINAL_VERSION;
namespace rack { namespace rack {
#if DISTRHO_PLUGIN_HAS_UI && ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS #if CARDINAL_VARIANT_MINI || defined(HEADLESS)
namespace app { namespace app {
rack::widget::Widget* createMenuBar() { return new rack::widget::Widget; } rack::widget::Widget* createMenuBar() { return new rack::widget::Widget; }
} }

View file

@ -32,11 +32,12 @@
# undef HAVE_LIBLO # undef HAVE_LIBLO
#endif #endif
#ifdef HAVE_LIBLO #if (CARDINAL_VARIANT_MINI && !defined(HEADLESS)) || defined(HAVE_LIBLO)
# include <lo/lo.h> # define CARDINAL_REMOTE_ENABLED
#endif #endif
#ifdef HAVE_LIBLO #ifdef HAVE_LIBLO
# include <lo/lo.h>
// # define REMOTE_HOST "localhost" // # define REMOTE_HOST "localhost"
# define REMOTE_HOST "192.168.51.1" # define REMOTE_HOST "192.168.51.1"
#endif #endif
@ -63,6 +64,7 @@ static int osc_handler(const char* const path, const char* const types, lo_arg**
RemoteDetails* getRemote() RemoteDetails* getRemote()
{ {
#ifdef CARDINAL_REMOTE_ENABLED
CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP); CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP);
DISTRHO_SAFE_ASSERT_RETURN(context != nullptr, nullptr); DISTRHO_SAFE_ASSERT_RETURN(context != nullptr, nullptr);
@ -70,10 +72,14 @@ RemoteDetails* getRemote()
DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr, nullptr); DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr, nullptr);
return ui->remoteDetails; return ui->remoteDetails;
#else
return nullptr;
#endif
} }
bool connectToRemote() bool connectToRemote()
{ {
#ifdef CARDINAL_REMOTE_ENABLED
CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP); CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP);
DISTRHO_SAFE_ASSERT_RETURN(context != nullptr, false); DISTRHO_SAFE_ASSERT_RETURN(context != nullptr, false);
@ -115,6 +121,9 @@ bool connectToRemote()
#endif #endif
return remoteDetails != nullptr; return remoteDetails != nullptr;
#else
return false;
#endif
} }
void disconnectFromRemote(RemoteDetails* const remote) void disconnectFromRemote(RemoteDetails* const remote)
@ -138,6 +147,7 @@ void idleRemote(RemoteDetails* const remote)
void sendParamChangeToRemote(RemoteDetails* const remote, int64_t moduleId, int paramId, float value) void sendParamChangeToRemote(RemoteDetails* const remote, int64_t moduleId, int paramId, float value)
{ {
#ifdef CARDINAL_REMOTE_ENABLED
#if CARDINAL_VARIANT_MINI #if CARDINAL_VARIANT_MINI
char paramBuf[512] = {}; char paramBuf[512] = {};
{ {
@ -153,10 +163,12 @@ void sendParamChangeToRemote(RemoteDetails* const remote, int64_t moduleId, int
lo_address_free(addr); lo_address_free(addr);
#endif #endif
#endif
} }
void sendFullPatchToRemote(RemoteDetails* const remote) void sendFullPatchToRemote(RemoteDetails* const remote)
{ {
#ifdef CARDINAL_REMOTE_ENABLED
CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP); CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP);
DISTRHO_SAFE_ASSERT_RETURN(context != nullptr,); DISTRHO_SAFE_ASSERT_RETURN(context != nullptr,);
@ -204,11 +216,12 @@ void sendFullPatchToRemote(RemoteDetails* const remote)
lo_address_free(addr); lo_address_free(addr);
#endif #endif
#endif
} }
void sendScreenshotToRemote(RemoteDetails*, const char* const screenshot) void sendScreenshotToRemote(RemoteDetails*, const char* const screenshot)
{ {
#ifdef HAVE_LIBLO #if defined(HAVE_LIBLO) && ! CARDINAL_VARIANT_MINI
const lo_address addr = lo_address_new_with_proto(LO_UDP, REMOTE_HOST, CARDINAL_DEFAULT_REMOTE_HOST_PORT); const lo_address addr = lo_address_new_with_proto(LO_UDP, REMOTE_HOST, CARDINAL_DEFAULT_REMOTE_HOST_PORT);
DISTRHO_SAFE_ASSERT_RETURN(addr != nullptr,); DISTRHO_SAFE_ASSERT_RETURN(addr != nullptr,);

View file

@ -78,6 +78,8 @@ START_NAMESPACE_DISTRHO
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
#if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS #if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
uint32_t Plugin::getBufferSize() const noexcept { return 0; }
double Plugin::getSampleRate() const noexcept { return 0.0; }
const char* Plugin::getBundlePath() const noexcept { return nullptr; } const char* Plugin::getBundlePath() const noexcept { return nullptr; }
bool Plugin::isSelfTestInstance() const noexcept { return false; } bool Plugin::isSelfTestInstance() const noexcept { return false; }
bool Plugin::writeMidiEvent(const MidiEvent&) noexcept { return false; } bool Plugin::writeMidiEvent(const MidiEvent&) noexcept { return false; }

View file

@ -1,6 +1,6 @@
/* /*
* DISTRHO Cardinal Plugin * DISTRHO Cardinal Plugin
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@ -15,10 +15,6 @@
* For a full copy of the GNU General Public License see the LICENSE file. * For a full copy of the GNU General Public License see the LICENSE file.
*/ */
#ifdef HEADLESS
# error wrong include
#endif
#pragma once #pragma once
#include "DistrhoUtils.hpp" #include "DistrhoUtils.hpp"

View file

@ -42,6 +42,21 @@
# undef DEBUG # undef DEBUG
#endif #endif
#include "DistrhoUI.hpp"
#include "Application.hpp"
#include "extra/String.hpp"
#include "../CardinalCommon.hpp"
#include "../PluginContext.hpp"
#include "../WindowParameters.hpp"
#ifndef DGL_NO_SHARED_RESOURCES
# include "src/Resources.hpp"
#endif
#if !(defined(DGL_USE_GLES) || CARDINAL_VARIANT_MINI)
#define CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
// comment out if wanting to generate a local screenshot.png // comment out if wanting to generate a local screenshot.png
#define STBI_WRITE_NO_STDIO #define STBI_WRITE_NO_STDIO
@ -52,15 +67,6 @@
#define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h" #include "stb_image_write.h"
#include "DistrhoUI.hpp"
#include "Application.hpp"
#include "extra/String.hpp"
#include "../CardinalCommon.hpp"
#include "../PluginContext.hpp"
#include "../WindowParameters.hpp"
#ifndef DGL_NO_SHARED_RESOURCES
# include "src/Resources.hpp"
#endif #endif
#ifdef DISTRHO_OS_WASM #ifdef DISTRHO_OS_WASM
@ -133,6 +139,7 @@ std::shared_ptr<Image> Image::load(const std::string& filename) {
} }
#ifdef CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
enum ScreenshotStep { enum ScreenshotStep {
kScreenshotStepNone, kScreenshotStepNone,
kScreenshotStepStarted, kScreenshotStepStarted,
@ -140,6 +147,7 @@ enum ScreenshotStep {
kScreenshotStepSecondPass, kScreenshotStepSecondPass,
kScreenshotStepSaving kScreenshotStepSaving
}; };
#endif
struct Window::Internal { struct Window::Internal {
@ -165,7 +173,7 @@ struct Window::Internal {
int frame = 0; int frame = 0;
int frameSwapInterval = 1; int frameSwapInterval = 1;
#ifndef DGL_USE_GLES #ifdef CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
int generateScreenshotStep = kScreenshotStepNone; int generateScreenshotStep = kScreenshotStepNone;
#endif #endif
double monitorRefreshRate = 60.0; double monitorRefreshRate = 60.0;
@ -538,7 +546,7 @@ void Window::run() {
} }
#ifndef DGL_USE_GLES #ifdef CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
static void Window__flipBitmap(uint8_t* pixels, const int width, const int height, const int depth) { static void Window__flipBitmap(uint8_t* pixels, const int width, const int height, const int depth) {
for (int y = 0; y < height / 2; y++) { for (int y = 0; y < height / 2; y++) {
const int flipY = height - y - 1; const int flipY = height - y - 1;
@ -634,7 +642,7 @@ void Window::step() {
APP->event->handleDirty(); APP->event->handleDirty();
} }
#ifndef DGL_USE_GLES #ifdef CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
// Hide menu and background if generating screenshot // Hide menu and background if generating screenshot
if (internal->generateScreenshotStep == kScreenshotStepStarted) { if (internal->generateScreenshotStep == kScreenshotStepStarted) {
#ifdef CARDINAL_TRANSPARENT_SCREENSHOTS #ifdef CARDINAL_TRANSPARENT_SCREENSHOTS
@ -684,7 +692,7 @@ void Window::step() {
++internal->frame; ++internal->frame;
#ifndef DGL_USE_GLES #ifdef CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
if (internal->generateScreenshotStep != kScreenshotStepNone) { if (internal->generateScreenshotStep != kScreenshotStepNone) {
++internal->generateScreenshotStep; ++internal->generateScreenshotStep;
@ -799,7 +807,7 @@ bool Window::isFullScreen() {
if (emscripten_get_fullscreen_status(&status) == EMSCRIPTEN_RESULT_SUCCESS) if (emscripten_get_fullscreen_status(&status) == EMSCRIPTEN_RESULT_SUCCESS)
return status.isFullscreen; return status.isFullscreen;
return false; return false;
#elif defined(CARDINAL_TRANSPARENT_SCREENSHOTS) && !defined(DGL_USE_GLES) #elif defined(CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS) && defined(CARDINAL_TRANSPARENT_SCREENSHOTS)
return internal->generateScreenshotStep != kScreenshotStepNone; return internal->generateScreenshotStep != kScreenshotStepNone;
#else #else
return false; return false;
@ -880,7 +888,7 @@ int& Window::fbCount() {
void generateScreenshot() { void generateScreenshot() {
#ifndef DGL_USE_GLES #ifdef CARDINAL_WINDOW_CAN_GENERATE_SCREENSHOTS
APP->window->internal->generateScreenshotStep = kScreenshotStepStarted; APP->window->internal->generateScreenshotStep = kScreenshotStepStarted;
#endif #endif
} }