Skip to content

Commit

Permalink
Update to latest carla bits
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Sep 29, 2023
1 parent 1e6b991 commit 9dcfee5
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 75 deletions.
3 changes: 1 addition & 2 deletions build-aux/com.obsproject.Studio.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"--env=LADSPA_PATH=/app/extensions/Plugins/ladspa",
"--env=LV2_PATH=/app/extensions/Plugins/lv2:/app/lib/lv2",
"--env=VST_PATH=/app/extensions/Plugins/vst",
"--env=VST3_PATH=/app/extensions/Plugins/vst3",
"--env=ENGINE_OPTION_PATH_BINARIES=/app/bin"
"--env=VST3_PATH=/app/extensions/Plugins/vst3"
],
"add-extensions": {
"com.obsproject.Studio.Plugin": {
Expand Down
7 changes: 3 additions & 4 deletions build-aux/modules/90-carla.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
"subdir": "cmake",
"config-opts": [
"-DCMAKE_BUILD_TYPE=Release",
"-DCARLA_SKIP_LIBDIR_SUFFIX:BOOL=ON",
"-DCARLA_USE_JACK:BOOL=OFF",
"-DCARLA_USE_OSC:BOOL=OFF"
],
"cleanup": [
"/include",
"/lib/libcarla_native-plugin.so",
"/lib/libcarla_standalone2.so",
"/lib/carla/libcarla_native-plugin.so",
"/lib/carla/libcarla_standalone2.so",
"/lib/pkgconfig"
],
"sources": [
{
"type": "git",
"url": "https://github.com/falkTX/Carla.git",
"commit": "f69896bcff8a4154bb07f792ece2bb157c3f1cdb"
"commit": "a627caf17f141009602a76e99cbfc93f5b7d1455"
}
]
}
44 changes: 38 additions & 6 deletions cmake/Modules/FindCarlaUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,42 @@ find_path(
CarlaUtils_INCLUDE_DIR
NAMES utils/CarlaBridgeUtils.hpp
HINTS ${PC_CarlaUtils_INCLUDE_DIRS}
PATHS /usr/include/carla /usr/local/include/carla
PATH_SUFFIXES carla
DOC "carla include directory")
PATHS /usr/include /usr/local/include /app/include
PATH_SUFFIXES carla)

find_library(
CarlaUtils_LIBRARY
NAMES carla_utils libcarla_utils
HINTS ${PC_CarlaUtils_LIBRARY_DIRS}
PATHS /usr/lib/carla /usr/local/lib/carla /app/lib/carla
PATHS /usr/lib /usr/local/lib /app/lib
PATH_SUFFIXES carla)

find_program(
CarlaUtils_BRIDGE_LV2_GTK2
NAMES carla-bridge-lv2-gtk2
HINTS ${PC_CarlaUtils_LIBRARY_DIRS}
PATHS /usr/lib /usr/local/lib /app/lib
PATH_SUFFIXES carla)

find_program(
CarlaUtils_BRIDGE_LV2_GTK3
NAMES carla-bridge-lv2-gtk3
HINTS ${PC_CarlaUtils_LIBRARY_DIRS}
PATHS /usr/lib /usr/local/lib /app/lib
PATH_SUFFIXES carla)

find_program(
CarlaUtils_BRIDGE_NATIVE
NAMES carla-bridge-native
HINTS ${PC_CarlaUtils_LIBRARY_DIRS}
PATHS /usr/lib/carla /usr/local/lib/carla /app/bin
PATHS /usr/lib /usr/local/lib /app/lib
PATH_SUFFIXES carla)

find_program(
CarlaUtils_DISCOVERY_NATIVE
NAMES carla-discovery-native
HINTS ${PC_CarlaUtils_LIBRARY_DIRS}
PATHS /usr/lib/carla /usr/local/lib/carla /app/bin
PATHS /usr/lib /usr/local/lib /app/lib
PATH_SUFFIXES carla)

include(FindPackageHandleStandardArgs)
Expand All @@ -57,9 +70,28 @@ if(CarlaUtils_FOUND)
set_target_properties(carla::utils PROPERTIES IMPORTED_LIBNAME "${CarlaUtils_LIBRARIES}")
endif()

