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());
|
|
|
|
}
|
|
|
|
|
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:37 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aInput.Length() >= 1, "Should have one or more input ports");
|
|
|
|
|
|
|
|
// Get the number of output channels, and allocate it
|
2014-05-16 01:23:38 +04:00
|
|
|
size_t channelCount = 0;
|
2013-05-05 19:49:37 +04:00
|
|
|
for (uint16_t i = 0; i < InputCount(); ++i) {
|
2015-09-03 08:30:16 +03:00
|
|
|
channelCount += aInput[i].ChannelCount();
|
2013-05-05 19:49:37 +04:00
|
|
|
}
|
|
|
|
if (channelCount == 0) {
|
|
|
|
aOutput[0].SetNull(WEBAUDIO_BLOCK_SIZE);
|
|
|
|
return;
|
|
|
|
}
|
2014-05-16 01:23:38 +04:00
|
|
|
channelCount = std::min(channelCount, WebAudioUtils::MaxChannelCount);
|
2015-09-03 10:01:50 +03:00
|
|
|
aOutput[0].AllocateChannels(channelCount);
|
2013-05-05 19:49:37 +04:00
|
|
|
|
|
|
|
// Append each channel in each input to the output
|
2014-05-16 01:23:38 +04:00
|
|
|
size_t channelIndex = 0;
|
|
|
|
for (uint16_t i = 0; true; ++i) {
|
|
|
|
MOZ_ASSERT(i < InputCount());
|
2015-09-03 08:30:16 +03:00
|
|
|
for (size_t j = 0; j < aInput[i].ChannelCount(); ++j) {
|
2013-05-06 22:30:47 +04:00
|
|
|
AudioBlockCopyChannelWithScale(
|
|
|
|
static_cast<const float*>(aInput[i].mChannelData[j]),
|
|
|
|
aInput[i].mVolume,
|
2015-07-22 08:59:21 +03:00
|
|
|
aOutput[0].ChannelFloatsForWrite(channelIndex));
|
2013-05-05 19:49:37 +04:00
|
|
|
++channelIndex;
|
2014-05-16 01:23:38 +04:00
|
|
|
if (channelIndex >= channelCount) {
|
|
|
|
return;
|
|
|
|
}
|
2013-05-05 19:49:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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:37 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
ChannelMergerNode::ChannelMergerNode(AudioContext* aContext,
|
|
|
|
uint16_t aInputCount)
|
|
|
|
: AudioNode(aContext,
|
|
|
|
2,
|
|
|
|
ChannelCountMode::Max,
|
|
|
|
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),
|
2015-08-13 07:13:34 +03:00
|
|
|
AudioNodeStream::NO_STREAM_FLAGS);
|
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
|
|
|
|