1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/webaudio/AudioProcessingEvent.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "AudioProcessingEvent.h" 1.11 +#include "mozilla/dom/AudioProcessingEventBinding.h" 1.12 +#include "AudioContext.h" 1.13 + 1.14 +namespace mozilla { 1.15 +namespace dom { 1.16 + 1.17 +NS_IMPL_CYCLE_COLLECTION_INHERITED(AudioProcessingEvent, Event, 1.18 + mInputBuffer, mOutputBuffer, mNode) 1.19 + 1.20 +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(AudioProcessingEvent) 1.21 +NS_INTERFACE_MAP_END_INHERITING(Event) 1.22 + 1.23 +NS_IMPL_ADDREF_INHERITED(AudioProcessingEvent, Event) 1.24 +NS_IMPL_RELEASE_INHERITED(AudioProcessingEvent, Event) 1.25 + 1.26 +AudioProcessingEvent::AudioProcessingEvent(ScriptProcessorNode* aOwner, 1.27 + nsPresContext* aPresContext, 1.28 + WidgetEvent* aEvent) 1.29 + : Event(aOwner, aPresContext, aEvent) 1.30 + , mPlaybackTime(0.0) 1.31 + , mNode(aOwner) 1.32 +{ 1.33 + SetIsDOMBinding(); 1.34 +} 1.35 + 1.36 +JSObject* 1.37 +AudioProcessingEvent::WrapObject(JSContext* aCx) 1.38 +{ 1.39 + return AudioProcessingEventBinding::Wrap(aCx, this); 1.40 +} 1.41 + 1.42 +already_AddRefed<AudioBuffer> 1.43 +AudioProcessingEvent::LazilyCreateBuffer(uint32_t aNumberOfChannels, 1.44 + ErrorResult& aRv) 1.45 +{ 1.46 + AutoPushJSContext cx(mNode->Context()->GetJSContext()); 1.47 + nsRefPtr<AudioBuffer> buffer = 1.48 + AudioBuffer::Create(mNode->Context(), aNumberOfChannels, 1.49 + mNode->BufferSize(), 1.50 + mNode->Context()->SampleRate(), cx, aRv); 1.51 + MOZ_ASSERT(buffer || aRv.ErrorCode() == NS_ERROR_OUT_OF_MEMORY); 1.52 + return buffer.forget(); 1.53 +} 1.54 + 1.55 +} 1.56 +} 1.57 +