From 33a517fbc68f1ca1afdfb5dea57099f815aa9dc7 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sun, 7 Oct 2012 13:36:45 +0200 Subject: [PATCH] Some changes to the AV sync code --- videoomx.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/videoomx.cc b/videoomx.cc index 50da679..39527ac 100644 --- a/videoomx.cc +++ b/videoomx.cc @@ -2195,7 +2195,7 @@ void VideoOMX::FrameWaitforDisplay(long long pts) long long offset=Demuxer::getInstance()->getFrameRate(); long long current_time=GetCurrentSystemTime(); if (offset==0) offset=25; - offset=-2*10000000LL/offset; + offset=-3*10000000LL/offset; target_time+=offset; //Log::getInstance()->log("Video", Log::DEBUG, "Wait for display pts: %lld tg: %lld sys: %lld off: %lld diff %lld po: %lld",pts,target_time,current_time,offset, // target_time-current_time,playbacktimeoffset); @@ -2210,13 +2210,13 @@ void VideoOMX::FrameWaitforDisplay(long long pts) void VideoOMX::AdjustAudioPTS(long long pts) { long long newplaybacktimeoffset=pts-GetCurrentSystemTime(); -/* if ((newplaybacktimeoffset-1000000LL)>playbacktimeoffset + if ((newplaybacktimeoffset-1000000LL)>playbacktimeoffset || (newplaybacktimeoffset+1000000LL)log("Video", Log::DEBUG, "Adjust Playbackoffsettime o: %lld n: %lld", - playbacktimeoffset,newplaybacktimeoffset);*/ + playbacktimeoffset,newplaybacktimeoffset); playbacktimeoffset=newplaybacktimeoffset; - //} + } } void VideoOMX::threadPostStopCleanup() @@ -2265,18 +2265,19 @@ void VideoOMX::threadMethod() } else { // Log::getInstance()->log("Video", Log::DEBUG, // "prot empty this buffer in"); + if (islast) FrameWaitforDisplay(time); OMX_ERRORTYPE error = ProtOMXEmptyThisBuffer(omx_vid_dec, pict); if (error != OMX_ErrorNone) { Log::getInstance()->log("Video", Log::DEBUG, "OMX_EmptyThisBuffer failed %x", error); } //Log::getInstance()->log("Video", Log::DEBUG, - // "prot empty this buffer out"); + // "time %lld",time); if (deint_first_frame && dodeint) DeinterlaceFix(); - if (islast) FrameWaitforDisplay(time); + } } else { - MILLISLEEP(5); + MILLISLEEP(1); } threadCheckExit(); -- 2.39.2