Backout Bug 612799 due to crashtests orange
authorMarco Bonardo <mbonardo@mozilla.com>
Fri, 10 Jun 2011 19:46:36 +0200
changeset 70881 e598a0c0eb1cbc049409b414db6209710359d5f1
parent 70878 e109c624ae001f2fa0f0d262e64ad4a2a655717e
child 70882 24b3cd3c8ed79f6f8d910015d383f9ac8e90aeac
push id20435
push usereakhgari@mozilla.com
push dateFri, 10 Jun 2011 20:08:22 +0000
treeherdermozilla-central@28217403cd02 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs612799
milestone7.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
Backout Bug 612799 due to crashtests orange
content/media/nsAudioStream.cpp
content/media/nsAudioStream.h
dom/ipc/AudioChild.cpp
dom/ipc/AudioChild.h
dom/ipc/AudioParent.cpp
dom/ipc/AudioParent.h
dom/ipc/PAudio.ipdl
--- a/content/media/nsAudioStream.cpp
+++ b/content/media/nsAudioStream.cpp
@@ -84,21 +84,21 @@ class nsAudioStreamLocal : public nsAudi
 {
  public:
   NS_DECL_ISUPPORTS
 
   ~nsAudioStreamLocal();
   nsAudioStreamLocal();
 
   nsresult Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat);
-  nsresult Shutdown();
+  void Shutdown();
   nsresult Write(const void* aBuf, PRUint32 aCount, PRBool aBlocking);
   PRUint32 Available();
-  nsresult SetVolume(double aVolume);
-  nsresult Drain();
+  void SetVolume(double aVolume);
+  void Drain();
   void Pause();
   void Resume();
   PRInt64 GetPosition();
   PRInt64 GetSampleOffset();
   PRBool IsPaused();
   PRInt32 GetMinWriteSamples();
 
  private:
@@ -128,21 +128,21 @@ class nsAudioStreamRemote : public nsAud
 {
  public:
   NS_DECL_ISUPPORTS
 
   nsAudioStreamRemote();
   ~nsAudioStreamRemote();
 
   nsresult Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat);
-  nsresult Shutdown();
+  void Shutdown();
   nsresult Write(const void* aBuf, PRUint32 aCount, PRBool aBlocking);
   PRUint32 Available();
-  nsresult SetVolume(double aVolume);
-  nsresult Drain();
+  void SetVolume(double aVolume);
+  void Drain();
   void Pause();
   void Resume();
   PRInt64 GetPosition();
   PRInt64 GetSampleOffset();
   PRBool IsPaused();
   PRInt32 GetMinWriteSamples();
 
 private:
@@ -405,18 +405,17 @@ nsAudioStreamLocal::nsAudioStreamLocal()
 
 nsAudioStreamLocal::~nsAudioStreamLocal()
 {
   Shutdown();
 }
 
 NS_IMPL_THREADSAFE_ISUPPORTS0(nsAudioStreamLocal)
 
-nsresult 
-nsAudioStreamLocal::Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat)
+nsresult nsAudioStreamLocal::Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat)
 {
   mRate = aRate;
   mChannels = aNumChannels;
   mFormat = aFormat;
 
   if (sa_stream_create_pcm(reinterpret_cast<sa_stream_t**>(&mAudioHandle),
                            NULL, 
                            SA_MODE_WRONLY, 
@@ -436,31 +435,24 @@ nsAudioStreamLocal::Init(PRInt32 aNumCha
     PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsAudioStreamLocal: sa_stream_open error"));
     return NS_ERROR_FAILURE;
   }
   mInError = PR_FALSE;
 
   return NS_OK;
 }
 
-nsresult
-nsAudioStreamLocal::Shutdown()
+void nsAudioStreamLocal::Shutdown()
 {
   if (!mAudioHandle)
-    return NS_ERROR_FAILURE;
+    return;
 
-  if (sa_stream_destroy(static_cast<sa_stream_t*>(mAudioHandle)));
-  {
-    PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsAudioStreamLocal: sa_stream_destroy error"));
-    mInError = true;
-    return NS_ERROR_FAILURE;
-  }
+  sa_stream_destroy(static_cast<sa_stream_t*>(mAudioHandle));
   mAudioHandle = nsnull;
   mInError = PR_TRUE;
-  return NS_OK;
 }
 
 nsresult nsAudioStreamLocal::Write(const void* aBuf, PRUint32 aCount, PRBool aBlocking)
 {
   NS_ABORT_IF_FALSE(aCount % mChannels == 0,
                     "Buffer size must be divisible by channel count");
   NS_ASSERTION(!mPaused, "Don't write audio when paused, you'll block");
 
@@ -550,56 +542,51 @@ PRUint32 nsAudioStreamLocal::Available()
 
   size_t s = 0; 
   if (sa_stream_get_write_size(static_cast<sa_stream_t*>(mAudioHandle), &s) != SA_SUCCESS)
     return 0;
 
   return s / sizeof(short);
 }
 
-nsresult
-nsAudioStreamLocal::SetVolume(double aVolume)
+void nsAudioStreamLocal::SetVolume(double aVolume)
 {
   NS_ASSERTION(aVolume >= 0.0 && aVolume <= 1.0, "Invalid volume");
 #if defined(SA_PER_STREAM_VOLUME)
   if (sa_stream_set_volume_abs(static_cast<sa_stream_t*>(mAudioHandle), aVolume) != SA_SUCCESS) {
     PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsAudioStreamLocal: sa_stream_set_volume_abs error"));
     mInError = PR_TRUE;
-    return NS_ERROR_FAILURE;
   }
 #else
   mVolume = aVolume;
 #endif
-  return NS_OK;
 }
 
-nsresult nsAudioStreamLocal::Drain()
+void nsAudioStreamLocal::Drain()
 {
   NS_ASSERTION(!mPaused, "Don't drain audio when paused, it won't finish!");
 
   if (mInError)
-    return NS_ERROR_FAILURE;
+    return;
 
   // Write any remaining unwritten sound data in the overflow buffer
   if (!mBufferOverflow.IsEmpty()) {
     if (sa_stream_write(static_cast<sa_stream_t*>(mAudioHandle),
                         mBufferOverflow.Elements(),
                         mBufferOverflow.Length() * sizeof(short)) != SA_SUCCESS)
       PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsAudioStreamLocal: sa_stream_write error"));
       mInError = PR_TRUE;
-      return NS_ERROR_FAILURE;
+      return;
   }
 
   int r = sa_stream_drain(static_cast<sa_stream_t*>(mAudioHandle));
   if (r != SA_SUCCESS && r != SA_ERROR_INVALID) {
     PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsAudioStreamLocal: sa_stream_drain error"));
     mInError = PR_TRUE;
-    return NS_ERROR_FAILURE;
   }
-  return NS_OK;
 }
 
 void nsAudioStreamLocal::Pause()
 {
   if (mInError)
     return;
   mPaused = PR_TRUE;
   sa_stream_pause(static_cast<sa_stream_t*>(mAudioHandle));
@@ -698,33 +685,32 @@ nsAudioStreamRemote::Init(PRInt32 aNumCh
     }
   }
 
   nsCOMPtr<nsIRunnable> event = new AudioInitEvent(this);
   NS_DispatchToMainThread(event, NS_DISPATCH_SYNC);
   return NS_OK;
 }
 
-nsresult
+void
 nsAudioStreamRemote::Shutdown()
 {
   if (!mAudioChild)
-    return NS_ERROR_FAILURE;
+    return;
   nsCOMPtr<nsIRunnable> event = new AudioShutdownEvent(mAudioChild);
   NS_DispatchToMainThread(event);
   mAudioChild = nsnull;
-  return NS_OK;
 }
 
 nsresult
 nsAudioStreamRemote::Write(const void* aBuf,
                            PRUint32 aCount,
                            PRBool aBlocking)
 {
-  if (!mAudioChild || mAudioChild->IsInError())
+  if (!mAudioChild)
     return NS_ERROR_FAILURE;
   nsCOMPtr<nsIRunnable> event = new AudioWriteEvent(mAudioChild,
                                                     aBuf,
                                                     aCount,
                                                     mBytesPerSample);
   NS_DispatchToMainThread(event);
   return NS_OK;
 }
@@ -739,52 +725,51 @@ PRInt32 nsAudioStreamRemote::GetMinWrite
 {
   if (!mAudioChild)
     return -1;
   nsCOMPtr<nsIRunnable> event = new AudioMinWriteSampleEvent(mAudioChild);
   NS_DispatchToMainThread(event);
   return mAudioChild->WaitForMinWriteSample();
 }
 
-nsresult
+void
 nsAudioStreamRemote::SetVolume(double aVolume)
 {
-  if (!mAudioChild || mAudioChild->IsInError())
-    return NS_ERROR_FAILURE;
+  if (!mAudioChild)
+    return;
   nsCOMPtr<nsIRunnable> event = new AudioSetVolumeEvent(mAudioChild, aVolume);
   NS_DispatchToMainThread(event);
-  return NS_OK;
 }
 
-nsresult
+void
 nsAudioStreamRemote::Drain()
 {
   if (!mAudioChild)
-    return NS_ERROR_FAILURE;
+    return;
   nsCOMPtr<nsIRunnable> event = new AudioDrainEvent(mAudioChild);
   NS_DispatchToMainThread(event);
-  return mAudioChild->WaitForDrain();
+  mAudioChild->WaitForDrain();
 }
-
+ 
 void
 nsAudioStreamRemote::Pause()
 {
-  if (!mAudioChild || mAudioChild->IsInError())
+  mPaused = PR_TRUE;
+  if (!mAudioChild)
     return;
-  mPaused = PR_TRUE;
   nsCOMPtr<nsIRunnable> event = new AudioPauseEvent(mAudioChild, PR_TRUE);
   NS_DispatchToMainThread(event);
 }
 
 void
 nsAudioStreamRemote::Resume()
 {
-  if (!mAudioChild || mAudioChild->IsInError())
+  mPaused = PR_FALSE;
+  if (!mAudioChild)
     return;
-  mPaused = PR_FALSE;
   nsCOMPtr<nsIRunnable> event = new AudioPauseEvent(mAudioChild, PR_FALSE);
   NS_DispatchToMainThread(event);
 }
 
 PRInt64 nsAudioStreamRemote::GetPosition()
 {
   PRInt64 sampleOffset = GetSampleOffset();
   if (sampleOffset >= 0) {
--- a/content/media/nsAudioStream.h
+++ b/content/media/nsAudioStream.h
@@ -74,36 +74,36 @@ public:
   static nsAudioStream* AllocateStream();
 
   // Initialize the audio stream. aNumChannels is the number of audio channels 
   // (1 for mono, 2 for stereo, etc) and aRate is the frequency of the sound 
   // samples (22050, 44100, etc).
   virtual nsresult Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat) = 0;
 
   // Closes the stream. All future use of the stream is an error.
-  virtual nsresult Shutdown() = 0;
+  virtual void Shutdown() = 0;
 
   // Write sound data to the audio hardware.  aBuf is an array of samples in
   // the format specified by mFormat of length aCount.  aCount should be
   // evenly divisible by the number of channels in this audio stream.
   // When aBlocking is PR_TRUE, we'll block until the write has completed,
   // otherwise we'll buffer any data we can't write immediately, and write
   // it in a later call.
   virtual nsresult Write(const void* aBuf, PRUint32 aCount, PRBool aBlocking) = 0;
 
   // Return the number of sound samples that can be written to the audio device
   // without blocking.
   virtual PRUint32 Available() = 0;
 
   // Set the current volume of the audio playback. This is a value from
   // 0 (meaning muted) to 1 (meaning full volume).
-  virtual nsresult SetVolume(double aVolume) = 0;
+  virtual void SetVolume(double aVolume) = 0;
 
   // Block until buffered audio data has been consumed.
-  virtual nsresult Drain() = 0;
+  virtual void Drain() = 0;
 
   // Pause audio playback
   virtual void Pause() = 0;
 
   // Resume audio playback
   virtual void Resume() = 0;
 
   // Return the position in microseconds of the sample being played by the
--- a/dom/ipc/AudioChild.cpp
+++ b/dom/ipc/AudioChild.cpp
@@ -71,34 +71,24 @@ AudioChild::RecvSampleOffsetUpdate(const
                                    const PRInt64& time)
 {
   mLastSampleOffset = offset;
   mLastSampleOffsetTime = time;
   return true;
 }
 
 bool
-AudioChild::RecvDrainDone(const nsresult& status)
+AudioChild::RecvDrainDone()
 {
   ReentrantMonitorAutoEnter mon(mAudioReentrantMonitor);
-
-  if (status == NS_OK)
-    mDrained = PR_TRUE;
-
+  mDrained = PR_TRUE;
   mAudioReentrantMonitor.NotifyAll();
   return true;
 }
 
-bool
-AudioChild::RecvEnteringErrorState()
-{
-  mInError = PR_TRUE;
-  return true;
-}
-
 PRInt32
 AudioChild::WaitForMinWriteSample()
 {
   ReentrantMonitorAutoEnter mon(mAudioReentrantMonitor);
   // -2 : initial value
   while (mMinWriteSample == -2 && mIPCOpen)
     mAudioReentrantMonitor.Wait();
   return mMinWriteSample;
@@ -108,27 +98,23 @@ bool
 AudioChild::RecvMinWriteSampleDone(const PRInt32& minSamples)
 {
   ReentrantMonitorAutoEnter mon(mAudioReentrantMonitor);
   mMinWriteSample = minSamples;
   mAudioReentrantMonitor.NotifyAll();
   return true;
 }
 
-nsresult
+void
 AudioChild::WaitForDrain()
 {
   ReentrantMonitorAutoEnter mon(mAudioReentrantMonitor);
   while (!mDrained && mIPCOpen) {
     mAudioReentrantMonitor.Wait();
   }
-  if (mDrained)
-    return NS_OK;
-
-  return NS_ERROR_FAILURE;
 }
 
 PRInt64
 AudioChild::GetLastKnownSampleOffset()
 {
   return mLastSampleOffset;
 }
 
--- a/dom/ipc/AudioChild.h
+++ b/dom/ipc/AudioChild.h
@@ -50,35 +50,32 @@ class AudioChild : public PAudioChild
 {
  public:
     NS_IMETHOD_(nsrefcnt) AddRef();
     NS_IMETHOD_(nsrefcnt) Release();
 
     AudioChild();
     virtual ~AudioChild();
     virtual bool RecvSampleOffsetUpdate(const PRInt64&, const PRInt64&);
-    virtual bool RecvEnteringErrorState();
-    virtual bool RecvDrainDone(const nsresult& status);
+    virtual bool RecvDrainDone();
     virtual PRInt32 WaitForMinWriteSample();
     virtual bool RecvMinWriteSampleDone(const PRInt32& sampleCount);
-    virtual nsresult WaitForDrain();
+    virtual void WaitForDrain();
     virtual void ActorDestroy(ActorDestroyReason);
 
     PRInt64 GetLastKnownSampleOffset();
     PRInt64 GetLastKnownSampleOffsetTime();
 
     PRBool IsIPCOpen() { return mIPCOpen; };
-    PRBool IsInError() { return mInError; };
  private:
     nsAutoRefCnt mRefCnt;
     NS_DECL_OWNINGTHREAD
     PRInt64 mLastSampleOffset, mLastSampleOffsetTime;
     PRInt32 mMinWriteSample;
     mozilla::ReentrantMonitor mAudioReentrantMonitor;
     PRPackedBool mIPCOpen;
     PRPackedBool mDrained;
-    PRPackedBool mInError;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif
--- a/dom/ipc/AudioParent.cpp
+++ b/dom/ipc/AudioParent.cpp
@@ -43,34 +43,31 @@
 
 // C++ file contents
 namespace mozilla {
 namespace dom {
 
 class AudioWriteEvent : public nsRunnable
 {
  public:
-  AudioWriteEvent(AudioParent* parent, nsAudioStream* owner, nsCString data, PRUint32 count)
+  AudioWriteEvent(nsAudioStream* owner, nsCString data, PRUint32 count)
   {
-    mParent = parent;
     mOwner = owner;
     mData  = data;
     mCount = count;
   }
 
   NS_IMETHOD Run()
   {
-    if (mOwner->Write(mData.get(), mCount, true) != NS_OK) 
-      mParent->EnteringErrorState();
+    mOwner->Write(mData.get(), mCount, true);
     return NS_OK;
   }
 
  private:
     nsRefPtr<nsAudioStream> mOwner;
-    nsRefPtr<AudioParent> mParent;
     nsCString mData;
     PRUint32  mCount;
 };
 
 class AudioPauseEvent : public nsRunnable
 {
  public:
   AudioPauseEvent(nsAudioStream* owner, PRBool aPause)
@@ -152,46 +149,44 @@ class AudioMinWriteSampleEvent : public 
  private:
     nsRefPtr<nsAudioStream> mOwner;
     nsRefPtr<AudioParent> mParent;
 };
 
 class AudioDrainDoneEvent : public nsRunnable
 {
  public:
-  AudioDrainDoneEvent(AudioParent* owner, nsresult status)
+  AudioDrainDoneEvent(AudioParent* owner)
   {
     mOwner = owner;
-    mStatus = status;
   }
 
   NS_IMETHOD Run()
   {
-    mOwner->SendDrainDone(mStatus);
+    mOwner->SendDrainDone();
     return NS_OK;
   }
 
  private:
     nsRefPtr<AudioParent> mOwner;
-    nsresult mStatus;
 };
 
 class AudioDrainEvent : public nsRunnable
 {
  public:
   AudioDrainEvent(AudioParent* parent, nsAudioStream* owner)
   {
     mParent = parent;
     mOwner = owner;
   }
 
   NS_IMETHOD Run()
   {
-    nsresult rv = mOwner->Drain();
-    nsCOMPtr<nsIRunnable> event = new AudioDrainDoneEvent(mParent, rv);
+    mOwner->Drain();
+    nsCOMPtr<nsIRunnable> event = new AudioDrainDoneEvent(mParent);
     NS_DispatchToMainThread(event);
     return NS_OK;
   }
 
  private:
     nsRefPtr<nsAudioStream> mOwner;
     nsRefPtr<AudioParent> mParent;
 };
@@ -214,17 +209,17 @@ AudioParent::Notify(nsITimer* timer)
 
 bool
 AudioParent::RecvWrite(
         const nsCString& data,
         const PRUint32& count)
 {
   if (!mStream)
     return false;
-  nsCOMPtr<nsIRunnable> event = new AudioWriteEvent(this, mStream, data, count);
+  nsCOMPtr<nsIRunnable> event = new AudioWriteEvent(mStream, data, count);
   nsCOMPtr<nsIThread> thread = mStream->GetThread();
   thread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
   return true;
 }
 
 bool
 AudioParent::RecvSetVolume(const float& aVolume)
 {
@@ -281,50 +276,42 @@ AudioParent::RecvResume()
 bool
 AudioParent::RecvShutdown()
 {
   Shutdown();
   unused << PAudioParent::Send__delete__(this);
   return true;
 }
 
-void
-AudioParent::EnteringErrorState()
-{
-  if (mIPCOpen)
-    PAudioParent::SendEnteringErrorState();
-}
-
 bool
 AudioParent::SendMinWriteSampleDone(PRInt32 minSamples)
 {
   if (mIPCOpen)
     return PAudioParent::SendMinWriteSampleDone(minSamples);
   return true;
 }
 
 bool
-AudioParent::SendDrainDone(nsresult status)
+AudioParent::SendDrainDone()
 {
   if (mIPCOpen)
-    return PAudioParent::SendDrainDone(status);
+    return PAudioParent::SendDrainDone();
   return true;
 }
 
 AudioParent::AudioParent(PRInt32 aNumChannels, PRInt32 aRate, PRInt32 aFormat)
   : mIPCOpen(PR_TRUE)
 {
   mStream = nsAudioStream::AllocateStream();
   NS_ASSERTION(mStream, "AudioStream allocation failed.");
   if (NS_FAILED(mStream->Init(aNumChannels,
                               aRate,
                               (nsAudioStream::SampleFormat) aFormat))) {
       NS_WARNING("AudioStream initialization failed.");
       mStream = nsnull;
-      EnteringErrorState();
       return;
   }
 
   mTimer = do_CreateInstance("@mozilla.org/timer;1");
   mTimer->InitWithCallback(this, 1000, nsITimer::TYPE_REPEATING_SLACK);
 }
 
 AudioParent::~AudioParent()
--- a/dom/ipc/AudioParent.h
+++ b/dom/ipc/AudioParent.h
@@ -75,24 +75,22 @@ class AudioParent : public PAudioParent,
 
     virtual bool
     RecvShutdown();
 
     virtual bool
     SendMinWriteSampleDone(PRInt32 minSamples);
 
     virtual bool
-    SendDrainDone(nsresult status);
+    SendDrainDone();
 
     AudioParent(PRInt32 aNumChannels, PRInt32 aRate, PRInt32 aFormat);
     virtual ~AudioParent();
     virtual void ActorDestroy(ActorDestroyReason);
 
-    void EnteringErrorState();
-
     nsRefPtr<nsAudioStream> mStream;
     nsCOMPtr<nsITimer> mTimer;
 
 private:
     void Shutdown();
 
     PRPackedBool mIPCOpen;
 };
--- a/dom/ipc/PAudio.ipdl
+++ b/dom/ipc/PAudio.ipdl
@@ -60,15 +60,14 @@ parent:
   Shutdown();
 
  child:
 
   __delete__();
 
   SampleOffsetUpdate(PRInt64 offset, PRInt64 time);
   MinWriteSampleDone(PRInt32 sampleCount);
-  DrainDone(nsresult status);
- 
-  EnteringErrorState();
+  DrainDone();
+
 };
 
 } // namespace dom
 } // namespace mozilla