Browse Source

Make jack-apps work under macOS

pull/1723/head
falkTX 2 years ago
parent
commit
52f5322087
8 changed files with 62 additions and 26 deletions
  1. +24
    -8
      source/backend/plugin/CarlaPluginJack.cpp
  2. +3
    -1
      source/frontend/carla_settings.py
  3. +5
    -3
      source/frontend/utils/qsafesettings.cpp
  4. +10
    -10
      source/interposer/Makefile
  5. +4
    -0
      source/interposer/interposer-jack-x11.cpp
  6. +10
    -3
      source/libjack/Makefile
  7. +0
    -1
      source/libjack/libjack.cpp
  8. +6
    -0
      source/libjack/libjack_base.cpp

+ 24
- 8
source/backend/plugin/CarlaPluginJack.cpp View File

@@ -18,7 +18,7 @@
#include "CarlaPluginInternal.hpp"
#include "CarlaEngine.hpp"

#ifdef CARLA_OS_LINUX
#if defined(CARLA_OS_LINUX) || defined(CARLA_OS_MAC)

#include "CarlaLibJackHints.h"
#include "CarlaBackendUtils.hpp"
@@ -142,14 +142,20 @@ public:
{
const EngineOptions& options(kEngine->getOptions());
CarlaString binaryDir(options.binaryDir);
#ifdef HAVE_LIBLO
#ifdef HAVE_LIBLO
const int sessionManager = fSetupLabel[4U] - '0';
#endif
#endif

CarlaString ret;
#ifdef CARLA_OS_MAC
ret += "export DYLD_LIBRARY_PATH=" + binaryDir + "/jack\n";
ret += "export DYLD_INSERT_LIBRARIES=" + binaryDir + "/libcarla_interposer-jack-x11.dylib\n";
ret += "export DYLD_FORCE_FLAT_NAMESPACE=1\n";
#else
ret += "export LD_LIBRARY_PATH=" + binaryDir + "/jack\n";
ret += "export LD_PRELOAD=" + binaryDir + "/libcarla_interposer-jack-x11.so\n";
#ifdef HAVE_LIBLO
#endif
#ifdef HAVE_LIBLO
if (sessionManager == LIBJACK_SESSION_MANAGER_NSM)
{
for (int i=50; fOscServer == nullptr && --i>=0;)
@@ -159,7 +165,7 @@ public:
ret += lo_server_get_url(fOscServer);
ret += "\n";
}
#endif
#endif

if (kPlugin->getHints() & PLUGIN_HAS_CUSTOM_UI)
ret += "export CARLA_FRONTEND_WIN_ID=" + CarlaString(options.frontendWinId) + "\n";
@@ -362,15 +368,25 @@ protected:
winIdStr[STR_MAX] = '\0';

const CarlaString libjackdir(CarlaString(options.binaryDir) + "/jack");
#ifdef CARLA_OS_MAC
const CarlaString ldpreload(CarlaString(options.binaryDir) + "/libcarla_interposer-jack-x11.dylib");
#else
const CarlaString ldpreload(CarlaString(options.binaryDir) + "/libcarla_interposer-jack-x11.so");
#endif

const ScopedEngineEnvironmentLocker _seel(kEngine);

#ifdef CARLA_OS_MAC
const CarlaScopedEnvVar sev2("DYLD_LIBRARY_PATH", libjackdir.buffer());
const CarlaScopedEnvVar sev1("DYLD_INSERT_LIBRARIES", ldpreload.isNotEmpty() ? ldpreload.buffer() : nullptr);
const CarlaScopedEnvVar sev0("DYLD_FORCE_FLAT_NAMESPACE", "1");
#else
const CarlaScopedEnvVar sev2("LD_LIBRARY_PATH", libjackdir.buffer());
const CarlaScopedEnvVar sev1("LD_PRELOAD", ldpreload.isNotEmpty() ? ldpreload.buffer() : nullptr);
#ifdef HAVE_LIBLO
#endif
#ifdef HAVE_LIBLO
const CarlaScopedEnvVar sev3("NSM_URL", lo_server_get_url(fOscServer));
#endif
#endif

if (kPlugin->getHints() & PLUGIN_HAS_CUSTOM_UI)
carla_setenv("CARLA_FRONTEND_WIN_ID", winIdStr);
@@ -2048,7 +2064,7 @@ CarlaPluginPtr CarlaPlugin::newJackApp(const Initializer& init)
carla_debug("CarlaPlugin::newJackApp({%p, \"%s\", \"%s\", \"%s\"})",
init.engine, init.filename, init.name, init.label);

#ifdef CARLA_OS_LINUX
#if defined(CARLA_OS_LINUX) || defined(CARLA_OS_MAC)
std::shared_ptr<CarlaPluginJack> plugin(new CarlaPluginJack(init.engine, init.id));

if (! plugin->init(plugin, init.filename, init.name, init.label, init.options))


+ 3
- 1
source/frontend/carla_settings.py View File

@@ -586,13 +586,15 @@ class CarlaSettingsW(QDialog):

if not LINUX:
self.ui.ch_exp_wine_bridges.setVisible(False)
self.ui.ch_exp_jack_apps.setVisible(False)
self.ui.ch_exp_prevent_bad_behaviour.setVisible(False)
self.ui.lw_page.hideRow(self.TAB_INDEX_WINE)

if not MACOS:
self.ui.label_engine_ui_bridges_mac_note.setVisible(False)

if not (LINUX or MACOS):
self.ui.ch_exp_jack_apps.setVisible(False)

# FIXME, not implemented yet
self.ui.ch_engine_uis_always_on_top.hide()



+ 5
- 3
source/frontend/utils/qsafesettings.cpp View File

@@ -54,10 +54,12 @@ int QSafeSettings::valueIntPositive(const QString& key, const int defaultValue)
QVariant var(value(key, defaultValue));

if (!var.isNull() && var.convert(QVariant::Int) && var.isValid())
return defaultValue;
{
const int value = var.toInt();
return value >= 0 ? value : defaultValue;
}

const int value = var.toInt();
return value >= 0 ? value : defaultValue;
return defaultValue;
}

