Bug 1505250 - Change state to 'completedState' if we can't get any sample anymore. r=jya, a=RyanVM
authoralwu <alwu@mozilla.com>
Fri, 21 Dec 2018 21:06:42 +0000
changeset 509199 1d747c8ca942c7594f682259a3a59f3995ea6d1d
parent 509198 49db147e8a5c4f9a5e13896cb9db8981e417404e
child 509200 e453e25d62cb66588c5370f8a95965220c241582
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, RyanVM
bugs1505250
milestone65.0
Bug 1505250 - Change state to 'completedState' if we can't get any sample anymore. r=jya, a=RyanVM If we can't get any sample anymore, the resource might have been closed, so we should change state to 'completedState'. Differential Revision: https://phabricator.services.mozilla.com/D15029
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -844,21 +844,17 @@ class MediaDecoderStateMachine::LoopingD
                },
                [this](const SeekRejectValue& aReject) -> void {
                  mAudioSeekRequest.Complete();
                  HandleError(aReject.mError);
                })
         ->Track(mAudioSeekRequest);
   }
 
-  void HandleError(const MediaResult& aError) {
-    SLOG("audio looping failed, aError=%s", aError.ErrorName().get());
-    MOZ_ASSERT(aError != NS_ERROR_DOM_MEDIA_END_OF_STREAM);
-    mMaster->DecodeError(aError);
-  }
+  void HandleError(const MediaResult& aError);
 
   void EnsureAudioDecodeTaskQueued() override {
     if (mAudioSeekRequest.Exists() || mAudioDataRequest.Exists()) {
       return;
     }
     DecodingState::EnsureAudioDecodeTaskQueued();
   }
 
@@ -2416,16 +2412,28 @@ void MediaDecoderStateMachine::DecodingS
   }
 
   if (Reader()->UseBufferingHeuristics() && mMaster->HasLowDecodedData() &&
       mMaster->HasLowBufferedData() && !mMaster->mCanPlayThrough) {
     SetState<BufferingState>();
   }
 }
 
+void MediaDecoderStateMachine::LoopingDecodingState::HandleError(
+    const MediaResult& aError) {
+  SLOG("audio looping failed, aError=%s", aError.ErrorName().get());
+  // This would happen after we've closed resouce so that we won't be able to
+  // get any sample anymore.
+  if (aError == NS_ERROR_DOM_MEDIA_END_OF_STREAM) {
+    SetState<CompletedState>();
+    return;
+  }
+  mMaster->DecodeError(aError);
+}
+
 void MediaDecoderStateMachine::SeekingState::SeekCompleted() {
   const auto newCurrentTime = CalculateNewCurrentTime();
 
   if (newCurrentTime == mMaster->Duration() && !mMaster->mIsLiveStream) {
     // Seeked to end of media. Explicitly finish the queues so DECODING
     // will transition to COMPLETED immediately. Note we don't do
     // this when playing a live stream, since the end of media will advance
     // once we download more data!