Skip to content

Commit a77eb69

Browse files
authored
Merge pull request #1868 from daschuer/wdm-ks
WDM-KS teething fix
2 parents 045ca47 + ed7fd00 commit a77eb69

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/soundio/sounddeviceportaudio.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ SoundDeviceError SoundDevicePortAudio::open(bool isClkRefDevice, int syncBuffers
361361
ControlObject::set(ConfigKey("[Master]", "samplerate"), m_dSampleRate);
362362
ControlObject::set(ConfigKey("[Master]", "audio_buffer_size"), bufferMSec);
363363
m_invalidTimeInfoCount = 0;
364+
m_clkRefTimer.start();
364365
}
365366
m_pStream = pStream;
366367
return SOUNDDEVICE_ERROR_OK;
@@ -999,10 +1000,12 @@ void SoundDevicePortAudio::updateCallbackEntryToDacTime(
9991000
double diff = (timeSinceLastCbSecs + callbackEntrytoDacSecs) -
10001001
(m_lastCallbackEntrytoDacSecs + bufferSizeSec);
10011002

1002-
if (timeSinceLastCbSecs < bufferSizeSec * 2 &&
1003-
fabs(diff) / bufferSizeSec > 0.1) {
1003+
if (callbackEntrytoDacSecs <= 0 ||
1004+
(timeSinceLastCbSecs < bufferSizeSec * 2 &&
1005+
fabs(diff) / bufferSizeSec > 0.1)) {
10041006
// Fall back to CPU timing:
1005-
// If timeSinceLastCbSecs from a CPU timer is reasonable (no underflow)
1007+
// If timeSinceLastCbSecs from a CPU timer is reasonable (no underflow),
1008+
// the callbackEntrytoDacSecs time is not in the past
10061009
// and we have more than 10 % difference to the timing provided by Portaudio
10071010
// we do not trust the Portaudio timing.
10081011
// (A difference up to ~ 5 % is normal)

0 commit comments

Comments
 (0)