Bug 1376227. P3 - move Load() down the class hierarchy. r=gerald

So we won't pass an unused |nsIStreamListener**| to MediaSourceDecoder::Load().

MozReview-Commit-ID: 2TCby8m8K5H
This commit is contained in:
JW Wang
2017-06-23 14:12:41 +08:00
parent d6e01cebbe
commit e61275e384
7 changed files with 63 additions and 48 deletions

View File

@@ -2513,6 +2513,13 @@ nsresult HTMLMediaElement::LoadResource()
}
ChangeDelayLoadStatus(false);
decoder->CreateResource(mMediaSource->GetPrincipal());
nsresult rv = decoder->Load();
if (NS_FAILED(rv)) {
decoder->Shutdown();
LOG(LogLevel::Debug,
("%p Failed to load for decoder %p", this, decoder.get()));
return rv;
}
return FinishDecoderSetup(decoder, nullptr);
}
@@ -4656,6 +4663,14 @@ HTMLMediaElement::InitializeDecoderAsClone(ChannelMediaDecoder* aOriginal)
return rv;
}
rv = decoder->Load(nullptr);
if (NS_FAILED(rv)) {
decoder->Shutdown();
LOG(LogLevel::Debug,
("%p Failed to load for decoder %p", this, decoder.get()));
return rv;
}
return FinishDecoderSetup(decoder, nullptr);
}
@@ -4709,12 +4724,21 @@ nsresult HTMLMediaElement::InitializeDecoderForChannel(nsIChannel* aChannel,
mChannelLoader = nullptr;
}
rv = decoder->Load(aListener);
if (NS_FAILED(rv)) {
decoder->Shutdown();
LOG(LogLevel::Debug,
("%p Failed to load for decoder %p", this, decoder.get()));
return rv;
}
rv = FinishDecoderSetup(decoder, aListener);
if (NS_SUCCEEDED(rv)) {
AddMediaElementToURITable();
NS_ASSERTION(MediaElementTableCount(this, mLoadingSrc) == 1,
"Media element should have single table entry if decode initialized");
}
return rv;
}
@@ -4737,13 +4761,6 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder,
// can affect how we feed data to MediaStreams
NotifyDecoderPrincipalChanged();
nsresult rv = aDecoder->Load(aListener);
if (NS_FAILED(rv)) {
ShutdownDecoder();
LOG(LogLevel::Debug, ("%p Failed to load for decoder %p", this, aDecoder));
return rv;
}
for (OutputMediaStream& ms : mOutputStreams) {
if (ms.mCapturingMediaStream) {
MOZ_ASSERT(!ms.mCapturingDecoder);
@@ -4781,6 +4798,7 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder,
// This will also do an AddRemoveSelfReference.
NotifyOwnerDocumentActivityChanged();
nsresult rv = NS_OK;
if (!mPaused) {
SetPlayedOrSeeked(true);
if (!mPausedForInactiveDocumentOrChannel) {