Bug 1547899 - Discard output streams also when playback is aborted. r=jib
This was done as a catch-all in PlaybackEnded(), but playback might not end if the source changes in the middle of playback. This catches those cases too. Differential Revision: https://phabricator.services.mozilla.com/D35321
This commit is contained in:
@@ -1649,6 +1649,7 @@ void HTMLMediaElement::ShutdownDecoder() {
|
||||
mNextAvailableMediaDecoderOutputTrackID =
|
||||
mDecoder->GetNextOutputStreamTrackID();
|
||||
}
|
||||
DiscardFinishWhenEndedOutputStreams();
|
||||
mDecoder->Shutdown();
|
||||
DDUNLINKCHILD(mDecoder.get());
|
||||
mDecoder = nullptr;
|
||||
@@ -1750,6 +1751,8 @@ void HTMLMediaElement::AbortExistingLoads() {
|
||||
EndSrcMediaStreamPlayback();
|
||||
}
|
||||
|
||||
DiscardFinishWhenEndedOutputStreams();
|
||||
|
||||
RemoveMediaElementFromURITable();
|
||||
mLoadingSrc = nullptr;
|
||||
mLoadingSrcTriggeringPrincipal = nullptr;
|
||||
@@ -3093,6 +3096,23 @@ void HTMLMediaElement::AddCaptureMediaTrackToOutputStream(
|
||||
destinationTrackID, inputTrack, port.get()));
|
||||
}
|
||||
|
||||
void HTMLMediaElement::DiscardFinishWhenEndedOutputStreams() {
|
||||
// Discard all output streams that have finished now.
|
||||
for (int32_t i = mOutputStreams.Length() - 1; i >= 0; --i) {
|
||||
if (!mOutputStreams[i].mFinishWhenEnded) {
|
||||
continue;
|
||||
}
|
||||
LOG(LogLevel::Debug,
|
||||
("Playback ended. Letting output stream %p go inactive",
|
||||
mOutputStreams[i].mStream.get()));
|
||||
mOutputStreams[i].mStream->SetFinishedOnInactive(true);
|
||||
if (mOutputStreams[i].mCapturingDecoder) {
|
||||
mDecoder->RemoveOutputStream(mOutputStreams[i].mStream);
|
||||
}
|
||||
mOutputStreams.RemoveElementAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
bool HTMLMediaElement::CanBeCaptured(StreamCaptureType aCaptureType) {
|
||||
// Don't bother capturing when the document has gone away
|
||||
nsPIDOMWindowInner* window = OwnerDoc()->GetInnerWindow();
|
||||
@@ -5092,19 +5112,7 @@ void HTMLMediaElement::PlaybackEnded() {
|
||||
NS_ASSERTION(!mDecoder || mDecoder->IsEnded(),
|
||||
"Decoder fired ended, but not in ended state");
|
||||
|
||||
// Discard all output streams that have finished now.
|
||||
for (int32_t i = mOutputStreams.Length() - 1; i >= 0; --i) {
|
||||
if (mOutputStreams[i].mFinishWhenEnded) {
|
||||
LOG(LogLevel::Debug,
|
||||
("Playback ended. Letting output stream %p go inactive",
|
||||
mOutputStreams[i].mStream.get()));
|
||||
mOutputStreams[i].mStream->SetFinishedOnInactive(true);
|
||||
if (mOutputStreams[i].mCapturingDecoder) {
|
||||
mDecoder->RemoveOutputStream(mOutputStreams[i].mStream);
|
||||
}
|
||||
mOutputStreams.RemoveElementAt(i);
|
||||
}
|
||||
}
|
||||
DiscardFinishWhenEndedOutputStreams();
|
||||
|
||||
if (mSrcStream) {
|
||||
LOG(LogLevel::Debug,
|
||||
|
||||
Reference in New Issue
Block a user