Bug 814708 - Use nsAutoPtr for mTimeStretcher r=padenot
authorJacek Caban <jacek@codeweavers.com>
Wed, 28 Nov 2012 17:25:57 +0100
changeset 114373 2d3251f224f748bb95a587f3af07159ca2a09435
parent 114372 9c0bd1afbf063a651899ea2275442f8bfe83986d
child 114374 6b05a49691aea310fa8915cc03e25ce76f647b15
push id23917
push useremorley@mozilla.com
push dateThu, 29 Nov 2012 14:20:29 +0000
treeherdermozilla-central@c72d38e7a212 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs814708
milestone20.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 814708 - Use nsAutoPtr for mTimeStretcher r=padenot
content/media/AudioStream.cpp
content/media/AudioStream.h
--- a/content/media/AudioStream.cpp
+++ b/content/media/AudioStream.cpp
@@ -218,21 +218,20 @@ void AudioStream::ShutdownLibrary()
 AudioStream::~AudioStream()
 {
 }
 
 bool AudioStream::EnsureTimeStretcherInitialized()
 {
   if (mTimeStretcher)
     return true;
-  soundtouch::SoundTouch* state = new soundtouch::SoundTouch();
-  if (!state) {
+  mTimeStretcher = new soundtouch::SoundTouch();
+  if (!mTimeStretcher) {
     return false;
   }
-  mTimeStretcher.own(state);
   mTimeStretcher->setSampleRate(mInRate);
   mTimeStretcher->setChannels(mChannels);
   mTimeStretcher->setPitch(1.0);
   return true;
 }
 
 nsresult AudioStream::SetPlaybackRate(double aPlaybackRate)
 {
--- a/content/media/AudioStream.h
+++ b/content/media/AudioStream.h
@@ -5,28 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #if !defined(AudioStream_h_)
 #define AudioStream_h_
 
 #include "nscore.h"
 #include "AudioSampleFormat.h"
 #include "AudioChannelCommon.h"
 #include "soundtouch/SoundTouch.h"
-#include "nsAutoRef.h"
-
-
-template <>
-class nsAutoRefTraits<soundtouch::SoundTouch> : public nsPointerRefTraits<soundtouch::SoundTouch>
-{
-public:
-  static void Release(soundtouch::SoundTouch* resamplerState) {
-    delete resamplerState;
-    resamplerState = nullptr;
-  }
-};
+#include "nsAutoPtr.h"
 
 namespace mozilla {
 
 class AudioStream;
 
 class AudioClock
 {
   public:
@@ -181,14 +170,14 @@ public:
 
 protected:
   // Input rate in Hz (characteristic of the media being played)
   int mInRate;
   // Output rate in Hz (characteristic of the playback rate)
   int mOutRate;
   int mChannels;
   AudioClock mAudioClock;
-  nsAutoRef<soundtouch::SoundTouch> mTimeStretcher;
+  nsAutoPtr<soundtouch::SoundTouch> mTimeStretcher;
 };
 
 } // namespace mozilla
 
 #endif