Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioBuffer.cpp

Issue 1865583002: Implement BaseAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
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 "modules/webaudio/AudioBuffer.h" 29 #include "modules/webaudio/AudioBuffer.h"
30 #include "bindings/core/v8/ExceptionMessages.h" 30 #include "bindings/core/v8/ExceptionMessages.h"
31 #include "bindings/core/v8/ExceptionState.h" 31 #include "bindings/core/v8/ExceptionState.h"
32 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
33 #include "modules/webaudio/AbstractAudioContext.h" 33 #include "modules/webaudio/BaseAudioContext.h"
34 #include "platform/audio/AudioBus.h" 34 #include "platform/audio/AudioBus.h"
35 #include "platform/audio/AudioFileReader.h" 35 #include "platform/audio/AudioFileReader.h"
36 #include "platform/audio/AudioUtilities.h" 36 #include "platform/audio/AudioUtilities.h"
37 #include "wtf/Float32Array.h" 37 #include "wtf/Float32Array.h"
38 38
39 namespace blink { 39 namespace blink {
40 40
41 AudioBuffer* AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrame s, float sampleRate) 41 AudioBuffer* AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrame s, float sampleRate)
42 { 42 {
43 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate) || numberOfCha nnels > AbstractAudioContext::maxNumberOfChannels() || !numberOfChannels || !num berOfFrames) 43 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate) || numberOfCha nnels > BaseAudioContext::maxNumberOfChannels() || !numberOfChannels || !numberO fFrames)
44 return nullptr; 44 return nullptr;
45 45
46 AudioBuffer* buffer = new AudioBuffer(numberOfChannels, numberOfFrames, samp leRate); 46 AudioBuffer* buffer = new AudioBuffer(numberOfChannels, numberOfFrames, samp leRate);
47 47
48 if (!buffer->createdSuccessfully(numberOfChannels)) 48 if (!buffer->createdSuccessfully(numberOfChannels))
49 return nullptr; 49 return nullptr;
50 return buffer; 50 return buffer;
51 } 51 }
52 52
53 AudioBuffer* AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrame s, float sampleRate, ExceptionState& exceptionState) 53 AudioBuffer* AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrame s, float sampleRate, ExceptionState& exceptionState)
54 { 54 {
55 if (!numberOfChannels || numberOfChannels > AbstractAudioContext::maxNumberO fChannels()) { 55 if (!numberOfChannels || numberOfChannels > BaseAudioContext::maxNumberOfCha nnels()) {
56 exceptionState.throwDOMException( 56 exceptionState.throwDOMException(
57 NotSupportedError, 57 NotSupportedError,
58 ExceptionMessages::indexOutsideRange( 58 ExceptionMessages::indexOutsideRange(
59 "number of channels", 59 "number of channels",
60 numberOfChannels, 60 numberOfChannels,
61 1u, 61 1u,
62 ExceptionMessages::InclusiveBound, 62 ExceptionMessages::InclusiveBound,
63 AbstractAudioContext::maxNumberOfChannels(), 63 BaseAudioContext::maxNumberOfChannels(),
64 ExceptionMessages::InclusiveBound)); 64 ExceptionMessages::InclusiveBound));
65 return nullptr; 65 return nullptr;
66 } 66 }
67 67
68 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate)) { 68 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate)) {
69 exceptionState.throwDOMException( 69 exceptionState.throwDOMException(
70 NotSupportedError, 70 NotSupportedError,
71 ExceptionMessages::indexOutsideRange( 71 ExceptionMessages::indexOutsideRange(
72 "sample rate", 72 "sample rate",
73 sampleRate, 73 sampleRate,
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 for (unsigned i = 0; i < m_channels.size(); ++i) { 299 for (unsigned i = 0; i < m_channels.size(); ++i) {
300 if (DOMFloat32Array* array = getChannelData(i)) { 300 if (DOMFloat32Array* array = getChannelData(i)) {
301 float* data = array->data(); 301 float* data = array->data();
302 memset(data, 0, length() * sizeof(*data)); 302 memset(data, 0, length() * sizeof(*data));
303 } 303 }
304 } 304 }
305 } 305 }
306 306
307 } // namespace blink 307 } // namespace blink
308 308
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698