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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 , m_isDopplerRateDirty(true) | 56 , m_isDopplerRateDirty(true) |
57 , m_lastGain(-1.0) | 57 , m_lastGain(-1.0) |
58 , m_cachedAzimuth(0) | 58 , m_cachedAzimuth(0) |
59 , m_cachedElevation(0) | 59 , m_cachedElevation(0) |
60 , m_cachedDistanceConeGain(1.0f) | 60 , m_cachedDistanceConeGain(1.0f) |
61 , m_cachedDopplerRate(1) | 61 , m_cachedDopplerRate(1) |
62 , m_connectionCount(0) | 62 , m_connectionCount(0) |
63 { | 63 { |
64 // Load the HRTF database asynchronously so we don't block the Javascript th
read while creating the HRTF database. | 64 // Load the HRTF database asynchronously so we don't block the Javascript th
read while creating the HRTF database. |
65 // The HRTF panner will return zeroes until the database is loaded. | 65 // The HRTF panner will return zeroes until the database is loaded. |
66 m_hrtfDatabaseLoader = HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNece
ssary(context->sampleRate()); | 66 listener()->createAndLoadHRTFDatabaseLoader(context->sampleRate()); |
67 | 67 |
68 ScriptWrappable::init(this); | 68 ScriptWrappable::init(this); |
69 addInput(); | 69 addInput(); |
70 addOutput(AudioNodeOutput::create(this, 2)); | 70 addOutput(AudioNodeOutput::create(this, 2)); |
71 | 71 |
72 // Node-specific default mixing rules. | 72 // Node-specific default mixing rules. |
73 m_channelCount = 2; | 73 m_channelCount = 2; |
74 m_channelCountMode = ClampedMax; | 74 m_channelCountMode = ClampedMax; |
75 m_channelInterpretation = AudioBus::Speakers; | 75 m_channelInterpretation = AudioBus::Speakers; |
76 | 76 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 destination->zero(); | 116 destination->zero(); |
117 return; | 117 return; |
118 } | 118 } |
119 | 119 |
120 // The audio thread can't block on this lock, so we call tryLock() instead. | 120 // The audio thread can't block on this lock, so we call tryLock() instead. |
121 MutexTryLocker tryLocker(m_processLock); | 121 MutexTryLocker tryLocker(m_processLock); |
122 MutexTryLocker tryListenerLocker(listener()->listenerLock()); | 122 MutexTryLocker tryListenerLocker(listener()->listenerLock()); |
123 | 123 |
124 if (tryLocker.locked() && tryListenerLocker.locked()) { | 124 if (tryLocker.locked() && tryListenerLocker.locked()) { |
125 // HRTFDatabase should be loaded before proceeding for offline audio con
text when the panning model is HRTF. | 125 // HRTFDatabase should be loaded before proceeding for offline audio con
text when the panning model is HRTF. |
126 if (m_panningModel == Panner::PanningModelHRTF && !m_hrtfDatabaseLoader-
>isLoaded()) { | 126 if (m_panningModel == Panner::PanningModelHRTF && !listener()->isHRTFDat
abaseLoaded()) { |
127 if (context()->isOfflineContext()) { | 127 if (context()->isOfflineContext()) { |
128 m_hrtfDatabaseLoader->waitForLoaderThreadCompletion(); | 128 listener()->waitForHRTFDatabaseLoaderThreadCompletion(); |
129 } else { | 129 } else { |
130 destination->zero(); | 130 destination->zero(); |
131 return; | 131 return; |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 // Apply the panning effect. | 135 // Apply the panning effect. |
136 double azimuth; | 136 double azimuth; |
137 double elevation; | 137 double elevation; |
138 azimuthElevation(&azimuth, &elevation); | 138 azimuthElevation(&azimuth, &elevation); |
(...skipping 14 matching lines...) Expand all Loading... |
153 // We must be in the middle of changing the properties of the panner or
the listener. | 153 // We must be in the middle of changing the properties of the panner or
the listener. |
154 destination->zero(); | 154 destination->zero(); |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 void PannerNode::initialize() | 158 void PannerNode::initialize() |
159 { | 159 { |
160 if (isInitialized()) | 160 if (isInitialized()) |
161 return; | 161 return; |
162 | 162 |
163 m_panner = Panner::create(m_panningModel, sampleRate(), m_hrtfDatabaseLoader
.get()); | 163 m_panner = Panner::create(m_panningModel, sampleRate(), listener()->hrtfData
baseLoader()); |
164 listener()->addPanner(this); | 164 listener()->addPanner(this); |
165 | 165 |
166 AudioNode::initialize(); | 166 AudioNode::initialize(); |
167 } | 167 } |
168 | 168 |
169 void PannerNode::uninitialize() | 169 void PannerNode::uninitialize() |
170 { | 170 { |
171 if (!isInitialized()) | 171 if (!isInitialized()) |
172 return; | 172 return; |
173 | 173 |
(...skipping 30 matching lines...) Expand all Loading... |
204 } | 204 } |
205 | 205 |
206 bool PannerNode::setPanningModel(unsigned model) | 206 bool PannerNode::setPanningModel(unsigned model) |
207 { | 207 { |
208 switch (model) { | 208 switch (model) { |
209 case Panner::PanningModelEqualPower: | 209 case Panner::PanningModelEqualPower: |
210 case Panner::PanningModelHRTF: | 210 case Panner::PanningModelHRTF: |
211 if (!m_panner.get() || model != m_panningModel) { | 211 if (!m_panner.get() || model != m_panningModel) { |
212 // This synchronizes with process(). | 212 // This synchronizes with process(). |
213 MutexLocker processLocker(m_processLock); | 213 MutexLocker processLocker(m_processLock); |
214 OwnPtr<Panner> newPanner = Panner::create(model, sampleRate(), m_hrt
fDatabaseLoader.get()); | 214 OwnPtr<Panner> newPanner = Panner::create(model, sampleRate(), liste
ner()->hrtfDatabaseLoader()); |
215 m_panner = newPanner.release(); | 215 m_panner = newPanner.release(); |
216 m_panningModel = model; | 216 m_panningModel = model; |
217 } | 217 } |
218 break; | 218 break; |
219 default: | 219 default: |
220 ASSERT_NOT_REACHED(); | 220 ASSERT_NOT_REACHED(); |
221 return false; | 221 return false; |
222 } | 222 } |
223 | 223 |
224 return true; | 224 return true; |
(...skipping 346 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 blink | 578 } // namespace blink |
579 | 579 |
580 #endif // ENABLE(WEB_AUDIO) | 580 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |