Also account for user-specified delay

- Woops, don't use global audio time for sorting, use the latest audio
   timestamp from that specific device.

 - Also, made it so lastSentTimestamp is only done when data is actually
   used, accidentally put it in the wrong scope.
This commit is contained in:
jp9000 2014-01-05 17:23:27 -07:00
parent 327eda646d
commit c042ffc6ac
2 changed files with 11 additions and 5 deletions

View File

@ -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;

View File

@ -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; i<auxAudioSources.Num(); i++)
{
while (auxAudioSources[i]->QueryAudio(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);
}
}