Only enable remote control for headless builds

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-01-31 23:09:01 +00:00
parent 9b7e289928
commit ca25477990
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0

View file

@ -34,7 +34,7 @@
# undef DEBUG # undef DEBUG
#endif #endif
#ifdef HAVE_LIBLO #if defined(HAVE_LIBLO) && defined(HEADLESS)
# include <lo/lo.h> # include <lo/lo.h>
# include "extra/Thread.hpp" # include "extra/Thread.hpp"
#endif #endif
@ -54,8 +54,6 @@ static const constexpr uint kCardinalStateCount = 2; // patch, windowSize
static const constexpr uint kCardinalStateCount = 1; // patch static const constexpr uint kCardinalStateCount = 1; // patch
#endif #endif
#define REMOTE_HOST_PORT "2228"
namespace rack { namespace rack {
namespace plugin { namespace plugin {
void initStaticPlugins(); void initStaticPlugins();
@ -73,11 +71,11 @@ START_NAMESPACE_DISTRHO
// ----------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------
struct Initializer struct Initializer
#ifdef HAVE_LIBLO #if defined(HAVE_LIBLO) && defined(HEADLESS)
: public Thread : public Thread
#endif #endif
{ {
#ifdef HAVE_LIBLO #if defined(HAVE_LIBLO) && defined(HEADLESS)
lo_server oscServer = nullptr; lo_server oscServer = nullptr;
CardinalBasePlugin* oscPlugin = nullptr; CardinalBasePlugin* oscPlugin = nullptr;
#endif #endif
@ -188,7 +186,7 @@ struct Initializer
INFO("Initializing plugin browser DB"); INFO("Initializing plugin browser DB");
app::browserInit(); app::browserInit();
#ifdef HAVE_LIBLO #if defined(HAVE_LIBLO) && defined(HEADLESS)
INFO("Initializing OSC Remote control"); INFO("Initializing OSC Remote control");
oscServer = lo_server_new_with_proto(REMOTE_HOST_PORT, LO_UDP, osc_error_handler); oscServer = lo_server_new_with_proto(REMOTE_HOST_PORT, LO_UDP, osc_error_handler);
DISTRHO_SAFE_ASSERT_RETURN(oscServer != nullptr,); DISTRHO_SAFE_ASSERT_RETURN(oscServer != nullptr,);
@ -198,7 +196,7 @@ struct Initializer
lo_server_add_method(oscServer, nullptr, nullptr, osc_fallback_handler, nullptr); lo_server_add_method(oscServer, nullptr, nullptr, osc_fallback_handler, nullptr);
startThread(); startThread();
#else #elif defined(HEADLESS)
INFO("OSC Remote control is not enabled in this build"); INFO("OSC Remote control is not enabled in this build");
#endif #endif
} }
@ -207,7 +205,7 @@ struct Initializer
{ {
using namespace rack; using namespace rack;
#ifdef HAVE_LIBLO #if defined(HAVE_LIBLO) && defined(HEADLESS)
if (oscServer != nullptr) if (oscServer != nullptr)
{ {
stopThread(5000); stopThread(5000);
@ -229,7 +227,7 @@ struct Initializer
logger::destroy(); logger::destroy();
} }
#ifdef HAVE_LIBLO #if defined(HAVE_LIBLO) && defined(HEADLESS)
void run() override void run() override
{ {
INFO("OSC Thread Listening for remote commands"); INFO("OSC Thread Listening for remote commands");
@ -471,14 +469,14 @@ public:
context->patch->loadTemplate(); context->patch->loadTemplate();
context->scene->rackScroll->reset(); context->scene->rackScroll->reset();
#ifdef HAVE_LIBLO #if defined(HAVE_LIBLO) && defined(HEADLESS)
fInitializer->oscPlugin = this; fInitializer->oscPlugin = this;
#endif #endif
} }
~CardinalPlugin() override ~CardinalPlugin() override
{ {
#ifdef HAVE_LIBLO #if defined(HAVE_LIBLO) && defined(HEADLESS)
fInitializer->oscPlugin = nullptr; fInitializer->oscPlugin = nullptr;
#endif #endif