uint QSafeSettings::valueUInt(const QString& key, const uint defaultValue) const


+ 10
- 10
source/interposer/Makefile View File

@@ -31,15 +31,15 @@ INTERPOSER_X11_LIBS = $(X11_LIBS) $(LIBDL_LIBS)
OBJS =
TARGETS =

ifeq ($(LINUX),true)
ifeq ($(LINUX)$(MACOS),true)
OBJS += $(OBJDIR)/interposer-safe.cpp.o
OBJS += $(OBJDIR)/interposer-jack-x11.cpp.o
TARGETS += $(BINDIR)/libcarla_interposer-safe.so
TARGETS += $(BINDIR)/libcarla_interposer-jack-x11.so
TARGETS += $(BINDIR)/libcarla_interposer-safe$(LIB_EXT)
TARGETS += $(BINDIR)/libcarla_interposer-jack-x11$(LIB_EXT)

ifeq ($(HAVE_X11),true)
OBJS += $(OBJDIR)/interposer-x11.cpp.o
TARGETS += $(BINDIR)/libcarla_interposer-x11.so
TARGETS += $(BINDIR)/libcarla_interposer-x11$(LIB_EXT)
endif
endif

@@ -57,19 +57,19 @@ debug:

# ---------------------------------------------------------------------------------------------------------------------

$(BINDIR)/libcarla_interposer-safe.so: $(OBJDIR)/interposer-safe.cpp.o
$(BINDIR)/libcarla_interposer-safe$(LIB_EXT): $(OBJDIR)/interposer-safe.cpp.o
-@mkdir -p $(BINDIR)
@echo "Linking libcarla_interposer-safe.so"
@echo "Linking libcarla_interposer-safe$(LIB_EXT)"
$(SILENT)$(CXX) $< $(SHARED) $(LINK_FLAGS) $(INTERPOSER_SAFE_LIBS) -o $@

$(BINDIR)/libcarla_interposer-x11.so: $(OBJDIR)/interposer-x11.cpp.o
$(BINDIR)/libcarla_interposer-x11$(LIB_EXT): $(OBJDIR)/interposer-x11.cpp.o
-@mkdir -p $(BINDIR)
@echo "Linking libcarla_interposer-x11.so"
@echo "Linking libcarla_interposer-x11$(LIB_EXT)"
$(SILENT)$(CXX) $< $(SHARED) $(LINK_FLAGS) $(INTERPOSER_X11_LIBS) -o $@

