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 <parona@protonmail.com>
This commit is contained in:
Alfred Wingate
2022-01-26 08:15:32 -08:00
committed by GitHub
parent 953adf856b
commit a484644dd6
2 changed files with 11 additions and 4 deletions
+7
View File
@@ -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})
+4 -4
View File
@@ -20,7 +20,7 @@
#include "audiomanager.h"
#ifdef Q_OS_LINUX
#ifdef PA_HAS_JACK
#include <pa_jack.h>
#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);