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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 "unable to create buffer of " + String::number(numberOfChannels) | 300 "unable to create buffer of " + String::number(numberOfChannels) |
301 + " channel(s) of " + String::number(numberOfFrames) | 301 + " channel(s) of " + String::number(numberOfFrames) |
302 + " frames each."); | 302 + " frames each."); |
303 } | 303 } |
304 return nullptr; | 304 return nullptr; |
305 } | 305 } |
306 | 306 |
307 return audioBuffer; | 307 return audioBuffer; |
308 } | 308 } |
309 | 309 |
310 PassRefPtr<AudioBuffer> AudioContext::createBuffer(ArrayBuffer* arrayBuffer, boo
l mixToMono, ExceptionState& exceptionState) | |
311 { | |
312 ASSERT(arrayBuffer); | |
313 if (!arrayBuffer) { | |
314 exceptionState.throwDOMException( | |
315 SyntaxError, | |
316 "invalid ArrayBuffer."); | |
317 return nullptr; | |
318 } | |
319 | |
320 RefPtr<AudioBuffer> audioBuffer = AudioBuffer::createFromAudioFileData(array
Buffer->data(), arrayBuffer->byteLength(), mixToMono, sampleRate()); | |
321 if (!audioBuffer.get()) { | |
322 exceptionState.throwDOMException( | |
323 SyntaxError, | |
324 "invalid audio data in ArrayBuffer."); | |
325 return nullptr; | |
326 } | |
327 | |
328 return audioBuffer; | |
329 } | |
330 | |
331 void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassOwnPtr<AudioBuffe
rCallback> successCallback, PassOwnPtr<AudioBufferCallback> errorCallback, Excep
tionState& exceptionState) | 310 void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassOwnPtr<AudioBuffe
rCallback> successCallback, PassOwnPtr<AudioBufferCallback> errorCallback, Excep
tionState& exceptionState) |
332 { | 311 { |
333 if (!audioData) { | 312 if (!audioData) { |
334 exceptionState.throwDOMException( | 313 exceptionState.throwDOMException( |
335 SyntaxError, | 314 SyntaxError, |
336 "invalid ArrayBuffer for audioData."); | 315 "invalid ArrayBuffer for audioData."); |
337 return; | 316 return; |
338 } | 317 } |
339 m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCa
llback); | 318 m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCa
llback); |
340 } | 319 } |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 } | 992 } |
1014 | 993 |
1015 void AudioContext::decrementActiveSourceCount() | 994 void AudioContext::decrementActiveSourceCount() |
1016 { | 995 { |
1017 atomicDecrement(&m_activeSourceCount); | 996 atomicDecrement(&m_activeSourceCount); |
1018 } | 997 } |
1019 | 998 |
1020 } // namespace WebCore | 999 } // namespace WebCore |
1021 | 1000 |
1022 #endif // ENABLE(WEB_AUDIO) | 1001 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |