Bug 805254. Part 1: Remove mFormat from nsAudioStream. r=kinetik
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 25 Oct 2012 23:09:38 +1300
changeset 111617 b9102f7a79c0dc6038954876ce59f5967d662779
parent 111616 dd4d9137c1a5af3365433046a7c5c0ed62799e52
child 111618 c30be4a4cd06a4ac8e608270c26554f4f347d693
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewerskinetik
bugs805254
milestone19.0a1
Bug 805254. Part 1: Remove mFormat from nsAudioStream. r=kinetik
content/media/nsAudioStream.cpp
content/media/nsAudioStream.h
--- a/content/media/nsAudioStream.cpp
+++ b/content/media/nsAudioStream.cpp
@@ -128,17 +128,17 @@ class AudioInitEvent : public nsRunnable
   }
 
   NS_IMETHOD Run()
   {
     ContentChild * cpc = ContentChild::GetSingleton();
     NS_ASSERTION(cpc, "Content Protocol is NULL!");
     mOwner->mAudioChild =  static_cast<AudioChild*>(cpc->SendPAudioConstructor(mOwner->mChannels,
                                                                                mOwner->mRate,
-                                                                               mOwner->mFormat));
+                                                                               MOZ_AUDIO_DATA_FORMAT));
     return NS_OK;
   }
 
   nsRefPtr<nsRemotedAudioStream> mOwner;
 };
 
 class AudioWriteEvent : public nsRunnable
 {
@@ -425,17 +425,16 @@ nsNativeAudioStream::~nsNativeAudioStrea
 }
 
 NS_IMPL_THREADSAFE_ISUPPORTS0(nsNativeAudioStream)
 
 nsresult nsNativeAudioStream::Init(int32_t aNumChannels, int32_t aRate)
 {
   mRate = aRate;
   mChannels = aNumChannels;
-  mFormat = MOZ_AUDIO_DATA_FORMAT;
 
   if (sa_stream_create_pcm(reinterpret_cast<sa_stream_t**>(&mAudioHandle),
                            NULL,
                            SA_MODE_WRONLY,
                            SA_PCM_FORMAT_S16_NE,
                            aRate,
                            aNumChannels) != SA_SUCCESS) {
     mAudioHandle = nullptr;
@@ -630,17 +629,16 @@ nsRemotedAudioStream::~nsRemotedAudioStr
 NS_IMPL_THREADSAFE_ISUPPORTS0(nsRemotedAudioStream)
 
 nsresult
 nsRemotedAudioStream::Init(int32_t aNumChannels,
                            int32_t aRate)
 {
   mRate = aRate;
   mChannels = aNumChannels;
-  mFormat = MOZ_AUDIO_DATA_FORMAT;
   mBytesPerFrame = sizeof(SampleType) * mChannels;
 
   nsCOMPtr<nsIRunnable> event = new AudioInitEvent(this);
   NS_DispatchToMainThread(event, NS_DISPATCH_SYNC);
   return NS_OK;
 }
 
 void
@@ -941,17 +939,16 @@ nsBufferedAudioStream::Init(int32_t aNum
   cubeb* cubebContext = GetCubebContext();
 
   if (!cubebContext || aNumChannels < 0 || aRate < 0) {
     return NS_ERROR_FAILURE;
   }
 
   mRate = aRate;
   mChannels = aNumChannels;
-  mFormat = MOZ_AUDIO_DATA_FORMAT;
 
   cubeb_stream_params params;
   params.rate = aRate;
   params.channels = aNumChannels;
 #ifdef MOZ_SAMPLE_TYPE_S16
   params.format =  CUBEB_SAMPLE_S16NE;
   mBytesPerFrame = sizeof(int16_t) * aNumChannels;
 #else /* MOZ_SAMPLE_TYPE_FLOAT32 */
--- a/content/media/nsAudioStream.h
+++ b/content/media/nsAudioStream.h
@@ -66,17 +66,17 @@ public:
   virtual nsresult Init(int32_t aNumChannels, int32_t aRate) = 0;
 
   // Closes the stream. All future use of the stream is an error.
   // Unsafe to call with a monitor held due to synchronous event execution
   // on the main thread, which may attempt to acquire any held monitor.
   virtual void Shutdown() = 0;
 
   // Write audio data to the audio hardware.  aBuf is an array of frames in
-  // the format specified by mFormat of length aCount.  If aFrames is larger
+  // the format MOZ_AUDIO_DATA_FORMAT of length aCount.  If aFrames is larger
   // than the result of Available(), the write will block until sufficient
   // buffer space is available.
   virtual nsresult Write(const void* aBuf, uint32_t aFrames) = 0;
 
   // Return the number of audio frames that can be written without blocking.
   virtual uint32_t Available() = 0;
 
   // Set the current volume of the audio playback. This is a value from
@@ -114,12 +114,11 @@ public:
   int GetRate() { return mRate; }
   int GetChannels() { return mChannels; }
   SampleFormat GetFormat() { return MOZ_AUDIO_DATA_FORMAT; }
 
 protected:
   nsCOMPtr<nsIThread> mAudioPlaybackThread;
   int mRate;
   int mChannels;
-  SampleFormat mFormat;
 };
 
 #endif