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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 | 30 |
| 31 #if ENABLE(WEB_AUDIO) | 31 #if ENABLE(WEB_AUDIO) |
| 32 | 32 |
| 33 #include "modules/webaudio/AudioListener.h" | 33 #include "modules/webaudio/AudioListener.h" |
| 34 | 34 |
| 35 #include "modules/webaudio/PannerNode.h" | |
|
Raymond Toy
2014/04/16 17:36:15
Is this necessary?
KhNo
2014/04/17 13:41:03
Yes, it is for m_panners[i]->updatePannerDirty(typ
| |
| 35 #include "platform/audio/AudioBus.h" | 36 #include "platform/audio/AudioBus.h" |
| 36 | 37 |
| 37 namespace WebCore { | 38 namespace WebCore { |
| 38 | 39 |
| 39 AudioListener::AudioListener() | 40 AudioListener::AudioListener() |
| 40 : m_position(0, 0, 0) | 41 : m_position(0, 0, 0) |
| 41 , m_orientation(0, 0, -1) | 42 , m_orientation(0, 0, -1) |
| 42 , m_upVector(0, 1, 0) | 43 , m_upVector(0, 1, 0) |
| 43 , m_velocity(0, 0, 0) | 44 , m_velocity(0, 0, 0) |
| 44 , m_dopplerFactor(1) | 45 , m_dopplerFactor(1) |
| 45 , m_speedOfSound(343.3) | 46 , m_speedOfSound(343.3) |
| 46 { | 47 { |
| 47 ScriptWrappable::init(this); | 48 ScriptWrappable::init(this); |
| 48 } | 49 } |
| 49 | 50 |
| 51 AudioListener::~AudioListener() | |
| 52 { | |
| 53 m_panners.clear(); | |
| 54 } | |
| 55 | |
| 56 void AudioListener::addPanner(PannerNode* panner) | |
| 57 { | |
| 58 if (!panner) | |
| 59 return; | |
| 60 | |
| 61 m_panners.append(panner); | |
| 62 } | |
| 63 | |
| 64 void AudioListener::removePanner(PannerNode* panner) | |
| 65 { | |
| 66 for (unsigned i = 0; i < m_panners.size(); ++i) { | |
| 67 if (panner == m_panners[i]) { | |
| 68 m_panners.remove(i); | |
| 69 break; | |
| 70 } | |
| 71 } | |
| 72 } | |
| 73 | |
| 74 void AudioListener::updatePannersDirty(unsigned type) | |
|
Raymond Toy
2014/04/16 17:36:15
I think updateDirtyPanners is a better name.
KhNo
2014/04/17 13:41:03
Changed to markPannersAsDirty
| |
| 75 { | |
| 76 for (unsigned i = 0; i < m_panners.size(); ++i) | |
| 77 m_panners[i]->updatePannerDirty(type); | |
| 78 } | |
| 79 | |
| 80 void AudioListener::setPosition(const FloatPoint3D &position) | |
| 81 { | |
| 82 if (m_position == position) | |
| 83 return; | |
| 84 | |
| 85 // This synchronizes with panner's process(). | |
| 86 MutexLocker listenerLocker(m_listenerLock); | |
| 87 m_position = position; | |
| 88 updatePannersDirty(PannerNode::AzimuthElevationDirty | PannerNode::DistanceC oneGainDirty | PannerNode::DopplerRateDirty); | |
|
Raymond Toy
2014/04/16 17:36:15
udpatePannersDirty is protected by m_processLock (
KhNo
2014/04/17 13:41:03
Actually, I have tried to using pannerNode's proce
| |
| 89 } | |
| 90 | |
| 91 void AudioListener::setOrientation(const FloatPoint3D &orientation) | |
| 92 { | |
| 93 if (m_orientation == orientation) | |
| 94 return; | |
| 95 | |
| 96 // This synchronizes with panner's process(). | |
| 97 MutexLocker listenerLocker(m_listenerLock); | |
| 98 m_orientation = orientation; | |
| 99 updatePannersDirty(PannerNode::AzimuthElevationDirty); | |
| 100 } | |
| 101 | |
| 102 void AudioListener::setUpVector(const FloatPoint3D &upVector) | |
| 103 { | |
| 104 if (m_upVector == upVector) | |
| 105 return; | |
| 106 | |
| 107 // This synchronizes with panner's process(). | |
| 108 MutexLocker listenerLocker(m_listenerLock); | |
| 109 m_upVector = upVector; | |
| 110 updatePannersDirty(PannerNode::AzimuthElevationDirty); | |
| 111 } | |
| 112 | |
| 113 void AudioListener::setVelocity(const FloatPoint3D &velocity) | |
| 114 { | |
| 115 if (m_velocity == velocity) | |
| 116 return; | |
| 117 | |
| 118 // This synchronizes with panner's process(). | |
| 119 MutexLocker listenerLocker(m_listenerLock); | |
| 120 m_velocity = velocity; | |
| 121 updatePannersDirty(PannerNode::DopplerRateDirty); | |
| 122 } | |
| 123 | |
| 124 void AudioListener::setDopplerFactor(double dopplerFactor) | |
| 125 { | |
| 126 if (m_dopplerFactor == dopplerFactor) | |
| 127 return; | |
| 128 | |
| 129 // This synchronizes with panner's process(). | |
| 130 MutexLocker listenerLocker(m_listenerLock); | |
| 131 m_dopplerFactor = dopplerFactor; | |
| 132 updatePannersDirty(PannerNode::DopplerRateDirty); | |
| 133 } | |
| 134 | |
| 135 void AudioListener::setSpeedOfSound(double speedOfSound) | |
| 136 { | |
| 137 if (m_speedOfSound == speedOfSound) | |
| 138 return; | |
| 139 | |
| 140 // This synchronizes with panner's process(). | |
| 141 MutexLocker listenerLocker(m_listenerLock); | |
| 142 m_speedOfSound = speedOfSound; | |
| 143 updatePannersDirty(PannerNode::DopplerRateDirty); | |
| 144 } | |
| 145 | |
| 50 } // namespace WebCore | 146 } // namespace WebCore |
| 51 | 147 |
| 52 #endif // ENABLE(WEB_AUDIO) | 148 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |