From a971dd5bb42f742199155acbd74822f0f2afc7f0 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 23 Sep 2017 21:23:34 -0400 Subject: [PATCH] Detect whether ALSA is the portaudio host (possible only on Linux) --- src/AudioIO.cpp | 9 +++++++-- src/AudioIO.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 51adc3e10..66eae0bc3 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -1678,6 +1678,12 @@ int AudioIO::StartStream(const ConstWaveTrackArray &playbackTracks, wxMilliSleep( 50 ); } +#ifdef __WXGTK__ + // Detect whether ALSA is the chosen host, and do the various involved MIDI + // timing compensations only then. + mUsingAlsa = (gPrefs->Read(wxT("/AudioIO/Host"), wxT("")) == "ALSA"); +#endif + gPrefs->Read(wxT("/AudioIO/SWPlaythrough"), &mSoftwarePlaythrough, false); gPrefs->Read(wxT("/AudioIO/SoundActivatedRecord"), &mPauseRec, false); int silenceLevelDB; @@ -2033,8 +2039,7 @@ int AudioIO::StartStream(const ConstWaveTrackArray &playbackTracks, // (Which we should be able to determine from fields of // PaStreamCallbackTimeInfo, but that seems not to work as documented with // ALSA.) - wxString hostName = gPrefs->Read(wxT("/AudioIO/Host"), wxT("")); - if (hostName == "ALSA") + if (mUsingAlsa) // Perhaps we should do this only if also playing MIDI ? PaAlsa_EnableRealtimeScheduling( mPortStreamV19, 1 ); #endif diff --git a/src/AudioIO.h b/src/AudioIO.h index e83587263..609e649ff 100644 --- a/src/AudioIO.h +++ b/src/AudioIO.h @@ -727,6 +727,8 @@ private: const TimeTrack *mTimeTrack; + bool mUsingAlsa { false }; + // For cacheing supported sample rates static int mCachedPlaybackIndex; static wxArrayLong mCachedPlaybackRates;