| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 return m_outputs[i].get(); | 123 return m_outputs[i].get(); |
| 124 return 0; | 124 return 0; |
| 125 } | 125 } |
| 126 | 126 |
| 127 void AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned i
nputIndex, ExceptionState& es) | 127 void AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned i
nputIndex, ExceptionState& es) |
| 128 { | 128 { |
| 129 ASSERT(isMainThread()); | 129 ASSERT(isMainThread()); |
| 130 AudioContext::AutoLocker locker(context()); | 130 AudioContext::AutoLocker locker(context()); |
| 131 | 131 |
| 132 if (!destination) { | 132 if (!destination) { |
| 133 es.throwDOMException(SyntaxError); | 133 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 134 return; | 134 return; |
| 135 } | 135 } |
| 136 | 136 |
| 137 // Sanity check input and output indices. | 137 // Sanity check input and output indices. |
| 138 if (outputIndex >= numberOfOutputs()) { | 138 if (outputIndex >= numberOfOutputs()) { |
| 139 es.throwDOMException(IndexSizeError); | 139 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 140 return; | 140 return; |
| 141 } | 141 } |
| 142 | 142 |
| 143 if (destination && inputIndex >= destination->numberOfInputs()) { | 143 if (destination && inputIndex >= destination->numberOfInputs()) { |
| 144 es.throwDOMException(IndexSizeError); | 144 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 145 return; | 145 return; |
| 146 } | 146 } |
| 147 | 147 |
| 148 if (context() != destination->context()) { | 148 if (context() != destination->context()) { |
| 149 es.throwDOMException(SyntaxError); | 149 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 150 return; | 150 return; |
| 151 } | 151 } |
| 152 | 152 |
| 153 AudioNodeInput* input = destination->input(inputIndex); | 153 AudioNodeInput* input = destination->input(inputIndex); |
| 154 AudioNodeOutput* output = this->output(outputIndex); | 154 AudioNodeOutput* output = this->output(outputIndex); |
| 155 input->connect(output); | 155 input->connect(output); |
| 156 | 156 |
| 157 // Let context know that a connection has been made. | 157 // Let context know that a connection has been made. |
| 158 context()->incrementConnectionCount(); | 158 context()->incrementConnectionCount(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionState&
es) | 161 void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionState&
es) |
| 162 { | 162 { |
| 163 ASSERT(isMainThread()); | 163 ASSERT(isMainThread()); |
| 164 AudioContext::AutoLocker locker(context()); | 164 AudioContext::AutoLocker locker(context()); |
| 165 | 165 |
| 166 if (!param) { | 166 if (!param) { |
| 167 es.throwDOMException(SyntaxError); | 167 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 168 return; | 168 return; |
| 169 } | 169 } |
| 170 | 170 |
| 171 if (outputIndex >= numberOfOutputs()) { | 171 if (outputIndex >= numberOfOutputs()) { |
| 172 es.throwDOMException(IndexSizeError); | 172 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 173 return; | 173 return; |
| 174 } | 174 } |
| 175 | 175 |
| 176 if (context() != param->context()) { | 176 if (context() != param->context()) { |
| 177 es.throwDOMException(SyntaxError); | 177 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 178 return; | 178 return; |
| 179 } | 179 } |
| 180 | 180 |
| 181 AudioNodeOutput* output = this->output(outputIndex); | 181 AudioNodeOutput* output = this->output(outputIndex); |
| 182 param->connect(output); | 182 param->connect(output); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void AudioNode::disconnect(unsigned outputIndex, ExceptionState& es) | 185 void AudioNode::disconnect(unsigned outputIndex, ExceptionState& es) |
| 186 { | 186 { |
| 187 ASSERT(isMainThread()); | 187 ASSERT(isMainThread()); |
| 188 AudioContext::AutoLocker locker(context()); | 188 AudioContext::AutoLocker locker(context()); |
| 189 | 189 |
| 190 // Sanity check input and output indices. | 190 // Sanity check input and output indices. |
| 191 if (outputIndex >= numberOfOutputs()) { | 191 if (outputIndex >= numberOfOutputs()) { |
| 192 es.throwDOMException(IndexSizeError); | 192 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 193 return; | 193 return; |
| 194 } | 194 } |
| 195 | 195 |
| 196 AudioNodeOutput* output = this->output(outputIndex); | 196 AudioNodeOutput* output = this->output(outputIndex); |
| 197 output->disconnectAll(); | 197 output->disconnectAll(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 unsigned long AudioNode::channelCount() | 200 unsigned long AudioNode::channelCount() |
| 201 { | 201 { |
| 202 return m_channelCount; | 202 return m_channelCount; |
| 203 } | 203 } |
| 204 | 204 |
| 205 void AudioNode::setChannelCount(unsigned long channelCount, ExceptionState& es) | 205 void AudioNode::setChannelCount(unsigned long channelCount, ExceptionState& es) |
| 206 { | 206 { |
| 207 ASSERT(isMainThread()); | 207 ASSERT(isMainThread()); |
| 208 AudioContext::AutoLocker locker(context()); | 208 AudioContext::AutoLocker locker(context()); |
| 209 | 209 |
| 210 if (channelCount > 0 && channelCount <= AudioContext::maxNumberOfChannels())
{ | 210 if (channelCount > 0 && channelCount <= AudioContext::maxNumberOfChannels())
{ |
| 211 if (m_channelCount != channelCount) { | 211 if (m_channelCount != channelCount) { |
| 212 m_channelCount = channelCount; | 212 m_channelCount = channelCount; |
| 213 if (m_channelCountMode != Max) | 213 if (m_channelCountMode != Max) |
| 214 updateChannelsForInputs(); | 214 updateChannelsForInputs(); |
| 215 } | 215 } |
| 216 } else { | 216 } else { |
| 217 es.throwDOMException(InvalidStateError); | 217 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 String AudioNode::channelCountMode() | 221 String AudioNode::channelCountMode() |
| 222 { | 222 { |
| 223 switch (m_channelCountMode) { | 223 switch (m_channelCountMode) { |
| 224 case Max: | 224 case Max: |
| 225 return "max"; | 225 return "max"; |
| 226 case ClampedMax: | 226 case ClampedMax: |
| 227 return "clamped-max"; | 227 return "clamped-max"; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 239 | 239 |
| 240 ChannelCountMode oldMode = m_channelCountMode; | 240 ChannelCountMode oldMode = m_channelCountMode; |
| 241 | 241 |
| 242 if (mode == "max") | 242 if (mode == "max") |
| 243 m_channelCountMode = Max; | 243 m_channelCountMode = Max; |
| 244 else if (mode == "clamped-max") | 244 else if (mode == "clamped-max") |
| 245 m_channelCountMode = ClampedMax; | 245 m_channelCountMode = ClampedMax; |
| 246 else if (mode == "explicit") | 246 else if (mode == "explicit") |
| 247 m_channelCountMode = Explicit; | 247 m_channelCountMode = Explicit; |
| 248 else | 248 else |
| 249 es.throwDOMException(InvalidStateError); | 249 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 250 | 250 |
| 251 if (m_channelCountMode != oldMode) | 251 if (m_channelCountMode != oldMode) |
| 252 updateChannelsForInputs(); | 252 updateChannelsForInputs(); |
| 253 } | 253 } |
| 254 | 254 |
| 255 String AudioNode::channelInterpretation() | 255 String AudioNode::channelInterpretation() |
| 256 { | 256 { |
| 257 switch (m_channelInterpretation) { | 257 switch (m_channelInterpretation) { |
| 258 case AudioBus::Speakers: | 258 case AudioBus::Speakers: |
| 259 return "speakers"; | 259 return "speakers"; |
| 260 case AudioBus::Discrete: | 260 case AudioBus::Discrete: |
| 261 return "discrete"; | 261 return "discrete"; |
| 262 } | 262 } |
| 263 ASSERT_NOT_REACHED(); | 263 ASSERT_NOT_REACHED(); |
| 264 return ""; | 264 return ""; |
| 265 } | 265 } |
| 266 | 266 |
| 267 void AudioNode::setChannelInterpretation(const String& interpretation, Exception
State& es) | 267 void AudioNode::setChannelInterpretation(const String& interpretation, Exception
State& es) |
| 268 { | 268 { |
| 269 ASSERT(isMainThread()); | 269 ASSERT(isMainThread()); |
| 270 AudioContext::AutoLocker locker(context()); | 270 AudioContext::AutoLocker locker(context()); |
| 271 | 271 |
| 272 if (interpretation == "speakers") | 272 if (interpretation == "speakers") |
| 273 m_channelInterpretation = AudioBus::Speakers; | 273 m_channelInterpretation = AudioBus::Speakers; |
| 274 else if (interpretation == "discrete") | 274 else if (interpretation == "discrete") |
| 275 m_channelInterpretation = AudioBus::Discrete; | 275 m_channelInterpretation = AudioBus::Discrete; |
| 276 else | 276 else |
| 277 es.throwDOMException(InvalidStateError); | 277 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| 278 } | 278 } |
| 279 | 279 |
| 280 void AudioNode::updateChannelsForInputs() | 280 void AudioNode::updateChannelsForInputs() |
| 281 { | 281 { |
| 282 for (unsigned i = 0; i < m_inputs.size(); ++i) | 282 for (unsigned i = 0; i < m_inputs.size(); ++i) |
| 283 input(i)->changedOutputs(); | 283 input(i)->changedOutputs(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 const AtomicString& AudioNode::interfaceName() const | 286 const AtomicString& AudioNode::interfaceName() const |
| 287 { | 287 { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 fprintf(stderr, "%d: %d\n", i, s_nodeCount[i]); | 519 fprintf(stderr, "%d: %d\n", i, s_nodeCount[i]); |
| 520 | 520 |
| 521 fprintf(stderr, "===========================\n\n\n"); | 521 fprintf(stderr, "===========================\n\n\n"); |
| 522 } | 522 } |
| 523 | 523 |
| 524 #endif // DEBUG_AUDIONODE_REFERENCES | 524 #endif // DEBUG_AUDIONODE_REFERENCES |
| 525 | 525 |
| 526 } // namespace WebCore | 526 } // namespace WebCore |
| 527 | 527 |
| 528 #endif // ENABLE(WEB_AUDIO) | 528 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |