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

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

Issue 2159403002: Replace ASSERT with DCHECK in WebAudio (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/webaudio/StereoPannerNode.h" 5 #include "modules/webaudio/StereoPannerNode.h"
6 #include "bindings/core/v8/ExceptionMessages.h" 6 #include "bindings/core/v8/ExceptionMessages.h"
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/dom/ExceptionCode.h" 8 #include "core/dom/ExceptionCode.h"
9 #include "core/dom/ExecutionContext.h" 9 #include "core/dom/ExecutionContext.h"
10 #include "modules/webaudio/AudioNodeInput.h" 10 #include "modules/webaudio/AudioNodeInput.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 AudioBus* inputBus = input(0).bus(); 54 AudioBus* inputBus = input(0).bus();
55 if (!inputBus) { 55 if (!inputBus) {
56 outputBus->zero(); 56 outputBus->zero();
57 return; 57 return;
58 } 58 }
59 59
60 if (m_pan->hasSampleAccurateValues()) { 60 if (m_pan->hasSampleAccurateValues()) {
61 // Apply sample-accurate panning specified by AudioParam automation. 61 // Apply sample-accurate panning specified by AudioParam automation.
62 ASSERT(framesToProcess <= m_sampleAccuratePanValues.size()); 62 DCHECK_LE(framesToProcess, m_sampleAccuratePanValues.size());
63 if (framesToProcess <= m_sampleAccuratePanValues.size()) { 63 if (framesToProcess <= m_sampleAccuratePanValues.size()) {
64 float* panValues = m_sampleAccuratePanValues.data(); 64 float* panValues = m_sampleAccuratePanValues.data();
65 m_pan->calculateSampleAccurateValues(panValues, framesToProcess); 65 m_pan->calculateSampleAccurateValues(panValues, framesToProcess);
66 m_stereoPanner->panWithSampleAccurateValues(inputBus, outputBus, pan Values, framesToProcess); 66 m_stereoPanner->panWithSampleAccurateValues(inputBus, outputBus, pan Values, framesToProcess);
67 } 67 }
68 } else { 68 } else {
69 m_stereoPanner->panToTargetValue(inputBus, outputBus, m_pan->value(), fr amesToProcess); 69 m_stereoPanner->panToTargetValue(inputBus, outputBus, m_pan->value(), fr amesToProcess);
70 } 70 }
71 } 71 }
72 72
73 void StereoPannerHandler::initialize() 73 void StereoPannerHandler::initialize()
74 { 74 {
75 if (isInitialized()) 75 if (isInitialized())
76 return; 76 return;
77 77
78 m_stereoPanner = Spatializer::create(Spatializer::PanningModelEqualPower, sa mpleRate()); 78 m_stereoPanner = Spatializer::create(Spatializer::PanningModelEqualPower, sa mpleRate());
79 79
80 AudioHandler::initialize(); 80 AudioHandler::initialize();
81 } 81 }
82 82
83 void StereoPannerHandler::setChannelCount(unsigned long channelCount, ExceptionS tate& exceptionState) 83 void StereoPannerHandler::setChannelCount(unsigned long channelCount, ExceptionS tate& exceptionState)
84 { 84 {
85 ASSERT(isMainThread()); 85 DCHECK(isMainThread());
86 BaseAudioContext::AutoLocker locker(context()); 86 BaseAudioContext::AutoLocker locker(context());
87 87
88 // A PannerNode only supports 1 or 2 channels 88 // A PannerNode only supports 1 or 2 channels
89 if (channelCount > 0 && channelCount <= 2) { 89 if (channelCount > 0 && channelCount <= 2) {
90 if (m_channelCount != channelCount) { 90 if (m_channelCount != channelCount) {
91 m_channelCount = channelCount; 91 m_channelCount = channelCount;
92 if (internalChannelCountMode() != Max) 92 if (internalChannelCountMode() != Max)
93 updateChannelsForInputs(); 93 updateChannelsForInputs();
94 } 94 }
95 } else { 95 } else {
96 exceptionState.throwDOMException( 96 exceptionState.throwDOMException(
97 NotSupportedError, 97 NotSupportedError,
98 ExceptionMessages::indexOutsideRange<unsigned long>( 98 ExceptionMessages::indexOutsideRange<unsigned long>(
99 "channelCount", 99 "channelCount",
100 channelCount, 100 channelCount,
101 1, 101 1,
102 ExceptionMessages::InclusiveBound, 102 ExceptionMessages::InclusiveBound,
103 2, 103 2,
104 ExceptionMessages::InclusiveBound)); 104 ExceptionMessages::InclusiveBound));
105 } 105 }
106 } 106 }
107 107
108 void StereoPannerHandler::setChannelCountMode(const String& mode, ExceptionState & exceptionState) 108 void StereoPannerHandler::setChannelCountMode(const String& mode, ExceptionState & exceptionState)
109 { 109 {
110 ASSERT(isMainThread()); 110 DCHECK(isMainThread());
111 BaseAudioContext::AutoLocker locker(context()); 111 BaseAudioContext::AutoLocker locker(context());
112 112
113 if (mode == "clamped-max") { 113 if (mode == "clamped-max") {
114 setInternalChannelCountMode(ClampedMax); 114 setInternalChannelCountMode(ClampedMax);
115 } else if (mode == "explicit") { 115 } else if (mode == "explicit") {
116 setInternalChannelCountMode(Explicit); 116 setInternalChannelCountMode(Explicit);
117 } else if (mode == "max") { 117 } else if (mode == "max") {
118 // This is not supported for a StereoPannerNode, which can only handle 118 // This is not supported for a StereoPannerNode, which can only handle
119 // 1 or 2 channels. 119 // 1 or 2 channels.
120 exceptionState.throwDOMException( 120 exceptionState.throwDOMException(
(...skipping 29 matching lines...) Expand all
150 AudioNode::trace(visitor); 150 AudioNode::trace(visitor);
151 } 151 }
152 152
153 AudioParam* StereoPannerNode::pan() const 153 AudioParam* StereoPannerNode::pan() const
154 { 154 {
155 return m_pan; 155 return m_pan;
156 } 156 }
157 157
158 } // namespace blink 158 } // namespace blink
159 159
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698