2013-05-05 19:49:37 +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/ChannelMergerNode.h"
|
|
|
|
#include "mozilla/dom/ChannelMergerNodeBinding.h"
|
|
|
|
#include "AudioNodeEngine.h"
|
|
|
|
#include "AudioNodeStream.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(ChannelMergerNode, AudioNode)
|
|
|
|
|
2015-04-28 09:42:00 +03:00
|
|
|
class ChannelMergerNodeEngine final : public AudioNodeEngine
|
2013-05-05 19:49:37 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 07:50:59 +04:00
|
|
|
explicit ChannelMergerNodeEngine(ChannelMergerNode* aNode)
|
2013-05-05 19:49:37 +04:00
|
|
|
: AudioNodeEngine(aNode)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
}
|
|
|
|
|
2016-01-18 06:22:51 +03:00
|
|
|
void ProcessBlocksOnPorts(AudioNodeStream* aStream,
|
|
|
|
const OutputChunks& aInput,
|
|
|
|
OutputChunks& aOutput,
|
|
|
|
bool* aFinished) override
|
2013-05-05 19:49:37 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aInput.Length() >= 1, "Should have one or more input ports");
|
|
|
|
|
|
|
|
// Get the number of output channels, and allocate it
|
2015-10-30 00:22:45 +03:00
|
|
|
size_t channelCount = InputCount();
|
|
|
|
bool allNull = true;
|
|
|
|
for (size_t i = 0; i < channelCount; ++i) {
|
|
|
|
allNull &= aInput[i].IsNull();
|
2013-05-05 19:49:37 +04:00
|
|
|
}
|
2015-10-30 00:22:45 +03:00
|
|
|
if (allNull) {
|
2013-05-05 19:49:37 +04:00
|
|
|
aOutput[0].SetNull(WEBAUDIO_BLOCK_SIZE);
|
|
|
|
return;
|
|
|
|
}
|
2015-10-30 00:22:45 +03:00
|
|
|
|
2015-09-03 10:01:50 +03:00
|
|
|
aOutput[0].AllocateChannels(channelCount);
|
2013-05-05 19:49:37 +04:00
|
|
|
|
2015-10-30 00:22:45 +03:00
|
|
|
for (size_t i = 0; i < channelCount; ++i) {
|
|
|
|
float* output = aOutput[0].ChannelFloatsForWrite(i);
|
|
|
|
if (aInput[i].IsNull()) {
|
|
|
|
PodZero(output, WEBAUDIO_BLOCK_SIZE);
|
|
|
|
} else {
|
2013-05-06 22:30:47 +04:00
|
|
|
AudioBlockCopyChannelWithScale(
|
2015-10-30 00:22:45 +03:00
|
|
|
static_cast<const float*>(aInput[i].mChannelData[0]),
|
|
|
|
aInput[i].mVolume, output);
|
2013-05-05 19:49:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-13 22:08:10 +04:00
|
|
|
|
2016-01-18 06:22:51 +03:00
|
|
|
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:37 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
ChannelMergerNode::ChannelMergerNode(AudioContext* aContext,
|
|
|
|
uint16_t aInputCount)
|
|
|
|
: AudioNode(aContext,
|
2015-10-30 00:22:45 +03:00
|
|
|
1,
|
|
|
|
ChannelCountMode::Explicit,
|
2013-05-05 19:49:37 +04:00
|
|
|
ChannelInterpretation::Speakers)
|
|
|
|
, mInputCount(aInputCount)
|
|
|
|
{
|
2015-09-08 16:22:16 +03:00
|
|
|
mStream = AudioNodeStream::Create(aContext,
|
2015-08-12 02:26:24 +03:00
|
|
|
new ChannelMergerNodeEngine(this),
|
2016-09-05 18:25:41 +03:00
|
|
|
AudioNodeStream::NO_STREAM_FLAGS,
|
|
|
|
aContext->Graph());
|
2013-05-05 19:49:37 +04:00
|
|
|
}
|
|
|
|
|
2014-07-09 01:23:17 +04:00
|
|
|
ChannelMergerNode::~ChannelMergerNode()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-05 19:49:37 +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
|
|
|
ChannelMergerNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-05-05 19:49:37 +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 ChannelMergerNodeBinding::Wrap(aCx, this, aGivenProto);
|
2013-05-05 19:49:37 +04:00
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2013-05-05 19:49:37 +04:00
|
|
|
|