Bug 1362793 - part1 : shouldn't shutdown decoder too early. draft
authorAlastor Wu <alwu@mozilla.com>
Fri, 19 May 2017 12:38:17 +0800
changeset 580908 86200c2752df7b1412477e7174db67dfc34ce8db
parent 580904 4c63b20d6fa218241a1c175a1ada205668f88094
child 580909 122e083382c535fbeeb2288ac6b3b57336483ea7
child 580910 c87bb44730a934236b62f333c004ab178ae3b62b
push id59709
push useralwu@mozilla.com
push dateFri, 19 May 2017 04:38:51 +0000
bugs1362793
milestone55.0a1
Bug 1362793 - part1 : shouldn't shutdown decoder too early. The spec says that we don't need to change the ready state when getting the error. If the ready state is "HAVE_METADATA", it means we could get the video's duration at that time. However, if we shutdown decoder too early, we won't get the correct duration. In addition, since we remove old decoder prior to create new one in the function HTMLMediaElement::SetDecoder(), we can remove the decoder checking assertion in HTMLMediaElement::InitializeDecoderForChannel(). MozReview-Commit-ID: CHRJHng8Xm0
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4607,17 +4607,16 @@ nsresult HTMLMediaElement::InitializeDec
 
   return FinishDecoderSetup(decoder, resource, nullptr);
 }
 
 nsresult HTMLMediaElement::InitializeDecoderForChannel(nsIChannel* aChannel,
                                                        nsIStreamListener** aListener)
 {
   NS_ASSERTION(mLoadingSrc, "mLoadingSrc must already be set");
-  NS_ASSERTION(mDecoder == nullptr, "Shouldn't have a decoder");
 
   nsAutoCString mimeType;
 
   aChannel->GetContentType(mimeType);
   NS_ASSERTION(!mimeType.IsEmpty(), "We should have the Content-Type.");
 
   DecoderDoctorDiagnostics diagnostics;
   RefPtr<MediaDecoder> decoder =
@@ -5275,20 +5274,16 @@ void HTMLMediaElement::DecodeError(const
   ReportLoadError("MediaLoadDecodeError", params, ArrayLength(params));
 
   DecoderDoctorDiagnostics diagnostics;
   diagnostics.StoreDecodeError(OwnerDoc(), aError, src, __func__);
 
   AudioTracks()->EmptyTracks();
   VideoTracks()->EmptyTracks();
   if (mIsLoadingFromSourceChildren) {
-    if (mDecoder) {
-      // Shut down the exiting decoder before loading the next source child.
-      ShutdownDecoder();
-    }
     mErrorSink->ResetError();
     if (mSourceLoadCandidate) {
       DispatchAsyncSourceError(mSourceLoadCandidate);
       QueueLoadFromSourceTask();
     } else {
       NS_WARNING("Should know the source we were loading from!");
     }
   } else if (mReadyState == nsIDOMHTMLMediaElement::HAVE_NOTHING) {