| @@ -203,9 +203,7 @@ typedef struct _CarlaParameterInfo { | |||
| * C++ constructor and destructor. | |||
| */ | |||
| CARLA_API _CarlaParameterInfo() noexcept; | |||
| CARLA_API _CarlaParameterInfo(const char* n) noexcept; | |||
| CARLA_API ~_CarlaParameterInfo() noexcept; | |||
| const char* _reserved; | |||
| CARLA_DECLARE_NON_COPY_STRUCT(_CarlaParameterInfo) | |||
| #endif | |||
| @@ -1156,12 +1154,12 @@ CARLA_EXPORT const char* carla_get_host_osc_url_udp(CarlaHostHandle handle); | |||
| /*! | |||
| * Get the absolute filename of this carla library. | |||
| */ | |||
| CARLA_EXPORT const char* carla_get_library_filename(void); | |||
| CARLA_EXPORT const char* carla_standalone_get_library_filename(void); | |||
| /*! | |||
| * Get the folder where this carla library resides. | |||
| */ | |||
| CARLA_EXPORT const char* carla_get_library_folder(void); | |||
| CARLA_EXPORT const char* carla_standalone_get_library_folder(void); | |||
| /*! | |||
| * Initialize NSM (that is, announce ourselves to it). | |||
| @@ -1,157 +0,0 @@ | |||
| /* | |||
| * Carla Plugin Host | |||
| * Copyright (C) 2011-2014 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. | |||
| */ | |||
| #include "CarlaHost.h" | |||
| #include "CarlaString.hpp" | |||
| #include "water/files/File.h" | |||
| namespace CB = CarlaBackend; | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| // Always return a valid string ptr | |||
| static const char* const gNullCharPtr = ""; | |||
| #ifdef CARLA_COMMON_NEED_CHECKSTRINGPTR | |||
| static void checkStringPtr(const char*& charPtr) noexcept | |||
| { | |||
| if (charPtr == nullptr) | |||
| charPtr = gNullCharPtr; | |||
| } | |||
| #endif | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| // Constructors | |||
| _CarlaPluginInfo::_CarlaPluginInfo() noexcept | |||
| : type(CB::PLUGIN_NONE), | |||
| category(CB::PLUGIN_CATEGORY_NONE), | |||
| hints(0x0), | |||
| optionsAvailable(0x0), | |||
| optionsEnabled(0x0), | |||
| filename(gNullCharPtr), | |||
| name(gNullCharPtr), | |||
| label(gNullCharPtr), | |||
| maker(gNullCharPtr), | |||
| copyright(gNullCharPtr), | |||
| iconName(gNullCharPtr), | |||
| uniqueId(0) {} | |||
| _CarlaPluginInfo::~_CarlaPluginInfo() noexcept | |||
| { | |||
| if (label != gNullCharPtr) | |||
| delete[] label; | |||
| if (maker != gNullCharPtr) | |||
| delete[] maker; | |||
| if (copyright != gNullCharPtr) | |||
| delete[] copyright; | |||
| } | |||
| _CarlaParameterInfo::_CarlaParameterInfo() noexcept | |||
| : name(gNullCharPtr), | |||
| symbol(gNullCharPtr), | |||
| unit(gNullCharPtr), | |||
| comment(gNullCharPtr), | |||
| groupName(gNullCharPtr), | |||
| scalePointCount(0), | |||
| _reserved(gNullCharPtr) {} | |||
| _CarlaParameterInfo::_CarlaParameterInfo(const char* const n) noexcept | |||
| : name(n), | |||
| symbol(n), | |||
| unit(n), | |||
| comment(n), | |||
| groupName(n), | |||
| scalePointCount(0), | |||
| _reserved(n) {} | |||
| _CarlaParameterInfo::~_CarlaParameterInfo() noexcept | |||
| { | |||
| if (name != _reserved) | |||
| delete[] name; | |||
| if (symbol != _reserved) | |||
| delete[] symbol; | |||
| if (unit != _reserved) | |||
| delete[] unit; | |||
| if (comment != _reserved) | |||
| delete[] comment; | |||
| if (groupName != _reserved) | |||
| delete[] groupName; | |||
| } | |||
| _CarlaScalePointInfo::_CarlaScalePointInfo() noexcept | |||
| : value(0.0f), | |||
| label(gNullCharPtr) {} | |||
| _CarlaScalePointInfo::~_CarlaScalePointInfo() noexcept | |||
| { | |||
| if (label != gNullCharPtr) | |||
| delete[] label; | |||
| } | |||
| _CarlaTransportInfo::_CarlaTransportInfo() noexcept | |||
| : playing(false), | |||
| frame(0), | |||
| bar(0), | |||
| beat(0), | |||
| tick(0), | |||
| bpm(0.0) {} | |||
| void _CarlaTransportInfo::clear() noexcept | |||
| { | |||
| playing = false; | |||
| frame = 0; | |||
| bar = 0; | |||
| beat = 0; | |||
| tick = 0; | |||
| bpm = 0.0; | |||
| } | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| const char* carla_get_library_filename() | |||
| { | |||
| carla_debug("carla_get_library_filename()"); | |||
| static CarlaString ret; | |||
| if (ret.isEmpty()) | |||
| { | |||
| using water::File; | |||
| ret = File(File::getSpecialLocation(File::currentExecutableFile)).getFullPathName().toRawUTF8(); | |||
| } | |||
| return ret; | |||
| } | |||
| const char* carla_get_library_folder() | |||
| { | |||
| carla_debug("carla_get_library_folder()"); | |||
| static CarlaString ret; | |||
| if (ret.isEmpty()) | |||
| { | |||
| using water::File; | |||
| ret = File(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory()).getFullPathName().toRawUTF8(); | |||
| } | |||
| return ret; | |||
| } | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| @@ -27,13 +27,12 @@ | |||
| #include "CarlaBackendUtils.hpp" | |||
| #include "CarlaBase64Utils.hpp" | |||
| #include "ThreadSafeFFTW.hpp" | |||
| #ifdef BUILD_BRIDGE | |||
| # include "water/files/File.h" | |||
| #else | |||
| #ifndef BUILD_BRIDGE | |||
| # include "CarlaLogThread.hpp" | |||
| #endif | |||
| #include "water/files/File.h" | |||
| #define CARLA_SAFE_ASSERT_WITH_LAST_ERROR_RETURN(cond, msg, ret) \ | |||
| if (! (cond)) { \ | |||
| carla_stderr2("%s: " msg, __FUNCTION__); \ | |||
| @@ -43,21 +42,108 @@ | |||
| } | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| // API | |||
| #ifndef CARLA_PLUGIN_EXPORT | |||
| # define CARLA_COMMON_NEED_CHECKSTRINGPTR | |||
| # include "CarlaHostCommon.cpp" | |||
| # undef CARLA_COMMON_NEED_CHECKSTRINGPTR | |||
| #endif | |||
| #ifdef USING_JUCE | |||
| static void carla_juce_init(); | |||
| static void carla_juce_idle(); | |||
| static void carla_juce_cleanup(); | |||
| static void carla_standalone_juce_init(void); | |||
| static void carla_standalone_juce_idle(void); | |||
| static void carla_standalone_juce_cleanup(void); | |||
| # define carla_juce_init carla_standalone_juce_init | |||
| # define carla_juce_idle carla_standalone_juce_idle | |||
| # define carla_juce_cleanup carla_standalone_juce_cleanup | |||
| # include "utils/JUCE.cpp" | |||
| # undef carla_juce_init | |||
| # undef carla_juce_idle | |||
| # undef carla_juce_cleanup | |||
| #endif | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| // Always return a valid string ptr for standalone functions | |||
| static const char* const gNullCharPtr = ""; | |||
| static void checkStringPtr(const char*& charPtr) noexcept | |||
| { | |||
| if (charPtr == nullptr) | |||
| charPtr = gNullCharPtr; | |||
| } | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| // Constructors | |||
| _CarlaPluginInfo::_CarlaPluginInfo() noexcept | |||
| : type(CB::PLUGIN_NONE), | |||
| category(CB::PLUGIN_CATEGORY_NONE), | |||
| hints(0x0), | |||
| optionsAvailable(0x0), | |||
| optionsEnabled(0x0), | |||
| filename(gNullCharPtr), | |||
| name(gNullCharPtr), | |||
| label(gNullCharPtr), | |||
| maker(gNullCharPtr), | |||
| copyright(gNullCharPtr), | |||
| iconName(gNullCharPtr), | |||
| uniqueId(0) {} | |||
| _CarlaPluginInfo::~_CarlaPluginInfo() noexcept | |||
| { | |||
| if (label != gNullCharPtr) | |||
| delete[] label; | |||
| if (maker != gNullCharPtr) | |||
| delete[] maker; | |||
| if (copyright != gNullCharPtr) | |||
| delete[] copyright; | |||
| } | |||
| _CarlaParameterInfo::_CarlaParameterInfo() noexcept | |||
| : name(gNullCharPtr), | |||
| symbol(gNullCharPtr), | |||
| unit(gNullCharPtr), | |||
| comment(gNullCharPtr), | |||
| groupName(gNullCharPtr), | |||
| scalePointCount(0) {} | |||
| _CarlaParameterInfo::~_CarlaParameterInfo() noexcept | |||
| { | |||
| if (name != gNullCharPtr) | |||
| delete[] name; | |||
| if (symbol != gNullCharPtr) | |||
| delete[] symbol; | |||
| if (unit != gNullCharPtr) | |||
| delete[] unit; | |||
| if (comment != gNullCharPtr) | |||
| delete[] comment; | |||
| if (groupName != gNullCharPtr) | |||
| delete[] groupName; | |||
| } | |||
| _CarlaScalePointInfo::_CarlaScalePointInfo() noexcept | |||
| : value(0.0f), | |||
| label(gNullCharPtr) {} | |||
| _CarlaScalePointInfo::~_CarlaScalePointInfo() noexcept | |||
| { | |||
| if (label != gNullCharPtr) | |||
| delete[] label; | |||
| } | |||
| _CarlaTransportInfo::_CarlaTransportInfo() noexcept | |||
| : playing(false), | |||
| frame(0), | |||
| bar(0), | |||
| beat(0), | |||
| tick(0), | |||
| bpm(0.0) {} | |||
| void _CarlaTransportInfo::clear() noexcept | |||
| { | |||
| playing = false; | |||
| frame = 0; | |||
| bar = 0; | |||
| beat = 0; | |||
| tick = 0; | |||
| bpm = 0.0; | |||
| } | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| using CarlaBackend::CarlaPluginPtr; | |||
| @@ -319,7 +405,7 @@ bool carla_engine_init(CarlaHostHandle handle, const char* driverName, const cha | |||
| #endif | |||
| #ifdef USING_JUCE | |||
| carla_juce_init(); | |||
| carla_standalone_juce_init(); | |||
| #endif | |||
| CarlaHostStandalone& shandle((CarlaHostStandalone&)*handle); | |||
| @@ -369,7 +455,7 @@ bool carla_engine_init(CarlaHostHandle handle, const char* driverName, const cha | |||
| shandle.engine = nullptr; | |||
| delete engine; | |||
| #ifdef USING_JUCE | |||
| carla_juce_cleanup(); | |||
| carla_standalone_juce_cleanup(); | |||
| #endif | |||
| return false; | |||
| } | |||
| @@ -449,7 +535,7 @@ bool carla_engine_close(CarlaHostHandle handle) | |||
| delete engine; | |||
| #ifdef USING_JUCE | |||
| carla_juce_cleanup(); | |||
| carla_standalone_juce_cleanup(); | |||
| #endif | |||
| return closed; | |||
| } | |||
| @@ -462,7 +548,7 @@ void carla_engine_idle(CarlaHostHandle handle) | |||
| #ifdef USING_JUCE | |||
| if (handle->isStandalone) | |||
| carla_juce_idle(); | |||
| carla_standalone_juce_idle(); | |||
| #endif | |||
| } | |||
| @@ -1354,7 +1440,7 @@ const CarlaPortCountInfo* carla_get_parameter_count_info(CarlaHostHandle handle, | |||
| const CarlaParameterInfo* carla_get_parameter_info(CarlaHostHandle handle, uint pluginId, uint32_t parameterId) | |||
| { | |||
| static CarlaParameterInfo retInfo(gNullCharPtr); | |||
| static CarlaParameterInfo retInfo; | |||
| // reset | |||
| retInfo.scalePointCount = 0; | |||
| @@ -2267,6 +2353,38 @@ const char* carla_get_host_osc_url_udp(CarlaHostHandle handle) | |||
| #endif | |||
| } | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| const char* carla_standalone_get_library_filename() | |||
| { | |||
| carla_debug("carla_standalone_get_library_filename()"); | |||
| static CarlaString ret; | |||
| if (ret.isEmpty()) | |||
| { | |||
| using water::File; | |||
| ret = File(File::getSpecialLocation(File::currentExecutableFile)).getFullPathName().toRawUTF8(); | |||
| } | |||
| return ret; | |||
| } | |||
| const char* carla_standalone_get_library_folder() | |||
| { | |||
| carla_debug("carla_standalone_get_library_folder()"); | |||
| static CarlaString ret; | |||
| if (ret.isEmpty()) | |||
| { | |||
| using water::File; | |||
| ret = File(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory()).getFullPathName().toRawUTF8(); | |||
| } | |||
| return ret; | |||
| } | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| #ifndef CARLA_PLUGIN_EXPORT | |||
| @@ -2279,6 +2397,6 @@ const char* carla_get_host_osc_url_udp(CarlaHostHandle handle) | |||
| # include "CarlaPipeUtils.cpp" | |||
| # include "CarlaProcessUtils.cpp" | |||
| # include "CarlaStateUtils.cpp" | |||
| #endif | |||
| #endif /* CARLA_PLUGIN_EXPORT */ | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| @@ -262,19 +262,29 @@ CARLA_EXPORT bool carla_pipe_client_flush_and_unlock(CarlaPipeClientHandle handl | |||
| */ | |||
| CARLA_EXPORT void carla_pipe_client_destroy(CarlaPipeClientHandle handle); | |||
| #ifndef CARLA_HOST_H_INCLUDED | |||
| /* -------------------------------------------------------------------------------------------------------------------- | |||
| * window control */ | |||
| CARLA_EXPORT int carla_cocoa_get_window(void* nsViewPtr); | |||
| CARLA_EXPORT void carla_x11_reparent_window(uintptr_t winId1, uintptr_t winId2); | |||
| CARLA_EXPORT void carla_x11_move_window(uintptr_t winId, int x, int y); | |||
| CARLA_EXPORT int* carla_x11_get_window_pos(uintptr_t winId); | |||
| /* -------------------------------------------------------------------------------------------------------------------- | |||
| * info about current library */ | |||
| /*! | |||
| * Get the absolute filename of this carla library. | |||
| */ | |||
| CARLA_EXPORT const char* carla_get_library_filename(void); | |||
| CARLA_EXPORT const char* carla_utils_get_library_filename(void); | |||
| /*! | |||
| * Get the folder where this carla library resides. | |||
| */ | |||
| CARLA_EXPORT const char* carla_get_library_folder(void); | |||
| CARLA_EXPORT const char* carla_utils_get_library_folder(void); | |||
| /* -------------------------------------------------------------------------------------------------------------------- | |||
| * JUCE */ | |||
| @@ -287,30 +297,18 @@ CARLA_EXPORT const char* carla_get_library_folder(void); | |||
| * | |||
| * Make sure to call carla_juce_cleanup after you are done with APIs that need JUCE. | |||
| */ | |||
| CARLA_EXPORT void carla_juce_init(); | |||
| CARLA_EXPORT void carla_juce_init(void); | |||
| /*! | |||
| * Give idle time to JUCE stuff. | |||
| * Currently only used for Linux. | |||
| */ | |||
| CARLA_EXPORT void carla_juce_idle(); | |||
| CARLA_EXPORT void carla_juce_idle(void); | |||
| /*! | |||
| * Cleanup the JUCE stuff that was initialized by carla_juce_init. | |||
| */ | |||
| CARLA_EXPORT void carla_juce_cleanup(); | |||
| #endif | |||
| /* -------------------------------------------------------------------------------------------------------------------- | |||
| * window control */ | |||
| CARLA_EXPORT int carla_cocoa_get_window(void* nsViewPtr); | |||
| CARLA_EXPORT void carla_x11_reparent_window(uintptr_t winId1, uintptr_t winId2); | |||
| CARLA_EXPORT void carla_x11_move_window(uintptr_t winId, int x, int y); | |||
| CARLA_EXPORT int* carla_x11_get_window_pos(uintptr_t winId); | |||
| CARLA_EXPORT void carla_juce_cleanup(void); | |||
| /* ----------------------------------------------------------------------------------------------------------------- */ | |||
| @@ -218,8 +218,10 @@ public: | |||
| if (pData->options.binaryDir != nullptr) | |||
| delete[] pData->options.binaryDir; | |||
| const water::String binaryDir(File(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory()).getFullPathName()); | |||
| pData->options.resourceDir = carla_strdup(pHost->resourceDir); | |||
| pData->options.binaryDir = carla_strdup(carla_get_library_folder()); | |||
| pData->options.binaryDir = carla_strdup(binaryDir.toRawUTF8()); | |||
| } | |||
| ~CarlaEngineNative() override | |||
| @@ -2877,9 +2879,9 @@ const EngineDriverDeviceInfo* getRtAudioDeviceInfo(const uint, const char* const | |||
| CARLA_BACKEND_END_NAMESPACE | |||
| #define CARLA_PLUGIN_UI_CLASS_PREFIX EngineNative | |||
| #include "CarlaHostCommon.cpp" | |||
| #define CARLA_PLUGIN_UI_CLASS_PREFIX Plugin | |||
| #include "CarlaPluginUI.cpp" | |||
| # undef CARLA_PLUGIN_UI_CLASS_PREFIX | |||
| #include "CarlaDssiUtils.cpp" | |||
| #include "CarlaMacUtils.cpp" | |||
| #include "CarlaPatchbayUtils.cpp" | |||
| @@ -2887,6 +2889,6 @@ CARLA_BACKEND_END_NAMESPACE | |||
| #include "CarlaProcessUtils.cpp" | |||
| #include "CarlaStateUtils.cpp" | |||
| #endif | |||
| #endif /* CARLA_PLUGIN_EXPORT */ | |||
| // ----------------------------------------------------------------------- | |||
| @@ -1,6 +1,6 @@ | |||
| /* | |||
| * Carla Plugin Host | |||
| * Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com> | |||
| * Copyright (C) 2011-2020 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 | |||
| @@ -221,8 +221,34 @@ const char* const* carla_get_supported_features() | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| #ifndef CARLA_PLUGIN_EXPORT | |||
| # include "../CarlaHostCommon.cpp" | |||
| #endif | |||
| const char* carla_utils_get_library_filename() | |||
| { | |||
| carla_debug("carla_utils_get_library_filename()"); | |||
| static CarlaString ret; | |||
| if (ret.isEmpty()) | |||
| { | |||
| using water::File; | |||
| ret = File(File::getSpecialLocation(File::currentExecutableFile)).getFullPathName().toRawUTF8(); | |||
| } | |||
| return ret; | |||
| } | |||
| const char* carla_utils_get_library_folder() | |||
| { | |||
| carla_debug("carla_utils_get_library_folder()"); | |||
| static CarlaString ret; | |||
| if (ret.isEmpty()) | |||
| { | |||
| using water::File; | |||
| ret = File(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory()).getFullPathName().toRawUTF8(); | |||
| } | |||
| return ret; | |||
| } | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| @@ -19,7 +19,7 @@ | |||
| #include "CarlaUtils.hpp" | |||
| #ifdef CARLA_OS_MAC | |||
| #if defined(CARLA_OS_MAC) && !defined(CARLA_PLUGIN_EXPORT) | |||
| # import <Cocoa/Cocoa.h> | |||
| #endif | |||
| @@ -35,7 +35,7 @@ int carla_cocoa_get_window(void* nsViewPtr) | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(nsViewPtr != nullptr, 0); | |||
| #ifdef CARLA_OS_MAC | |||
| #if defined(CARLA_OS_MAC) && !defined(CARLA_PLUGIN_EXPORT) | |||
| NSView* const nsView = (NSView*)nsViewPtr; | |||
| return [[nsView window] windowNumber]; | |||
| #else | |||
| @@ -20,20 +20,7 @@ | |||
| #include "CarlaNative.h" | |||
| #include "CarlaHost.h" | |||
| #ifndef CARLA_HOST_H_INCLUDED | |||
| #ifndef CARLA_UTILS_H_INCLUDED | |||
| /*! | |||
| * Get the absolute filename of this carla library. | |||
| */ | |||
| CARLA_EXPORT const char* carla_get_library_filename(void); | |||
| /*! | |||
| * Get the folder where this carla library resides. | |||
| */ | |||
| CARLA_EXPORT const char* carla_get_library_folder(void); | |||
| #endif | |||
| #endif | |||
| #include "CarlaUtils.h" | |||
| /*! | |||
| * Get the native plugin descriptor for the carla-rack plugin. | |||
| @@ -15,8 +15,7 @@ | |||
| * For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
| */ | |||
| #include "CarlaHost.h" | |||
| #include "CarlaUtils.h" | |||
| #include "CarlaNativePlugin.h" | |||
| #define CARLA_PLUGIN_EXPORT | |||
| @@ -25,20 +24,10 @@ | |||
| #include "utils/CachedPlugins.cpp" | |||
| #include "utils/Information.cpp" | |||
| #include "utils/JUCE.cpp" | |||
| #include "utils/PipeClient.cpp" | |||
| #include "utils/System.cpp" | |||
| // #include "utils/Windows.cpp" | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| // Always return a valid string ptr | |||
| static const char* const gNullCharPtr = ""; | |||
| static void checkStringPtr(const char*& charPtr) noexcept | |||
| { | |||
| if (charPtr == nullptr) | |||
| charPtr = gNullCharPtr; | |||
| } | |||
| #include "utils/Windows.cpp" | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| // Include all standalone code | |||