| 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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 OscillatorNode* OscillatorNode::Create(BaseAudioContext* context, | 395 OscillatorNode* OscillatorNode::Create(BaseAudioContext* context, |
| 396 const OscillatorOptions& options, | 396 const OscillatorOptions& options, |
| 397 ExceptionState& exception_state) { | 397 ExceptionState& exception_state) { |
| 398 OscillatorNode* node = Create(*context, exception_state); | 398 OscillatorNode* node = Create(*context, exception_state); |
| 399 | 399 |
| 400 if (!node) | 400 if (!node) |
| 401 return nullptr; | 401 return nullptr; |
| 402 | 402 |
| 403 node->HandleChannelOptions(options, exception_state); | 403 node->HandleChannelOptions(options, exception_state); |
| 404 | 404 |
| 405 if (options.hasType()) { | 405 if (options.hasPeriodicWave()) { |
| 406 if (options.type() == "custom" && !options.hasPeriodicWave()) { | 406 // Set up the custom wave; this also sets the type to "custom", |
| 407 exception_state.ThrowDOMException(kInvalidStateError, | 407 // overriding any |type| option the user may have set. Per spec. |
| 408 "'type' cannot be set to 'custom' " | 408 node->setPeriodicWave(options.periodicWave()); |
| 409 "without also specifying " | 409 } else { |
| 410 "'periodicWave'"); | 410 node->setType(options.type(), exception_state); |
| 411 return nullptr; | 411 } |
| 412 } | |
| 413 if (options.type() != "custom" && options.hasPeriodicWave()) { | |
| 414 exception_state.ThrowDOMException( | |
| 415 kInvalidStateError, "'type' MUST be 'custom' instead of '" + | |
| 416 options.type() + | |
| 417 "' if 'periodicWave' is also given"); | |
| 418 return nullptr; | |
| 419 } | |
| 420 | 412 |
| 421 // At this both type and periodicWave are consistently defined. In that | 413 node->detune()->setValue(options.detune()); |
| 422 // case, don't set the type if periodicWave is specified because that | 414 node->frequency()->setValue(options.frequency()); |
| 423 // will cause an (incorrect) error to be signaled. | |
| 424 if (options.type() != "custom") | |
| 425 node->setType(options.type(), exception_state); | |
| 426 } | |
| 427 if (options.hasDetune()) | |
| 428 node->detune()->setValue(options.detune()); | |
| 429 if (options.hasFrequency()) | |
| 430 node->frequency()->setValue(options.frequency()); | |
| 431 | |
| 432 if (options.hasPeriodicWave()) | |
| 433 node->setPeriodicWave(options.periodicWave()); | |
| 434 | 415 |
| 435 return node; | 416 return node; |
| 436 } | 417 } |
| 437 | 418 |
| 438 DEFINE_TRACE(OscillatorNode) { | 419 DEFINE_TRACE(OscillatorNode) { |
| 439 visitor->Trace(frequency_); | 420 visitor->Trace(frequency_); |
| 440 visitor->Trace(detune_); | 421 visitor->Trace(detune_); |
| 441 AudioScheduledSourceNode::Trace(visitor); | 422 AudioScheduledSourceNode::Trace(visitor); |
| 442 } | 423 } |
| 443 | 424 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 460 | 441 |
| 461 AudioParam* OscillatorNode::detune() { | 442 AudioParam* OscillatorNode::detune() { |
| 462 return detune_; | 443 return detune_; |
| 463 } | 444 } |
| 464 | 445 |
| 465 void OscillatorNode::setPeriodicWave(PeriodicWave* wave) { | 446 void OscillatorNode::setPeriodicWave(PeriodicWave* wave) { |
| 466 GetOscillatorHandler().SetPeriodicWave(wave); | 447 GetOscillatorHandler().SetPeriodicWave(wave); |
| 467 } | 448 } |
| 468 | 449 |
| 469 } // namespace blink | 450 } // namespace blink |
| OLD | NEW |