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
--- 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) {