if(PC_CarlaUtils_FOUND)
message("DEBUG: using carla-utils pkg-config | ${PC_CarlaUtils_FOUND} | ${PC_CarlaUtils_LDFLAGS}")
set_target_properties(carla::utils PROPERTIES INTERFACE_LINK_OPTIONS ${PC_CarlaUtils_LDFLAGS})
else()
message("DEBUG: NOT using carla-utils pkg-config | ${PC_CarlaUtils_FOUND} | ${PC_CarlaUtils_LDFLAGS}")
endif()

set_target_properties(carla::utils PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CarlaUtils_INCLUDE_DIRS}")
endif()

if(NOT TARGET carla::bridge-lv2-gtk2)
add_executable(carla::bridge-lv2-gtk2 IMPORTED GLOBAL)
set_target_properties(carla::bridge-lv2-gtk2 PROPERTIES IMPORTED_LOCATION "${CarlaUtils_BRIDGE_LV2_GTK2}")
add_dependencies(carla::utils carla::bridge-lv2-gtk2)
endif()

if(NOT TARGET carla::bridge-lv2-gtk3)
add_executable(carla::bridge-lv2-gtk3 IMPORTED GLOBAL)
set_target_properties(carla::bridge-lv2-gtk3 PROPERTIES IMPORTED_LOCATION "${CarlaUtils_BRIDGE_LV2_GTK3}")
add_dependencies(carla::utils carla::bridge-lv2-gtk3)
endif()

if(NOT TARGET carla::bridge-native)
add_executable(carla::bridge-native IMPORTED GLOBAL)
set_target_properties(carla::bridge-native PROPERTIES IMPORTED_LOCATION "${CarlaUtils_BRIDGE_NATIVE}")
Expand Down
77 changes: 61 additions & 16 deletions cmake/finders/FindCarlaUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,54 @@ if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_CarlaUtils QUIET carla-utils)
endif()

find_path(
CarlaUtils_INCLUDE_DIR
NAMES utils/CarlaBridgeUtils.hpp
HINTS ${PC_CarlaUtils_INCLUDE_DIRS}
PATHS /usr/include/carla /usr/local/include/carla
PATH_SUFFIXES carla
DOC "carla include directory")
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND NOT PC_CarlaUtils_FOUND)
message("DEBUG: using carla-utils macos framework | ${PC_CarlaUtils_FOUND} | ${PC_CarlaUtils_LDFLAGS}")
set(CarlaUtils_USE_MACOS_FRAMEWORK TRUE)
else()
message("DEBUG: NOT using carla-utils macos framework | ${PC_CarlaUtils_FOUND} | ${PC_CarlaUtils_LDFLAGS}")
# set(CarlaUtils_USE_MACOS_FRAMEWORK FALSE)
endif()

find_library(
CarlaUtils_LIBRARY
NAMES carla_utils libcarla_utils
NAMES carla-utils carla_utils libcarla_utils
HINTS ${PC_CarlaUtils_LIBRARY_DIRS}
PATHS /usr/lib/carla /usr/local/lib/carla /app/lib/carla
PATHS /usr/lib /usr/local/lib /app/lib
PATH_SUFFIXES carla)

find_path(
CarlaUtils_INCLUDE_DIR
NAMES utils/CarlaBridgeUtils.hpp
HINTS ${PC_CarlaUtils_INCLUDE_DIRS} ${CarlaUtils_LIBRARY}
PATHS /usr/include /usr/local/include /app/include
PATH_SUFFIXES carla Headers)

find_program(
CarlaUtils_BRIDGE_LV2_GTK2
NAMES carla-bridge-lv2-gtk2
HINTS ${PC_CarlaUtils_LIBRARY_DIRS} ${CarlaUtils_LIBRARY}
PATHS /usr/lib /usr/local/lib /app/lib
PATH_SUFFIXES carla)

find_program(
CarlaUtils_BRIDGE_LV2_GTK3
NAMES carla-bridge-lv2-gtk3
HINTS ${PC_CarlaUtils_LIBRARY_DIRS} ${CarlaUtils_LIBRARY}
PATHS /usr/lib /usr/local/lib /app/lib
PATH_SUFFIXES carla)

find_program(
CarlaUtils_BRIDGE_NATIVE
NAMES carla-bridge-native
HINTS ${PC_CarlaUtils_LIBRARY_DIRS}
PATHS /usr/lib/carla /usr/local/lib/carla /app/bin
HINTS ${PC_CarlaUtils_LIBRARY_DIRS} ${CarlaUtils_LIBRARY}
PATHS /usr/lib /usr/local/lib /app/lib
PATH_SUFFIXES carla)

find_program(
CarlaUtils_DISCOVERY_NATIVE
NAMES carla-discovery-native
HINTS ${PC_CarlaUtils_LIBRARY_DIRS}
PATHS /usr/lib/carla /usr/local/lib/carla /app/bin
HINTS ${PC_CarlaUtils_LIBRARY_DIRS} ${CarlaUtils_LIBRARY}
PATHS /usr/lib /usr/local/lib /app/lib
PATH_SUFFIXES carla)

if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin|Windows")
Expand All @@ -70,9 +91,9 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
CarlaUtils
FOUND_VAR CarlaUtils_FOUND
REQUIRED_VARS CarlaUtils_INCLUDE_DIR CarlaUtils_LIBRARY CarlaUtils_BRIDGE_NATIVE CarlaUtils_DISCOVERY_NATIVE
REQUIRED_VARS CarlaUtils_LIBRARY CarlaUtils_INCLUDE_DIR CarlaUtils_BRIDGE_NATIVE CarlaUtils_DISCOVERY_NATIVE
REASON_FAILURE_MESSAGE "${CarlaUtils_ERROR_REASON}")
mark_as_advanced(CarlaUtils_INCLUDE_DIR CarlaUtils_LIBRARY CarlaUtils_BRIDGE_NATIVE CarlaUtils_DISCOVERY_NATIVE)
mark_as_advanced(CarlaUtils_LIBRARY CarlaUtils_INCLUDE_DIR CarlaUtils_BRIDGE_NATIVE CarlaUtils_DISCOVERY_NATIVE)
unset(CarlaUtils_ERROR_REASON)

if(CarlaUtils_FOUND)
Expand All @@ -81,17 +102,39 @@ if(CarlaUtils_FOUND)
set(CarlaUtils_LIBRARIES ${CarlaUtils_LIBRARY})

if(NOT TARGET carla::utils)
if(IS_ABSOLUTE "${CarlaUtils_LIBRARIES}")
if(${CarlaUtils_USE_MACOS_FRAMEWORK})
add_library(carla::utils INTERFACE IMPORTED GLOBAL)
set_target_properties(carla::utils PROPERTIES IMPORTED_LOCATION "${CarlaUtils_LIBRARIES}")
set_target_properties(carla::utils PROPERTIES INTERFACE_LINK_LIBRARIES $<LINK_LIBRARY:FRAMEWORK,${CarlaUtils_LIBRARIES}>)
elseif(IS_ABSOLUTE "${CarlaUtils_LIBRARIES}")
add_library(carla::utils UNKNOWN IMPORTED GLOBAL)
set_target_properties(carla::utils PROPERTIES IMPORTED_LOCATION "${CarlaUtils_LIBRARIES}")
else()
add_library(carla::utils INTERFACE IMPORTED GLOBAL)
set_target_properties(carla::utils PROPERTIES IMPORTED_LIBNAME "${CarlaUtils_LIBRARIES}")
endif()

if(PC_CarlaUtils_FOUND)
set_target_properties(carla::utils PROPERTIES INTERFACE_LINK_OPTIONS ${PC_CarlaUtils_LDFLAGS})
# elseif(${CarlaUtils_USE_MACOS_FRAMEWORK})
# set_target_properties(carla::utils PROPERTIES INTERFACE_LINK_LIBRARIES $<LINK_LIBRARY:FRAMEWORK,${CarlaUtils_LIBRARIES}>)
endif()

set_target_properties(carla::utils PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CarlaUtils_INCLUDE_DIRS}")
endif()

if(NOT TARGET carla::bridge-lv2-gtk2)
add_executable(carla::bridge-lv2-gtk2 IMPORTED GLOBAL)
set_target_properties(carla::bridge-lv2-gtk2 PROPERTIES IMPORTED_LOCATION "${CarlaUtils_BRIDGE_LV2_GTK2}")
add_dependencies(carla::utils carla::bridge-lv2-gtk2)
endif()

