Bug 901633 - Part 6 - Update DelayBuffer to use the new AudioChunk methods. r=karlt
authorPaul Adenot <paul@paul.cx>
Thu, 30 Jul 2015 11:27:26 +0200
changeset 260328 10869420ec36d5db74ad3e40d26616c56f137895
parent 260327 b026e7f47823ffbc1f32798f8ce5ba00f964e7f5
child 260329 f13da3f6b4943b43dfab477af39f8c01fff26bc5
push id29307
push userryanvm@gmail.com
push dateWed, 02 Sep 2015 01:01:53 +0000
treeherdermozilla-central@e2eb0442ece9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs901633
milestone43.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 901633 - Part 6 - Update DelayBuffer to use the new AudioChunk methods. r=karlt
dom/media/webaudio/DelayBuffer.cpp
dom/media/webaudio/DelayBuffer.h
--- a/dom/media/webaudio/DelayBuffer.cpp
+++ b/dom/media/webaudio/DelayBuffer.cpp
@@ -151,17 +151,17 @@ DelayBuffer::ReadChannels(const double a
       if (!mChunks[readChunk].IsNull()) {
         int readOffset = OffsetForPosition(positions[tick]);
         UpdateUpmixChannels(readChunk, totalChannelCount,
                             aChannelInterpretation);
         double multiplier = interpolationFactor * mChunks[readChunk].mVolume;
         for (uint32_t channel = aFirstChannel;
              channel < readChannelsEnd; ++channel) {
           aOutputChunk->ChannelFloatsForWrite(channel)[i] += multiplier *
-            static_cast<const float*>(mUpmixChannels[channel])[readOffset];
+            mUpmixChannels[channel][readOffset];
         }
       }
 
       interpolationFactor = 1.0 - interpolationFactor;
     }
   }
 }
 
@@ -233,32 +233,31 @@ void
 DelayBuffer::UpdateUpmixChannels(int aNewReadChunk, uint32_t aChannelCount,
                                  ChannelInterpretation aChannelInterpretation)
 {
   if (aNewReadChunk == mLastReadChunk) {
     MOZ_ASSERT(mUpmixChannels.Length() == aChannelCount);
     return;
   }
 
-  static const float silenceChannel[WEBAUDIO_BLOCK_SIZE] = {};
-
   NS_WARN_IF_FALSE(mHaveWrittenBlock || aNewReadChunk != mCurrentChunk,
                    "Smoothing is making feedback delay too small.");
 
   mLastReadChunk = aNewReadChunk;
-  mUpmixChannels = mChunks[aNewReadChunk].mChannelData;
+  mUpmixChannels = mChunks[aNewReadChunk].ChannelData<float>();
   MOZ_ASSERT(mUpmixChannels.Length() <= aChannelCount);
   if (mUpmixChannels.Length() < aChannelCount) {
     if (aChannelInterpretation == ChannelInterpretation::Speakers) {
-      AudioChannelsUpMix(&mUpmixChannels, aChannelCount, silenceChannel);
+      AudioChannelsUpMix(&mUpmixChannels,
+                         aChannelCount, SilentChannel::ZeroChannel<float>());
       MOZ_ASSERT(mUpmixChannels.Length() == aChannelCount,
                  "We called GetAudioChannelsSuperset to avoid this");
     } else {
       // Fill up the remaining channels with zeros
       for (uint32_t channel = mUpmixChannels.Length();
            channel < aChannelCount; ++channel) {
-        mUpmixChannels.AppendElement(silenceChannel);
+        mUpmixChannels.AppendElement(SilentChannel::ZeroChannel<float>());
       }
     }
   }
 }
 
 } // namespace mozilla
--- a/dom/media/webaudio/DelayBuffer.h
+++ b/dom/media/webaudio/DelayBuffer.h
@@ -89,17 +89,17 @@ private:
   int OffsetForPosition(int aPosition);
   int ChunkForDelay(int aDelay);
   void UpdateUpmixChannels(int aNewReadChunk, uint32_t channelCount,
                            ChannelInterpretation aChannelInterpretation);
 
   // Circular buffer for capturing delayed samples.
   FallibleTArray<AudioChunk> mChunks;
   // Cache upmixed channel arrays.
-  nsAutoTArray<const void*,GUESS_AUDIO_CHANNELS> mUpmixChannels;
+  nsAutoTArray<const float*,GUESS_AUDIO_CHANNELS> mUpmixChannels;
   double mSmoothingRate;
   // Current delay, in fractional ticks
   double mCurrentDelay;
   // Maximum delay, in ticks
   int mMaxDelayTicks;
   // The current position in the circular buffer.  The next write will be to
   // this chunk, and the next read may begin before this chunk.
   int mCurrentChunk;