Backed out 4 changesets (bug 1401471) because it depends on 1401461 which is being backed out
authorPhil Ringnalda <philringnalda@gmail.com>
Thu, 21 Sep 2017 20:29:08 -0700
changeset 433090 fec2e3f42ddf13f8fac3a314486e62704ecdf766
parent 433089 d1d60297f919afdf9022e9f0a895941134b43a51
child 433091 c5cd3ceffc282b74e01d1b957dad0210a34c6a50
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1401471, 1401461
milestone58.0a1
backs out6a2c85349226d5ab611fdf2e4fa10d0efcb9850e
554875cb6a2ee1cbdb1f54f9ecb123d64e5d6152
f871c6aa4d9083c3cb88289e945248581fda32bb
ff9dbb6a6692dd7d949d594d47e61c2d6490252b
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 4 changesets (bug 1401471) because it depends on 1401461 which is being backed out Backed out changeset 6a2c85349226 (bug 1401471) Backed out changeset 554875cb6a2e (bug 1401471) Backed out changeset f871c6aa4d90 (bug 1401471) Backed out changeset ff9dbb6a6692 (bug 1401471) MozReview-Commit-ID: 80kxfUqbik4
dom/media/MediaCache.cpp
dom/media/MediaCache.h
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -457,16 +457,17 @@ MediaCacheStream::MediaCacheStream(Chann
                                    bool aIsPrivateBrowsing)
   : mMediaCache(nullptr)
   , mClient(aClient)
   , mDidNotifyDataEnded(false)
   , mResourceID(0)
   , mIsTransportSeekable(false)
   , mCacheSuspended(false)
   , mChannelEnded(false)
+  , mChannelOffset(0)
   , mStreamLength(-1)
   , mStreamOffset(0)
   , mPlaybackBytesPerSecond(10000)
   , mPinCount(0)
   , mCurrentMode(MODE_PLAYBACK)
   , mMetadataInPartialBlockBuffer(false)
   , mIsPrivateBrowsing(aIsPrivateBrowsing)
 {
@@ -1117,35 +1118,23 @@ MediaCache::PredictNextUseForIncomingDat
   }
   if (bytesAhead <= 0)
     return TimeDuration(0);
   int64_t millisecondsAhead = bytesAhead*1000/aStream->mPlaybackBytesPerSecond;
   return TimeDuration::FromMilliseconds(
       std::min<int64_t>(millisecondsAhead, INT32_MAX));
 }
 
+enum StreamAction { NONE, SEEK, SEEK_AND_RESUME, RESUME, SUSPEND };
+
 void
 MediaCache::Update()
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
-  struct StreamAction
-  {
-    enum
-    {
-      NONE,
-      SEEK,
-      RESUME,
-      SUSPEND
-    } mTag = NONE;
-    // Members for 'SEEK' only.
-    bool mResume = false;
-    int64_t mSeekTarget = -1;
-  };
-
   // The action to use for each stream. We store these so we can make
   // decisions while holding the cache lock but implement those decisions
   // without holding the cache lock, since we need to call out to
   // stream, decoder and element code.
   AutoTArray<StreamAction,10> actions;
 
   {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
@@ -1256,17 +1245,17 @@ MediaCache::Update()
         latestNextUse = PredictNextUse(now, reusableBlock);
       }
     }
 
     int32_t resumeThreshold = Preferences::GetInt("media.cache_resume_threshold", 10);
     int32_t readaheadLimit = Preferences::GetInt("media.cache_readahead_limit", 30);
 
     for (uint32_t i = 0; i < mStreams.Length(); ++i) {
-      actions.AppendElement(StreamAction{});
+      actions.AppendElement(NONE);
 
       MediaCacheStream* stream = mStreams[i];
       if (stream->mClosed) {
         LOG("Stream %p closed", stream);
         continue;
       }
 
       // Figure out where we should be reading from. It's the first
@@ -1394,27 +1383,25 @@ MediaCache::Update()
         // We need to seek now.
         NS_ASSERTION(stream->mIsTransportSeekable || desiredOffset == 0,
                      "Trying to seek in a non-seekable stream!");
         // Round seek offset down to the start of the block. This is essential
         // because we don't want to think we have part of a block already
         // in mPartialBlockBuffer.
         stream->mChannelOffset =
           OffsetToBlockIndexUnchecked(desiredOffset) * BLOCK_SIZE;
-        actions[i].mTag = StreamAction::SEEK;
-        actions[i].mResume = stream->mCacheSuspended;
-        actions[i].mSeekTarget = stream->mChannelOffset;
+        actions[i] = stream->mCacheSuspended ? SEEK_AND_RESUME : SEEK;
         // mChannelOffset is updated to a new position. We don't want data from
         // the old channel to be written to the wrong position. 0 is a sentinel
         // value which will not match any ID passed to NotifyDataReceived().
         stream->mLoadID = 0;
       } else if (enableReading && stream->mCacheSuspended) {
-        actions[i].mTag = StreamAction::RESUME;
+        actions[i] = RESUME;
       } else if (!enableReading && !stream->mCacheSuspended) {
-        actions[i].mTag = StreamAction::SUSPEND;
+        actions[i] = SUSPEND;
       }
     }
 #ifdef DEBUG
     mInUpdate = false;
 #endif
   }
 
   // Update the channel state without holding our cache lock. While we're
