| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "modules/webaudio/ChannelSplitterOptions.h" | 33 #include "modules/webaudio/ChannelSplitterOptions.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 ChannelSplitterHandler::ChannelSplitterHandler(AudioNode& node, | 37 ChannelSplitterHandler::ChannelSplitterHandler(AudioNode& node, |
| 38 float sampleRate, | 38 float sampleRate, |
| 39 unsigned numberOfOutputs) | 39 unsigned numberOfOutputs) |
| 40 : AudioHandler(NodeTypeChannelSplitter, node, sampleRate) { | 40 : AudioHandler(NodeTypeChannelSplitter, node, sampleRate) { |
| 41 addInput(); | 41 addInput(); |
| 42 | 42 |
| 43 // Create a fixed number of outputs (able to handle the maximum number of chan
nels fed to an input). | 43 // Create a fixed number of outputs (able to handle the maximum number of |
| 44 // channels fed to an input). |
| 44 for (unsigned i = 0; i < numberOfOutputs; ++i) | 45 for (unsigned i = 0; i < numberOfOutputs; ++i) |
| 45 addOutput(1); | 46 addOutput(1); |
| 46 | 47 |
| 47 initialize(); | 48 initialize(); |
| 48 } | 49 } |
| 49 | 50 |
| 50 PassRefPtr<ChannelSplitterHandler> ChannelSplitterHandler::create( | 51 PassRefPtr<ChannelSplitterHandler> ChannelSplitterHandler::create( |
| 51 AudioNode& node, | 52 AudioNode& node, |
| 52 float sampleRate, | 53 float sampleRate, |
| 53 unsigned numberOfOutputs) { | 54 unsigned numberOfOutputs) { |
| 54 return adoptRef( | 55 return adoptRef( |
| 55 new ChannelSplitterHandler(node, sampleRate, numberOfOutputs)); | 56 new ChannelSplitterHandler(node, sampleRate, numberOfOutputs)); |
| 56 } | 57 } |
| 57 | 58 |
| 58 void ChannelSplitterHandler::process(size_t framesToProcess) { | 59 void ChannelSplitterHandler::process(size_t framesToProcess) { |
| 59 AudioBus* source = input(0).bus(); | 60 AudioBus* source = input(0).bus(); |
| 60 DCHECK(source); | 61 DCHECK(source); |
| 61 DCHECK_EQ(framesToProcess, source->length()); | 62 DCHECK_EQ(framesToProcess, source->length()); |
| 62 | 63 |
| 63 unsigned numberOfSourceChannels = source->numberOfChannels(); | 64 unsigned numberOfSourceChannels = source->numberOfChannels(); |
| 64 | 65 |
| 65 for (unsigned i = 0; i < numberOfOutputs(); ++i) { | 66 for (unsigned i = 0; i < numberOfOutputs(); ++i) { |
| 66 AudioBus* destination = output(i).bus(); | 67 AudioBus* destination = output(i).bus(); |
| 67 DCHECK(destination); | 68 DCHECK(destination); |
| 68 | 69 |
| 69 if (i < numberOfSourceChannels) { | 70 if (i < numberOfSourceChannels) { |
| 70 // Split the channel out if it exists in the source. | 71 // Split the channel out if it exists in the source. |
| 71 // It would be nice to avoid the copy and simply pass along pointers, but
this becomes extremely difficult with fanout and fanin. | 72 // It would be nice to avoid the copy and simply pass along pointers, but |
| 73 // this becomes extremely difficult with fanout and fanin. |
| 72 destination->channel(0)->copyFrom(source->channel(i)); | 74 destination->channel(0)->copyFrom(source->channel(i)); |
| 73 } else if (output(i).renderingFanOutCount() > 0) { | 75 } else if (output(i).renderingFanOutCount() > 0) { |
| 74 // Only bother zeroing out the destination if it's connected to anything | 76 // Only bother zeroing out the destination if it's connected to anything |
| 75 destination->zero(); | 77 destination->zero(); |
| 76 } | 78 } |
| 77 } | 79 } |
| 78 } | 80 } |
| 79 | 81 |
| 80 // ---------------------------------------------------------------- | 82 // ---------------------------------------------------------------- |
| 81 | 83 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 131 |
| 130 if (!node) | 132 if (!node) |
| 131 return nullptr; | 133 return nullptr; |
| 132 | 134 |
| 133 node->handleChannelOptions(options, exceptionState); | 135 node->handleChannelOptions(options, exceptionState); |
| 134 | 136 |
| 135 return node; | 137 return node; |
| 136 } | 138 } |
| 137 | 139 |
| 138 } // namespace blink | 140 } // namespace blink |
| OLD | NEW |