| Index: third_party/WebKit/Source/modules/webaudio/ConvolverNode.cpp
|
| diff --git a/third_party/WebKit/Source/modules/webaudio/ConvolverNode.cpp b/third_party/WebKit/Source/modules/webaudio/ConvolverNode.cpp
|
| index ca23bcfe9784dbffa7c003c9944e82e448bfab8c..ec2a5337688026fe6f6ae1137bb3e217232c894d 100644
|
| --- a/third_party/WebKit/Source/modules/webaudio/ConvolverNode.cpp
|
| +++ b/third_party/WebKit/Source/modules/webaudio/ConvolverNode.cpp
|
| @@ -48,7 +48,7 @@ namespace blink {
|
| ConvolverHandler::ConvolverHandler(AudioNode& node, float sampleRate)
|
| : AudioHandler(NodeTypeConvolver, node, sampleRate), m_normalize(true) {
|
| addInput();
|
| - addOutput(2);
|
| + addOutput(1);
|
|
|
| // Node-specific default mixing rules.
|
| m_channelCount = 2;
|
| @@ -136,9 +136,10 @@ void ConvolverHandler::setBuffer(AudioBuffer* buffer,
|
| bufferBus->setSampleRate(buffer->sampleRate());
|
|
|
| // Create the reverb with the given impulse response.
|
| - std::unique_ptr<Reverb> reverb = WTF::wrapUnique(new Reverb(
|
| - bufferBus.get(), AudioUtilities::kRenderQuantumFrames, MaxFFTSize, 2,
|
| - context() && context()->hasRealtimeConstraint(), m_normalize));
|
| + std::unique_ptr<Reverb> reverb = WTF::wrapUnique(
|
| + new Reverb(bufferBus.get(), AudioUtilities::kRenderQuantumFrames,
|
| + MaxFFTSize, numberOfChannels,
|
| + context() && context()->hasRealtimeConstraint(), m_normalize));
|
|
|
| {
|
| // Synchronize with process().
|
| @@ -177,6 +178,66 @@ double ConvolverHandler::latencyTime() const {
|
| return std::numeric_limits<double>::infinity();
|
| }
|
|
|
| +void ConvolverHandler::setChannelCount(unsigned long channelCount,
|
| + ExceptionState& exceptionState) {
|
| + DCHECK(isMainThread());
|
| + BaseAudioContext::AutoLocker locker(context());
|
| +
|
| + // channelCount must be 2.
|
| + if (channelCount != 2) {
|
| + exceptionState.throwDOMException(
|
| + NotSupportedError,
|
| + "ConvolverNode: channelCount cannot be changed from 2");
|
| + }
|
| +}
|
| +
|
| +void ConvolverHandler::setChannelCountMode(const String& mode,
|
| + ExceptionState& exceptionState) {
|
| + DCHECK(isMainThread());
|
| + BaseAudioContext::AutoLocker locker(context());
|
| +
|
| + // channcelCountMode must be 'clamped-max'.
|
| + if (mode != "clamped-max") {
|
| + exceptionState.throwDOMException(
|
| + NotSupportedError,
|
| + "ConvolverNode: channelCountMode cannot be changed from 'clamped-max'");
|
| + }
|
| +}
|
| +
|
| +void ConvolverHandler::checkNumberOfChannelsForInput(AudioNodeInput* input) {
|
| + DCHECK(context()->isAudioThread());
|
| +#if DCHECK_IS_ON()
|
| + DCHECK(context()->isGraphOwner());
|
| +#endif
|
| +
|
| + DCHECK(input);
|
| + DCHECK_EQ(input, &this->input(0));
|
| + if (input != &this->input(0))
|
| + return;
|
| +
|
| + if (m_buffer) {
|
| + unsigned numberOfChannels = input->numberOfChannels();
|
| + unsigned numberOfReverbeChannels = m_buffer->numberOfChannels();
|
| + unsigned numberOfOutputChannels =
|
| + std::min(2u, std::max(numberOfChannels, numberOfReverbeChannels));
|
| +
|
| + if (isInitialized() &&
|
| + numberOfOutputChannels != output(0).numberOfChannels()) {
|
| + // We're already initialized but the channel count has changed.
|
| + uninitialize();
|
| + }
|
| +
|
| + if (!isInitialized()) {
|
| + // This will propagate the channel count to any nodes connected further
|
| + // downstream in the graph.
|
| + output(0).setNumberOfChannels(numberOfOutputChannels);
|
| + initialize();
|
| + }
|
| + }
|
| +
|
| + // Update the input's internal bus if needed.
|
| + AudioHandler::checkNumberOfChannelsForInput(input);
|
| +}
|
| // ----------------------------------------------------------------
|
|
|
| ConvolverNode::ConvolverNode(BaseAudioContext& context) : AudioNode(context) {
|
|
|