diff --git a/amp/src/ddl/comp_clk/include/clk_avsync.h b/amp/src/ddl/comp_clk/include/clk_avsync.h index 0b4471e..3159322 100755 --- a/amp/src/ddl/comp_clk/include/clk_avsync.h +++ b/amp/src/ddl/comp_clk/include/clk_avsync.h @@ -261,6 +261,7 @@ typedef struct avsync_mgr_t { UINT m_uiBufTimeCnt; // Buffering time counter UINT m_uiBufTimeThresh; // Threshold for bufferred time of all streams UINT m_uiStartTimeThresh;// Threshold for buffering time before kick off + UINT32 m_uiReadyWaitTime; // Waiting time after one stream is ready UINT64 m_uiStartPTS; // Start PTS for streams UINT64 m_uiStopPTS; // Stop PTS for streams diff --git a/amp/src/ddl/comp_clk/source/clk_avsync.c b/amp/src/ddl/comp_clk/source/clk_avsync.c index f299de8..4cf5475 100755 --- a/amp/src/ddl/comp_clk/source/clk_avsync.c +++ b/amp/src/ddl/comp_clk/source/clk_avsync.c @@ -1272,6 +1272,7 @@ VOID file_playback_get_stream_info(AVSYNC_MGR *pSyncMgr) if (pStream->m_uiBuffedTime > pStream->m_uiBufTimeThresh) { pStream->m_fReady = TRUE; + pSyncMgr->m_uiReadyWaitTime += pSyncMgr->m_uiStcCnt4 >> 2; } else { pStream->m_fReady = FALSE; if (IS_PTS_VALID64(pSyncMgr->m_uiTimeFirstSample) && @@ -1286,6 +1287,12 @@ VOID file_playback_get_stream_info(AVSYNC_MGR *pSyncMgr) } pStream->m_uiPrevInput = pStream->m_uiInput; + AVSM("Type[%d] Input[%d] WaitInput[%d] ReadyWait[%d] Ready[%d] Underflow[%d] " + "EosRcvd[%d] Ended[%d] m_uiFCnt[%d] ResyncPending[%d]\n", + pStream->m_eType, pStream->m_uiInput, pStream->m_uiWaitInput, + pSyncMgr->m_uiReadyWaitTime, pStream->m_fReady, + pStream->m_fUnderflow, pStream->m_fEosRcvd, pStream->m_fEnded, + pStream->m_uiFCnt, pStream->m_fResyncPending); if (pStream->m_eType == STREAM_TYPE_VIDEO) { uiMinV = uiNextPTS; @@ -1367,18 +1374,27 @@ VOID file_playback_get_stream_info(AVSYNC_MGR *pSyncMgr) } if (pSyncMgr->m_eSyncStatus == SYNC_INIT) { + const INT8* cond = NULL; if (pSyncMgr->m_uiNumAStreams > 0 && !bAudEosRcvd && !bAudReady) { pSyncMgr->m_fAllStreamsReady = FALSE; } + AVSM("MinPCR[0x%x(%d)], BufTimeCnt[0x%x], BufTimeThresh[0x%x], NumStreams[%d], + StreamsReady[%d], StreamsEnded[%d]", + (INT32)pSyncMgr->m_uiMinPCR, IS_PTS_VALID64(pSyncMgr->m_uiMinPCR), + pSyncMgr->m_uiBufTimeCnt, pSyncMgr->m_uiBufTimeThresh, pSyncMgr->m_uiNumStreams, + pSyncMgr->m_fAllStreamsReady, pSyncMgr->m_fAllStreamsEnded); if (IS_PTS_VALID64(pSyncMgr->m_uiMinPCR) && pSyncMgr->m_uiBufTimeCnt == 0) { + cond = "PCR"; pSyncMgr->m_uiStartSTC = GET_PTS_VAL64(pSyncMgr->m_uiMinPCR); pSyncMgr->m_uiBufTimeCnt += pSyncMgr->m_uiStcCnt4 >> 2; if (pSyncMgr->m_uiBufTimeCnt > pSyncMgr->m_uiStartTimeThresh) { SET_PTS_VALID64(pSyncMgr->m_uiStartSTC); + AVSH("Got and Valid start STC: 0x%llX from %s\n", pSyncMgr->m_uiStartSTC, cond); } } else { if (pSyncMgr->m_uiNumVStreams == 0) { + cond = "A_PTS"; pSyncMgr->m_uiMinPTS = uiMinA; pSyncMgr->m_uiStartSTC = IS_PTS_VALID64(uiMinA) ? GET_PTS_VAL64(uiMinA) : 0; @@ -1387,6 +1403,12 @@ VOID file_playback_get_stream_info(AVSYNC_MGR *pSyncMgr) pSyncMgr->m_uiStartSTC = IS_PTS_VALID64(uiMinV) ? GET_PTS_VAL64(uiMinV) : IS_PTS_VALID64(uiMinA) ? GET_PTS_VAL64(uiMinA) : 0; + cond = IS_PTS_VALID64(uiMinV) ? "V_PTS": IS_PTS_VALID64(uiMinA) ? "A_PTS": " "; + if (pSyncMgr->m_uiNumVStreams && pSyncMgr->m_uiNumAStreams) { + if (pSyncMgr->m_uiReadyWaitTime > 90000) { + pSyncMgr->m_fAllStreamsReady = TRUE; + } + } /*if (pSyncMgr->m_uiNumAStreams > 0 && IS_PTS_VALID64(uiMinA) && IS_PTS_VALID64(uiMinV) && check_pts_range(uiMinA, uiMinV, 900000, 0, FALSE) == @@ -1400,7 +1422,9 @@ VOID file_playback_get_stream_info(AVSYNC_MGR *pSyncMgr) pSyncMgr->m_uiBufTimeCnt += pSyncMgr->m_uiStcCnt4 >> 2; if (pSyncMgr->m_uiBufTimeCnt > pSyncMgr->m_uiBufTimeThresh) { SET_PTS_VALID64(pSyncMgr->m_uiStartSTC); - AVSH("Got and Valid start STC: 0x%llX\n", pSyncMgr->m_uiStartSTC); + AVSH("Got and Valid start STC: 0x%llX from %s\n", pSyncMgr->m_uiStartSTC, cond); + + pSyncMgr->m_uiReadyWaitTime = 0; } } }