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

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

Issue 99083002: WIP: Migrate generated bindings to new ExceptionState constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Created 7 years 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 14 matching lines...) Expand all
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 "config.h" 29 #include "config.h"
30 30
31 #if ENABLE(WEB_AUDIO) 31 #if ENABLE(WEB_AUDIO)
32 32
33 #include "modules/webaudio/AudioBuffer.h" 33 #include "modules/webaudio/AudioBuffer.h"
34 34
35 #include "bindings/v8/ExceptionMessages.h"
36 #include "bindings/v8/ExceptionState.h" 35 #include "bindings/v8/ExceptionState.h"
37 #include "core/dom/ExceptionCode.h" 36 #include "core/dom/ExceptionCode.h"
38 #include "platform/audio/AudioBus.h" 37 #include "platform/audio/AudioBus.h"
39 #include "platform/audio/AudioFileReader.h" 38 #include "platform/audio/AudioFileReader.h"
40 #include "modules/webaudio/AudioContext.h" 39 #include "modules/webaudio/AudioContext.h"
41 40
42 namespace WebCore { 41 namespace WebCore {
43 42
44 float AudioBuffer::minAllowedSampleRate() 43 float AudioBuffer::minAllowedSampleRate()
45 { 44 {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 123 }
125 124
126 void AudioBuffer::releaseMemory() 125 void AudioBuffer::releaseMemory()
127 { 126 {
128 m_channels.clear(); 127 m_channels.clear();
129 } 128 }
130 129
131 PassRefPtr<Float32Array> AudioBuffer::getChannelData(unsigned channelIndex, Exce ptionState& exceptionState) 130 PassRefPtr<Float32Array> AudioBuffer::getChannelData(unsigned channelIndex, Exce ptionState& exceptionState)
132 { 131 {
133 if (channelIndex >= m_channels.size()) { 132 if (channelIndex >= m_channels.size()) {
134 exceptionState.throwDOMException( 133 exceptionState.throwDOMException(IndexSizeError, "channel index (" + Str ing::number(channelIndex) + ") exceeds number of channels (" + String::number(m_ channels.size()) + ")");
135 IndexSizeError,
136 ExceptionMessages::failedToExecute(
137 "getChannelData",
138 "AudioBuffer",
139 "channel index (" + String::number(channelIndex) + ") exceeds nu mber of channels (" + String::number(m_channels.size()) + ")"));
140 return 0; 134 return 0;
141 } 135 }
142 136
143 Float32Array* channelData = m_channels[channelIndex].get(); 137 Float32Array* channelData = m_channels[channelIndex].get();
144 return Float32Array::create(channelData->buffer(), channelData->byteOffset() , channelData->length()); 138 return Float32Array::create(channelData->buffer(), channelData->byteOffset() , channelData->length());
145 } 139 }
146 140
147 Float32Array* AudioBuffer::getChannelData(unsigned channelIndex) 141 Float32Array* AudioBuffer::getChannelData(unsigned channelIndex)
148 { 142 {
149 if (channelIndex >= m_channels.size()) 143 if (channelIndex >= m_channels.size())
150 return 0; 144 return 0;
151 145
152 return m_channels[channelIndex].get(); 146 return m_channels[channelIndex].get();
153 } 147 }
154 148
155 void AudioBuffer::zero() 149 void AudioBuffer::zero()
156 { 150 {
157 for (unsigned i = 0; i < m_channels.size(); ++i) { 151 for (unsigned i = 0; i < m_channels.size(); ++i) {
158 if (getChannelData(i)) 152 if (getChannelData(i))
159 getChannelData(i)->zeroRange(0, length()); 153 getChannelData(i)->zeroRange(0, length());
160 } 154 }
161 } 155 }
162 156
163 } // namespace WebCore 157 } // namespace WebCore
164 158
165 #endif // ENABLE(WEB_AUDIO) 159 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/speech/SpeechRecognition.cpp ('k') | Source/modules/webaudio/AudioBufferSourceNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698