bug 1203380 add custom AudioBlock copy constructor and make AudioChunk conversion constructor explicit r=padenot
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 10 Sep 2015 09:29:34 +1200
changeset 296416 3f4912c6cf479fba90859f6cb9be99c8fd702819
parent 296415 0919409dd75fa4b326619879f212d34fdc213994
child 296417 cffdd225055ecd92fc9005a5851103bd844e1dd6
child 296465 dc09037597461b7550f6ddc7359af6a9b80b9ed3
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1203380
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 1203380 add custom AudioBlock copy constructor and make AudioChunk conversion constructor explicit r=padenot Making the conversion constructor explicit means that it will be obvious if a temporary is created to pass an AudioChunk as an AudioBlock parameter.
dom/media/webaudio/AudioBlock.h
--- a/dom/media/webaudio/AudioBlock.h
+++ b/dom/media/webaudio/AudioBlock.h
@@ -19,19 +19,26 @@ namespace mozilla {
  * Use on graph thread only.
  */
 class AudioBlock : private AudioChunk
 {
 public:
   AudioBlock() {
     mDuration = WEBAUDIO_BLOCK_SIZE;
   }
-  MOZ_IMPLICIT AudioBlock(const AudioChunk& aChunk) {
-    mDuration = WEBAUDIO_BLOCK_SIZE;
-    operator=(aChunk);
+  // No effort is made in constructors to ensure that mBufferIsDownstreamRef
+  // is set because the block is expected to be a temporary and so the
+  // reference will be released before the next iteration.
+  // The custom copy constructor is required so as not to set
+  // mBufferIsDownstreamRef without notifying AudioBlockBuffer.
+  AudioBlock(const AudioBlock& aBlock) : AudioChunk(aBlock.AsAudioChunk()) {}
+  explicit AudioBlock(const AudioChunk& aChunk)
+    : AudioChunk(aChunk)
+  {
+    MOZ_ASSERT(aChunk.mDuration == WEBAUDIO_BLOCK_SIZE);
   }
   ~AudioBlock();
 
   using AudioChunk::GetDuration;
   using AudioChunk::IsNull;
   using AudioChunk::ChannelCount;
   using AudioChunk::ChannelData;
   using AudioChunk::SizeOfExcludingThisIfUnshared;