From cc8b7e3ce1560b1c4d2ebe7002f89612da28419d Mon Sep 17 00:00:00 2001 From: JW Wang Date: Wed, 22 Jul 2015 20:57:41 +0800 Subject: [PATCH] Bug 1185892. Part 2 - delegate the job of MediaDecoder::IsExpectingMoreData to its MediaResource. r=jya. --- dom/media/MediaDecoder.cpp | 14 +------------- dom/media/MediaResource.h | 5 +++-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index ba7bb30e86fd..ca9cc3d3eb52 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -659,19 +659,7 @@ bool MediaDecoder::IsExpectingMoreData() { ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); - - // If there's no resource, we're probably just getting set up. - if (!mResource) { - return true; - } - - // If we've downloaded anything, we're not waiting for anything. - if (mResource->IsDataCachedToEndOfResource(mDecoderPosition)) { - return false; - } - - // Otherwise, we should be getting data unless the stream is suspended. - return !mResource->IsSuspended(); + return !mResource || mResource->IsExpectingMoreData(); } void MediaDecoder::MetadataLoaded(nsAutoPtr aInfo, diff --git a/dom/media/MediaResource.h b/dom/media/MediaResource.h index 5f401d7b5c53..87d3794e8916 100644 --- a/dom/media/MediaResource.h +++ b/dom/media/MediaResource.h @@ -407,8 +407,9 @@ public: // an appendBuffer call on a MediaSource element. virtual bool IsExpectingMoreData() { - // TODO: return a sensible value for all sub-classes in next patch. - return false; + // MediaDecoder::mDecoderPosition is roughly the same as Tell() which + // returns a position updated by latest Read() or ReadAt(). + return !IsDataCachedToEndOfResource(Tell()) && !IsSuspended(); } // Returns true if this stream is suspended by the cache because the // cache is full. If true then the decoder should try to start consuming