OLD | NEW |
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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 DCHECK(isMainThread()); | 347 DCHECK(isMainThread()); |
348 | 348 |
349 if (context.isContextClosed()) { | 349 if (context.isContextClosed()) { |
350 context.throwExceptionForClosedState(exceptionState); | 350 context.throwExceptionForClosedState(exceptionState); |
351 return nullptr; | 351 return nullptr; |
352 } | 352 } |
353 | 353 |
354 return new OscillatorNode(context); | 354 return new OscillatorNode(context); |
355 } | 355 } |
356 | 356 |
| 357 OscillatorNode* OscillatorNode::create(BaseAudioContext* context, const Oscillat
orOptions& options, ExceptionState& exceptionState) |
| 358 { |
| 359 OscillatorNode* node = create(*context, exceptionState); |
| 360 |
| 361 if (!node) |
| 362 return nullptr; |
| 363 |
| 364 node->handleChannelOptions(options, exceptionState); |
| 365 |
| 366 if (options.hasType()) { |
| 367 if (options.type() == "custom" && !options.hasPeriodicWave()) { |
| 368 exceptionState.throwDOMException( |
| 369 InvalidStateError, |
| 370 "'type' cannot be set to 'custom' without also specifying 'perio
dicWave'"); |
| 371 return nullptr; |
| 372 } |
| 373 if (options.type() != "custom" && options.hasPeriodicWave()) { |
| 374 exceptionState.throwDOMException( |
| 375 InvalidStateError, |
| 376 "'type' MUST be 'custom' instead of '" |
| 377 + options.type() |
| 378 + "' if 'periodicWave' is also given"); |
| 379 return nullptr; |
| 380 } |
| 381 |
| 382 // At this both type and periodicWave are consistently defined. In that |
| 383 // case, don't set the type if periodicWave is specified because that |
| 384 // will cause an (incorrect) error to be signaled. |
| 385 if (options.type() != "custom") |
| 386 node->setType(options.type(), exceptionState); |
| 387 } |
| 388 if (options.hasDetune()) |
| 389 node->detune()->setValue(options.detune()); |
| 390 if (options.hasFrequency()) |
| 391 node->frequency()->setValue(options.frequency()); |
| 392 |
| 393 if (options.hasPeriodicWave()) |
| 394 node->setPeriodicWave(options.periodicWave()); |
| 395 |
| 396 return node; |
| 397 } |
| 398 |
357 DEFINE_TRACE(OscillatorNode) | 399 DEFINE_TRACE(OscillatorNode) |
358 { | 400 { |
359 visitor->trace(m_frequency); | 401 visitor->trace(m_frequency); |
360 visitor->trace(m_detune); | 402 visitor->trace(m_detune); |
361 AudioScheduledSourceNode::trace(visitor); | 403 AudioScheduledSourceNode::trace(visitor); |
362 } | 404 } |
363 | 405 |
364 OscillatorHandler& OscillatorNode::oscillatorHandler() const | 406 OscillatorHandler& OscillatorNode::oscillatorHandler() const |
365 { | 407 { |
366 return static_cast<OscillatorHandler&>(handler()); | 408 return static_cast<OscillatorHandler&>(handler()); |
(...skipping 19 matching lines...) Expand all Loading... |
386 return m_detune; | 428 return m_detune; |
387 } | 429 } |
388 | 430 |
389 void OscillatorNode::setPeriodicWave(PeriodicWave* wave) | 431 void OscillatorNode::setPeriodicWave(PeriodicWave* wave) |
390 { | 432 { |
391 oscillatorHandler().setPeriodicWave(wave); | 433 oscillatorHandler().setPeriodicWave(wave); |
392 } | 434 } |
393 | 435 |
394 } // namespace blink | 436 } // namespace blink |
395 | 437 |
OLD | NEW |