☠☠ backed out by 710566a1315f ☠ ☠ | |
author | JW Wang <jwwang@mozilla.com> |
Thu, 29 Sep 2016 16:10:02 +0800 | |
changeset 316164 | 1510da178dbd8abaa85a6dd17a44b93a97afeb3e |
parent 316163 | ea57d7034a0d09dc764dbd77c21d6470be9a9253 |
child 316165 | 2b6868859c21af4e24651be7e308fe96f66680cf |
push id | 30765 |
push user | philringnalda@gmail.com |
push date | Tue, 04 Oct 2016 03:06:46 +0000 |
treeherder | mozilla-central@adb484f84dec [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | kikuo |
bugs | 1306186 |
milestone | 52.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
dom/media/MediaDecoderStateMachine.cpp | file | annotate | diff | comparison | revisions | |
dom/media/MediaDecoderStateMachine.h | file | annotate | diff | comparison | revisions |
--- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -432,33 +432,31 @@ public: if (mMaster->CheckIfDecodeComplete()) { SetState(DECODER_STATE_COMPLETED); return; } mDecodeStartTime = TimeStamp::Now(); - mMaster->mIsAudioPrerolling = true; - mMaster->mIsVideoPrerolling = true; + mMaster->mIsPrerolling = true; // 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()); } - mMaster->mIsAudioPrerolling = false; - mMaster->mIsVideoPrerolling = false; + mMaster->mIsPrerolling = false; } void Step() override { if (mMaster->mPlayState != MediaDecoder::PLAY_STATE_PLAYING && mMaster->IsPlaying()) { // We're playing, but the element/decoder is in paused state. Stop // playing! @@ -712,18 +710,16 @@ MediaDecoderStateMachine::MediaDecoderSt INIT_WATCHABLE(mObservedDuration, TimeUnit()), mFragmentEndTime(-1), mReader(new MediaDecoderReaderWrapper(mTaskQueue, aReader)), mDecodedAudioEndTime(0), mDecodedVideoEndTime(0), mPlaybackRate(1.0), mLowAudioThresholdUsecs(detail::LOW_AUDIO_USECS), mAmpleAudioThresholdUsecs(detail::AMPLE_AUDIO_USECS), - mIsAudioPrerolling(false), - mIsVideoPrerolling(false), mAudioCaptured(false), INIT_WATCHABLE(mAudioCompleted, false), INIT_WATCHABLE(mVideoCompleted, false), mNotifyMetadataBeforeFirstFrame(false), mMinimizePreroll(false), mDecodeThreadWaiting(false), mSentLoadedMetadataEvent(false), mSentFirstFrameLoadedEvent(false), @@ -1043,17 +1039,17 @@ MediaDecoderStateMachine::OnAudioDecoded case DECODER_STATE_DECODING_FIRSTFRAME: { Push(audio, MediaData::AUDIO_DATA); MaybeFinishDecodeFirstFrame(); return; } case DECODER_STATE_DECODING: { Push(audio, MediaData::AUDIO_DATA); - if (mIsAudioPrerolling) { + if (mIsPrerolling) { // Schedule next cycle to check if we can stop prerolling. ScheduleStateMachine(); } return; } default: { // Ignore other cases. @@ -1123,17 +1119,17 @@ MediaDecoderStateMachine::OnNotDecoded(M // If the decoder is waiting for data, we tell it to call us back when the // data arrives. if (aError == NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA) { MOZ_ASSERT(mReader->IsWaitForDataSupported(), "Readers that send WAITING_FOR_DATA need to implement WaitForData"); mReader->WaitForData(aType); - if ((isAudio && mIsAudioPrerolling) || (!isAudio && mIsVideoPrerolling)) { + if (mIsPrerolling) { // Schedule next cycle to stop prerolling so we can play the frames we've // decoded so far. ScheduleStateMachine(); } return; } if (aError == NS_ERROR_DOM_MEDIA_CANCELED) { @@ -1154,17 +1150,17 @@ MediaDecoderStateMachine::OnNotDecoded(M // This is an EOS. Finish off the queue, and then handle things based on our // state. if (isAudio) { AudioQueue().Finish(); } else { VideoQueue().Finish(); } - if ((isAudio && mIsAudioPrerolling) || (!isAudio && mIsVideoPrerolling)) { + if (mIsPrerolling) { // No more data to decode. Schedule next cycle to stop prerolling // and start playback. ScheduleStateMachine(); } switch (mState) { case DECODER_STATE_DECODING_FIRSTFRAME: MaybeFinishDecodeFirstFrame(); @@ -1234,17 +1230,17 @@ MediaDecoderStateMachine::OnVideoDecoded case DECODER_STATE_DECODING_FIRSTFRAME: { Push(video, MediaData::VIDEO_DATA); MaybeFinishDecodeFirstFrame(); return; } case DECODER_STATE_DECODING: { Push(video, MediaData::VIDEO_DATA); - if (mIsVideoPrerolling) { + if (mIsPrerolling) { // Schedule next cycle to check if we can stop prerolling. ScheduleStateMachine(); } // For non async readers, if the requested video sample was slow to // arrive, increase the amount of audio we buffer to ensure that we // don't run out of audio. This is unnecessary for async readers, // since they decode audio and video on different threads so they @@ -1410,34 +1406,27 @@ void MediaDecoderStateMachine::MaybeStar MOZ_ASSERT(mState == DECODER_STATE_DECODING || mState == DECODER_STATE_COMPLETED); if (IsPlaying()) { // Logging this case is really spammy - don't do it. return; } - if (mIsAudioPrerolling && - (DonePrerollingAudio() || mReader->IsWaitingAudioData())) { - mIsAudioPrerolling = false; - } - - if (mIsVideoPrerolling && + if (mIsPrerolling && + (DonePrerollingAudio() || mReader->IsWaitingAudioData()) && (DonePrerollingVideo() || mReader->IsWaitingVideoData())) { - mIsVideoPrerolling = false; + mIsPrerolling = false; } bool playStatePermits = mPlayState == MediaDecoder::PLAY_STATE_PLAYING; - if (!playStatePermits || mIsAudioPrerolling || - mIsVideoPrerolling || mAudioOffloading) { + if (!playStatePermits || mIsPrerolling || mAudioOffloading) { DECODER_LOG("Not starting playback [playStatePermits: %d, " - "mIsAudioPrerolling: %d, mIsVideoPrerolling: %d, " - "mAudioOffloading: %d]", - (int)playStatePermits, (int)mIsAudioPrerolling, - (int)mIsVideoPrerolling, (int)mAudioOffloading); + "mIsPrerolling: %d, mAudioOffloading: %d]", + playStatePermits, mIsPrerolling, mAudioOffloading); return; } DECODER_LOG("MaybeStartPlayback() starting playback"); mOnPlaybackEvent.Notify(MediaEventType::PlaybackStarted); StartMediaSink(); if (!IsPlaying()) { @@ -2931,17 +2920,17 @@ MediaDecoderStateMachine::SetAudioCaptur ScheduleStateMachine(); // Don't buffer as much when audio is captured because we don't need to worry // about high latency audio devices. mAmpleAudioThresholdUsecs = mAudioCaptured ? detail::AMPLE_AUDIO_USECS / 2 : detail::AMPLE_AUDIO_USECS; - if (mIsAudioPrerolling) { + if (mIsPrerolling) { // Schedule next cycle to check if we can stop prerolling. ScheduleStateMachine(); } } uint32_t MediaDecoderStateMachine::GetAmpleVideoFrames() const { MOZ_ASSERT(OnTaskQueue()); @@ -2958,22 +2947,21 @@ MediaDecoderStateMachine::DumpDebugInfo( // It is fine to capture a raw pointer here because MediaDecoder only call // this function before shutdown begins. nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([this] () { mMediaSink->DumpDebugInfo(); DUMP_LOG( "GetMediaTime=%lld GetClock=%lld mMediaSink=%p " "mState=%s mPlayState=%d mSentFirstFrameLoadedEvent=%d IsPlaying=%d " "mAudioStatus=%s mVideoStatus=%s mDecodedAudioEndTime=%lld mDecodedVideoEndTime=%lld " - "mIsAudioPrerolling=%d mIsVideoPrerolling=%d " - "mAudioCompleted=%d mVideoCompleted=%d", + "mIsPrerolling=%d mAudioCompleted=%d mVideoCompleted=%d", GetMediaTime(), mMediaSink->IsStarted() ? GetClock() : -1, mMediaSink.get(), ToStateStr(), mPlayState.Ref(), mSentFirstFrameLoadedEvent, IsPlaying(), AudioRequestStatus(), VideoRequestStatus(), mDecodedAudioEndTime, mDecodedVideoEndTime, - mIsAudioPrerolling, mIsVideoPrerolling, mAudioCompleted.Ref(), mVideoCompleted.Ref()); + mIsPrerolling, mAudioCompleted.Ref(), mVideoCompleted.Ref()); }); OwnerThread()->DispatchStateChange(r.forget()); } void MediaDecoderStateMachine::AddOutputStream(ProcessedMediaStream* aStream, bool aFinishWhenEnded) {
--- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -731,20 +731,18 @@ private: } // When we start decoding (either for the first time, or after a pause) // we may be low on decoded data. We don't want our "low data" logic to // kick in and decide that we're low on decoded data because the download // can't keep up with the decode, and cause us to pause playback. So we // have a "preroll" stage, where we ignore the results of our "low data" // logic during the first few frames of our decode. This occurs during - // playback. The flags below are true when the corresponding stream is - // being "prerolled". - bool mIsAudioPrerolling; - bool mIsVideoPrerolling; + // playback. + bool mIsPrerolling = false; // Only one of a given pair of ({Audio,Video}DataPromise, WaitForDataPromise) // should exist at any given moment. MediaEventListener mAudioCallback; MediaEventListener mVideoCallback; MediaEventListener mAudioWaitCallback; MediaEventListener mVideoWaitCallback;