From 4a6177bed10c319a33863bda966797a5bb58ae01 Mon Sep 17 00:00:00 2001 From: Bob Owen Date: Fri, 9 May 2014 19:51:56 +0100 Subject: [PATCH] Bug 1006024 - Part 7: Replace AutoPushJSContext in WebAudioDecodeJob::AllocateBuffer. r=bholley --- content/media/webaudio/MediaBufferDecoder.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/content/media/webaudio/MediaBufferDecoder.cpp b/content/media/webaudio/MediaBufferDecoder.cpp index 5be70a13eed1..90c239d37a3e 100644 --- a/content/media/webaudio/MediaBufferDecoder.cpp +++ b/content/media/webaudio/MediaBufferDecoder.cpp @@ -7,6 +7,7 @@ #include "MediaBufferDecoder.h" #include "BufferDecoder.h" #include "mozilla/dom/AudioContextBinding.h" +#include "mozilla/dom/ScriptSettings.h" #include #include "nsXPCOMCIDInternal.h" #include "nsComponentManagerUtils.h" @@ -18,7 +19,6 @@ #include "nsIScriptObjectPrincipal.h" #include "nsIScriptError.h" #include "nsMimeTypes.h" -#include "nsCxPusher.h" #include "WebAudioUtils.h" namespace mozilla { @@ -402,12 +402,16 @@ WebAudioDecodeJob::AllocateBuffer() MOZ_ASSERT(!mOutput); MOZ_ASSERT(NS_IsMainThread()); - // First, get a JSContext - AutoPushJSContext cx(mContext->GetJSContext()); - if (!cx) { + // We need the global for the context so that we can enter its compartment. + JSObject* global = mContext->GetGlobalJSObject(); + if (NS_WARN_IF(!global)) { return false; } + AutoJSAPI jsapi; + JSContext* cx = jsapi.cx(); + JSAutoCompartment ac(cx, global); + // Now create the AudioBuffer mOutput = new AudioBuffer(mContext, mWriteIndex, mContext->SampleRate()); if (!mOutput->InitializeBuffers(mChannelBuffers.Length(), cx)) {