Bug 1139380: Ensure all queued tasks are aborted when shutting down. r=cpearce

This commit is contained in:
Jean-Yves Avenard 2015-03-06 16:49:00 +11:00
parent ac2c26d8f4
commit aff59a70fb
2 changed files with 20 additions and 0 deletions

View File

@ -836,6 +836,10 @@ MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType,
} else {
mVideoDataRequest.Complete();
}
if (IsShutdown()) {
// Already shutdown;
return;
}
// If this is a decode error, delegate to the generic error path.
if (aReason == MediaDecoderReader::DECODE_ERROR) {
@ -1927,6 +1931,10 @@ MediaDecoderStateMachine::DispatchAudioDecodeTaskIfNeeded()
MOZ_ASSERT(OnStateMachineThread());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
if (IsShutdown()) {
return NS_ERROR_FAILURE;
}
if (NeedToDecodeAudio()) {
return EnsureAudioDecodeTaskQueued();
}
@ -1973,6 +1981,10 @@ MediaDecoderStateMachine::DispatchVideoDecodeTaskIfNeeded()
MOZ_ASSERT(OnStateMachineThread());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
if (IsShutdown()) {
return NS_ERROR_FAILURE;
}
if (NeedToDecodeVideo()) {
return EnsureVideoDecodeTaskQueued();
}

View File

@ -418,6 +418,14 @@ nsRefPtr<ShutdownPromise>
MediaSourceReader::Shutdown()
{
mSeekPromise.RejectIfExists(NS_ERROR_FAILURE, __func__);
// Any previous requests we've been waiting on are now unwanted.
mAudioRequest.DisconnectIfExists();
mVideoRequest.DisconnectIfExists();
// Additionally, reject any outstanding promises _we_ made that we might have
// been waiting on the above to fulfill.
mAudioPromise.RejectIfExists(CANCELED, __func__);
mVideoPromise.RejectIfExists(CANCELED, __func__);
MOZ_ASSERT(mMediaSourceShutdownPromise.IsEmpty());
nsRefPtr<ShutdownPromise> p = mMediaSourceShutdownPromise.Ensure(__func__);