@@ -1425,57 +1412,57 @@ MediaCache::Update()
   // the action, which can only be written by the main thread (i.e., this
   // thread), so we don't have races here.
 
   // First, update the mCacheSuspended/mCacheEnded flags so that they're all correct
   // when we fire our CacheClient commands below. Those commands can rely on these flags
   // being set correctly for all streams.
   for (uint32_t i = 0; i < mStreams.Length(); ++i) {
     MediaCacheStream* stream = mStreams[i];
-    switch (actions[i].mTag) {
-      case StreamAction::SEEK:
-        stream->mCacheSuspended = false;
-        stream->mChannelEnded = false;
-        break;
-      case StreamAction::RESUME:
-        stream->mCacheSuspended = false;
-        break;
-      case StreamAction::SUSPEND:
-        stream->mCacheSuspended = true;
-        break;
-      default:
-        break;
+    switch (actions[i]) {
+    case SEEK:
+	case SEEK_AND_RESUME:
+      stream->mCacheSuspended = false;
+      stream->mChannelEnded = false;
+      break;
+    case RESUME:
+      stream->mCacheSuspended = false;
+      break;
+    case SUSPEND:
+      stream->mCacheSuspended = true;
+      break;
+    default:
+      break;
     }
   }
 
   for (uint32_t i = 0; i < mStreams.Length(); ++i) {
     MediaCacheStream* stream = mStreams[i];
     nsresult rv;
-    switch (actions[i].mTag) {
-      case StreamAction::SEEK:
-        LOG("Stream %p CacheSeek to %" PRId64 " (resume=%d)",
-            stream,
-            actions[i].mSeekTarget,
-            actions[i].mResume);
-        rv = stream->mClient->CacheClientSeek(actions[i].mSeekTarget,
-                                              actions[i].mResume);
-        break;
-      case StreamAction::RESUME:
-        LOG("Stream %p Resumed", stream);
-        rv = stream->mClient->CacheClientResume();
-        QueueSuspendedStatusUpdate(stream->mResourceID);
-        break;
-      case StreamAction::SUSPEND:
-        LOG("Stream %p Suspended", stream);
-        rv = stream->mClient->CacheClientSuspend();
-        QueueSuspendedStatusUpdate(stream->mResourceID);
-        break;
-      default:
-        rv = NS_OK;
-        break;
+    switch (actions[i]) {
+    case SEEK:
+	case SEEK_AND_RESUME:
+      LOG("Stream %p CacheSeek to %" PRId64 " (resume=%d)", stream,
+          stream->mChannelOffset, actions[i] == SEEK_AND_RESUME);
+      rv = stream->mClient->CacheClientSeek(stream->mChannelOffset,
+                                            actions[i] == SEEK_AND_RESUME);
+      break;
+    case RESUME:
+      LOG("Stream %p Resumed", stream);
+      rv = stream->mClient->CacheClientResume();
+      QueueSuspendedStatusUpdate(stream->mResourceID);
+      break;
+    case SUSPEND:
+      LOG("Stream %p Suspended", stream);
+      rv = stream->mClient->CacheClientSuspend();
+      QueueSuspendedStatusUpdate(stream->mResourceID);
+      break;
+    default:
+      rv = NS_OK;
+      break;
     }
 
     if (NS_FAILED(rv)) {
       // Close the streams that failed due to error. This will cause all
       // client Read and Seek operations on those streams to fail. Blocked
       // Reads will also be woken up.
       stream->mClient->Close();
     }
@@ -2200,17 +2187,17 @@ MediaCacheStream::GetLength()
 {
   ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
   return mStreamLength;
 }
 
 int64_t
 MediaCacheStream::GetOffset() const
 {
-  ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
+  MOZ_ASSERT(NS_IsMainThread());
   return mChannelOffset;
 }
 
 int64_t
 MediaCacheStream::GetNextCachedData(int64_t aOffset)
 {
   ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
   return GetNextCachedDataInternal(aOffset);
--- a/dom/media/MediaCache.h
+++ b/dom/media/MediaCache.h
@@ -455,25 +455,25 @@ private:
   // The last reported seekability state for the underlying channel
   bool mIsTransportSeekable;
   // True if the cache has suspended our channel because the cache is
   // full and the priority of the data that would be received is lower
   // than the priority of the data already in the cache
   bool mCacheSuspended;
   // True if the channel ended and we haven't seeked it again.
   bool mChannelEnded;
+  // The offset where the next data from the channel will arrive
+  int64_t      mChannelOffset;
   // The reported or discovered length of the data, or -1 if nothing is
   // known
   int64_t      mStreamLength;
 
   // The following fields are protected by the cache's monitor can can be written
   // by any thread.
 
-  // The offset where the next data from the channel will arrive
-  int64_t mChannelOffset = 0;
   // The offset where the reader is positioned in the stream
   int64_t           mStreamOffset;
   // For each block in the stream data, maps to the cache entry for the
   // block, or -1 if the block is not cached.
   nsTArray<int32_t> mBlocks;
   // The list of read-ahead blocks, ordered by stream offset; the first
   // block is the earliest in the stream (so the last block will be the
   // least valuable).