Bug 1293572 - Flushing a decoder that is not initialized causes hang. Don't create decoders when the reader is suspened. r=jya

MozReview-Commit-ID: 7ylrYLrrwIS

--HG--
extra : rebase_source : 7421d6b0ee804f30cdfdba0ffda8d9c44d3d7ba5
This commit is contained in:
JW Wang 2016-08-05 17:25:49 +08:00
Родитель 296eb5268a
Коммит f18a46b384
1 изменённых файлов: 12 добавлений и 8 удалений

Просмотреть файл

@ -388,6 +388,7 @@ bool
MediaFormatReader::EnsureDecoderCreated(TrackType aTrack)
{
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(!IsSuspended());
auto& decoder = GetDecoderData(aTrack);
@ -454,6 +455,8 @@ bool
MediaFormatReader::EnsureDecoderInitialized(TrackType aTrack)
{
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(!IsSuspended());
auto& decoder = GetDecoderData(aTrack);
if (!decoder.mDecoder || decoder.mInitPromise.Exists()) {
@ -463,21 +466,14 @@ MediaFormatReader::EnsureDecoderInitialized(TrackType aTrack)
if (decoder.mDecoderInitialized) {
return true;
}
if (IsSuspended()) {
return false;
}
RefPtr<MediaFormatReader> self = this;
decoder.mInitPromise.Begin(decoder.mDecoder->Init()
->Then(OwnerThread(), __func__,
[self] (TrackType aTrack) {
MOZ_ASSERT(!self->IsSuspended());
auto& decoder = self->GetDecoderData(aTrack);
decoder.mInitPromise.Complete();
if (self->IsSuspended()) {
return;
}
decoder.mDecoderInitialized = true;
MonitorAutoLock mon(decoder.mMonitor);
decoder.mDescription = decoder.mDecoder->GetDescriptionName();
@ -946,6 +942,14 @@ MediaFormatReader::HandleDemuxedSamples(TrackType aTrack,
{
MOZ_ASSERT(OnTaskQueue());
// Don't try to create or initialize decoders
// (which might allocate hardware resources) when suspended.
if (IsSuspended()) {
// Should've deleted decoders when suspended.
MOZ_ASSERT(!mAudio.mDecoder && !mVideo.mDecoder);
return;
}
auto& decoder = GetDecoderData(aTrack);
if (decoder.mQueuedSamples.IsEmpty()) {