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

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

Issue 1481793002: Drop [LegacyInterfaceTypeChecking] where trivial in Web Audio (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update tests Created 5 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 * 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return AudioBuffer::create(numberOfChannels, numberOfFrames, sampleRate, exc eptionState); 191 return AudioBuffer::create(numberOfChannels, numberOfFrames, sampleRate, exc eptionState);
192 } 192 }
193 193
194 void AbstractAudioContext::decodeAudioData(DOMArrayBuffer* audioData, AudioBuffe rCallback* successCallback, AudioBufferCallback* errorCallback, ExceptionState& exceptionState) 194 void AbstractAudioContext::decodeAudioData(DOMArrayBuffer* audioData, AudioBuffe rCallback* successCallback, AudioBufferCallback* errorCallback, ExceptionState& exceptionState)
195 { 195 {
196 if (isContextClosed()) { 196 if (isContextClosed()) {
197 throwExceptionForClosedState(exceptionState); 197 throwExceptionForClosedState(exceptionState);
198 return; 198 return;
199 } 199 }
200 200
201 if (!audioData) {
202 exceptionState.throwDOMException(
203 SyntaxError,
204 "invalid ArrayBuffer for audioData.");
205 return;
206 }
207 m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCa llback); 201 m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCa llback);
208 } 202 }
209 203
210 AudioBufferSourceNode* AbstractAudioContext::createBufferSource(ExceptionState& exceptionState) 204 AudioBufferSourceNode* AbstractAudioContext::createBufferSource(ExceptionState& exceptionState)
211 { 205 {
212 ASSERT(isMainThread()); 206 ASSERT(isMainThread());
213 207
214 if (isContextClosed()) { 208 if (isContextClosed()) {
215 throwExceptionForClosedState(exceptionState); 209 throwExceptionForClosedState(exceptionState);
216 return nullptr; 210 return nullptr;
217 } 211 }
218 212
219 AudioBufferSourceNode* node = AudioBufferSourceNode::create(*this, sampleRat e()); 213 AudioBufferSourceNode* node = AudioBufferSourceNode::create(*this, sampleRat e());
220 214
221 // Do not add a reference to this source node now. The reference will be add ed when start() is 215 // Do not add a reference to this source node now. The reference will be add ed when start() is
222 // called. 216 // called.
223 217
224 return node; 218 return node;
225 } 219 }
226 220
227 MediaElementAudioSourceNode* AbstractAudioContext::createMediaElementSource(HTML MediaElement* mediaElement, ExceptionState& exceptionState) 221 MediaElementAudioSourceNode* AbstractAudioContext::createMediaElementSource(HTML MediaElement* mediaElement, ExceptionState& exceptionState)
228 { 222 {
229 ASSERT(isMainThread()); 223 ASSERT(isMainThread());
230 224
231 if (isContextClosed()) { 225 if (isContextClosed()) {
232 throwExceptionForClosedState(exceptionState); 226 throwExceptionForClosedState(exceptionState);
233 return nullptr; 227 return nullptr;
234 } 228 }
235 229
236 if (!mediaElement) {
237 exceptionState.throwDOMException(
238 InvalidStateError,
239 "invalid HTMLMedialElement.");
240 return nullptr;
241 }
242
243 // First check if this media element already has a source node. 230 // First check if this media element already has a source node.
244 if (mediaElement->audioSourceNode()) { 231 if (mediaElement->audioSourceNode()) {
245 exceptionState.throwDOMException( 232 exceptionState.throwDOMException(
246 InvalidStateError, 233 InvalidStateError,
247 "HTMLMediaElement already connected previously to a different MediaE lementSourceNode."); 234 "HTMLMediaElement already connected previously to a different MediaE lementSourceNode.");
248 return nullptr; 235 return nullptr;
249 } 236 }
250 237
251 MediaElementAudioSourceNode* node = MediaElementAudioSourceNode::create(*thi s, *mediaElement); 238 MediaElementAudioSourceNode* node = MediaElementAudioSourceNode::create(*thi s, *mediaElement);
252 239
253 mediaElement->setAudioSourceNode(node); 240 mediaElement->setAudioSourceNode(node);
254 241
255 notifySourceNodeStartedProcessing(node); // context keeps reference until no de is disconnected 242 notifySourceNodeStartedProcessing(node); // context keeps reference until no de is disconnected
256 return node; 243 return node;
257 } 244 }
258 245
259 MediaStreamAudioSourceNode* AbstractAudioContext::createMediaStreamSource(MediaS tream* mediaStream, ExceptionState& exceptionState) 246 MediaStreamAudioSourceNode* AbstractAudioContext::createMediaStreamSource(MediaS tream* mediaStream, ExceptionState& exceptionState)
260 { 247 {
261 ASSERT(isMainThread()); 248 ASSERT(isMainThread());
262 249
263 if (isContextClosed()) { 250 if (isContextClosed()) {
264 throwExceptionForClosedState(exceptionState); 251 throwExceptionForClosedState(exceptionState);
265 return nullptr; 252 return nullptr;
266 } 253 }
267 254
268 if (!mediaStream) {
269 exceptionState.throwDOMException(
270 InvalidStateError,
271 "invalid MediaStream source");
272 return nullptr;
273 }
274
275 MediaStreamTrackVector audioTracks = mediaStream->getAudioTracks(); 255 MediaStreamTrackVector audioTracks = mediaStream->getAudioTracks();
276 if (audioTracks.isEmpty()) { 256 if (audioTracks.isEmpty()) {
277 exceptionState.throwDOMException( 257 exceptionState.throwDOMException(
278 InvalidStateError, 258 InvalidStateError,
279 "MediaStream has no audio track"); 259 "MediaStream has no audio track");
280 return nullptr; 260 return nullptr;
281 } 261 }
282 262
283 // Use the first audio track in the media stream. 263 // Use the first audio track in the media stream.
284 MediaStreamTrack* audioTrack = audioTracks[0]; 264 MediaStreamTrack* audioTrack = audioTracks[0];
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 531
552 PeriodicWave* AbstractAudioContext::createPeriodicWave(DOMFloat32Array* real, DO MFloat32Array* imag, const Dictionary& options, ExceptionState& exceptionState) 532 PeriodicWave* AbstractAudioContext::createPeriodicWave(DOMFloat32Array* real, DO MFloat32Array* imag, const Dictionary& options, ExceptionState& exceptionState)
553 { 533 {
554 ASSERT(isMainThread()); 534 ASSERT(isMainThread());
555 535
556 if (isContextClosed()) { 536 if (isContextClosed()) {
557 throwExceptionForClosedState(exceptionState); 537 throwExceptionForClosedState(exceptionState);
558 return nullptr; 538 return nullptr;
559 } 539 }
560 540
561 if (!real) {
562 exceptionState.throwDOMException(
563 SyntaxError,
564 "invalid real array");
565 return nullptr;
566 }
567
568 if (!imag) {
569 exceptionState.throwDOMException(
570 SyntaxError,
571 "invalid imaginary array");
572 return nullptr;
573 }
574
575 if (real->length() != imag->length()) { 541 if (real->length() != imag->length()) {
576 exceptionState.throwDOMException( 542 exceptionState.throwDOMException(
577 IndexSizeError, 543 IndexSizeError,
578 "length of real array (" + String::number(real->length()) 544 "length of real array (" + String::number(real->length())
579 + ") and length of imaginary array (" + String::number(imag->length ()) 545 + ") and length of imaginary array (" + String::number(imag->length ())
580 + ") must match."); 546 + ") must match.");
581 return nullptr; 547 return nullptr;
582 } 548 }
583 549
584 bool isNormalizationDisabled = false; 550 bool isNormalizationDisabled = false;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 { 785 {
820 if (executionContext()) 786 if (executionContext())
821 return executionContext()->securityOrigin(); 787 return executionContext()->securityOrigin();
822 788
823 return nullptr; 789 return nullptr;
824 } 790 }
825 791
826 } // namespace blink 792 } // namespace blink
827 793
828 #endif // ENABLE(WEB_AUDIO) 794 #endif // ENABLE(WEB_AUDIO)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698