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 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 return m_channels[channelIndex].get(); | 201 return m_channels[channelIndex].get(); |
202 } | 202 } |
203 | 203 |
204 void AudioBuffer::copyFromChannel(DOMFloat32Array* destination, long channelNumb
er, ExceptionState& exceptionState) | 204 void AudioBuffer::copyFromChannel(DOMFloat32Array* destination, long channelNumb
er, ExceptionState& exceptionState) |
205 { | 205 { |
206 return copyFromChannel(destination, channelNumber, 0, exceptionState); | 206 return copyFromChannel(destination, channelNumber, 0, exceptionState); |
207 } | 207 } |
208 | 208 |
209 void AudioBuffer::copyFromChannel(DOMFloat32Array* destination, long channelNumb
er, unsigned long startInChannel, ExceptionState& exceptionState) | 209 void AudioBuffer::copyFromChannel(DOMFloat32Array* destination, long channelNumb
er, unsigned long startInChannel, ExceptionState& exceptionState) |
210 { | 210 { |
211 if (!destination) { | |
212 exceptionState.throwDOMException( | |
213 TypeMismatchError, | |
214 ExceptionMessages::argumentNullOrIncorrectType( | |
215 1, | |
216 "Float32Array")); | |
217 return; | |
218 } | |
219 | |
220 if (channelNumber < 0 || channelNumber >= static_cast<long>(m_channels.size(
))) { | 211 if (channelNumber < 0 || channelNumber >= static_cast<long>(m_channels.size(
))) { |
221 exceptionState.throwDOMException( | 212 exceptionState.throwDOMException( |
222 IndexSizeError, | 213 IndexSizeError, |
223 ExceptionMessages::indexOutsideRange( | 214 ExceptionMessages::indexOutsideRange( |
224 "channelNumber", | 215 "channelNumber", |
225 channelNumber, | 216 channelNumber, |
226 0L, | 217 0L, |
227 ExceptionMessages::InclusiveBound, | 218 ExceptionMessages::InclusiveBound, |
228 static_cast<long>(m_channels.size() - 1), | 219 static_cast<long>(m_channels.size() - 1), |
229 ExceptionMessages::InclusiveBound)); | 220 ExceptionMessages::InclusiveBound)); |
(...skipping 28 matching lines...) Expand all Loading... |
258 memcpy(dst, src + startInChannel, count * sizeof(*src)); | 249 memcpy(dst, src + startInChannel, count * sizeof(*src)); |
259 } | 250 } |
260 | 251 |
261 void AudioBuffer::copyToChannel(DOMFloat32Array* source, long channelNumber, Exc
eptionState& exceptionState) | 252 void AudioBuffer::copyToChannel(DOMFloat32Array* source, long channelNumber, Exc
eptionState& exceptionState) |
262 { | 253 { |
263 return copyToChannel(source, channelNumber, 0, exceptionState); | 254 return copyToChannel(source, channelNumber, 0, exceptionState); |
264 } | 255 } |
265 | 256 |
266 void AudioBuffer::copyToChannel(DOMFloat32Array* source, long channelNumber, uns
igned long startInChannel, ExceptionState& exceptionState) | 257 void AudioBuffer::copyToChannel(DOMFloat32Array* source, long channelNumber, uns
igned long startInChannel, ExceptionState& exceptionState) |
267 { | 258 { |
268 if (!source) { | |
269 exceptionState.throwDOMException( | |
270 TypeMismatchError, | |
271 ExceptionMessages::argumentNullOrIncorrectType( | |
272 1, | |
273 "Float32Array")); | |
274 return; | |
275 } | |
276 | |
277 if (channelNumber < 0 || channelNumber >= static_cast<long>(m_channels.size(
))) { | 259 if (channelNumber < 0 || channelNumber >= static_cast<long>(m_channels.size(
))) { |
278 exceptionState.throwDOMException( | 260 exceptionState.throwDOMException( |
279 IndexSizeError, | 261 IndexSizeError, |
280 ExceptionMessages::indexOutsideRange( | 262 ExceptionMessages::indexOutsideRange( |
281 "channelNumber", | 263 "channelNumber", |
282 channelNumber, | 264 channelNumber, |
283 0L, | 265 0L, |
284 ExceptionMessages::InclusiveBound, | 266 ExceptionMessages::InclusiveBound, |
285 static_cast<long>(m_channels.size() - 1), | 267 static_cast<long>(m_channels.size() - 1), |
286 ExceptionMessages::InclusiveBound)); | 268 ExceptionMessages::InclusiveBound)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 if (DOMFloat32Array* array = getChannelData(i)) { | 303 if (DOMFloat32Array* array = getChannelData(i)) { |
322 float* data = array->data(); | 304 float* data = array->data(); |
323 memset(data, 0, length() * sizeof(*data)); | 305 memset(data, 0, length() * sizeof(*data)); |
324 } | 306 } |
325 } | 307 } |
326 } | 308 } |
327 | 309 |
328 } // namespace blink | 310 } // namespace blink |
329 | 311 |
330 #endif // ENABLE(WEB_AUDIO) | 312 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |