Skip to content

Commit

Permalink
do not assume PortAudio on Linux was built with ALSA backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing committed Aug 25, 2021
1 parent f2258d1 commit f472ab2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 8 additions & 0 deletions cmake/modules/FindPortAudio.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ find_path(PortAudio_INCLUDE_DIR
DOC "PortAudio include directory")
mark_as_advanced(PortAudio_INCLUDE_DIR)

find_path(PortAudio_ALSA_H
NAMES pa_linux_alsa.h
PATHS ${PC_PortAudio_INCLUDE_DIRS})
mark_as_advanced(PortAudio_ALSA_H)

find_library(PortAudio_LIBRARY
NAMES portaudio
PATHS ${PC_PortAudio_LIBRARY_DIRS}
Expand All @@ -78,5 +83,8 @@ if(PortAudio_FOUND)
INTERFACE_COMPILE_OPTIONS "${PC_PortAudio_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${PortAudio_INCLUDE_DIR}"
)
if(PortAudio_ALSA_H)
target_compile_definitions(PortAudio::PortAudio INTERFACE PA_USE_ALSA)
endif()
endif()
endif()
5 changes: 2 additions & 3 deletions src/soundio/sounddeviceportaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "vinylcontrol/defs_vinylcontrol.h"
#include "waveform/visualplayposition.h"

#ifdef __LINUX__
#ifdef PA_USE_ALSA
// for PaAlsa_EnableRealtimeScheduling
#include <pa_linux_alsa.h>
#endif
Expand Down Expand Up @@ -333,8 +333,7 @@ SoundDeviceError SoundDevicePortAudio::open(bool isClkRefDevice, int syncBuffers
qDebug() << "Opened PortAudio stream successfully... starting";
}


#ifdef __LINUX__
#ifdef PA_USE_ALSA
if (m_deviceTypeId == paALSA) {
qInfo() << "Enabling ALSA real-time scheduling";
PaAlsa_EnableRealtimeScheduling(pStream, 1);
Expand Down

0 comments on commit f472ab2

Please sign in to comment.