b=914030 keep a self reference on destination while offline context is rendering r=ehsan

--HG--
extra : transplant_source : %FAk%98%E7%CB%2C%C6uf%EE%F4%CFq%3D%A7%D1%D6%E9%F1%29
This commit is contained in:
Karl Tomlinson 2013-09-10 17:10:53 +12:00
Родитель 501043ae47
Коммит d42a4b06c8
3 изменённых файлов: 9 добавлений и 4 удалений

Просмотреть файл

@ -552,7 +552,7 @@ AudioContext::Shutdown()
// For offline contexts, we can destroy the MediaStreamGraph at this point. // For offline contexts, we can destroy the MediaStreamGraph at this point.
if (mIsOffline) { if (mIsOffline) {
mDestination->DestroyGraph(); mDestination->OfflineShutdown();
} }
} }

Просмотреть файл

@ -125,12 +125,13 @@ public:
AudioNode* node = mStream->Engine()->Node(); AudioNode* node = mStream->Engine()->Node();
if (node) { if (node) {
context = node->Context(); context = node->Context();
MOZ_ASSERT(context, "node hasn't kept context alive");
} }
} }
if (!context) { if (!context) {
return NS_OK; return NS_OK;
} }
context->Shutdown(); context->Shutdown(); // drops self reference
AutoPushJSContext cx(context->GetJSContext()); AutoPushJSContext cx(context->GetJSContext());
if (cx) { if (cx) {
@ -281,11 +282,13 @@ AudioDestinationNode::Unmute()
} }
void void
AudioDestinationNode::DestroyGraph() AudioDestinationNode::OfflineShutdown()
{ {
MOZ_ASSERT(Context() && Context()->IsOffline(), MOZ_ASSERT(Context() && Context()->IsOffline(),
"Should only be called on a valid OfflineAudioContext"); "Should only be called on a valid OfflineAudioContext");
MediaStreamGraph::DestroyNonRealtimeInstance(mStream->Graph()); MediaStreamGraph::DestroyNonRealtimeInstance(mStream->Graph());
mOfflineRenderingRef.Drop(this);
} }
JSObject* JSObject*
@ -297,6 +300,7 @@ AudioDestinationNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
void void
AudioDestinationNode::StartRendering() AudioDestinationNode::StartRendering()
{ {
mOfflineRenderingRef.Take(this);
mStream->Graph()->StartNonRealtimeProcessing(mFramesToProduce); mStream->Graph()->StartNonRealtimeProcessing(mFramesToProduce);
} }

Просмотреть файл

@ -46,9 +46,10 @@ public:
void StartRendering(); void StartRendering();
void DestroyGraph(); void OfflineShutdown();
private: private:
SelfReference<AudioDestinationNode> mOfflineRenderingRef;
uint32_t mFramesToProduce; uint32_t mFramesToProduce;
}; };