Bug 1530322 - P3. Add diagnostics. r=gerald
☠☠ backed out by 63242317442c ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 26 Feb 2019 06:39:57 +0000
changeset 518917 65870fec6eea2103719af73c7369d5242250ecdb
parent 518916 d5159dfc6d8636fb84fc8447ff15c03f0a4283b0
child 518918 1e169e0e9d17d376d31e491db36530a4ca3e18f9
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1530322
milestone67.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 1530322 - P3. Add diagnostics. r=gerald Depends on D21172 Differential Revision: https://phabricator.services.mozilla.com/D21173
dom/media/MediaData.cpp
dom/media/MediaData.h
--- a/dom/media/MediaData.cpp
+++ b/dom/media/MediaData.cpp
@@ -81,24 +81,30 @@ bool AudioData::SetTrimWindow(const medi
   auto trimBefore = TimeUnitToFrames(aTrim.mStart - mOriginalTime, mRate);
   auto trimAfter = aTrim.mEnd == GetEndTime()
                        ? originalFrames
                        : TimeUnitToFrames(aTrim.mEnd - mOriginalTime, mRate);
   if (!trimBefore.isValid() || !trimAfter.isValid()) {
     // Overflow.
     return false;
   }
+  MOZ_DIAGNOSTIC_ASSERT(trimAfter.value() >= trimBefore.value(),
+                        "Something went wrong with trimming value");
   if (!mTrimWindow && trimBefore == 0 && trimAfter == originalFrames) {
     // Nothing to change, abort early to prevent rounding errors.
     return true;
   }
 
   mTrimWindow = Some(aTrim);
   mDataOffset = trimBefore.value() * mChannels;
+  MOZ_DIAGNOSTIC_ASSERT(mDataOffset <= mAudioData.Length(),
+                        "Data offset outside original buffer");
   mFrames = (trimAfter - trimBefore).value();
+  MOZ_DIAGNOSTIC_ASSERT(mFrames <= originalFrames,
+                        "More frames than found in container");
   mTime = mOriginalTime + FramesToTimeUnit(trimBefore.value(), mRate);
   mDuration = FramesToTimeUnit(mFrames, mRate);
 
   return true;
 }
 
 AudioDataValue* AudioData::GetAdjustedData() const {
   if (!mAudioData) {
--- a/dom/media/MediaData.h
+++ b/dom/media/MediaData.h
@@ -177,17 +177,17 @@ class AlignedBuffer {
   // For backward compatibility with UniquePtr<Type[]>
   Type* get() const { return mData; }
   explicit operator bool() const { return mData != nullptr; }
 
   // Size in bytes of extra space allocated for padding.
   static size_t AlignmentPaddingSize() { return AlignmentOffset() * 2; }
 
   void PopFront(size_t aSize) {
-    MOZ_ASSERT(mLength >= aSize);
+    MOZ_DIAGNOSTIC_ASSERT(mLength >= aSize, "Popping too many frames");
     PodMove(mData, mData + aSize, mLength - aSize);
     mLength -= aSize;
   }
 
  private:
   static size_t AlignmentOffset() { return Alignment ? Alignment - 1 : 0; }
 
   // Ensure that the backend buffer can hold aLength data. Will update mData.