From a484644dd6dfae3ebfc4d2383b8f166c41028ad8 Mon Sep 17 00:00:00 2001 From: Alfred Wingate Date: Wed, 26 Jan 2022 18:15:32 +0200 Subject: [PATCH] Fix jack client naming and improve use of pa_jack (#1847) * Switch around Pa_Initialize and PaJack_SetClientName so that the jack client is named "Olive" on the first initialization and not on subsequent initializations when refreshing devices. * Make use of pa_jack.h dependant on availability of the header and not on the usage of the linux platform. Signed-off-by: Alfred Wingate --- CMakeLists.txt | 7 +++++++ app/audio/audiomanager.cpp | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c9f307ad..cd0c6d89a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,13 @@ list(APPEND OLIVE_LIBRARIES # Link PortAudio find_package(PortAudio REQUIRED) +set(CMAKE_REQUIRED_INCLUDES ${PORTAUDIO_INCLUDE_DIRS}) +include(CheckIncludeFileCXX) +check_include_file_cxx( "pa_jack.h" PA_HAS_JACK) +if (PA_HAS_JACK) + list(APPEND OLIVE_DEFINITIONS PA_HAS_JACK) +endif() + list(APPEND OLIVE_INCLUDE_DIRS ${PORTAUDIO_INCLUDE_DIRS}) list(APPEND OLIVE_LIBRARIES ${PORTAUDIO_LIBRARIES}) diff --git a/app/audio/audiomanager.cpp b/app/audio/audiomanager.cpp index 86d64b692..201b78ce6 100644 --- a/app/audio/audiomanager.cpp +++ b/app/audio/audiomanager.cpp @@ -20,7 +20,7 @@ #include "audiomanager.h" -#ifdef Q_OS_LINUX +#ifdef PA_HAS_JACK #include #endif @@ -202,14 +202,14 @@ PaDeviceIndex AudioManager::FindDeviceByName(const QString &s, bool is_output_de AudioManager::AudioManager() : output_stream_(nullptr) { - Pa_Initialize(); - -#ifdef Q_OS_LINUX +#ifdef PA_HAS_JACK // PortAudio doesn't do a strcpy, so we need a const char that's readily accessible (i.e. not // a QString converted to UTF-8) PaJack_SetClientName("Olive"); #endif + Pa_Initialize(); + // Get device from config PaDeviceIndex output_device = FindConfigDeviceByName(true); PaDeviceIndex input_device = FindConfigDeviceByName(false);