Bug 1182808 - Part 1: Add and use fallible variant of AlignedTArray_Impl::SetLength. r=padenot
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Wed, 15 Jul 2015 12:58:15 -0700
changeset 253098 31e0ecbf97812fb9f9b5a16dab9680c45809cb0c
parent 253097 5ebdd39f878955a2a8de6b9c4acf2bebeb233663
child 253099 6adef19499671e44b0feaa79434f9b407a75cd16
push id29061
push userryanvm@gmail.com
push dateThu, 16 Jul 2015 18:53:45 +0000
treeherdermozilla-central@a0f4a688433d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1182808
milestone42.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 1182808 - Part 1: Add and use fallible variant of AlignedTArray_Impl::SetLength. r=padenot
dom/media/webaudio/AlignedTArray.h
dom/media/webaudio/AnalyserNode.cpp
--- a/dom/media/webaudio/AlignedTArray.h
+++ b/dom/media/webaudio/AlignedTArray.h
@@ -26,19 +26,27 @@ public:
 
   AlignedTArray_Impl() {}
   explicit AlignedTArray_Impl(size_type capacity) : base_type(capacity+sExtra) {}
   elem_type* Elements() { return getAligned(base_type::Elements()); }
   const elem_type* Elements() const { return getAligned(base_type::Elements()); }
   elem_type& operator[](index_type i) { return Elements()[i];}
   const elem_type& operator[](index_type i) const { return Elements()[i]; }
 
-  typename Alloc::ResultType SetLength(size_type newLen) {
-    return base_type::SetLength(newLen + sExtra);
+  void SetLength(size_type newLen)
+  {
+    base_type::SetLength(newLen + sExtra);
   }
+
+  MOZ_WARN_UNUSED_RESULT
+  bool SetLength(size_type newLen, const mozilla::fallible_t&)
+  {
+    return base_type::SetLength(newLen + sExtra, mozilla::fallible);
+  }
+
   size_type Length() const {
     return base_type::Length() <= sExtra ? 0 : base_type::Length() - sExtra;
   }
 
 private:
   AlignedTArray_Impl(const AlignedTArray_Impl& other) = delete;
   void operator=(const AlignedTArray_Impl& other) = delete;
 
--- a/dom/media/webaudio/AnalyserNode.cpp
+++ b/dom/media/webaudio/AnalyserNode.cpp
@@ -250,17 +250,17 @@ AnalyserNode::GetByteTimeDomainData(cons
 bool
 AnalyserNode::FFTAnalysis()
 {
   float* inputBuffer;
   AlignedFallibleTArray<float> tmpBuffer;
   if (mWriteIndex == 0) {
     inputBuffer = mBuffer.Elements();
   } else {
-    if (!tmpBuffer.SetLength(FftSize())) {
+    if (!tmpBuffer.SetLength(FftSize(), fallible)) {
       return false;
     }
     inputBuffer = tmpBuffer.Elements();
     memcpy(inputBuffer, mBuffer.Elements() + mWriteIndex, sizeof(float) * (FftSize() - mWriteIndex));
     memcpy(inputBuffer + FftSize() - mWriteIndex, mBuffer.Elements(), sizeof(float) * mWriteIndex);
   }
 
   ApplyBlackmanWindow(inputBuffer, FftSize());
@@ -296,23 +296,23 @@ AnalyserNode::ApplyBlackmanWindow(float*
   }
 }
 
 bool
 AnalyserNode::AllocateBuffer()
 {
   bool result = true;
   if (mBuffer.Length() != FftSize()) {
-    if (!mBuffer.SetLength(FftSize())) {
+    if (!mBuffer.SetLength(FftSize(), fallible)) {
       return false;
     }
     memset(mBuffer.Elements(), 0, sizeof(float) * FftSize());
     mWriteIndex = 0;
 
-    if (!mOutputBuffer.SetLength(FrequencyBinCount())) {
+    if (!mOutputBuffer.SetLength(FrequencyBinCount(), fallible)) {
       return false;
     }
     memset(mOutputBuffer.Elements(), 0, sizeof(float) * FrequencyBinCount());
   }
   return result;
 }
 
 void