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 return false; | 222 return false; |
Raymond Toy
2014/04/22 16:54:42
Might be good to put an ASSERT_NOT_REACHED() here.
| |
223 } | 223 } |
224 | 224 |
225 return true; | 225 return true; |
226 } | 226 } |
227 | 227 |
228 String PannerNode::distanceModel() const | 228 String PannerNode::distanceModel() const |
229 { | 229 { |
230 switch (const_cast<PannerNode*>(this)->m_distanceEffect.model()) { | 230 switch (const_cast<PannerNode*>(this)->m_distanceEffect.model()) { |
231 case DistanceEffect::ModelLinear: | 231 case DistanceEffect::ModelLinear: |
232 return "linear"; | 232 return "linear"; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
571 notifyAudioSourcesConnectedToNode(connectedNode, visitedNode s); // recurse | 571 notifyAudioSourcesConnectedToNode(connectedNode, visitedNode s); // recurse |
572 } | 572 } |
573 } | 573 } |
574 } | 574 } |
575 } | 575 } |
576 } | 576 } |
577 | 577 |
578 } // namespace WebCore | 578 } // namespace WebCore |
579 | 579 |
580 #endif // ENABLE(WEB_AUDIO) | 580 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |