Bug 1374184. P2 - merge NotifyDataArrived() and NotifyDownloadProgressed().
We also move NotifyDownloadProgressed() to private
since it won't be called outside MediaDecoder.
MozReview-Commit-ID: GISbJEW7wwx
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1546,16 +1546,17 @@ MediaDecoder::NotifyDataArrivedInternal(
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
mDataArrivedEvent.Notify();
}
void
MediaDecoder::NotifyDataArrived()
{
NotifyDataArrivedInternal();
+ NotifyDownloadProgressed();
}
// Provide access to the state machine object
MediaDecoderStateMachine*
MediaDecoder::GetStateMachine() const
{
MOZ_ASSERT(NS_IsMainThread());
return mDecoderStateMachine;
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -248,20 +248,16 @@ public:
virtual void RemoveOutputStream(MediaStream* aStream);
// Return the duration of the video in seconds.
virtual double GetDuration();
// Return true if the stream is infinite (see SetInfinite).
bool IsInfinite() const;
- // Called by MediaResource when some data has been received.
- // Call on the main thread only.
- void NotifyDownloadProgressed();
-
// Called as data arrives on the stream and is read into the cache. Called
// on the main thread only.
void NotifyDataArrived();
// Return true if we are currently seeking in the media resource.
// Call on the main thread only.
bool IsSeeking() const;
@@ -586,16 +582,20 @@ protected:
// the next frame is available.
// An arbitrary value of 250ms is used.
static constexpr auto DEFAULT_NEXT_FRAME_AVAILABLE_BUFFERED =
media::TimeUnit::FromMicroseconds(250000);
private:
void NotifyDataArrivedInternal();
+ // Called by MediaResource when some data has been received.
+ // Call on the main thread only.
+ void NotifyDownloadProgressed();
+
nsCString GetDebugInfo();
// Called when the metadata from the media file has been loaded by the
// state machine. Call on the main thread only.
void MetadataLoaded(UniquePtr<MediaInfo> aInfo,
UniquePtr<MetadataTags> aTags,
MediaDecoderEventVisibility aEventVisibility);
--- a/dom/media/mediasource/SourceBuffer.cpp
+++ b/dom/media/mediasource/SourceBuffer.cpp
@@ -442,20 +442,19 @@ SourceBuffer::AppendDataCompletedWithSuc
MSE_DEBUG("Complete AppendBuffer operation");
mCompletionPromise.Complete();
StopUpdating();
})
->Track(mCompletionPromise);
}
}
if (mActive) {
- // Tell our parent decoder that we have received new data.
+ // Tell our parent decoder that we have received new data
+ // and send progress event.
mMediaSource->GetDecoder()->NotifyDataArrived();
- // Send progress event.
- mMediaSource->GetDecoder()->NotifyDownloadProgressed();
}
mCurrentAttributes = aResult.second();
CheckEndTime();
if (!mCompletionPromise.Exists()) {
StopUpdating();