Bug 1401471. P2 - remove SEEK_AND_RESUME. draft
authorJW Wang <jwwang@mozilla.com>
Wed, 20 Sep 2017 16:16:07 +0800
changeset 668974 955887fe04b5ded1b75923572c6b39ff455679f4
parent 668973 57e1b54c03c45af12fc66eb03e4614d6a3df486e
child 668975 b2cdc28c84e7fba347a1514617034d524fd0ed65
push id81174
push userjwwang@mozilla.com
push dateFri, 22 Sep 2017 09:08:50 +0000
bugs1401471
milestone57.0a1
Bug 1401471. P2 - remove SEEK_AND_RESUME. MozReview-Commit-ID: ACdp3wVuurb
dom/media/MediaCache.cpp
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -1129,20 +1129,21 @@ MediaCache::Update()
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
   struct StreamAction
   {
     enum
     {
       NONE,
       SEEK,
-      SEEK_AND_RESUME,
       RESUME,
       SUSPEND
     } mTag = NONE;
+    // Members for 'SEEK' only.
+    bool mResume = false;
   };
 
   // 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;
 
@@ -1393,19 +1394,18 @@ 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 = stream->mCacheSuspended
-                            ? StreamAction::SEEK_AND_RESUME
-                            : StreamAction::SEEK;
+        actions[i].mTag = StreamAction::SEEK;
+        actions[i].mResume = stream->mCacheSuspended;
         // 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;
       } else if (!enableReading && !stream->mCacheSuspended) {
         actions[i].mTag = StreamAction::SUSPEND;
@@ -1426,17 +1426,16 @@ MediaCache::Update()
 
   // 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:
-      case StreamAction::SEEK_AND_RESUME:
         stream->mCacheSuspended = false;
         stream->mChannelEnded = false;
         break;
       case StreamAction::RESUME:
         stream->mCacheSuspended = false;
         break;
       case StreamAction::SUSPEND:
         stream->mCacheSuspended = true;
@@ -1446,24 +1445,22 @@ MediaCache::Update()
     }
   }
 
   for (uint32_t i = 0; i < mStreams.Length(); ++i) {
     MediaCacheStream* stream = mStreams[i];
     nsresult rv;
     switch (actions[i].mTag) {
       case StreamAction::SEEK:
-      case StreamAction::SEEK_AND_RESUME:
         LOG("Stream %p CacheSeek to %" PRId64 " (resume=%d)",
             stream,
             stream->mChannelOffset,
-            actions[i].mTag == StreamAction::SEEK_AND_RESUME);
+            actions[i].mResume);
         rv = stream->mClient->CacheClientSeek(stream->mChannelOffset,
-                                              actions[i].mTag ==
-                                                StreamAction::SEEK_AND_RESUME);
+                                              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);