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*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
AudioProcessingEvent::WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-04-14 01:37:04 +00:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
return AudioProcessingEventBinding::Wrap(aCx, this, aGivenProto);
|
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);
|
2015-04-27 13:18:52 +00:00
|
|
|
MOZ_ASSERT(buffer || aRv.ErrorCodeIs(NS_ERROR_OUT_OF_MEMORY));
|
2014-05-15 21:11:13 +00:00
|
|
|
return buffer.forget();
|
2013-04-14 01:37:04 +00:00
|
|
|
}
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2013-04-14 01:37:04 +00:00
|
|
|
|