Bug 1530322 - P3. Add temporary diagnostics. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 26 Feb 2019 09:10:04 +0000
changeset 518928 a5516893759bb32fb264c2d69c2ae0880697c018
parent 518927 8ba89b2f60ff62709b44699b9909c00f3f32a5c0
child 518929 78c216fb82c3911c0569b56e050a87064b4b4319
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 temporary diagnostics. r=gerald 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.