Bug 1401471. P3 - store the seek target in StreamAction so we won't need to read mChannelOffset outside the cache monitor. r=gerald
authorJW Wang <jwwang@mozilla.com>
Wed, 20 Sep 2017 16:20:56 +0800
changeset 382412 2682041ff5dc11fc2b25394facc674ca13b8789f
parent 382411 aa7c1fc82e560cf8959149b85a24edd6d58893e8
child 382413 f62add4838600d2c7405eec95fc5d965161123c7
push id32558
push userkwierso@gmail.com
push dateFri, 22 Sep 2017 21:29:46 +0000
treeherdermozilla-central@61e58a7d800b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1401471
milestone58.0a1
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
Bug 1401471. P3 - store the seek target in StreamAction so we won't need to read mChannelOffset outside the cache monitor. r=gerald MozReview-Commit-ID: Kkbs3WbSBVm
dom/media/MediaCache.cpp
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -1134,16 +1134,17 @@ MediaCache::Update()
     {
       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;
 
@@ -1396,16 +1397,17 @@ MediaCache::Update()
                      "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;
         // 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;
@@ -1447,19 +1449,19 @@ MediaCache::Update()
 
   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,
-            stream->mChannelOffset,
+            actions[i].mSeekTarget,
             actions[i].mResume);
-        rv = stream->mClient->CacheClientSeek(stream->mChannelOffset,
+        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: