diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index d35cec479..7dcf76e92 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -503,6 +503,8 @@ std::vector AudioIoCallback::mCachedCaptureRates; std::vector AudioIoCallback::mCachedSampleRates; double AudioIoCallback::mCachedBestRateIn = 0.0; double AudioIoCallback::mCachedBestRateOut; +bool AudioIoCallback::mCachedBestRatePlaying; +bool AudioIoCallback::mCachedBestRateCapturing; enum { // This is the least positive latency we can @@ -3105,7 +3107,8 @@ int AudioIO::GetOptimalSupportedSampleRate() double AudioIO::GetBestRate(bool capturing, bool playing, double sampleRate) { // Check if we can use the cached value - if (mCachedBestRateIn != 0.0 && mCachedBestRateIn == sampleRate) { + if (mCachedBestRateIn != 0.0 && mCachedBestRateIn == sampleRate + && mCachedBestRatePlaying == playing && mCachedBestRateCapturing == capturing) { return mCachedBestRateOut; } @@ -3174,6 +3177,8 @@ double AudioIO::GetBestRate(bool capturing, bool playing, double sampleRate) finished: mCachedBestRateIn = sampleRate; mCachedBestRateOut = retval; + mCachedBestRatePlaying = playing; + mCachedBestRateCapturing = capturing; return retval; } diff --git a/src/AudioIO.h b/src/AudioIO.h index a91272a80..7423a5de8 100644 --- a/src/AudioIO.h +++ b/src/AudioIO.h @@ -585,6 +585,8 @@ protected: static std::vector mCachedSampleRates; static double mCachedBestRateIn; static double mCachedBestRateOut; + static bool mCachedBestRatePlaying; + static bool mCachedBestRateCapturing; // Serialize main thread and PortAudio thread's attempts to pause and change // the state used by the third, Audio thread.