Bug 726891. Move rate/channels/format up to nsAudioStream and add inline getters. r=kinetik
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 14 Feb 2012 17:39:33 +1300
changeset 86807 a8d19ab244cad3e322bb07c420827a5b6e9fe5fd
parent 86806 7812b8eae381fdc36baad319e38444a8ae4b515e
child 86808 3cf4980b7bd1c5fdc38ff65ede9c38ce50bf8cac
push id22058
push usermak77@bonardo.net
push dateWed, 15 Feb 2012 16:38:33 +0000
treeherdermozilla-central@46e22ce549b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs726891
milestone13.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 726891. Move rate/channels/format up to nsAudioStream and add inline getters. r=kinetik
content/media/nsAudioStream.cpp
content/media/nsAudioStream.h
--- a/content/media/nsAudioStream.cpp
+++ b/content/media/nsAudioStream.cpp
@@ -112,20 +112,16 @@ class nsNativeAudioStream : public nsAud
   PRInt64 GetPositionInFrames();
   bool IsPaused();
   PRInt32 GetMinWriteSize();
 
  private:
 
   double mVolume;
   void* mAudioHandle;
-  int mRate;
-  int mChannels;
-
-  SampleFormat mFormat;
 
   // True if this audio stream is paused.
   bool mPaused;
 
   // True if this stream has encountered an error.
   bool mInError;
 
 };
@@ -150,20 +146,16 @@ class nsRemotedAudioStream : public nsAu
   PRInt64 GetPosition();
   PRInt64 GetPositionInFrames();
   bool IsPaused();
   PRInt32 GetMinWriteSize();
 
 private:
   nsRefPtr<AudioChild> mAudioChild;
 
-  SampleFormat mFormat;
-  int mRate;
-  int mChannels;
-
   PRInt32 mBytesPerFrame;
 
   // True if this audio stream is paused.
   bool mPaused;
 
   friend class AudioInitEvent;
 };
 
@@ -425,19 +417,16 @@ nsAudioStream::~nsAudioStream()
     nsCOMPtr<nsIRunnable> event = new AsyncShutdownPlaybackThread(mAudioPlaybackThread);
     NS_DispatchToMainThread(event);
   }
 }
 
 nsNativeAudioStream::nsNativeAudioStream() :
   mVolume(1.0),
   mAudioHandle(0),
-  mRate(0),
-  mChannels(0),
-  mFormat(FORMAT_S16_LE),
   mPaused(false),
   mInError(false)
 {
 }
 
 nsNativeAudioStream::~nsNativeAudioStream()
 {
   Shutdown();
@@ -649,19 +638,16 @@ PRInt32 nsNativeAudioStream::GetMinWrite
     return -1;
 
   return static_cast<PRInt32>(size / mChannels / sizeof(short));
 }
 
 #if defined(REMOTE_AUDIO)
 nsRemotedAudioStream::nsRemotedAudioStream()
  : mAudioChild(nsnull),
-   mFormat(FORMAT_S16_LE),
-   mRate(0),
-   mChannels(0),
    mBytesPerFrame(0),
    mPaused(false)
 {}
 
 nsRemotedAudioStream::~nsRemotedAudioStream()
 {
   Shutdown();
 }
@@ -871,19 +857,16 @@ private:
 
   // Software volume level.  Applied during the servicing of DataCallback().
   double mVolume;
 
   // Owning reference to a cubeb_stream.  cubeb_stream_destroy is called by
   // nsAutoRef's destructor.
   nsAutoRef<cubeb_stream> mCubebStream;
 
-  PRInt32 mRate;
-  PRInt32 mChannels;
-  SampleFormat mFormat;
   PRUint32 mBytesPerFrame;
 
   enum StreamState {
     INITIALIZED, // Initialized, playback has not begun.
     STARTED,     // Started by a call to Write() (iff INITIALIZED) or Resume().
     STOPPED,     // Stopped by a call to Pause().
     DRAINING,    // Drain requested.  DataCallback will indicate end of stream
                  // once the remaining contents of mBuffer are requested by
@@ -912,17 +895,17 @@ nsAudioStream* nsAudioStream::AllocateSt
     return new nsBufferedAudioStream();
   }
 #endif
   return new nsNativeAudioStream();
 }
 
 #if defined(MOZ_CUBEB)
 nsBufferedAudioStream::nsBufferedAudioStream()
-  : mMonitor("nsBufferedAudioStream"), mLostFrames(0), mVolume(1.0), mRate(0), mChannels(0),
+  : mMonitor("nsBufferedAudioStream"), mLostFrames(0), mVolume(1.0),
     mBytesPerFrame(0), mState(INITIALIZED)
 {
 }
 
 nsBufferedAudioStream::~nsBufferedAudioStream()
 {
   Shutdown();
 }
--- a/content/media/nsAudioStream.h
+++ b/content/media/nsAudioStream.h
@@ -49,16 +49,22 @@ public:
 
   enum SampleFormat
   {
     FORMAT_U8,
     FORMAT_S16_LE,
     FORMAT_FLOAT32
   };
 
+  nsAudioStream()
+    : mRate(0),
+      mChannels(0),
+      mFormat(FORMAT_S16_LE)
+  {}
+
   virtual ~nsAudioStream();
 
   // Initialize Audio Library. Some Audio backends require initializing the
   // library before using it.
   static void InitLibrary();
 
   // Shutdown Audio Library. Some Audio backends require shutting down the
   // library after using it.
@@ -117,13 +123,20 @@ public:
   // Returns true when the audio stream is paused.
   virtual bool IsPaused() = 0;
 
   // Returns the minimum number of audio frames which must be written before
   // you can be sure that something will be played.
   // Unsafe to call with the decoder monitor held.
   virtual PRInt32 GetMinWriteSize() = 0;
 
+  int GetRate() { return mRate; }
+  int GetChannels() { return mChannels; }
+  SampleFormat GetFormat() { return mFormat; }
+
 protected:
   nsCOMPtr<nsIThread> mAudioPlaybackThread;
+  int mRate;
+  int mChannels;
+  SampleFormat mFormat;
 };
 
 #endif