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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 destination->zero(); | 118 destination->zero(); |
119 return; | 119 return; |
120 } | 120 } |
121 | 121 |
122 // The audio thread can't block on this lock, so we call tryLock() instead. | 122 // The audio thread can't block on this lock, so we call tryLock() instead. |
123 MutexTryLocker tryLocker(m_processLock); | 123 MutexTryLocker tryLocker(m_processLock); |
124 MutexTryLocker tryListenerLocker(listener()->listenerLock()); | 124 MutexTryLocker tryListenerLocker(listener()->listenerLock()); |
125 | 125 |
126 if (tryLocker.locked() && tryListenerLocker.locked()) { | 126 if (tryLocker.locked() && tryListenerLocker.locked()) { |
127 // HRTFDatabase should be loaded before proceeding for offline audio con
text when the panning model is HRTF. | 127 // HRTFDatabase should be loaded before proceeding for offline audio con
text when the panning model is HRTF. |
128 if (m_panningModel == HRTF && !m_hrtfDatabaseLoader->isLoaded()) { | 128 if (m_panningModel == Panner::PanningModelHRTF && !m_hrtfDatabaseLoader-
>isLoaded()) { |
129 if (context()->isOfflineContext()) { | 129 if (context()->isOfflineContext()) { |
130 m_hrtfDatabaseLoader->waitForLoaderThreadCompletion(); | 130 m_hrtfDatabaseLoader->waitForLoaderThreadCompletion(); |
131 } else { | 131 } else { |
132 destination->zero(); | 132 destination->zero(); |
133 return; | 133 return; |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 // Apply the panning effect. | 137 // Apply the panning effect. |
138 double azimuth; | 138 double azimuth; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 180 } |
181 | 181 |
182 AudioListener* PannerNode::listener() | 182 AudioListener* PannerNode::listener() |
183 { | 183 { |
184 return context()->listener(); | 184 return context()->listener(); |
185 } | 185 } |
186 | 186 |
187 String PannerNode::panningModel() const | 187 String PannerNode::panningModel() const |
188 { | 188 { |
189 switch (m_panningModel) { | 189 switch (m_panningModel) { |
190 case EQUALPOWER: | 190 case Panner::PanningModelEqualPower: |
191 return "equalpower"; | 191 return "equalpower"; |
192 case HRTF: | 192 case Panner::PanningModelHRTF: |
193 return "HRTF"; | 193 return "HRTF"; |
194 default: | 194 default: |
195 ASSERT_NOT_REACHED(); | 195 ASSERT_NOT_REACHED(); |
196 return "HRTF"; | 196 return "HRTF"; |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 void PannerNode::setPanningModel(const String& model) | 200 void PannerNode::setPanningModel(const String& model) |
201 { | 201 { |
202 if (model == "equalpower") | 202 if (model == "equalpower") |
203 setPanningModel(EQUALPOWER); | 203 setPanningModel(Panner::PanningModelEqualPower); |
204 else if (model == "HRTF") | 204 else if (model == "HRTF") |
205 setPanningModel(HRTF); | 205 setPanningModel(Panner::PanningModelHRTF); |
206 } | 206 } |
207 | 207 |
208 bool PannerNode::setPanningModel(unsigned model) | 208 bool PannerNode::setPanningModel(unsigned model) |
209 { | 209 { |
210 switch (model) { | 210 switch (model) { |
211 case EQUALPOWER: | 211 case Panner::PanningModelEqualPower: |
212 case HRTF: | 212 case Panner::PanningModelHRTF: |
213 if (!m_panner.get() || model != m_panningModel) { | 213 if (!m_panner.get() || model != m_panningModel) { |
214 // This synchronizes with process(). | 214 // This synchronizes with process(). |
215 MutexLocker processLocker(m_processLock); | 215 MutexLocker processLocker(m_processLock); |
216 OwnPtr<Panner> newPanner = Panner::create(model, sampleRate(), m_hrt
fDatabaseLoader.get()); | 216 OwnPtr<Panner> newPanner = Panner::create(model, sampleRate(), m_hrt
fDatabaseLoader.get()); |
217 m_panner = newPanner.release(); | 217 m_panner = newPanner.release(); |
218 m_panningModel = model; | 218 m_panningModel = model; |
219 } | 219 } |
220 break; | 220 break; |
221 default: | 221 default: |
| 222 ASSERT_NOT_REACHED(); |
222 return false; | 223 return false; |
223 } | 224 } |
224 | 225 |
225 return true; | 226 return true; |
226 } | 227 } |
227 | 228 |
228 String PannerNode::distanceModel() const | 229 String PannerNode::distanceModel() const |
229 { | 230 { |
230 switch (const_cast<PannerNode*>(this)->m_distanceEffect.model()) { | 231 switch (const_cast<PannerNode*>(this)->m_distanceEffect.model()) { |
231 case DistanceEffect::ModelLinear: | 232 case DistanceEffect::ModelLinear: |
(...skipping 25 matching lines...) Expand all Loading... |
257 case DistanceEffect::ModelInverse: | 258 case DistanceEffect::ModelInverse: |
258 case DistanceEffect::ModelExponential: | 259 case DistanceEffect::ModelExponential: |
259 if (model != m_distanceModel) { | 260 if (model != m_distanceModel) { |
260 // This synchronizes with process(). | 261 // This synchronizes with process(). |
261 MutexLocker processLocker(m_processLock); | 262 MutexLocker processLocker(m_processLock); |
262 m_distanceEffect.setModel(static_cast<DistanceEffect::ModelType>(mod
el), true); | 263 m_distanceEffect.setModel(static_cast<DistanceEffect::ModelType>(mod
el), true); |
263 m_distanceModel = model; | 264 m_distanceModel = model; |
264 } | 265 } |
265 break; | 266 break; |
266 default: | 267 default: |
| 268 ASSERT_NOT_REACHED(); |
267 return false; | 269 return false; |
268 } | 270 } |
269 | 271 |
270 return true; | 272 return true; |
271 } | 273 } |
272 | 274 |
273 void PannerNode::setRefDistance(double distance) | 275 void PannerNode::setRefDistance(double distance) |
274 { | 276 { |
275 if (refDistance() == distance) | 277 if (refDistance() == distance) |
276 return; | 278 return; |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 notifyAudioSourcesConnectedToNode(connectedNode, visitedNode
s); // recurse | 573 notifyAudioSourcesConnectedToNode(connectedNode, visitedNode
s); // recurse |
572 } | 574 } |
573 } | 575 } |
574 } | 576 } |
575 } | 577 } |
576 } | 578 } |
577 | 579 |
578 } // namespace WebCore | 580 } // namespace WebCore |
579 | 581 |
580 #endif // ENABLE(WEB_AUDIO) | 582 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |