Bug 1122372 - Fix dangerous UniquePtr usage pattern in AudioStream. r=cpearce a=lmandel
authorMatthew Gregan <kinetik@flim.org>
Thu, 15 Jan 2015 20:47:00 +1300
changeset 250175 bb90dd41c737
parent 250174 3f463a602bea
child 250176 5525ed289797
push id4521
push usercpearce@mozilla.com
push date2015-03-04 01:22 +0000
treeherdermozilla-beta@8abdbdecd2d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lmandel
bugs1122372
milestone37.0
Bug 1122372 - Fix dangerous UniquePtr usage pattern in AudioStream. r=cpearce a=lmandel
dom/media/AudioStream.h
--- a/dom/media/AudioStream.h
+++ b/dom/media/AudioStream.h
@@ -17,21 +17,19 @@
 #include "CubebUtils.h"
 
 namespace soundtouch {
 class SoundTouch;
 }
 
 namespace mozilla {
 
-template<>
-struct DefaultDelete<cubeb_stream>
+struct DestroyPolicy
 {
-  void operator()(cubeb_stream* aStream) const
-  {
+  void operator()(cubeb_stream* aStream) const {
     cubeb_stream_destroy(aStream);
   }
 };
 
 class AudioStream;
 class FrameHistory;
 
 class AudioClock
@@ -357,17 +355,17 @@ private:
 
   // Temporary audio buffer.  Filled by Write() and consumed by
   // DataCallback().  Once mBuffer is full, Write() blocks until sufficient
   // space becomes available in mBuffer.  mBuffer is sized in bytes, not
   // frames.
   CircularByteBuffer mBuffer;
 
   // Owning reference to a cubeb_stream.
-  UniquePtr<cubeb_stream> mCubebStream;
+  UniquePtr<cubeb_stream, DestroyPolicy> mCubebStream;
 
   uint32_t mBytesPerFrame;
 
   uint32_t BytesToFrames(uint32_t aBytes) {
     NS_ASSERTION(aBytes % mBytesPerFrame == 0,
                  "Byte count not aligned on frames size.");
     return aBytes / mBytesPerFrame;
   }