if(NOT TARGET carla::bridge-lv2-gtk3)
add_executable(carla::bridge-lv2-gtk3 IMPORTED GLOBAL)
set_target_properties(carla::bridge-lv2-gtk3 PROPERTIES IMPORTED_LOCATION "${CarlaUtils_BRIDGE_LV2_GTK3}")
add_dependencies(carla::utils carla::bridge-lv2-gtk3)
endif()

if(NOT TARGET carla::bridge-native)
add_executable(carla::bridge-native IMPORTED GLOBAL)
set_target_properties(carla::bridge-native PROPERTIES IMPORTED_LOCATION "${CarlaUtils_BRIDGE_NATIVE}")
Expand All @@ -105,6 +148,8 @@ if(CarlaUtils_FOUND)
endif()
endif()

unset(CarlaUtils_USE_MACOS_FRAMEWORK)

include(FeatureSummary)
set_package_properties(
CarlaUtils PROPERTIES
Expand Down
14 changes: 5 additions & 9 deletions plugins/carla/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ find_qt(COMPONENTS Core Widgets)
add_library(carla-bridge MODULE)
add_library(OBS::carla-bridge ALIAS carla-bridge)

if(OS_MACOS)
# needed for using Qt as framework
target_compile_options(carla-bridge PRIVATE -Wno-quoted-include-in-framework-header)
endif()

target_compile_definitions(carla-bridge PRIVATE CARLA_MODULE_ID="carla-bridge" CARLA_MODULE_NAME="Audio Plugin"
CARLA_UTILS_USE_QT)

Expand All @@ -44,15 +49,6 @@ target_sources(
pluginrefreshdialog.hpp
qtutils.cpp)

# non-mac/win systems should use rpath. this is typically automatically handled by pkg-config, but OBS does not read the
# link flags from there
if(NOT (OS_MACOS OR OS_WINDOWS))
set_property(
TARGET carla-bridge
APPEND
PROPERTY BUILD_RPATH "$<TARGET_FILE_DIR:carla::utils>" INSTALL_RPATH "$<TARGET_FILE_DIR:carla::utils>")
endif()

if(OBS_CMAKE_VERSION VERSION_GREATER_EQUAL 3.0.0)
set_target_properties_obs(
carla-bridge
Expand Down
9 changes: 4 additions & 5 deletions plugins/carla/carla-bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,11 +778,9 @@ void carla_bridge::process(float *buffers[MAX_AV_PLANES], const uint32_t frames)
carla_copyFloats(audiopool.data + (c * bufferSize), buffers[c],
frames);

{
rtClientCtrl.writeOpcode(kPluginBridgeRtClientProcess);
rtClientCtrl.writeUInt(frames);
rtClientCtrl.commitWrite();
}
rtClientCtrl.writeOpcode(kPluginBridgeRtClientProcess);
rtClientCtrl.writeUInt(frames);
rtClientCtrl.commitWrite();

if (wait("process", 1000)) {
for (uint32_t c = 0; c < MAX_AV_PLANES; ++c)
Expand Down Expand Up @@ -972,6 +970,7 @@ void carla_bridge::save_and_wait()
// deactivate plugin if we timeout during save
if (timedOut && activated) {
activated = false;

const CarlaMutexLocker cml(nonRtClientCtrl.mutex);

nonRtClientCtrl.writeOpcode(
Expand Down
16 changes: 2 additions & 14 deletions plugins/carla/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,9 @@ const char *get_carla_bin_path(void)
if (carla_bin_path != NULL)
return carla_bin_path;

char *binpath;
const char *utilspath;

#if defined(__linux__) || defined(__FreeBSD__)
if (access("/.flatpak-info", F_OK) == 0) {
// use known path under flatpak
utilspath = "/app/bin";
} else
#endif
{
// use path of linked carla-utils library
utilspath = carla_get_library_folder();
}

const char *const utilspath = carla_get_library_folder();
const size_t utilslen = strlen(utilspath);
char *binpath;

binpath = bmalloc(utilslen + 28);
memcpy(binpath, utilspath, utilslen);
Expand Down
Loading

0 comments on commit 9dcfee5

Please sign in to comment.