Bug 1421134. P1 - default MediaCacheStream::mCurrentMode to MODE_METADATA.
We always read metadata when decoding starts. This allows us to remove the call
to mResource->SetReadMode(MediaCacheStream::MODE_METADATA) in ChannelMediaDecoder::Load().
MozReview-Commit-ID: AQMq4HxDZdT
--- a/dom/media/BaseMediaResource.h
+++ b/dom/media/BaseMediaResource.h
@@ -59,17 +59,17 @@ public:
// since we don't expect to resume again any time soon. Otherwise we
// may resume again soon so resources should be held for a little
// while.
virtual void Suspend(bool aCloseImmediately) = 0;
// Resume any downloads that have been suspended.
virtual void Resume() = 0;
- // The mode is initially MODE_PLAYBACK.
+ // The mode is initially MODE_METADATA.
virtual void SetReadMode(MediaCacheStream::ReadMode aMode) = 0;
// Returns true if the resource can be seeked to unbuffered ranges, i.e.
// for an HTTP network stream this returns true if HTTP1.1 Byte Range
// requests are supported by the connection/server.
virtual bool IsTransportSeekable() = 0;
// Get the current principal for the channel
--- a/dom/media/ChannelMediaDecoder.cpp
+++ b/dom/media/ChannelMediaDecoder.cpp
@@ -250,19 +250,16 @@ ChannelMediaDecoder::Load(nsIChannel* aC
nsresult rv = MediaShutdownManager::Instance().Register(this);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = mResource->Open(aStreamListener);
NS_ENSURE_SUCCESS(rv, rv);
- // Set mode to METADATA since we are about to read metadata.
- mResource->SetReadMode(MediaCacheStream::MODE_METADATA);
-
SetStateMachine(CreateStateMachine());
NS_ENSURE_TRUE(GetStateMachine(), NS_ERROR_FAILURE);
return InitializeStateMachine();
}
nsresult
ChannelMediaDecoder::Load(BaseMediaResource* aOriginal)
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -502,17 +502,16 @@ MediaCacheStream::MediaCacheStream(Chann
: mMediaCache(nullptr)
, mClient(aClient)
, mIsTransportSeekable(false)
, mCacheSuspended(false)
, mChannelEnded(false)
, mStreamOffset(0)
, mPlaybackBytesPerSecond(10000)
, mPinCount(0)
- , mCurrentMode(MODE_PLAYBACK)
, mMetadataInPartialBlockBuffer(false)
, mIsPrivateBrowsing(aIsPrivateBrowsing)
{
}
size_t MediaCacheStream::SizeOfExcludingThis(
MallocSizeOf aMallocSizeOf) const
{
--- a/dom/media/MediaCache.h
+++ b/dom/media/MediaCache.h
@@ -518,17 +518,17 @@ private:
// corresponding Unpin
uint32_t mPinCount;
// True if CacheClientNotifyDataEnded has been called for this stream.
bool mDidNotifyDataEnded = false;
// The status used when we did CacheClientNotifyDataEnded. Only valid
// when mDidNotifyDataEnded is true.
nsresult mNotifyDataEndedStatus;
// The last reported read mode
- ReadMode mCurrentMode;
+ ReadMode mCurrentMode = MODE_METADATA;
// True if some data in mPartialBlockBuffer has been read as metadata
bool mMetadataInPartialBlockBuffer;
// The load ID of the current channel. Used to check whether the data is
// coming from an old channel and should be discarded.
uint32_t mLoadID = 0;
// The seek target initiated by MediaCache. -1 if no seek is going on.
int64_t mSeekTarget = -1;