Skip to content

Commit

Permalink
fix(supermediaplayer): update position when seek end
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <pingkai010@gmail.com>
  • Loading branch information
pingkai committed Sep 15, 2020
1 parent 5f8cfb6 commit 4a72906
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
33 changes: 7 additions & 26 deletions mediaPlayer/SuperMediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,24 +638,9 @@ void SuperMediaPlayer::GetOption(const char *key, char *value)
return;
}

int64_t SuperMediaPlayer::GetCurrentPosition()
{
return getCurrentPosition() / 1000;
}

void SuperMediaPlayer::NotifyPosition(int64_t position)
{
mPlayingPosition = position;
mPNotifier->NotifyPosition(position);
}

int64_t SuperMediaPlayer::GetPlayingPosition()
{
if (isSeeking()) {
return mSeekPos / 1000;
}

return mPlayingPosition;
mPNotifier->NotifyPosition(position / 1000);
}

int64_t SuperMediaPlayer::getCurrentPosition()
Expand Down Expand Up @@ -1563,7 +1548,7 @@ void SuperMediaPlayer::doRender()
} else {
mCurrentPos = mPlayedVideoPts;
}
NotifyPosition(getCurrentPosition() / 1000);
NotifyPosition(getCurrentPosition());

// seek preview can't render audio,but set the audio clock to here pts
if (HAVE_AUDIO && (mAudioTime.startTime <= 0)) {
Expand All @@ -1577,7 +1562,7 @@ void SuperMediaPlayer::doRender()
} else {// audio only
if (!mAudioFrameQue.empty()) {
int64_t audioPTS = mAudioFrameQue.front()->getInfo().pts;
NotifyPosition(audioPTS / 1000);
NotifyPosition(audioPTS);
rendered = true;
mAudioTime.startTime = audioPTS;
}
Expand Down Expand Up @@ -1605,9 +1590,7 @@ void SuperMediaPlayer::doRender()
// update position when seek end. in case of when paused.
// update position before reset seek status, so getCurrentPosition return mSeekPos instead of mCurrentPos
// fix bug the mCurrentPos not accuracy
if (mPlayStatus == PLAYER_PAUSED) {
NotifyPosition(getCurrentPosition() / 1000);
}
NotifyPosition(getCurrentPosition());
ResetSeekStatus();
mPNotifier->NotifySeekEnd(mSeekInCache);
mSeekInCache = false;
Expand Down Expand Up @@ -1750,7 +1733,7 @@ void SuperMediaPlayer::checkEOS()
}
}

NotifyPosition(mDuration / 1000);
NotifyPosition(mDuration);

if (mSet->bLooping && mDuration > 0) {
mSeekPos = 0;//19644161: need reset seek position
Expand Down Expand Up @@ -2234,9 +2217,8 @@ void SuperMediaPlayer::OnTimer(int64_t curTime)
* jumping
*/
if ((mPlayStatus == PLAYER_PLAYING) && !isSeeking()) {
int64_t pos = getCurrentPosition() / 1000;
//AF_LOGD("TIMEPOS OnTimer :%lld", pos);
NotifyPosition(pos);
//AF_LOGD("TIMEPOS OnTimer :%lld", getCurrentPosition());
NotifyPosition(getCurrentPosition());
}

PostBufferPositionMsg();
Expand Down Expand Up @@ -3318,7 +3300,6 @@ void SuperMediaPlayer::Reset()
mVideoChangedFirstPts = INT64_MIN;
mSubtitleChangedFirstPts = INT64_MIN;
mSoughtVideoPos = INT64_MIN;
mPlayingPosition = 0;
mFirstReadPacketSucMS = 0;
mCanceled = false;
mPNotifier->Enable(true);
Expand Down
9 changes: 4 additions & 5 deletions mediaPlayer/SuperMediaPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ namespace Cicada {

void GetOption(const char *key, char *value) override;

int64_t GetPlayingPosition() override;
int64_t GetPlayingPosition() override
{
return getCurrentPosition();
};

int64_t GetBufferPosition() override;

Expand Down Expand Up @@ -203,8 +206,6 @@ namespace Cicada {
private:
void NotifyPosition(int64_t position);

int64_t GetCurrentPosition();

void OnTimer(int64_t curTime);

void updateLoopGap();
Expand Down Expand Up @@ -487,8 +488,6 @@ namespace Cicada {
bool mWillSwitchVideo{false};
std::unique_ptr<player_type_set> mSet{};
int64_t mSoughtVideoPos{INT64_MIN};
std::atomic<int64_t> mPlayingPosition{0};

int mMaxRunningLoopGap = 10;
int mTimerInterval = 0;
int64_t mTimerLatestTime = 0;
Expand Down

0 comments on commit 4a72906

Please sign in to comment.