diff --git a/amp/src/ddl/comp_clk/source/clk_avsync.c b/amp/src/ddl/comp_clk/source/clk_avsync.c index a80fa15..0e094b6 100755 --- a/amp/src/ddl/comp_clk/source/clk_avsync.c +++ b/amp/src/ddl/comp_clk/source/clk_avsync.c @@ -938,6 +938,33 @@ BOOL check_pause_pts(AVSYNC_MGR *pSyncMgr, SYNC_STREAM *pStream, BD_INFO *pBDInf return ret; } +AMP_CLK_ACT check_sim_out_pts(AVSYNC_MGR *pSyncMgr, SYNC_STREAM *pStream, BD_INFO *pBDInfo) +{ + UINT uiRange = 900000; + AMP_CLK_ACT eAct = AMP_CLK_DISP; + + if (check_pts_range(pBDInfo->m_uiPtsStart, + pSyncMgr->m_uiMaxPTS, + uiRange, uiRange, + FALSE) == AMP_CLK_DISP) { + if (!pSyncMgr->m_fAllStreamsReady) { + eAct = AMP_CLK_HOLD; + } else if (GET_PTS_VAL64(pBDInfo->m_uiPtsStart) < + GET_PTS_VAL64(pSyncMgr->m_uiMaxPTS)) { + eAct = AMP_CLK_DROP; + } + } else { + // Disable simultaneous output + AVSH("[%d]CHECK_%s PTS:[0x%09llX][%lld],STC:[0x%09llX][%lld], [OPT]SIM_OUTPUT(DISABLED!)!", + pSyncMgr->m_pAVClock->m_uiClockID, pStream->m_szName, + GET_PTS_VAL64(pBDInfo->m_uiPtsStart), GET_PTS_VAL64(pBDInfo->m_uiPtsStart), + GET_PTS_VAL64(pSyncMgr->m_uiMaxPTS), GET_PTS_VAL64(pSyncMgr->m_uiMaxPTS)); + pSyncMgr->m_fSimOut = FALSE; + } + + return eAct; +} + VOID local_playback_res_change(AVSYNC_MGR *pSyncMgr, BOOL fDone) { if (!fDone) { @@ -3175,7 +3202,7 @@ VOID dtv_check_pcr(AVSYNC_MGR *pSyncMgr, UINT64 pcr, UINT64 stc) diff_local_clk = PTS64_DIFF_WRAP(stc, pSyncMgr->m_recent_local_clk); freq_diff = diff_local_clk - diff_src_clk; - AVSM("[AVS]%s(pcr:0x%x(%d), stc:0x%x(%d), diff: phase:%lld(%lld)" + AVSI("[AVS]%s(pcr:0x%x(%d), stc:0x%x(%d), diff: phase:%lld(%lld)" " freq:%lld(%lld))", __FUNCTION__, (UINT32)pcr, (UINT32)PTS64_DIFF_WRAP(pcr, last_pcr), (UINT32)stc, (UINT32)PTS64_DIFF_WRAP(stc, last_stc), @@ -3640,7 +3667,7 @@ VOID dtv_check_avsync(AVSYNC_MGR *pSyncMgr) } else if (IS_PTS_VALID64(pSyncMgr->m_uiTimeFirstSample)) { UINT64 t = avclock_get_wall64(pSyncMgr->m_pAVClock, FALSE); UINT64 diff = t - GET_PTS_VAL64(pSyncMgr->m_uiTimeFirstSample); - if (diff > 90000) { + if ((diff > 90000 && pSyncMgr->m_fAllStreamsReady) || diff > 900000) { pSyncMgr->m_sPsp.m_uiPcr = pSyncMgr->m_uiMinPTS; pSyncMgr->m_sPsp.m_uiStc = t; pSyncMgr->m_uiStartSTC = GET_PTS_VAL64(pSyncMgr->m_sPsp.m_uiPcr) - @@ -3715,12 +3742,8 @@ HRESULT dtv_check_video_pts(AVSYNC_MGR *pSyncMgr, } if (pSyncMgr->m_fSimOut && pSyncMgr->m_eSyncStatus == SYNC_LOCKING) { - if (!pSyncMgr->m_fAllStreamsReady) { - eAct = AMP_CLK_HOLD; - goto _Exit; - } else if (GET_PTS_VAL64(pBDInfo->m_uiPtsStart) < - GET_PTS_VAL64(pSyncMgr->m_uiMaxPTS)) { - eAct = AMP_CLK_DROP; + eAct = check_sim_out_pts(pSyncMgr, pStream, pBDInfo); + if (eAct != AMP_CLK_DISP) { goto _Exit; } } @@ -3954,12 +3977,8 @@ HRESULT dtv_check_audio_pts(AVSYNC_MGR *pSyncMgr, } if (pSyncMgr->m_fSimOut && pSyncMgr->m_eSyncStatus == SYNC_LOCKING) { - if (!pSyncMgr->m_fAllStreamsReady) { - eAct = AMP_CLK_HOLD; - goto _Exit; - } else if (GET_PTS_VAL64(pBDInfo->m_uiPtsStart) < - GET_PTS_VAL64(pSyncMgr->m_uiMaxPTS)) { - eAct = AMP_CLK_DROP; + eAct = check_sim_out_pts(pSyncMgr, pStream, pBDInfo); + if (eAct != AMP_CLK_DISP) { goto _Exit; } } @@ -4195,7 +4214,7 @@ VOID live_net_policy_init(AVSYNC_MGR *pSyncMgr) pSyncMgr->m_fPcrEnabled = TRUE; pSyncMgr->m_fPcrAdj = TRUE; - pSyncMgr->m_iPcrOffset = 27000; + pSyncMgr->m_iPcrOffset = 27000*4; pSyncMgr->m_uiPcrAdjThresh = 300; pSyncMgr->m_iPcrOrigOffset = pSyncMgr->m_iPcrOffset; @@ -5210,6 +5229,12 @@ HRESULT avsync_mgr_new_pcr(AVSYNC_MGR *pSyncMgr, UINT64 uiPcr, UINT64 uiStc, UIN dtv_check_pcr(pSyncMgr, uiPcr, uiClk); + if (!pSyncMgr->m_fPcrValid ){ + AVSH("[PCR]PCR:0x%08x, LastPCR:0x%08x, P-LP:%6lld, T-LT:%6d, [%d][%d]", + (INT32)pcr, (INT32)last_pcr, (pcr - last_pcr), + (stc - last_stc), pSyncMgr->m_fPcrDiscPending, + pSyncMgr->m_uiPcrContinueCnt); + } AVSI("[PCR]PCR:0x%08x, LastPCR:0x%08x, P-LP:%6lld, T-LT:%6d, [%d][%d]", (INT32)pcr, (INT32)last_pcr, (pcr - last_pcr), (stc - last_stc), pSyncMgr->m_fPcrDiscPending, @@ -5238,8 +5263,8 @@ HRESULT avsync_mgr_new_pcr(AVSYNC_MGR *pSyncMgr, UINT64 uiPcr, UINT64 uiStc, UIN SET_PTS_VALID64(pSyncMgr->m_uiMinPCR); } - if (!pSyncMgr->m_fPcrValid && last_pcr && pcr != last_pcr && - ((pcr - last_pcr) < (stc - last_stc))) { + if (!pSyncMgr->m_fPcrValid && last_pcr && pcr != last_pcr /* ){ */ + && ((pcr - last_pcr) < (stc - last_stc))) { pSyncMgr->m_fPcrValid = TRUE; AVSH("[AVS]PCR VALID(PCR:0x%x)!", pSyncMgr->m_sPsp.m_uiPcr); return SUCCESS;