bug 1186779 add a method to cast AudioChunk data for writing when not shared r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 22 Jul 2015 18:43:30 +1200
changeset 254836 eb35e246091350ef010da8a9ac42dc2efcf83757
parent 254835 1dce18779147b1d9ab6d371f567a5dc74c8111f3
child 254837 44b77af83570ab3e0f98fcf8041b62664135b2c8
push id62867
push userktomlinson@mozilla.com
push dateMon, 27 Jul 2015 23:30:01 +0000
treeherdermozilla-inbound@f59fb21369d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1186779
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 1186779 add a method to cast AudioChunk data for writing when not shared r=padenot
dom/media/AudioSegment.h
dom/media/webaudio/AudioNodeEngine.h
--- a/dom/media/AudioSegment.h
+++ b/dom/media/AudioSegment.h
@@ -145,16 +145,23 @@ struct AudioChunk {
       }
     }
 
     return true;
   }
 
   int ChannelCount() const { return mChannelData.Length(); }
 
+  float* ChannelFloatsForWrite(size_t aChannel)
+  {
+    MOZ_ASSERT(mBufferFormat == AUDIO_FORMAT_FLOAT32);
+    MOZ_ASSERT(!mBuffer->IsShared());
+    return static_cast<float*>(const_cast<void*>(mChannelData[aChannel]));
+  }
+
   bool IsMuted() const { return mVolume == 0.0f; }
 
   size_t SizeOfExcludingThisIfUnshared(MallocSizeOf aMallocSizeOf) const
   {
     return SizeOfExcludingThis(aMallocSizeOf, true);
   }
 
   size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, bool aUnshared) const
--- a/dom/media/webaudio/AudioNodeEngine.h
+++ b/dom/media/webaudio/AudioNodeEngine.h
@@ -110,17 +110,16 @@ public:
   }
 
 private:
   nsAutoTArray<Storage, 2> mContents;
 };
 
 /**
  * Allocates an AudioChunk with fresh buffers of WEBAUDIO_BLOCK_SIZE float samples.
- * AudioChunk::mChannelData's entries can be cast to float* for writing.
  */
 void AllocateAudioBlock(uint32_t aChannelCount, AudioChunk* aChunk);
 
 /**
  * aChunk must have been allocated by AllocateAudioBlock.
  */
 void WriteZeroesToAudioBlock(AudioChunk* aChunk, uint32_t aStart, uint32_t aLength);