Signed-off-by: falkTX <falktx@gmail.com>tags/v2.1-alpha2
| @@ -20,6 +20,7 @@ | |||
| #ifdef CARLA_OS_LINUX | |||
| #include "CarlaLibJackHints.h" | |||
| #include "CarlaBackendUtils.hpp" | |||
| #include "CarlaBridgeUtils.hpp" | |||
| #include "CarlaEngineUtils.hpp" | |||
| @@ -52,20 +53,6 @@ using water::Time; | |||
| CARLA_BACKEND_START_NAMESPACE | |||
| enum { | |||
| FLAG_CONTROL_WINDOW = 0x01, | |||
| FLAG_CAPTURE_FIRST_WINDOW = 0x02, | |||
| FLAG_BUFFERS_ADDITION_MODE = 0x10, | |||
| }; | |||
| enum { | |||
| SESSION_MGR_NONE = 0, | |||
| SESSION_MGR_AUTO = 1, | |||
| SESSION_MGR_JACK = 2, | |||
| SESSION_MGR_LADISH = 3, | |||
| SESSION_MGR_NSM = 4, | |||
| }; | |||
| static size_t safe_rand(const size_t limit) | |||
| { | |||
| const int r = std::rand(); | |||
| @@ -247,7 +234,7 @@ protected: | |||
| const int sessionManager = fSetupLabel[4] - '0'; | |||
| if (sessionManager == SESSION_MGR_NSM) | |||
| if (sessionManager == LIBJACK_SESSION_MANAGER_NSM) | |||
| { | |||
| // NSM support | |||
| fOscServer = lo_server_new_with_proto(nullptr, LO_UDP, _osc_error_handler); | |||
| @@ -324,7 +311,7 @@ protected: | |||
| for (; fProcess->isRunning() && ! shouldThreadExit();) | |||
| { | |||
| #ifdef HAVE_LIBLO | |||
| if (sessionManager == SESSION_MGR_NSM) | |||
| if (sessionManager == LIBJACK_SESSION_MANAGER_NSM) | |||
| { | |||
| lo_server_recv_noblock(fOscServer, 50); | |||
| } | |||
| @@ -336,7 +323,7 @@ protected: | |||
| } | |||
| #ifdef HAVE_LIBLO | |||
| if (sessionManager == SESSION_MGR_NSM) | |||
| if (sessionManager == LIBJACK_SESSION_MANAGER_NSM) | |||
| { | |||
| lo_server_free(fOscServer); | |||
| fOscServer = nullptr; | |||
| @@ -1563,7 +1550,7 @@ public: | |||
| #endif | |||
| //fInfo.optionsAvailable = optionAv; | |||
| if (setupHints & FLAG_CONTROL_WINDOW) | |||
| if (setupHints & LIBJACK_FLAG_CONTROL_WINDOW) | |||
| pData->hints |= PLUGIN_HAS_CUSTOM_UI; | |||
| // --------------------------------------------------------------- | |||
| @@ -0,0 +1,56 @@ | |||
| /* | |||
| * Carla JACK API for external applications | |||
| * Copyright (C) 2016-2019 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * This program is free software; you can redistribute it and/or | |||
| * modify it under the terms of the GNU General Public License as | |||
| * published by the Free Software Foundation; either version 2 of | |||
| * the License, or any later version. | |||
| * | |||
| * This program is distributed in the hope that it will be useful, | |||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| * GNU General Public License for more details. | |||
| * | |||
| * For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
| */ | |||
| #ifndef CARLA_LIBJACK_HINTS_H_INCLUDED | |||
| #define CARLA_LIBJACK_HINTS_H_INCLUDED | |||
| #include "CarlaDefines.h" | |||
| #ifdef __cplusplus | |||
| extern "C" { | |||
| #endif | |||
| enum SetupHints { | |||
| // Application Window management | |||
| LIBJACK_FLAG_CONTROL_WINDOW = 0x01, | |||
| LIBJACK_FLAG_CAPTURE_FIRST_WINDOW = 0x02, | |||
| // Audio/MIDI Buffers management | |||
| LIBJACK_FLAG_AUDIO_BUFFERS_ADDITION = 0x10, | |||
| LIBJACK_FLAG_MIDI_OUTPUT_BUFFERS_CHANNEL_MIXDOWN = 0x20, | |||
| }; | |||
| enum SessionManager { | |||
| LIBJACK_SESSION_MANAGER_NONE = 0, | |||
| LIBJACK_SESSION_MANAGER_AUTO = 1, | |||
| LIBJACK_SESSION_MANAGER_JACK = 2, | |||
| LIBJACK_SESSION_MANAGER_LADISH = 3, | |||
| LIBJACK_SESSION_MANAGER_NSM = 4, | |||
| }; | |||
| enum InterposerAction { | |||
| LIBJACK_INTERPOSER_ACTION_NONE = 0, | |||
| LIBJACK_INTERPOSER_ACTION_SET_HINTS_AND_CALLBACK, | |||
| LIBJACK_INTERPOSER_ACTION_SET_SESSION_MANAGER, | |||
| LIBJACK_INTERPOSER_ACTION_SHOW_HIDE_GUI, | |||
| LIBJACK_INTERPOSER_ACTION_CLOSE_EVERYTHING, | |||
| }; | |||
| #ifdef __cplusplus | |||
| } | |||
| #endif | |||
| #endif // CARLA_LIBJACK_HINTS_H_INCLUDED | |||
| @@ -15,14 +15,12 @@ | |||
| * For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
| */ | |||
| #include "CarlaLibJackHints.h" | |||
| #include "CarlaUtils.hpp" | |||
| #include <dlfcn.h> | |||
| #include <X11/Xlib.h> | |||
| CARLA_EXPORT | |||
| int jack_carla_interposed_action(int action, int value, void* ptr); | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| struct ScopedLibOpen { | |||
| @@ -81,8 +79,8 @@ typedef enum { | |||
| static Display* gCurrentlyMappedDisplay = nullptr; | |||
| static Window gCurrentlyMappedWindow = 0; | |||
| static CarlaInterposedCallback gInterposedCallback = nullptr; | |||
| static int gInterposedSessionManager = 0; | |||
| static int gInterposedHints = 0; | |||
| static uint gInterposedSessionManager = LIBJACK_SESSION_MANAGER_NONE; | |||
| static uint gInterposedHints = 0x0; | |||
| static WindowMappingType gCurrentWindowType = WindowMapNone; | |||
| static bool gCurrentWindowMapped = false; | |||
| static bool gCurrentWindowVisible = false; | |||
| @@ -357,24 +355,22 @@ int XNextEvent(Display* display, XEvent* event) | |||
| // Full control helper | |||
| CARLA_EXPORT | |||
| int jack_carla_interposed_action(int action, int value, void* ptr) | |||
| int jack_carla_interposed_action(uint action, uint value, void* ptr) | |||
| { | |||
| carla_debug("jack_carla_interposed_action(%i, %i, %p)", action, value, ptr); | |||
| switch (action) | |||
| { | |||
| case 1: | |||
| // set hints and callback | |||
| case LIBJACK_INTERPOSER_ACTION_SET_HINTS_AND_CALLBACK: | |||
| gInterposedHints = value; | |||
| gInterposedCallback = (CarlaInterposedCallback)ptr; | |||
| return 1; | |||
| case 2: | |||
| // session manager | |||
| case LIBJACK_INTERPOSER_ACTION_SET_SESSION_MANAGER: | |||
| gInterposedSessionManager = value; | |||
| return 1; | |||
| case 3: | |||
| case LIBJACK_INTERPOSER_ACTION_SHOW_HIDE_GUI: | |||
| // show gui | |||
| if (value != 0) | |||
| { | |||
| @@ -414,7 +410,7 @@ int jack_carla_interposed_action(int action, int value, void* ptr) | |||
| } | |||
| break; | |||
| case 4: // close everything | |||
| case LIBJACK_INTERPOSER_ACTION_CLOSE_EVERYTHING: | |||
| gCurrentWindowType = WindowMapNone; | |||
| gCurrentWindowMapped = false; | |||
| gCurrentWindowVisible = false; | |||
| @@ -18,8 +18,7 @@ | |||
| #ifndef CARLA_LIBJACK_API_H_INCLUDED | |||
| #define CARLA_LIBJACK_API_H_INCLUDED | |||
| #include "CarlaDefines.h" | |||
| #include "CarlaLibJackHints.h" | |||
| #include "jackbridge/JackBridge.hpp" | |||
| #include <pthread.h> | |||
| @@ -29,8 +28,6 @@ extern "C" { | |||
| typedef uint32_t jack_port_type_id_t; | |||
| typedef void*(*JackThreadCallback)(void* arg); | |||
| int jack_carla_interposed_action(int, int, void*); | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| // jack.h | |||
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * Carla JACK API for external applications | |||
| * Copyright (C) 2016-2018 Filipe Coelho <falktx@falktx.com> | |||
| * Copyright (C) 2016-2019 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * This program is free software; you can redistribute it and/or | |||
| * modify it under the terms of the GNU General Public License as | |||
| @@ -28,7 +28,7 @@ | |||
| typedef int (*CarlaInterposedCallback)(int, void*); | |||
| CARLA_EXPORT | |||
| int jack_carla_interposed_action(int, int, void*) | |||
| int jack_carla_interposed_action(uint, uint, void*) | |||
| { | |||
| carla_stderr2("Non-export jack_carla_interposed_action called, this should not happen!!"); | |||
| return 1337; | |||
| @@ -173,8 +173,8 @@ public: | |||
| fSessionManager = libjackSetup[4] - '0'; | |||
| fSetupHints = libjackSetup[5] - '0'; | |||
| jack_carla_interposed_action(1, fSetupHints, (void*)carla_interposed_callback); | |||
| jack_carla_interposed_action(2, fSessionManager, nullptr); | |||
| jack_carla_interposed_action(LIBJACK_INTERPOSER_ACTION_SET_HINTS_AND_CALLBACK, fSetupHints, (void*)carla_interposed_callback); | |||
| jack_carla_interposed_action(LIBJACK_INTERPOSER_ACTION_SET_SESSION_MANAGER, fSessionManager, nullptr); | |||
| fNonRealtimeThread.startThread(false); | |||
| } | |||
| @@ -975,7 +975,7 @@ bool CarlaJackAppClient::handleNonRtData() | |||
| break; | |||
| case kPluginBridgeNonRtClientShowUI: | |||
| if (jack_carla_interposed_action(3, 1, nullptr) == 1337) | |||
| if (jack_carla_interposed_action(LIBJACK_INTERPOSER_ACTION_SHOW_HIDE_GUI, 1, nullptr) == 1337) | |||
| { | |||
| // failed, LD_PRELOAD did not work? | |||
| const char* const message("Cannot show UI, LD_PRELOAD not working?"); | |||
| @@ -994,7 +994,7 @@ bool CarlaJackAppClient::handleNonRtData() | |||
| break; | |||
| case kPluginBridgeNonRtClientHideUI: | |||
| jack_carla_interposed_action(3, 0, nullptr); | |||
| jack_carla_interposed_action(LIBJACK_INTERPOSER_ACTION_SHOW_HIDE_GUI, 0, nullptr); | |||
| break; | |||
| case kPluginBridgeNonRtClientUiParameterChange: | |||
| @@ -15,6 +15,9 @@ | |||
| * For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
| */ | |||
| #ifndef CARLA_LIBJACK_HPP_INCLUDED | |||
| #define CARLA_LIBJACK_HPP_INCLUDED | |||
| // need to include this first | |||
| #include "CarlaDefines.h" | |||
| @@ -289,3 +292,5 @@ struct JackServerState { | |||
| CARLA_BACKEND_END_NAMESPACE | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| #endif // CARLA_LIBJACK_HPP_INCLUDED | |||