2013-05-05 19:49:13 +04: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 "mozilla/dom/ChannelSplitterNode.h"
|
|
|
|
#include "mozilla/dom/ChannelSplitterNodeBinding.h"
|
|
|
|
#include "AudioNodeEngine.h"
|
|
|
|
#include "AudioNodeStream.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(ChannelSplitterNode, AudioNode)
|
|
|
|
|
2015-04-28 09:42:00 +03:00
|
|
|
class ChannelSplitterNodeEngine final : public AudioNodeEngine
|
2013-05-05 19:49:13 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 07:50:59 +04:00
|
|
|
explicit ChannelSplitterNodeEngine(ChannelSplitterNode* aNode)
|
2013-05-05 19:49:13 +04:00
|
|
|
: AudioNodeEngine(aNode)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
}
|
|
|
|
|
2014-03-05 01:09:49 +04:00
|
|
|
virtual void ProcessBlocksOnPorts(AudioNodeStream* aStream,
|
|
|
|
const OutputChunks& aInput,
|
|
|
|
OutputChunks& aOutput,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool* aFinished) override
|
2013-05-05 19:49:13 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aInput.Length() == 1, "Should only have one input port");
|
|
|
|
|
|
|
|
aOutput.SetLength(OutputCount());
|
|
|
|
for (uint16_t i = 0; i < OutputCount(); ++i) {
|
2015-09-03 08:30:16 +03:00
|
|
|
if (i < aInput[0].ChannelCount()) {
|
2013-05-05 19:49:13 +04:00
|
|
|
// Split out existing channels
|
|
|
|
AllocateAudioBlock(1, &aOutput[i]);
|
2013-05-06 22:30:47 +04:00
|
|
|
AudioBlockCopyChannelWithScale(
|
|
|
|
static_cast<const float*>(aInput[0].mChannelData[i]),
|
|
|
|
aInput[0].mVolume,
|
2015-07-22 08:59:21 +03:00
|
|
|
aOutput[i].ChannelFloatsForWrite(0));
|
2013-05-05 19:49:13 +04:00
|
|
|
} else {
|
|
|
|
// Pad with silent channels if needed
|
|
|
|
aOutput[i].SetNull(WEBAUDIO_BLOCK_SIZE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-13 22:08:10 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override
|
2014-04-13 22:08:10 +04:00
|
|
|
{
|
|
|
|
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
}
|
2013-05-05 19:49:13 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
ChannelSplitterNode::ChannelSplitterNode(AudioContext* aContext,
|
|
|
|
uint16_t aOutputCount)
|
|
|
|
: AudioNode(aContext,
|
|
|
|
2,
|
|
|
|
ChannelCountMode::Max,
|
|
|
|
ChannelInterpretation::Speakers)
|
|
|
|
, mOutputCount(aOutputCount)
|
|
|
|
{
|
2015-08-12 02:26:24 +03:00
|
|
|
mStream = AudioNodeStream::Create(aContext->Graph(),
|
|
|
|
new ChannelSplitterNodeEngine(this),
|
2015-08-13 07:13:34 +03:00
|
|
|
AudioNodeStream::NO_STREAM_FLAGS);
|
2013-05-05 19:49:13 +04:00
|
|
|
}
|
|
|
|
|
2014-07-09 01:23:17 +04:00
|
|
|
ChannelSplitterNode::~ChannelSplitterNode()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-05 19:49:13 +04: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 17:13:33 +03:00
|
|
|
ChannelSplitterNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-05-05 19:49:13 +04: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 17:13:33 +03:00
|
|
|
return ChannelSplitterNodeBinding::Wrap(aCx, this, aGivenProto);
|
2013-05-05 19:49:13 +04:00
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2013-05-05 19:49:13 +04:00
|
|
|
|