$(BINDIR)/libcarla_interposer-jack-x11.so: $(OBJDIR)/interposer-jack-x11.cpp.o
$(BINDIR)/libcarla_interposer-jack-x11$(LIB_EXT): $(OBJDIR)/interposer-jack-x11.cpp.o
-@mkdir -p $(BINDIR)
@echo "Linking libcarla_interposer-jack-x11.so"
@echo "Linking libcarla_interposer-jack-x11$(LIB_EXT)"
$(SILENT)$(CXX) $< $(SHARED) $(LINK_FLAGS) $(INTERPOSER_X11_LIBS) -o $@

# ---------------------------------------------------------------------------------------------------------------------


+ 4
- 0
source/interposer/interposer-jack-x11.cpp View File

@@ -31,7 +31,11 @@ struct ScopedLibOpen {
long long winId;

ScopedLibOpen() noexcept
#ifdef CARLA_OS_MAC
: handle(dlopen("libjack.dylib", RTLD_NOW|RTLD_LOCAL)),
#else
: handle(dlopen("libjack.so.0", RTLD_NOW|RTLD_LOCAL)),
#endif
winId(-1)
{
CARLA_SAFE_ASSERT_RETURN(handle != nullptr,);


+ 10
- 3
source/libjack/Makefile View File

@@ -23,11 +23,14 @@ endif

BUILD_C_FLAGS += -I$(CWD) -I$(CWD)/includes
BUILD_CXX_FLAGS += -I$(CWD) -I$(CWD)/backend -I$(CWD)/includes -I$(CWD)/utils
LINK_FLAGS += -pthread -lrt
LINK_FLAGS += -pthread
ifeq ($(LINUX),true)
LINK_FLAGS += -lrt
endif

# ---------------------------------------------------------------------------------------------------------------------

ifeq ($(LINUX),true)
ifeq ($(LINUX)$(MACOS),true)
ifneq ($(JACKBRIDGE_DIRECT),true)
CAN_BUILD_LIBJACK=true
endif
@@ -51,7 +54,11 @@ OBJS = \
$(OBJDIR)/libjack_time.cpp.o \
$(OBJDIR)/libjack_transport.cpp.o \
$(OBJDIR)/ringbuffer.c.o
ifeq ($(MACOS),true)
TARGET = $(BINDIR)/jack/libjack.dylib
else
TARGET = $(BINDIR)/jack/libjack.so.0
endif
else
OBJS =
TARGET =
@@ -73,7 +80,7 @@ debug:

$(TARGET): $(OBJS)
-@mkdir -p $(BINDIR)/jack
@echo "Linking libjack.so.0"
@echo "Linking libjack"
$(SILENT)$(CXX) $^ $(SHARED) $(LINK_FLAGS) $(LIBJACK_LIBS) -o $@

# ---------------------------------------------------------------------------------------------------------------------


+ 0
- 1
source/libjack/libjack.cpp View File

@@ -21,7 +21,6 @@
#include "CarlaJuceUtils.hpp"

#include <signal.h>
#include <sys/prctl.h>
#include <sys/time.h>

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


+ 6
- 0
source/libjack/libjack_base.cpp View File

@@ -29,8 +29,14 @@ int jack_carla_interposed_action(uint, uint, void*)
printWarning = false;
carla_stderr2("Non-exported jack_carla_interposed_action called, this should not happen!!");
carla_stderr("Printing some info:");
#ifdef CARLA_OS_MAC
carla_stderr("\tDYLD_LIBRARY_PATH: '%s'", std::getenv("DYLD_LIBRARY_PATH"));
carla_stderr("\tDYLD_INSERT_LIBRARIES: '%s'", std::getenv("DYLD_INSERT_LIBRARIES"));
carla_stderr("\tDYLD_FORCE_FLAT_NAMESPACE: '%s'", std::getenv("DYLD_FORCE_FLAT_NAMESPACE"));
#else
carla_stderr("\tLD_LIBRARY_PATH: '%s'", std::getenv("LD_LIBRARY_PATH"));
carla_stderr("\tLD_PRELOAD: '%s'", std::getenv("LD_PRELOAD"));
#endif
std::fflush(stderr);
}



Loading…
Cancel
Save