diff options
author | Daniel Schürmann <daschuer@mixxx.org> | 2020-10-07 17:45:40 +0200 |
---|---|---|
committer | Daniel Schürmann <daschuer@mixxx.org> | 2020-10-07 21:08:40 +0200 |
commit | e6bc8b9a5efd1661da64f6adfb9d713349fa5864 (patch) | |
tree | 527c1ce255b013a2afe7d5cd5777dbfe5912f121 /src/soundio | |
parent | 7ad9de30558cbad2968a9199274e07380f90b861 (diff) |
Fix possible segfault due to random memaory write with Jack
Diffstat (limited to 'src/soundio')
-rw-r--r-- | src/soundio/sounddeviceportaudio.cpp | 27 | ||||
-rw-r--r-- | src/soundio/sounddeviceportaudio.h | 5 |
2 files changed, 10 insertions, 22 deletions
diff --git a/src/soundio/sounddeviceportaudio.cpp b/src/soundio/sounddeviceportaudio.cpp index 46de29a11e..1b95e6600f 100644 --- a/src/soundio/sounddeviceportaudio.cpp +++ b/src/soundio/sounddeviceportaudio.cpp @@ -24,10 +24,6 @@ #include <QRegularExpression> #include <QThread> -#ifdef __LINUX__ -#include <QLibrary> -#endif - #include "control/controlobject.h" #include "control/controlproxy.h" #include "soundio/sounddevice.h" @@ -41,6 +37,14 @@ #include "vinylcontrol/defs_vinylcontrol.h" #include "waveform/visualplayposition.h" +#ifdef __LINUX__ +extern "C" { + +// Declare the following function to enable real-time priority callback +// thread from ALSA/PortAudio. This is not part of the generic interface. +extern void PaAlsa_EnableRealtimeScheduling(PaStream* s, int enable); +} +#endif namespace { @@ -336,20 +340,9 @@ SoundDeviceError SoundDevicePortAudio::open(bool isClkRefDevice, int syncBuffers #ifdef __LINUX__ - //Attempt to dynamically load and resolve stuff in the PortAudio library - //in order to enable RT priority with ALSA. - QLibrary portaudio("libportaudio.so.2"); - if (!portaudio.load()) - qWarning() << "Failed to dynamically load PortAudio library"; - else - qDebug() << "Dynamically loaded PortAudio library"; - - EnableAlsaRT enableRealtime = (EnableAlsaRT) portaudio.resolve( - "PaAlsa_EnableRealtimeScheduling"); - if (enableRealtime) { - enableRealtime(pStream, 1); + if (m_deviceInfo->hostApi == paALSA) { + PaAlsa_EnableRealtimeScheduling(pStream, 1); } - portaudio.unload(); #endif // Start stream diff --git a/src/soundio/sounddeviceportaudio.h b/src/soundio/sounddeviceportaudio.h index 91cdc22f0d..22c6d92038 100644 --- a/src/soundio/sounddeviceportaudio.h +++ b/src/soundio/sounddeviceportaudio.h @@ -32,11 +32,6 @@ class SoundManager; class ControlProxy; -/** Dynamically resolved function which allows us to enable a realtime-priority callback - thread from ALSA/PortAudio. This must be dynamically resolved because PortAudio can't - tell us if ALSA is compiled into it or not. */ -typedef int (*EnableAlsaRT)(PaStream* s, int enable); - class SoundDevicePortAudio : public SoundDevice { public: SoundDevicePortAudio(UserSettingsPointer config, |