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