Bug 1296531 - Add MediaSegment::IsNull. r=jesup
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 16 May 2017 13:06:02 +0200
changeset 382992 5cba097bf1eda93c6e7e0b1d7e57e9362377c7e6
parent 382991 e70956077d8b3d3e67d23ec83af9bd1b70410f07
child 382993 02d44644658bc8727f66758afb81992a0436166d
push id52061
push userpehrsons@gmail.com
push dateTue, 26 Sep 2017 14:36:10 +0000
treeherderautoland@8448eee20c9a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1296531
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 1296531 - Add MediaSegment::IsNull. r=jesup This allows us to see if all chunks in a MediaSegment are null. When this is true for the MediaSegment passed to NotifyQueuedChanges, we can assume that the track's input is blocked for the given time. MozReview-Commit-ID: zf7V7aiohg
dom/media/AudioSegment.h
dom/media/MediaSegment.h
--- a/dom/media/AudioSegment.h
+++ b/dom/media/AudioSegment.h
@@ -403,26 +403,16 @@ public:
     for (ChunkIterator ci(*this); !ci.IsEnded(); ci.Next()) {
       if (ci->ChannelCount()) {
         return ci->ChannelCount();
       }
     }
     return 0;
   }
 
-  bool IsNull() const {
-    for (ChunkIterator ci(*const_cast<AudioSegment*>(this)); !ci.IsEnded();
-         ci.Next()) {
-      if (!ci->IsNull()) {
-        return false;
-      }
-    }
-    return true;
-  }
-
   static Type StaticType() { return AUDIO; }
 
   size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override
   {
     return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
   }
 };
 
--- a/dom/media/MediaSegment.h
+++ b/dom/media/MediaSegment.h
@@ -144,16 +144,21 @@ public:
    * principal id than the current one.
    */
   void SetLastPrincipalHandle(const PrincipalHandle& aLastPrincipalHandle)
   {
     mLastPrincipalHandle = aLastPrincipalHandle;
   }
 
   /**
+   * Returns true if all chunks in this segment are null.
+   */
+  virtual bool IsNull() const = 0;
+
+  /**
    * Create a MediaSegment of the same type.
    */
   virtual MediaSegment* CreateEmptyClone() const = 0;
   /**
    * Moves contents of aSource to the end of this segment.
    */
   virtual void AppendFrom(MediaSegment* aSource) = 0;
   /**
@@ -224,16 +229,25 @@ protected:
 };
 
 /**
  * C is the implementation class subclassed from MediaSegmentBase.
  * C must contain a Chunk class.
  */
 template <class C, class Chunk> class MediaSegmentBase : public MediaSegment {
 public:
+  bool IsNull() const override
+  {
+    for (typename C::ConstChunkIterator iter(*this); !iter.IsEnded(); iter.Next()) {
+      if (!iter->IsNull()) {
+        return false;
+      }
+    }
+    return true;
+  }
   MediaSegment* CreateEmptyClone() const override
   {
     return new C();
   }
   void AppendFrom(MediaSegment* aSource) override
   {
     NS_ASSERTION(aSource->GetType() == C::StaticType(), "Wrong type");
     AppendFromInternal(static_cast<C*>(aSource));