Skip to content

Commit

Permalink
fix(mediaPlayer): avoid video jump when catch up
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <pingkai010@gmail.com>
  • Loading branch information
pingkai committed Feb 25, 2020
1 parent 70d89b9 commit f0c4e75
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mediaPlayer/SuperMediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,7 @@ namespace Cicada {

if (videoFrameSize < max_cache_size) {
int64_t startDecodeTime = af_getsteady_ms();
int64_t videoEarlyUs = 0;

do {
// if still in seeking, don't send data to decoder in background
Expand All @@ -1576,8 +1577,10 @@ namespace Cicada {
mVideoPacket = mBufferController.getPacket(BUFFER_TYPE_VIDEO);
}

videoEarlyUs = mVideoPacket ? mVideoPacket->getInfo().dts - mMasterClock.GetTime() : 0;

// don't send too much data when in background
if (mVideoPacket && APP_BACKGROUND == mAppStatus && mVideoPacket->getInfo().dts > mMasterClock.GetTime()) {
if (mVideoPacket && APP_BACKGROUND == mAppStatus && videoEarlyUs > 0) {
break;
}

Expand All @@ -1603,7 +1606,7 @@ namespace Cicada {
if (af_getsteady_ms() - startDecodeTime > 50) {
break;
}
} while (mSeekNeedCatch || dropLateVideoFrames);
} while ((mSeekNeedCatch || dropLateVideoFrames) && (videoEarlyUs < 200 * 1000));
}
}

Expand Down

0 comments on commit f0c4e75

Please sign in to comment.