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 16 matching lines...) Expand all Loading... | |
| 27 #include "bindings/core/v8/ExceptionState.h" | 27 #include "bindings/core/v8/ExceptionState.h" |
| 28 #include "core/dom/ExceptionCode.h" | 28 #include "core/dom/ExceptionCode.h" |
| 29 #include "modules/webaudio/AudioBasicProcessorHandler.h" | 29 #include "modules/webaudio/AudioBasicProcessorHandler.h" |
| 30 #include "modules/webaudio/DelayProcessor.h" | 30 #include "modules/webaudio/DelayProcessor.h" |
| 31 #include "wtf/MathExtras.h" | 31 #include "wtf/MathExtras.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 const double maximumAllowedDelayTime = 180; | 35 const double maximumAllowedDelayTime = 180; |
| 36 | 36 |
| 37 DelayNode::DelayNode(AbstractAudioContext& context, float sampleRate, double max DelayTime) | 37 DelayNode::DelayNode(AbstractAudioContext& context, double maxDelayTime) |
| 38 : AudioNode(context) | 38 : AudioNode(context) |
| 39 , m_delayTime(AudioParam::create(context, ParamTypeDelayDelayTime, 0.0)) | 39 , m_delayTime(AudioParam::create(context, ParamTypeDelayDelayTime, 0.0)) |
| 40 { | 40 { |
| 41 setHandler(AudioBasicProcessorHandler::create(AudioHandler::NodeTypeDelay, * this, sampleRate, adoptPtr(new DelayProcessor(sampleRate, 1, m_delayTime->handle r(), maxDelayTime)))); | 41 setHandler(AudioBasicProcessorHandler::create( |
| 42 AudioHandler::NodeTypeDelay, | |
| 43 *this, | |
| 44 context.sampleRate(), | |
| 45 adoptPtr(new DelayProcessor( | |
| 46 context.sampleRate(), | |
| 47 1, | |
| 48 m_delayTime->handler(), | |
| 49 maxDelayTime)))); | |
| 42 } | 50 } |
| 43 | 51 |
| 44 DelayNode* DelayNode::create(AbstractAudioContext& context, float sampleRate, do uble maxDelayTime, ExceptionState& exceptionState) | 52 DelayNode* DelayNode::create(AbstractAudioContext& context, ExceptionState& exce ptionState) |
| 45 { | 53 { |
| 54 ASSERT(isMainThread()); | |
|
hongchan
2016/05/13 01:20:11
DCHECK.
Raymond Toy
2016/05/20 23:12:00
Done.
| |
| 55 | |
| 56 const double defaultMaxDelayTime = 1; | |
| 57 return create(context, defaultMaxDelayTime, exceptionState); | |
| 58 } | |
| 59 | |
| 60 DelayNode* DelayNode::create(AbstractAudioContext& context, double maxDelayTime, ExceptionState& exceptionState) | |
| 61 { | |
| 62 ASSERT(isMainThread()); | |
|
hongchan
2016/05/13 01:20:11
DCHECK.
Raymond Toy
2016/05/20 23:12:00
Done.
| |
| 63 | |
| 64 if (context.isContextClosed()) { | |
| 65 context.throwExceptionForClosedState(exceptionState); | |
| 66 return nullptr; | |
| 67 } | |
| 68 | |
| 46 if (maxDelayTime <= 0 || maxDelayTime >= maximumAllowedDelayTime) { | 69 if (maxDelayTime <= 0 || maxDelayTime >= maximumAllowedDelayTime) { |
| 47 exceptionState.throwDOMException( | 70 exceptionState.throwDOMException( |
| 48 NotSupportedError, | 71 NotSupportedError, |
| 49 ExceptionMessages::indexOutsideRange( | 72 ExceptionMessages::indexOutsideRange( |
| 50 "max delay time", | 73 "max delay time", |
| 51 maxDelayTime, | 74 maxDelayTime, |
| 52 0.0, | 75 0.0, |
| 53 ExceptionMessages::ExclusiveBound, | 76 ExceptionMessages::ExclusiveBound, |
| 54 maximumAllowedDelayTime, | 77 maximumAllowedDelayTime, |
| 55 ExceptionMessages::ExclusiveBound)); | 78 ExceptionMessages::ExclusiveBound)); |
| 56 return nullptr; | 79 return nullptr; |
| 57 } | 80 } |
| 58 return new DelayNode(context, sampleRate, maxDelayTime); | 81 |
| 82 return new DelayNode(context, maxDelayTime); | |
| 59 } | 83 } |
| 60 | 84 |
| 61 AudioParam* DelayNode::delayTime() | 85 AudioParam* DelayNode::delayTime() |
| 62 { | 86 { |
| 63 return m_delayTime; | 87 return m_delayTime; |
| 64 } | 88 } |
| 65 | 89 |
| 66 DEFINE_TRACE(DelayNode) | 90 DEFINE_TRACE(DelayNode) |
| 67 { | 91 { |
| 68 visitor->trace(m_delayTime); | 92 visitor->trace(m_delayTime); |
| 69 AudioNode::trace(visitor); | 93 AudioNode::trace(visitor); |
| 70 } | 94 } |
| 71 | 95 |
| 72 } // namespace blink | 96 } // namespace blink |
| 73 | 97 |
| OLD | NEW |