diff --git a/content/media/nsAudioStream.cpp b/content/media/nsAudioStream.cpp index 4edf0de541fd..2dd7082b0494 100644 --- a/content/media/nsAudioStream.cpp +++ b/content/media/nsAudioStream.cpp @@ -287,7 +287,7 @@ class AudioShutdownEvent : public nsRunnable NS_IMETHOD Run() { if (mAudioChild->IsIPCOpen()) - PAudioChild::Send__delete__(mAudioChild); + mAudioChild->SendShutdown(); return NS_OK; } diff --git a/dom/ipc/AudioParent.cpp b/dom/ipc/AudioParent.cpp index 300008cf20a1..9bb106627211 100644 --- a/dom/ipc/AudioParent.cpp +++ b/dom/ipc/AudioParent.cpp @@ -219,20 +219,10 @@ AudioParent::RecvResume() } bool -AudioParent::Recv__delete__() +AudioParent::RecvShutdown() { - if (mTimer) { - mTimer->Cancel(); - mTimer = nsnull; - } - - if (mStream) { - nsCOMPtr event = new AudioStreamShutdownEvent(mStream); - nsCOMPtr thread = mStream->GetThread(); - thread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL); - mStream = nsnull; - } - + Shutdown(); + PAudioParent::Send__delete__(this); return true; } @@ -261,6 +251,24 @@ void AudioParent::ActorDestroy(ActorDestroyReason aWhy) { mIPCOpen = PR_FALSE; + + Shutdown(); +} + +void +AudioParent::Shutdown() +{ + if (mTimer) { + mTimer->Cancel(); + mTimer = nsnull; + } + + if (mStream) { + nsCOMPtr event = new AudioStreamShutdownEvent(mStream); + nsCOMPtr thread = mStream->GetThread(); + thread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL); + mStream = nsnull; + } } } // namespace dom diff --git a/dom/ipc/AudioParent.h b/dom/ipc/AudioParent.h index 2d555164d2f0..1536e31a3180 100644 --- a/dom/ipc/AudioParent.h +++ b/dom/ipc/AudioParent.h @@ -71,7 +71,7 @@ class AudioParent : public PAudioParent, public nsITimerCallback RecvResume(); virtual bool - Recv__delete__(); + RecvShutdown(); AudioParent(PRInt32 aNumChannels, PRInt32 aRate, PRInt32 aFormat); virtual ~AudioParent(); @@ -81,6 +81,8 @@ class AudioParent : public PAudioParent, public nsITimerCallback nsCOMPtr mTimer; private: + void Shutdown(); + PRPackedBool mIPCOpen; }; } // namespace dom diff --git a/dom/ipc/PAudio.ipdl b/dom/ipc/PAudio.ipdl index 13d170cc0891..fc67809b77cd 100644 --- a/dom/ipc/PAudio.ipdl +++ b/dom/ipc/PAudio.ipdl @@ -48,8 +48,6 @@ protocol PAudio parent: - __delete__(); - Write(nsCString data, PRUint32 count); SetVolume(float aVolume); @@ -58,13 +56,15 @@ parent: Pause(); Resume(); + Shutdown(); child: + __delete__(); + SampleOffsetUpdate(PRInt64 offset, PRInt64 time); DrainDone(); - }; } // namespace dom