Bug 1303655. Part 3 - Move mDecodeStartTime into Decodingstate.
MozReview-Commit-ID: ELUr9AHaE2P
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -435,39 +435,51 @@ public:
// transitioning to DECODING.
MOZ_ASSERT(!mMaster->mQueuedSeek.Exists());
if (mMaster->CheckIfDecodeComplete()) {
SetState(DECODER_STATE_COMPLETED);
return;
}
- mMaster->mDecodeStartTime = TimeStamp::Now();
+ mDecodeStartTime = TimeStamp::Now();
// Reset other state to pristine values before starting decode.
mMaster->mIsAudioPrerolling = !mMaster->DonePrerollingAudio() &&
!Reader()->IsWaitingAudioData();
mMaster->mIsVideoPrerolling = !mMaster->DonePrerollingVideo() &&
!Reader()->IsWaitingVideoData();
// Ensure that we've got tasks enqueued to decode data if we need to.
mMaster->DispatchDecodeTasksIfNeeded();
mMaster->ScheduleStateMachine();
}
+ void Exit() override
+ {
+ if (!mDecodeStartTime.IsNull()) {
+ TimeDuration decodeDuration = TimeStamp::Now() - mDecodeStartTime;
+ SLOG("Exiting DECODING, decoded for %.3lfs", decodeDuration.ToSeconds());
+ }
+ }
+
void Step() override
{
mMaster->StepDecoding();
}
State GetState() const override
{
return DECODER_STATE_DECODING;
}
+
+private:
+ // Time at which we started decoding.
+ TimeStamp mDecodeStartTime;
};
class MediaDecoderStateMachine::SeekingState
: public MediaDecoderStateMachine::StateObject
{
public:
explicit SeekingState(Master* aPtr) : StateObject(aPtr) {}
@@ -2729,21 +2741,18 @@ MediaDecoderStateMachine::StartBuffering
{
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(mState == DECODER_STATE_BUFFERING);
if (IsPlaying()) {
StopPlayback();
}
- TimeDuration decodeDuration = TimeStamp::Now() - mDecodeStartTime;
mBufferingStart = TimeStamp::Now();
- DECODER_LOG("Changed state from DECODING to BUFFERING, decoded for %.3lfs",
- decodeDuration.ToSeconds());
MediaStatistics stats = GetStatistics();
DECODER_LOG("Playback rate: %.1lfKB/s%s download rate: %.1lfKB/s%s",
stats.mPlaybackRate/1024, stats.mPlaybackRateReliable ? "" : " (unreliable)",
stats.mDownloadRate/1024, stats.mDownloadRateReliable ? "" : " (unreliable)");
// Don't go straight back to the state machine loop since that might
// cause us to start decoding again and we could flip-flop between
// decoding and quick-buffering.
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -670,19 +670,16 @@ private:
// The end time of the last decoded video frame. Used to check if we are low
// on decoded video data.
int64_t mDecodedVideoEndTime;
// Playback rate. 1.0 : normal speed, 0.5 : two times slower.
double mPlaybackRate;
- // Time at which we started decoding. Synchronised via decoder monitor.
- TimeStamp mDecodeStartTime;
-
// The maximum number of second we spend buffering when we are short on
// unbuffered data.
uint32_t mBufferingWait;
int64_t mLowDataThresholdUsecs;
// If we've got more than this number of decoded video frames waiting in
// the video queue, we will not decode any more video frames until some have
// been consumed by the play state machine thread.