diff --git a/OBSApi/AudioSource.cpp b/OBSApi/AudioSource.cpp index 7842ce4a..8cf38fab 100644 --- a/OBSApi/AudioSource.cpp +++ b/OBSApi/AudioSource.cpp @@ -628,14 +628,14 @@ UINT AudioSource::QueryAudio(float curVolume, bool bCanBurst) float *newBuffer = (bResample) ? tempResampleBuffer.Array() : tempBuffer.Array(); - if (bCanBurst || lastUsedTimestamp >= lastSentTimestamp+10) + bool overshotAudio = (lastUsedTimestamp < lastSentTimestamp+10); + if (bCanBurst || !overshotAudio) { AudioSegment *newSegment = new AudioSegment(newBuffer, numAudioFrames*2, lastUsedTimestamp); AddAudioSegment(newSegment, curVolume*sourceVolume); + lastSentTimestamp = lastUsedTimestamp; } - lastSentTimestamp = lastUsedTimestamp; - //----------------------------------------------------------------------------- return AudioAvailable; diff --git a/Source/OBSCapture.cpp b/Source/OBSCapture.cpp index 4373b12b..6082c79d 100644 --- a/Source/OBSCapture.cpp +++ b/Source/OBSCapture.cpp @@ -1058,12 +1058,16 @@ bool OBS::QueryNewAudio() if (!bAudioBufferFilled) { + QWORD timestamp; + // No more desktop data, drain auxilary/mic buffers until they're dry to prevent burst data OSEnterMutex(hAuxAudioMutex); for(UINT i=0; iQueryAudio(auxAudioSources[i]->GetVolume(), true) != NoAudioAvailable); - auxAudioSources[i]->SortAudio(GetAudioTime()); + + if (auxAudioSources[i]->GetLatestTimestamp(timestamp)) + auxAudioSources[i]->SortAudio(timestamp); } OSLeaveMutex(hAuxAudioMutex); @@ -1071,7 +1075,9 @@ bool OBS::QueryNewAudio() if (micAudio) { while (micAudio->QueryAudio(curMicVol, true) != NoAudioAvailable); - micAudio->SortAudio(GetAudioTime()); + + if (micAudio->GetLatestTimestamp(timestamp)) + micAudio->SortAudio(timestamp); } }