From a560a610d9e3f48f22bd3a895da76e27a49896a3 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 27 Jan 2022 17:57:30 +1100 Subject: [PATCH] [client] audio: allow building without any audio support --- client/CMakeLists.txt | 14 ++++++++++---- client/src/audio.c | 4 ++++ client/src/audio.h | 10 ++++++++++ client/src/main.c | 2 ++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 4e003972..ac0bef16 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -26,7 +26,6 @@ include(UninstallTarget) find_package(PkgConfig) pkg_check_modules(FONTCONFIG REQUIRED IMPORTED_TARGET fontconfig) -pkg_check_modules(SAMPLERATE REQUIRED IMPORTED_TARGET samplerate) option(ENABLE_OPENGL "Enable the OpenGL renderer" ON) add_feature_info(ENABLE_OPENGL ENABLE_OPENGL "Legacy OpenGL renderer.") @@ -152,7 +151,6 @@ add_subdirectory("${PROJECT_TOP}/repos/cimgui" "${CMAKE_BINARY_DIR}/cimgui" E add_subdirectory(displayservers) add_subdirectory(renderers) -add_subdirectory(audiodevs) add_executable(looking-glass-client ${SOURCES}) @@ -161,16 +159,24 @@ target_compile_definitions(looking-glass-client PRIVATE CIMGUI_DEFINE_ENUMS_AND_ target_link_libraries(looking-glass-client ${EXE_FLAGS} PkgConfig::FONTCONFIG - PkgConfig::SAMPLERATE lg_common displayservers lgmp purespice renderers cimgui - audiodevs ) +if (ENABLE_PIPEWIRE OR ENABLE_PULSEAUDIO) + add_definitions(-D ENABLE_AUDIO) + add_subdirectory(audiodevs) + pkg_check_modules(SAMPLERATE REQUIRED IMPORTED_TARGET samplerate) + target_link_libraries(looking-glass-client + PkgConfig::SAMPLERATE + audiodevs + ) +endif() + install(TARGETS looking-glass-client RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT binary) diff --git a/client/src/audio.c b/client/src/audio.c index 587fad01..2df83a9a 100644 --- a/client/src/audio.c +++ b/client/src/audio.c @@ -18,6 +18,8 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#if ENABLE_AUDIO + #include "audio.h" #include "main.h" #include "common/array.h" @@ -691,3 +693,5 @@ void audio_tick(unsigned long long tickCount) app_invalidateGraphs(); } + +#endif diff --git a/client/src/audio.h b/client/src/audio.h index e4ebccb6..6e256130 100644 --- a/client/src/audio.h +++ b/client/src/audio.h @@ -18,6 +18,8 @@ * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#if ENABLE_AUDIO + #include #include @@ -39,3 +41,11 @@ void audio_recordVolume(int channels, const uint16_t volume[]); void audio_recordMute(bool mute); void audio_tick(unsigned long long tickCount); + +#else + +static inline void audio_init(void) {} +static inline void audio_free(void) {} +static inline void audio_tick(unsigned long long tickCount) {} + +#endif diff --git a/client/src/main.c b/client/src/main.c index c543e62b..ec22f15b 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -870,6 +870,7 @@ int spiceThread(void * arg) .release = cb_spiceRelease, .request = cb_spiceRequest }, +#if ENABLE_AUDIO .playback = { .enable = audio_supportsPlayback(), @@ -887,6 +888,7 @@ int spiceThread(void * arg) .mute = audio_recordMute, .stop = audio_recordStop } +#endif }; if (!purespice_connect(&config))