mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-26 19:55:39 +00:00
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:
parent
296eb5268a
commit
f18a46b384
@ -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()) {
|
||||
|
Loading…
Reference in New Issue
Block a user