Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #include "AudioProcessingEvent.h"
8 : #include "mozilla/dom/AudioProcessingEventBinding.h"
9 : #include "mozilla/dom/ScriptSettings.h"
10 : #include "AudioContext.h"
11 :
12 : namespace mozilla {
13 : namespace dom {
14 :
15 0 : NS_IMPL_CYCLE_COLLECTION_INHERITED(AudioProcessingEvent, Event,
16 : mInputBuffer, mOutputBuffer, mNode)
17 :
18 0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(AudioProcessingEvent)
19 0 : NS_INTERFACE_MAP_END_INHERITING(Event)
20 :
21 0 : NS_IMPL_ADDREF_INHERITED(AudioProcessingEvent, Event)
22 0 : NS_IMPL_RELEASE_INHERITED(AudioProcessingEvent, Event)
23 :
24 0 : AudioProcessingEvent::AudioProcessingEvent(ScriptProcessorNode* aOwner,
25 : nsPresContext* aPresContext,
26 0 : WidgetEvent* aEvent)
27 : : Event(aOwner, aPresContext, aEvent)
28 : , mPlaybackTime(0.0)
29 0 : , mNode(aOwner)
30 : {
31 0 : }
32 :
33 0 : AudioProcessingEvent::~AudioProcessingEvent()
34 : {
35 0 : }
36 :
37 : JSObject*
38 0 : AudioProcessingEvent::WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
39 : {
40 0 : return AudioProcessingEventBinding::Wrap(aCx, this, aGivenProto);
41 : }
42 :
43 : already_AddRefed<AudioBuffer>
44 0 : AudioProcessingEvent::LazilyCreateBuffer(uint32_t aNumberOfChannels,
45 : ErrorResult& aRv)
46 : {
47 : RefPtr<AudioBuffer> buffer =
48 0 : AudioBuffer::Create(mNode->Context()->GetOwner(), aNumberOfChannels,
49 : mNode->BufferSize(),
50 0 : mNode->Context()->SampleRate(), aRv);
51 0 : MOZ_ASSERT(buffer || aRv.ErrorCodeIs(NS_ERROR_OUT_OF_MEMORY));
52 0 : return buffer.forget();
53 : }
54 :
55 : } // namespace dom
56 : } // namespace mozilla
57 :
|