OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, 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 10 matching lines...) Expand all Loading... | |
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
23 * DAMAGE. | 23 * DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "modules/webaudio/MediaStreamAudioDestinationNode.h" | 26 #include "modules/webaudio/MediaStreamAudioDestinationNode.h" |
27 #include "bindings/core/v8/ExceptionMessages.h" | 27 #include "bindings/core/v8/ExceptionMessages.h" |
28 #include "bindings/core/v8/ExceptionState.h" | 28 #include "bindings/core/v8/ExceptionState.h" |
29 #include "core/dom/ExceptionCode.h" | 29 #include "core/dom/ExceptionCode.h" |
30 #include "modules/webaudio/AudioNodeInput.h" | 30 #include "modules/webaudio/AudioNodeInput.h" |
31 #include "modules/webaudio/AudioNodeOptions.h" | |
31 #include "modules/webaudio/BaseAudioContext.h" | 32 #include "modules/webaudio/BaseAudioContext.h" |
32 #include "platform/UUID.h" | 33 #include "platform/UUID.h" |
33 #include "platform/mediastream/MediaStreamCenter.h" | 34 #include "platform/mediastream/MediaStreamCenter.h" |
34 #include "public/platform/WebRTCPeerConnectionHandler.h" | 35 #include "public/platform/WebRTCPeerConnectionHandler.h" |
35 #include "wtf/Locker.h" | 36 #include "wtf/Locker.h" |
36 | 37 |
37 namespace blink { | 38 namespace blink { |
38 | 39 |
39 // WebAudioCapturerSource ignores the channel count beyond 8, so we set the | 40 // WebAudioCapturerSource ignores the channel count beyond 8, so we set the |
40 // block here to avoid anything can cause the crash. | 41 // block here to avoid anything can cause the crash. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 | 109 |
109 void MediaStreamAudioDestinationHandler::setChannelCount( | 110 void MediaStreamAudioDestinationHandler::setChannelCount( |
110 unsigned long channelCount, | 111 unsigned long channelCount, |
111 ExceptionState& exceptionState) { | 112 ExceptionState& exceptionState) { |
112 DCHECK(isMainThread()); | 113 DCHECK(isMainThread()); |
113 | 114 |
114 // Currently the maximum channel count supported for this node is 8, | 115 // Currently the maximum channel count supported for this node is 8, |
115 // which is constrained by m_source (WebAudioCapturereSource). Although | 116 // which is constrained by m_source (WebAudioCapturereSource). Although |
116 // it has its own safety check for the excessive channels, throwing an | 117 // it has its own safety check for the excessive channels, throwing an |
117 // exception here is useful to developers. | 118 // exception here is useful to developers. |
118 if (channelCount > maxChannelCount()) { | 119 if (channelCount < 1 || channelCount > maxChannelCount()) { |
119 exceptionState.throwDOMException( | 120 exceptionState.throwDOMException( |
120 IndexSizeError, | 121 NotSupportedError, |
121 ExceptionMessages::indexOutsideRange<unsigned>( | 122 ExceptionMessages::indexOutsideRange<unsigned>( |
122 "channel count", channelCount, 1, ExceptionMessages::InclusiveBound, | 123 "channel count", channelCount, 1, ExceptionMessages::InclusiveBound, |
123 maxChannelCount(), ExceptionMessages::InclusiveBound)); | 124 maxChannelCount(), ExceptionMessages::InclusiveBound)); |
124 return; | 125 return; |
125 } | 126 } |
126 | 127 |
127 // Synchronize changes in the channel count with process() which | 128 // Synchronize changes in the channel count with process() which |
128 // needs to update m_mixBus. | 129 // needs to update m_mixBus. |
129 MutexLocker locker(m_processLock); | 130 MutexLocker locker(m_processLock); |
130 | 131 |
(...skipping 21 matching lines...) Expand all Loading... | |
152 DCHECK(isMainThread()); | 153 DCHECK(isMainThread()); |
153 | 154 |
154 if (context.isContextClosed()) { | 155 if (context.isContextClosed()) { |
155 context.throwExceptionForClosedState(exceptionState); | 156 context.throwExceptionForClosedState(exceptionState); |
156 return nullptr; | 157 return nullptr; |
157 } | 158 } |
158 | 159 |
159 return new MediaStreamAudioDestinationNode(context, numberOfChannels); | 160 return new MediaStreamAudioDestinationNode(context, numberOfChannels); |
160 } | 161 } |
161 | 162 |
163 MediaStreamAudioDestinationNode* MediaStreamAudioDestinationNode::create( | |
164 BaseAudioContext* context, | |
165 const AudioNodeOptions& options, | |
166 ExceptionState& exceptionState) { | |
167 DCHECK(isMainThread()); | |
168 | |
169 // Default to stereo; |options| will update it approriately if needed. | |
170 MediaStreamAudioDestinationNode* node = | |
171 new MediaStreamAudioDestinationNode(*context, 2); | |
172 | |
173 if (!node) | |
tkent
2016/12/19 23:35:01
|new| operator never returns nullptr. This check i
| |
174 return nullptr; | |
175 | |
176 // Need to handle channelCount here ourselves because the upper | |
177 // limit is different from the normal AudioNode::setChannelCount | |
178 // limit of 32. Error messages will sometimes show the wrong | |
179 // limits. | |
180 if (options.hasChannelCount()) | |
181 node->setChannelCount(options.channelCount(), exceptionState); | |
182 | |
183 node->handleChannelOptions(options, exceptionState); | |
184 | |
185 return node; | |
186 } | |
187 | |
162 MediaStream* MediaStreamAudioDestinationNode::stream() const { | 188 MediaStream* MediaStreamAudioDestinationNode::stream() const { |
163 return static_cast<MediaStreamAudioDestinationHandler&>(handler()).stream(); | 189 return static_cast<MediaStreamAudioDestinationHandler&>(handler()).stream(); |
164 } | 190 } |
165 | 191 |
166 } // namespace blink | 192 } // namespace blink |
OLD | NEW |