Bug 2080: Using WASAPI, after recording, playback can fail
The bug: 1. Set Audio host to WASAPI 2. choose recording and playback devices which have different default sample rates in shared mode. 3. Set overdub, and playthrough to off. 4. make a short recording. 5. playback. Fails with error dialog. Cause of bug: In AudioIO::GetBestRate, the last returned sample rate is cached. If the function is called again, with the same requested sample rate, then the cached value is returned. So in the above steps, when GetBestRate is called for playback, the sample rate of the recording device is returned. Fix: Include in the conditions for returning the cached rate that the values of playing and capturing as the same as in the previous call.
This commit is contained in:
parent
dfeb7e18aa
commit
b8b2f4380e
|
@ -503,6 +503,8 @@ std::vector<long> AudioIoCallback::mCachedCaptureRates;
|
|||
std::vector<long> 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -585,6 +585,8 @@ protected:
|
|||
static std::vector<long> 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.
|
||||
|
|
Loading…
Reference in New Issue