| 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 20 matching lines...) Expand all Loading... |
| 31 #include "modules/webaudio/AudioNodeOutput.h" | 31 #include "modules/webaudio/AudioNodeOutput.h" |
| 32 #include "modules/webaudio/BaseAudioContext.h" | 32 #include "modules/webaudio/BaseAudioContext.h" |
| 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 // These properties are fixed and cannot be changed by the user. |
| 42 m_channelCount = numberOfOutputs; |
| 43 setInternalChannelCountMode(Explicit); |
| 41 addInput(); | 44 addInput(); |
| 42 | 45 |
| 43 // Create a fixed number of outputs (able to handle the maximum number of | 46 // Create a fixed number of outputs (able to handle the maximum number of |
| 44 // channels fed to an input). | 47 // channels fed to an input). |
| 45 for (unsigned i = 0; i < numberOfOutputs; ++i) | 48 for (unsigned i = 0; i < numberOfOutputs; ++i) |
| 46 addOutput(1); | 49 addOutput(1); |
| 47 | 50 |
| 48 initialize(); | 51 initialize(); |
| 49 } | 52 } |
| 50 | 53 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 72 // It would be nice to avoid the copy and simply pass along pointers, but | 75 // It would be nice to avoid the copy and simply pass along pointers, but |
| 73 // this becomes extremely difficult with fanout and fanin. | 76 // this becomes extremely difficult with fanout and fanin. |
| 74 destination->channel(0)->copyFrom(source->channel(i)); | 77 destination->channel(0)->copyFrom(source->channel(i)); |
| 75 } else if (output(i).renderingFanOutCount() > 0) { | 78 } else if (output(i).renderingFanOutCount() > 0) { |
| 76 // Only bother zeroing out the destination if it's connected to anything | 79 // Only bother zeroing out the destination if it's connected to anything |
| 77 destination->zero(); | 80 destination->zero(); |
| 78 } | 81 } |
| 79 } | 82 } |
| 80 } | 83 } |
| 81 | 84 |
| 85 void ChannelSplitterHandler::setChannelCount(unsigned long channelCount, |
| 86 ExceptionState& exceptionState) { |
| 87 DCHECK(isMainThread()); |
| 88 BaseAudioContext::AutoLocker locker(context()); |
| 89 |
| 90 // channelCount cannot be changed from the number of outputs. |
| 91 if (channelCount != numberOfOutputs()) { |
| 92 exceptionState.throwDOMException( |
| 93 InvalidStateError, |
| 94 "ChannelSplitter: channelCount cannot be changed from " + |
| 95 String::number(numberOfOutputs())); |
| 96 } |
| 97 } |
| 98 |
| 99 void ChannelSplitterHandler::setChannelCountMode( |
| 100 const String& mode, |
| 101 ExceptionState& exceptionState) { |
| 102 DCHECK(isMainThread()); |
| 103 BaseAudioContext::AutoLocker locker(context()); |
| 104 |
| 105 // channcelCountMode must be 'explicit'. |
| 106 if (mode != "explicit") { |
| 107 exceptionState.throwDOMException( |
| 108 InvalidStateError, |
| 109 "ChannelSplitter: channelCountMode cannot be changed from 'explicit'"); |
| 110 } |
| 111 } |
| 112 |
| 82 // ---------------------------------------------------------------- | 113 // ---------------------------------------------------------------- |
| 83 | 114 |
| 84 ChannelSplitterNode::ChannelSplitterNode(BaseAudioContext& context, | 115 ChannelSplitterNode::ChannelSplitterNode(BaseAudioContext& context, |
| 85 unsigned numberOfOutputs) | 116 unsigned numberOfOutputs) |
| 86 : AudioNode(context) { | 117 : AudioNode(context) { |
| 87 setHandler(ChannelSplitterHandler::create(*this, context.sampleRate(), | 118 setHandler(ChannelSplitterHandler::create(*this, context.sampleRate(), |
| 88 numberOfOutputs)); | 119 numberOfOutputs)); |
| 89 } | 120 } |
| 90 | 121 |
| 91 ChannelSplitterNode* ChannelSplitterNode::create( | 122 ChannelSplitterNode* ChannelSplitterNode::create( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 162 |
| 132 if (!node) | 163 if (!node) |
| 133 return nullptr; | 164 return nullptr; |
| 134 | 165 |
| 135 node->handleChannelOptions(options, exceptionState); | 166 node->handleChannelOptions(options, exceptionState); |
| 136 | 167 |
| 137 return node; | 168 return node; |
| 138 } | 169 } |
| 139 | 170 |
| 140 } // namespace blink | 171 } // namespace blink |
| OLD | NEW |