Bug 1294384 - make video-only attribute orthogonal to the seek type; r=jwwang
authorKaku Kuo <tkuo@mozilla.com>
Fri, 12 Aug 2016 11:45:02 +0800
changeset 309424 2fff8cb618fc6ced1558334f7e73d2a8799b172c
parent 309423 fcec4012543a543f444ed51a01ba8dbbe8ff670b
child 309425 d1bcccf544c4e1e3cc7cba663e2c7d23a6918299
push id80592
push userkwierso@gmail.com
push dateMon, 15 Aug 2016 21:54:03 +0000
treeherdermozilla-inbound@16b35e0c7644 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang
bugs1294384
milestone51.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 1294384 - make video-only attribute orthogonal to the seek type; r=jwwang MozReview-Commit-ID: 2oBjuiN7pLn
dom/media/MediaDecoderStateMachine.cpp
dom/media/SeekTarget.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1139,16 +1139,17 @@ MediaDecoderStateMachine::SetDormant(boo
         // Keep latest seek target
       } else if (mCurrentSeek.Exists()) {
         // Because both audio and video decoders are going to be reset in this
         // method later, we treat a VideoOnly seek task as a normal Accurate
         // seek task so that while it is resumed, both audio and video playback
         // are handled.
         if (mCurrentSeek.mTarget.IsVideoOnly()) {
           mCurrentSeek.mTarget.SetType(SeekTarget::Accurate);
+          mCurrentSeek.mTarget.SetVideoOnly(false);
         }
         mQueuedSeek = Move(mCurrentSeek);
         mSeekTaskRequest.DisconnectIfExists();
       } else {
         mQueuedSeek.mTarget = SeekTarget(mCurrentPosition,
                                          SeekTarget::Accurate,
                                          MediaDecoderEventVisibility::Suppressed);
         // XXXbholley - Nobody is listening to this promise. Do we need to pass it
@@ -1365,18 +1366,19 @@ void MediaDecoderStateMachine::Visibilit
     // one to catch up.
     if (mSeekTask || mQueuedSeek.Exists()) {
       return;
     }
 
     // Start video-only seek to the current time...
     SeekJob seekJob;
     seekJob.mTarget = SeekTarget(GetMediaTime(),
-                                 SeekTarget::Type::AccurateVideoOnly,
-                                 MediaDecoderEventVisibility::Suppressed);
+                                 SeekTarget::Type::Accurate,
+                                 MediaDecoderEventVisibility::Suppressed,
+                                 true /* aVideoOnly */);
     InitiateSeek(Move(seekJob));
   }
 }
 
 void MediaDecoderStateMachine::BufferedRangeUpdated()
 {
   MOZ_ASSERT(OnTaskQueue());
 
@@ -1554,18 +1556,17 @@ MediaDecoderStateMachine::InitiateSeek(S
 
   mSeekTaskRequest.DisconnectIfExists();
 
   // SeekTask will register its callbacks to MediaDecoderReaderWrapper.
   CancelMediaDecoderReaderWrapperCallback();
 
   // Create a new SeekTask instance for the incoming seek task.
   if (aSeekJob.mTarget.IsAccurate() ||
-      aSeekJob.mTarget.IsFast() ||
-      aSeekJob.mTarget.IsVideoOnly()) {
+      aSeekJob.mTarget.IsFast()) {
     mSeekTask = new AccurateSeekTask(mDecoderID, OwnerThread(),
                                      mReader.get(), aSeekJob.mTarget,
                                      mInfo, Duration(), GetMediaTime());
   } else if (aSeekJob.mTarget.IsNextFrame()) {
     mSeekTask = new NextFrameSeekTask(mDecoderID, OwnerThread(), mReader.get(),
                                       aSeekJob.mTarget, mInfo, Duration(),
                                       GetMediaTime(), AudioQueue(), VideoQueue());
   } else {
--- a/dom/media/SeekTarget.h
+++ b/dom/media/SeekTarget.h
@@ -19,86 +19,96 @@ enum class MediaDecoderEventVisibility :
 // Stores the seek target; the time to seek to, and whether an Accurate,
 // "Fast" (nearest keyframe), or "Video Only" (no audio seek) seek was
 // requested.
 struct SeekTarget {
   enum Type {
     Invalid,
     PrevSyncPoint,
     Accurate,
-    AccurateVideoOnly,
     NextFrame,
   };
   SeekTarget()
     : mEventVisibility(MediaDecoderEventVisibility::Observable)
     , mTime(media::TimeUnit::Invalid())
     , mType(SeekTarget::Invalid)
+    , mVideoOnly(false)
   {
   }
   SeekTarget(int64_t aTimeUsecs,
              Type aType,
              MediaDecoderEventVisibility aEventVisibility =
-               MediaDecoderEventVisibility::Observable)
+               MediaDecoderEventVisibility::Observable,
+             bool aVideoOnly = false)
     : mEventVisibility(aEventVisibility)
     , mTime(media::TimeUnit::FromMicroseconds(aTimeUsecs))
     , mType(aType)
+    , mVideoOnly(aVideoOnly)
   {
   }
   SeekTarget(const media::TimeUnit& aTime,
              Type aType,
              MediaDecoderEventVisibility aEventVisibility =
-               MediaDecoderEventVisibility::Observable)
+               MediaDecoderEventVisibility::Observable,
+             bool aVideoOnly = false)
     : mEventVisibility(aEventVisibility)
     , mTime(aTime)
     , mType(aType)
+    , mVideoOnly(aVideoOnly)
   {
   }
   SeekTarget(const SeekTarget& aOther)
     : mEventVisibility(aOther.mEventVisibility)
     , mTime(aOther.mTime)
     , mType(aOther.mType)
+    , mVideoOnly(aOther.mVideoOnly)
   {
   }
   bool IsValid() const {
     return mType != SeekTarget::Invalid;
   }
   void Reset() {
     mTime = media::TimeUnit::Invalid();
     mType = SeekTarget::Invalid;
+    mVideoOnly = false;
   }
   media::TimeUnit GetTime() const {
     NS_ASSERTION(mTime.IsValid(), "Invalid SeekTarget");
     return mTime;
   }
   void SetTime(const media::TimeUnit& aTime) {
     NS_ASSERTION(aTime.IsValid(), "Invalid SeekTarget destination");
     mTime = aTime;
   }
   void SetType(Type aType) {
     mType = aType;
   }
+  void SetVideoOnly(bool aVideoOnly) {
+    mVideoOnly = aVideoOnly;
+  }
   bool IsFast() const {
     return mType == SeekTarget::Type::PrevSyncPoint;
   }
   bool IsAccurate() const {
     return mType == SeekTarget::Type::Accurate;
   }
-  bool IsVideoOnly() const {
-    return mType == SeekTarget::Type::AccurateVideoOnly;
-  }
   bool IsNextFrame() const {
     return mType == SeekTarget::Type::NextFrame;
   }
+  bool IsVideoOnly() const {
+    return mVideoOnly;
+  }
 
   MediaDecoderEventVisibility mEventVisibility;
 
 private:
   // Seek target time.
   media::TimeUnit mTime;
   // Whether we should seek "Fast", or "Accurate".
   // "Fast" seeks to the seek point preceding mTime, whereas
   // "Accurate" seeks as close as possible to mTime.
   Type mType;
+  bool mVideoOnly;
 };
 
 } // namespace mozilla
 
 #endif /* SEEK_TARGET_H */