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 249050 bb90dd41c737aeee7456bf735db2de4f8df81ee8
parent 249049 3f463a602beac1f2d24c5bd5cf2d8b7be2c24a7a
child 249051 5525ed28979760bc6b70dac1855121cb3c17fd52
push id970
push userjryans@gmail.com
push dateTue, 10 Mar 2015 15:54:18 +0000
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;
   }