diff --git a/mediaPlayer/SuperMediaPlayer.cpp b/mediaPlayer/SuperMediaPlayer.cpp index 8d0daaf0f..09193cee0 100644 --- a/mediaPlayer/SuperMediaPlayer.cpp +++ b/mediaPlayer/SuperMediaPlayer.cpp @@ -351,6 +351,7 @@ namespace Cicada { AF_TRACE; mAudioRender = nullptr; + mBRendingStart = false; AF_TRACE; { std::lock_guard uMutex(mCreateMutex); @@ -1105,6 +1106,14 @@ namespace Cicada { } doDeCode(); + + if (!mBRendingStart && mPlayStatus == PLAYER_PLAYING && !mBufferingFlag) { + if ((!HAVE_VIDEO || !mVideoFrameQue.empty()) + && (!HAVE_AUDIO || !mAudioFrameQue.empty())) { + startRendering(true); + } + } + doRender(); checkEOS(); curTime = af_gettime_relative() / 1000; @@ -3155,6 +3164,7 @@ namespace Cicada { mCurrentVideoMeta = nullptr; mAdaptiveVideo = false; dropLateVideoFrames = false; + mBRendingStart = false; if (mVideoRender) { mVideoRender->setSpeed(1); @@ -3658,11 +3668,6 @@ namespace Cicada { } ChangePlayerStatus(PLAYER_PLAYING); - mMasterClock.start(); - - if (mAudioRender) { - mAudioRender->pause(false); - } } } @@ -3673,11 +3678,7 @@ namespace Cicada { } ChangePlayerStatus(PLAYER_PAUSED); - mMasterClock.pause(); - - if (mAudioRender) { - mAudioRender->pause(true); - } + startRendering(false); } void SuperMediaPlayer::VideoRenderCallback(void *arg, int64_t pts, void *userData) @@ -4031,4 +4032,23 @@ namespace Cicada { mMasterClock.SetScale(speed); } } + + void SuperMediaPlayer::startRendering(bool start) + { + if (start == mBRendingStart) { + return; + } + + mBRendingStart = start; + + if (start) { + mMasterClock.start(); + } else { + mMasterClock.pause(); + } + + if (mAudioRender) { + mAudioRender->pause(!start); + } + } }//namespace Cicada diff --git a/mediaPlayer/SuperMediaPlayer.h b/mediaPlayer/SuperMediaPlayer.h index b30b9fbdf..44dc0eaf2 100644 --- a/mediaPlayer/SuperMediaPlayer.h +++ b/mediaPlayer/SuperMediaPlayer.h @@ -477,6 +477,7 @@ namespace Cicada { bool dropLateVideoFrames = false; bool waitingForStart = false; + bool mBRendingStart {false}; private: bool mAutoPlay = false; @@ -494,6 +495,8 @@ namespace Cicada { void printTimePosition(int64_t time) const; void setUpAVPath(); + + void startRendering(bool start); }; }// namespace Cicada #endif // CICADA_PLAYER_SERVICE_H