michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "AudioProcessingEvent.h" michael@0: #include "mozilla/dom/AudioProcessingEventBinding.h" michael@0: #include "AudioContext.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_INHERITED(AudioProcessingEvent, Event, michael@0: mInputBuffer, mOutputBuffer, mNode) michael@0: michael@0: NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(AudioProcessingEvent) michael@0: NS_INTERFACE_MAP_END_INHERITING(Event) michael@0: michael@0: NS_IMPL_ADDREF_INHERITED(AudioProcessingEvent, Event) michael@0: NS_IMPL_RELEASE_INHERITED(AudioProcessingEvent, Event) michael@0: michael@0: AudioProcessingEvent::AudioProcessingEvent(ScriptProcessorNode* aOwner, michael@0: nsPresContext* aPresContext, michael@0: WidgetEvent* aEvent) michael@0: : Event(aOwner, aPresContext, aEvent) michael@0: , mPlaybackTime(0.0) michael@0: , mNode(aOwner) michael@0: { michael@0: SetIsDOMBinding(); michael@0: } michael@0: michael@0: JSObject* michael@0: AudioProcessingEvent::WrapObject(JSContext* aCx) michael@0: { michael@0: return AudioProcessingEventBinding::Wrap(aCx, this); michael@0: } michael@0: michael@0: already_AddRefed michael@0: AudioProcessingEvent::LazilyCreateBuffer(uint32_t aNumberOfChannels, michael@0: ErrorResult& aRv) michael@0: { michael@0: AutoPushJSContext cx(mNode->Context()->GetJSContext()); michael@0: nsRefPtr buffer = michael@0: AudioBuffer::Create(mNode->Context(), aNumberOfChannels, michael@0: mNode->BufferSize(), michael@0: mNode->Context()->SampleRate(), cx, aRv); michael@0: MOZ_ASSERT(buffer || aRv.ErrorCode() == NS_ERROR_OUT_OF_MEMORY); michael@0: return buffer.forget(); michael@0: } michael@0: michael@0: } michael@0: } michael@0: