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 15 matching lines...) Expand all Loading... |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #include "config.h" | 29 #include "config.h" |
30 #if ENABLE(WEB_AUDIO) | 30 #if ENABLE(WEB_AUDIO) |
31 #include "modules/webaudio/AudioBuffer.h" | 31 #include "modules/webaudio/AudioBuffer.h" |
32 | 32 |
33 #include "bindings/core/v8/ExceptionMessages.h" | 33 #include "bindings/core/v8/ExceptionMessages.h" |
34 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
35 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
36 #include "modules/webaudio/AudioContext.h" | 36 #include "modules/webaudio/AbstractAudioContext.h" |
37 #include "platform/audio/AudioBus.h" | 37 #include "platform/audio/AudioBus.h" |
38 #include "platform/audio/AudioFileReader.h" | 38 #include "platform/audio/AudioFileReader.h" |
39 #include "platform/audio/AudioUtilities.h" | 39 #include "platform/audio/AudioUtilities.h" |
40 #include "wtf/Float32Array.h" | 40 #include "wtf/Float32Array.h" |
41 | 41 |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 AudioBuffer* AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrame
s, float sampleRate) | 44 AudioBuffer* AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrame
s, float sampleRate) |
45 { | 45 { |
46 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate) || numberOfCha
nnels > AudioContext::maxNumberOfChannels() || !numberOfChannels || !numberOfFra
mes) | 46 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate) || numberOfCha
nnels > AbstractAudioContext::maxNumberOfChannels() || !numberOfChannels || !num
berOfFrames) |
47 return nullptr; | 47 return nullptr; |
48 | 48 |
49 AudioBuffer* buffer = new AudioBuffer(numberOfChannels, numberOfFrames, samp
leRate); | 49 AudioBuffer* buffer = new AudioBuffer(numberOfChannels, numberOfFrames, samp
leRate); |
50 | 50 |
51 if (!buffer->createdSuccessfully(numberOfChannels)) | 51 if (!buffer->createdSuccessfully(numberOfChannels)) |
52 return nullptr; | 52 return nullptr; |
53 return buffer; | 53 return buffer; |
54 } | 54 } |
55 | 55 |
56 AudioBuffer* AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrame
s, float sampleRate, ExceptionState& exceptionState) | 56 AudioBuffer* AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrame
s, float sampleRate, ExceptionState& exceptionState) |
57 { | 57 { |
58 if (!numberOfChannels || numberOfChannels > AudioContext::maxNumberOfChannel
s()) { | 58 if (!numberOfChannels || numberOfChannels > AbstractAudioContext::maxNumberO
fChannels()) { |
59 exceptionState.throwDOMException( | 59 exceptionState.throwDOMException( |
60 NotSupportedError, | 60 NotSupportedError, |
61 ExceptionMessages::indexOutsideRange( | 61 ExceptionMessages::indexOutsideRange( |
62 "number of channels", | 62 "number of channels", |
63 numberOfChannels, | 63 numberOfChannels, |
64 1u, | 64 1u, |
65 ExceptionMessages::InclusiveBound, | 65 ExceptionMessages::InclusiveBound, |
66 AudioContext::maxNumberOfChannels(), | 66 AbstractAudioContext::maxNumberOfChannels(), |
67 ExceptionMessages::InclusiveBound)); | 67 ExceptionMessages::InclusiveBound)); |
68 return nullptr; | 68 return nullptr; |
69 } | 69 } |
70 | 70 |
71 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate)) { | 71 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate)) { |
72 exceptionState.throwDOMException( | 72 exceptionState.throwDOMException( |
73 NotSupportedError, | 73 NotSupportedError, |
74 ExceptionMessages::indexOutsideRange( | 74 ExceptionMessages::indexOutsideRange( |
75 "sample rate", | 75 "sample rate", |
76 sampleRate, | 76 sampleRate, |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 if (DOMFloat32Array* array = getChannelData(i)) { | 321 if (DOMFloat32Array* array = getChannelData(i)) { |
322 float* data = array->data(); | 322 float* data = array->data(); |
323 memset(data, 0, length() * sizeof(*data)); | 323 memset(data, 0, length() * sizeof(*data)); |
324 } | 324 } |
325 } | 325 } |
326 } | 326 } |
327 | 327 |
328 } // namespace blink | 328 } // namespace blink |
329 | 329 |
330 #endif // ENABLE(WEB_AUDIO) | 330 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |