Bug 624572 - Abort in content process receiving PAudio:SampleOffsetUpdate r=dougt a=blocking-fennec
authorMatthew Gregan <kinetik@flim.org>
Fri, 28 Jan 2011 21:40:23 -0800
changeset 61615 7dc2ef0666bcd942ac118d2ed82bc5de0b220114
parent 61614 11638b7314557166f2ce849e9f84e74ad0b30b79
child 61616 28bef0ccd9278beb0e136c0f9bc6f66f38a72209
push idunknown
push userunknown
push dateunknown
reviewersdougt, blocking-fennec
bugs624572
milestone2.0b11pre
Bug 624572 - Abort in content process receiving PAudio:SampleOffsetUpdate r=dougt a=blocking-fennec
content/media/nsAudioStream.cpp
dom/ipc/AudioParent.cpp
dom/ipc/AudioParent.h
dom/ipc/PAudio.ipdl
--- a/content/media/nsAudioStream.cpp
+++ b/content/media/nsAudioStream.cpp
@@ -282,17 +282,17 @@ class AudioShutdownEvent : public nsRunn
   AudioShutdownEvent(AudioChild* aChild)
   {
     mAudioChild = aChild;
   }
 
   NS_IMETHOD Run()
   {
     if (mAudioChild->IsIPCOpen())
-      PAudioChild::Send__delete__(mAudioChild);
+      mAudioChild->SendShutdown();
     return NS_OK;
   }
   
   nsRefPtr<AudioChild> mAudioChild;
 };
 #endif // MOZ_IPC
 
 
--- a/dom/ipc/AudioParent.cpp
+++ b/dom/ipc/AudioParent.cpp
@@ -214,30 +214,20 @@ AudioParent::RecvResume()
     return false;
   nsCOMPtr<nsIRunnable> event = new AudioPauseEvent(mStream, PR_FALSE);
   nsCOMPtr<nsIThread> thread = mStream->GetThread();
   thread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
   return true;
 }
 
 bool
-AudioParent::Recv__delete__()
+AudioParent::RecvShutdown()
 {
-  if (mTimer) {
-    mTimer->Cancel();
-    mTimer = nsnull;
-  }
-
-  if (mStream) {
-      nsCOMPtr<nsIRunnable> event = new AudioStreamShutdownEvent(mStream);
-      nsCOMPtr<nsIThread> thread = mStream->GetThread();
-      thread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
-      mStream = nsnull;
-  }
-
+  Shutdown();
+  PAudioParent::Send__delete__(this);
   return true;
 }
 
 AudioParent::AudioParent(PRInt32 aNumChannels, PRInt32 aRate, PRInt32 aFormat)
   : mIPCOpen(PR_TRUE)
 {
   mStream = nsAudioStream::AllocateStream();
   NS_ASSERTION(mStream, "AudioStream allocation failed.");
@@ -256,12 +246,30 @@ AudioParent::AudioParent(PRInt32 aNumCha
 AudioParent::~AudioParent()
 {
 }
 
 void
 AudioParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   mIPCOpen = PR_FALSE;
+
+  Shutdown();
+}
+
+void
+AudioParent::Shutdown()
+{
+  if (mTimer) {
+    mTimer->Cancel();
+    mTimer = nsnull;
+  }
+
+  if (mStream) {
+      nsCOMPtr<nsIRunnable> event = new AudioStreamShutdownEvent(mStream);
+      nsCOMPtr<nsIThread> thread = mStream->GetThread();
+      thread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
+      mStream = nsnull;
+  }
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/ipc/AudioParent.h
+++ b/dom/ipc/AudioParent.h
@@ -66,24 +66,26 @@ class AudioParent : public PAudioParent,
 
     virtual bool
     RecvPause();
 
     virtual bool
     RecvResume();
 
     virtual bool
-    Recv__delete__();
+    RecvShutdown();
 
     AudioParent(PRInt32 aNumChannels, PRInt32 aRate, PRInt32 aFormat);
     virtual ~AudioParent();
     virtual void ActorDestroy(ActorDestroyReason);
 
     nsRefPtr<nsAudioStream> mStream;
     nsCOMPtr<nsITimer> mTimer;
 
 private:
+    void Shutdown();
+
     PRPackedBool mIPCOpen;
 };
 } // namespace dom
 } // namespace mozilla
 
 #endif
--- a/dom/ipc/PAudio.ipdl
+++ b/dom/ipc/PAudio.ipdl
@@ -43,29 +43,29 @@ namespace mozilla {
 namespace dom {
 
 protocol PAudio
 {
   manager PContent;
 
 parent:
 
-  __delete__();
-
   Write(nsCString data, PRUint32 count);
 
   SetVolume(float aVolume);
 
   Drain();
 
   Pause();
   Resume();
+  Shutdown();
 
  child:
 
+  __delete__();
+
   SampleOffsetUpdate(PRInt64 offset, PRInt64 time);
   DrainDone();
 
-
 };
 
 } // namespace dom
 } // namespace mozilla