2013-04-14 01:37:04 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "AudioProcessingEvent.h"
|
|
|
|
#include "mozilla/dom/AudioProcessingEventBinding.h"
|
2014-05-09 18:43:48 +00:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2013-08-15 19:44:14 +00:00
|
|
|
#include "AudioContext.h"
|
2013-04-14 01:37:04 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-04-25 16:49:00 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(AudioProcessingEvent, Event,
|
|
|
|
mInputBuffer, mOutputBuffer, mNode)
|
2013-04-14 01:37:04 +00:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(AudioProcessingEvent)
|
2014-03-05 00:37:43 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(Event)
|
2013-04-14 01:37:04 +00:00
|
|
|
|
2014-03-05 00:37:43 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(AudioProcessingEvent, Event)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(AudioProcessingEvent, Event)
|
2013-04-14 01:37:04 +00:00
|
|
|
|
|
|
|
AudioProcessingEvent::AudioProcessingEvent(ScriptProcessorNode* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
2013-10-02 03:46:04 +00:00
|
|
|
WidgetEvent* aEvent)
|
2014-03-05 00:37:43 +00:00
|
|
|
: Event(aOwner, aPresContext, aEvent)
|
2013-04-14 01:37:04 +00:00
|
|
|
, mPlaybackTime(0.0)
|
|
|
|
, mNode(aOwner)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-07-08 21:23:17 +00:00
|
|
|
AudioProcessingEvent::~AudioProcessingEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-14 01:37:04 +00:00
|
|
|
JSObject*
|
2014-04-08 22:27:18 +00:00
|
|
|
AudioProcessingEvent::WrapObject(JSContext* aCx)
|
2013-04-14 01:37:04 +00:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 22:27:17 +00:00
|
|
|
return AudioProcessingEventBinding::Wrap(aCx, this);
|
2013-04-14 01:37:04 +00:00
|
|
|
}
|
|
|
|
|
2014-05-15 21:11:13 +00:00
|
|
|
already_AddRefed<AudioBuffer>
|
|
|
|
AudioProcessingEvent::LazilyCreateBuffer(uint32_t aNumberOfChannels,
|
|
|
|
ErrorResult& aRv)
|
2013-04-14 01:37:04 +00:00
|
|
|
{
|
2014-06-19 07:21:14 +00:00
|
|
|
AutoJSAPI jsapi;
|
2014-06-25 10:17:17 +00:00
|
|
|
if (NS_WARN_IF(!jsapi.Init(mNode->GetOwner()))) {
|
2014-05-15 21:11:13 +00:00
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return nullptr;
|
2014-05-09 18:43:48 +00:00
|
|
|
}
|
|
|
|
JSContext* cx = jsapi.cx();
|
2013-04-14 01:37:04 +00:00
|
|
|
|
2014-05-15 21:11:13 +00:00
|
|
|
nsRefPtr<AudioBuffer> buffer =
|
2014-05-15 21:23:27 +00:00
|
|
|
AudioBuffer::Create(mNode->Context(), aNumberOfChannels,
|
|
|
|
mNode->BufferSize(),
|
|
|
|
mNode->Context()->SampleRate(), cx, aRv);
|
|
|
|
MOZ_ASSERT(buffer || aRv.ErrorCode() == NS_ERROR_OUT_OF_MEMORY);
|
2014-05-15 21:11:13 +00:00
|
|
|
return buffer.forget();
|
2013-04-14 01:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|