Fix potential sync issue with hardware encoders

Instead of the video just buffer using the 'buffering time', make it
properly interleave and wait for audio data to come in before it sends
out data.
This commit is contained in:
jp9000 2014-05-11 15:45:02 -07:00
parent 7f4522f9b5
commit e04b481c52

View File

@ -87,7 +87,24 @@ bool OBS::BufferVideoData(const List<DataPacket> &inputPackets, const List<Packe
segmentIn.packets[i].type = inputTypes[i];
}
if((bufferedVideo.Last().timestamp-bufferedVideo[0].timestamp) >= UINT(App->bufferingTime))
bool foundAudio = false;
// wait until there is audio before sending off data -- don't rely on buffering time
OSEnterMutex(hSoundDataMutex);
if (pendingAudioFrames.Num())
{
for (UINT i = 0; i < pendingAudioFrames.Num(); i++)
{
if (pendingAudioFrames[i].timestamp >= bufferedVideo[0].timestamp)
{
foundAudio = true;
break;
}
}
}
OSLeaveMutex(hSoundDataMutex);
if (foundAudio)
{
segmentOut.packets.TransferFrom(bufferedVideo[0].packets);
segmentOut.timestamp = bufferedVideo[0].timestamp;