From 5f8cfb6fda9ffa50f27ee8a3d53590bcf14be58a Mon Sep 17 00:00:00 2001 From: pingkai Date: Fri, 11 Sep 2020 18:18:45 +0800 Subject: [PATCH] fix(supermediaplayer): fix wrong deltaTimeTmp increase logic Signed-off-by: pingkai --- mediaPlayer/SuperMediaPlayer.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mediaPlayer/SuperMediaPlayer.cpp b/mediaPlayer/SuperMediaPlayer.cpp index cc7c23208..165de1417 100644 --- a/mediaPlayer/SuperMediaPlayer.cpp +++ b/mediaPlayer/SuperMediaPlayer.cpp @@ -1986,12 +1986,17 @@ RENDER_RESULT SuperMediaPlayer::RenderAudio() if (mLastAudioFrameDuration > 0) { int64_t offset = pts - (mPlayedAudioPts + mLastAudioFrameDuration); - if (llabs(offset) > 200000) { + /* + * the mLastAudioFrameDuration and the pts are all not the accurate value, + * the mLastAudioFrameDuration accurate for 1/1000000 s, + * the pts maybe accurate for 1/1000 s (eg. flv file), so can't increase the deltaTimeTmp when + * offset little than 1ms. + */ + if (llabs(offset) > 1000) { AF_LOGW("offset is %lld,pts is %lld", offset, pts); + mAudioTime.deltaTimeTmp += offset; } - mAudioTime.deltaTimeTmp += offset; - if (llabs(mAudioTime.deltaTimeTmp) > 100000) { AF_LOGW("correct audio and master clock offset is %lld, frameDuration :%lld", mAudioTime.deltaTimeTmp, mLastAudioFrameDuration);