Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 #include "modules/webaudio/AudioNodeInput.h" | 43 #include "modules/webaudio/AudioNodeInput.h" |
| 44 #include "modules/webaudio/AudioNodeOutput.h" | 44 #include "modules/webaudio/AudioNodeOutput.h" |
| 45 #include "modules/webaudio/BiquadFilterNode.h" | 45 #include "modules/webaudio/BiquadFilterNode.h" |
| 46 #include "modules/webaudio/ChannelMergerNode.h" | 46 #include "modules/webaudio/ChannelMergerNode.h" |
| 47 #include "modules/webaudio/ChannelSplitterNode.h" | 47 #include "modules/webaudio/ChannelSplitterNode.h" |
| 48 #include "modules/webaudio/ConvolverNode.h" | 48 #include "modules/webaudio/ConvolverNode.h" |
| 49 #include "modules/webaudio/DefaultAudioDestinationNode.h" | 49 #include "modules/webaudio/DefaultAudioDestinationNode.h" |
| 50 #include "modules/webaudio/DelayNode.h" | 50 #include "modules/webaudio/DelayNode.h" |
| 51 #include "modules/webaudio/DynamicsCompressorNode.h" | 51 #include "modules/webaudio/DynamicsCompressorNode.h" |
| 52 #include "modules/webaudio/GainNode.h" | 52 #include "modules/webaudio/GainNode.h" |
| 53 #include "modules/webaudio/IIRFilterNode.h" | |
| 53 #include "modules/webaudio/MediaElementAudioSourceNode.h" | 54 #include "modules/webaudio/MediaElementAudioSourceNode.h" |
| 54 #include "modules/webaudio/MediaStreamAudioDestinationNode.h" | 55 #include "modules/webaudio/MediaStreamAudioDestinationNode.h" |
| 55 #include "modules/webaudio/MediaStreamAudioSourceNode.h" | 56 #include "modules/webaudio/MediaStreamAudioSourceNode.h" |
| 56 #include "modules/webaudio/OfflineAudioCompletionEvent.h" | 57 #include "modules/webaudio/OfflineAudioCompletionEvent.h" |
| 57 #include "modules/webaudio/OfflineAudioContext.h" | 58 #include "modules/webaudio/OfflineAudioContext.h" |
| 58 #include "modules/webaudio/OfflineAudioDestinationNode.h" | 59 #include "modules/webaudio/OfflineAudioDestinationNode.h" |
| 59 #include "modules/webaudio/OscillatorNode.h" | 60 #include "modules/webaudio/OscillatorNode.h" |
| 60 #include "modules/webaudio/PannerNode.h" | 61 #include "modules/webaudio/PannerNode.h" |
| 61 #include "modules/webaudio/PeriodicWave.h" | 62 #include "modules/webaudio/PeriodicWave.h" |
| 62 #include "modules/webaudio/ScriptProcessorNode.h" | 63 #include "modules/webaudio/ScriptProcessorNode.h" |
| 63 #include "modules/webaudio/StereoPannerNode.h" | 64 #include "modules/webaudio/StereoPannerNode.h" |
| 64 #include "modules/webaudio/WaveShaperNode.h" | 65 #include "modules/webaudio/WaveShaperNode.h" |
| 65 #include "platform/ThreadSafeFunctional.h" | 66 #include "platform/ThreadSafeFunctional.h" |
| 67 #include "platform/audio/IIRFilter.h" | |
| 66 #include "public/platform/Platform.h" | 68 #include "public/platform/Platform.h" |
| 67 #include "wtf/text/WTFString.h" | 69 #include "wtf/text/WTFString.h" |
| 68 | 70 |
| 69 namespace blink { | 71 namespace blink { |
| 70 | 72 |
| 71 AbstractAudioContext* AbstractAudioContext::create(Document& document, Exception State& exceptionState) | 73 AbstractAudioContext* AbstractAudioContext::create(Document& document, Exception State& exceptionState) |
| 72 { | 74 { |
| 73 return AudioContext::create(document, exceptionState); | 75 return AudioContext::create(document, exceptionState); |
| 74 } | 76 } |
| 75 | 77 |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 + ") must match."); | 545 + ") must match."); |
| 544 return nullptr; | 546 return nullptr; |
| 545 } | 547 } |
| 546 | 548 |
| 547 bool isNormalizationDisabled = false; | 549 bool isNormalizationDisabled = false; |
| 548 DictionaryHelper::getWithUndefinedOrNullCheck(options, "disableNormalization ", isNormalizationDisabled); | 550 DictionaryHelper::getWithUndefinedOrNullCheck(options, "disableNormalization ", isNormalizationDisabled); |
| 549 | 551 |
| 550 return PeriodicWave::create(sampleRate(), real, imag, isNormalizationDisable d); | 552 return PeriodicWave::create(sampleRate(), real, imag, isNormalizationDisable d); |
| 551 } | 553 } |
| 552 | 554 |
| 555 IIRFilterNode* AbstractAudioContext::createIIRFilter(Vector<double> feedforwardC oef, Vector<double> feedbackCoef, ExceptionState& exceptionState) | |
| 556 { | |
| 557 ASSERT(isMainThread()); | |
| 558 | |
| 559 if (isContextClosed()) { | |
| 560 throwExceptionForClosedState(exceptionState); | |
| 561 return nullptr; | |
| 562 } | |
| 563 | |
| 564 if (!feedbackCoef.size() || (feedbackCoef.size() > IIRFilter::kMaxOrder + 1) ) { | |
|
tkent
2016/01/13 03:28:28
nit: You may compare with 0 like |feedbackCoef.siz
Raymond Toy
2016/01/13 18:30:53
Ah, this seems to have changed from the original w
| |
| 565 exceptionState.throwDOMException( | |
| 566 NotSupportedError, | |
| 567 ExceptionMessages::indexOutsideRange<size_t>( | |
| 568 "number of feedback coefficients", | |
| 569 feedbackCoef.size(), | |
| 570 1, | |
| 571 ExceptionMessages::InclusiveBound, | |
| 572 IIRFilter::kMaxOrder + 1, | |
| 573 ExceptionMessages::InclusiveBound)); | |
| 574 return nullptr; | |
| 575 } | |
| 576 | |
| 577 if (!feedforwardCoef.size() || (feedforwardCoef.size() > IIRFilter::kMaxOrde r + 1)) { | |
|
tkent
2016/01/13 03:28:28
Ditto.
Raymond Toy
2016/01/13 18:30:53
Done.
| |
| 578 exceptionState.throwDOMException( | |
| 579 NotSupportedError, | |
| 580 ExceptionMessages::indexOutsideRange<size_t>( | |
| 581 "number of feedforward coefficients", | |
| 582 feedforwardCoef.size(), | |
| 583 1, | |
| 584 ExceptionMessages::InclusiveBound, | |
| 585 IIRFilter::kMaxOrder + 1, | |
| 586 ExceptionMessages::InclusiveBound)); | |
| 587 return nullptr; | |
| 588 } | |
| 589 | |
| 590 if (!feedbackCoef[0]) { | |
|
tkent
2016/01/13 03:28:28
Ditto.
Raymond Toy
2016/01/13 18:30:53
Done.
| |
| 591 exceptionState.throwDOMException( | |
| 592 InvalidStateError, | |
| 593 "First feedback coefficient cannot be zero."); | |
| 594 return nullptr; | |
| 595 } | |
| 596 | |
| 597 bool hasNonZeroCoef = false; | |
| 598 | |
| 599 for (size_t k = 0; k < feedforwardCoef.size(); ++k) { | |
| 600 if (feedforwardCoef[k]) { | |
|
tkent
2016/01/13 03:28:28
Ditto.
Raymond Toy
2016/01/13 18:30:53
Done.
| |
| 601 hasNonZeroCoef = true; | |
| 602 break; | |
| 603 } | |
| 604 } | |
| 605 | |
| 606 if (!hasNonZeroCoef) { | |
| 607 exceptionState.throwDOMException( | |
| 608 InvalidStateError, | |
| 609 "At least one feedforward coefficient must be non-zero."); | |
| 610 return nullptr; | |
| 611 } | |
| 612 | |
| 613 // Make sure all coefficents are finite. | |
| 614 for (size_t k = 0; k < feedforwardCoef.size(); ++k) { | |
| 615 double c = feedforwardCoef[k]; | |
| 616 if (!std::isfinite(c)) { | |
| 617 String name = "feedforward coefficient " + String::number(k); | |
| 618 exceptionState.throwDOMException( | |
| 619 InvalidStateError, | |
| 620 ExceptionMessages::notAFiniteNumber(c, name.ascii().data())); | |
| 621 return nullptr; | |
| 622 } | |
| 623 } | |
| 624 | |
| 625 for (size_t k = 0; k < feedbackCoef.size(); ++k) { | |
| 626 double c = feedbackCoef[k]; | |
| 627 if (!std::isfinite(c)) { | |
| 628 String name = "feedback coefficient " + String::number(k); | |
| 629 exceptionState.throwDOMException( | |
| 630 InvalidStateError, | |
| 631 ExceptionMessages::notAFiniteNumber(c, name.ascii().data())); | |
| 632 return nullptr; | |
| 633 } | |
| 634 } | |
| 635 | |
| 636 return IIRFilterNode::create(*this, sampleRate(), feedforwardCoef, feedbackC oef); | |
| 637 } | |
| 638 | |
| 553 String AbstractAudioContext::state() const | 639 String AbstractAudioContext::state() const |
| 554 { | 640 { |
| 555 // These strings had better match the strings for AudioContextState in Audio Context.idl. | 641 // These strings had better match the strings for AudioContextState in Audio Context.idl. |
| 556 switch (m_contextState) { | 642 switch (m_contextState) { |
| 557 case Suspended: | 643 case Suspended: |
| 558 return "suspended"; | 644 return "suspended"; |
| 559 case Running: | 645 case Running: |
| 560 return "running"; | 646 return "running"; |
| 561 case Closed: | 647 case Closed: |
| 562 return "closed"; | 648 return "closed"; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 781 SecurityOrigin* AbstractAudioContext::securityOrigin() const | 867 SecurityOrigin* AbstractAudioContext::securityOrigin() const |
| 782 { | 868 { |
| 783 if (executionContext()) | 869 if (executionContext()) |
| 784 return executionContext()->securityOrigin(); | 870 return executionContext()->securityOrigin(); |
| 785 | 871 |
| 786 return nullptr; | 872 return nullptr; |
| 787 } | 873 } |
| 788 | 874 |
| 789 } // namespace blink | 875 } // namespace blink |
| 790 | 876 |
| OLD | NEW |