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

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

Issue 1952793002: Move the exception logic to the AudioNode creator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move more things to Node::create() Created 4 years, 7 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) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 m_type = CUSTOM; 323 m_type = CUSTOM;
324 } 324 }
325 325
326 bool OscillatorHandler::propagatesSilence() const 326 bool OscillatorHandler::propagatesSilence() const
327 { 327 {
328 return !isPlayingOrScheduled() || hasFinished() || !m_periodicWave.get(); 328 return !isPlayingOrScheduled() || hasFinished() || !m_periodicWave.get();
329 } 329 }
330 330
331 // ---------------------------------------------------------------- 331 // ----------------------------------------------------------------
332 332
333 OscillatorNode::OscillatorNode(AbstractAudioContext& context, float sampleRate) 333 OscillatorNode::OscillatorNode(AbstractAudioContext& context)
334 : AudioScheduledSourceNode(context) 334 : AudioScheduledSourceNode(context)
335 // Use musical pitch standard A440 as a default. 335 // Use musical pitch standard A440 as a default.
336 , m_frequency(AudioParam::create(context, ParamTypeOscillatorFrequency, 440) ) 336 , m_frequency(AudioParam::create(context, ParamTypeOscillatorFrequency, 440) )
337 // Default to no detuning. 337 // Default to no detuning.
338 , m_detune(AudioParam::create(context, ParamTypeOscillatorDetune, 0)) 338 , m_detune(AudioParam::create(context, ParamTypeOscillatorDetune, 0))
339 { 339 {
340 setHandler(OscillatorHandler::create(*this, sampleRate, m_frequency->handler (), m_detune->handler())); 340 setHandler(OscillatorHandler::create(*this, context.sampleRate(), m_frequenc y->handler(), m_detune->handler()));
hongchan 2016/05/13 01:20:12 Over 80 cols. Let's wrap this!
341 } 341 }
342 342
343 OscillatorNode* OscillatorNode::create(AbstractAudioContext& context, float samp leRate) 343 OscillatorNode* OscillatorNode::create(AbstractAudioContext& context, ExceptionS tate& exceptionState)
hongchan 2016/05/13 01:20:12 Over 80 cols.
344 { 344 {
345 return new OscillatorNode(context, sampleRate); 345 ASSERT(isMainThread());
hongchan 2016/05/13 01:20:12 DCHECK.
346
347 if (context.isContextClosed()) {
348 context.throwExceptionForClosedState(exceptionState);
349 return nullptr;
350 }
351
352 return new OscillatorNode(context);
346 } 353 }
347 354
348 DEFINE_TRACE(OscillatorNode) 355 DEFINE_TRACE(OscillatorNode)
349 { 356 {
350 visitor->trace(m_frequency); 357 visitor->trace(m_frequency);
351 visitor->trace(m_detune); 358 visitor->trace(m_detune);
352 AudioScheduledSourceNode::trace(visitor); 359 AudioScheduledSourceNode::trace(visitor);
353 } 360 }
354 361
355 OscillatorHandler& OscillatorNode::oscillatorHandler() const 362 OscillatorHandler& OscillatorNode::oscillatorHandler() const
(...skipping 21 matching lines...) Expand all
377 return m_detune; 384 return m_detune;
378 } 385 }
379 386
380 void OscillatorNode::setPeriodicWave(PeriodicWave* wave) 387 void OscillatorNode::setPeriodicWave(PeriodicWave* wave)
381 { 388 {
382 oscillatorHandler().setPeriodicWave(wave); 389 oscillatorHandler().setPeriodicWave(wave);
383 } 390 }
384 391
385 } // namespace blink 392 } // namespace blink
386 393
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698