| 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 20 matching lines...) Expand all Loading... |
| 31 #include "platform/audio/AudioBus.h" | 31 #include "platform/audio/AudioBus.h" |
| 32 #include "platform/audio/HRTFDatabaseLoader.h" | 32 #include "platform/audio/HRTFDatabaseLoader.h" |
| 33 #include "wtf/MainThread.h" | 33 #include "wtf/MainThread.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 AudioListener::AudioListener() | 37 AudioListener::AudioListener() |
| 38 : m_position(0, 0, 0) | 38 : m_position(0, 0, 0) |
| 39 , m_orientation(0, 0, -1) | 39 , m_orientation(0, 0, -1) |
| 40 , m_upVector(0, 1, 0) | 40 , m_upVector(0, 1, 0) |
| 41 , m_velocity(0, 0, 0) | |
| 42 , m_dopplerFactor(1) | 41 , m_dopplerFactor(1) |
| 43 , m_speedOfSound(343.3) | 42 , m_speedOfSound(343.3) |
| 44 { | 43 { |
| 45 } | 44 } |
| 46 | 45 |
| 47 AudioListener::~AudioListener() | 46 AudioListener::~AudioListener() |
| 48 { | 47 { |
| 49 } | 48 } |
| 50 | 49 |
| 51 DEFINE_TRACE(AudioListener) | 50 DEFINE_TRACE(AudioListener) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 88 } |
| 90 | 89 |
| 91 void AudioListener::setPosition(const FloatPoint3D& position) | 90 void AudioListener::setPosition(const FloatPoint3D& position) |
| 92 { | 91 { |
| 93 if (m_position == position) | 92 if (m_position == position) |
| 94 return; | 93 return; |
| 95 | 94 |
| 96 // This synchronizes with panner's process(). | 95 // This synchronizes with panner's process(). |
| 97 MutexLocker listenerLocker(m_listenerLock); | 96 MutexLocker listenerLocker(m_listenerLock); |
| 98 m_position = position; | 97 m_position = position; |
| 99 markPannersAsDirty(PannerHandler::AzimuthElevationDirty | PannerHandler::Dis
tanceConeGainDirty | PannerHandler::DopplerRateDirty); | 98 markPannersAsDirty(PannerHandler::AzimuthElevationDirty | PannerHandler::Dis
tanceConeGainDirty); |
| 100 } | 99 } |
| 101 | 100 |
| 102 void AudioListener::setOrientation(const FloatPoint3D& orientation) | 101 void AudioListener::setOrientation(const FloatPoint3D& orientation) |
| 103 { | 102 { |
| 104 if (m_orientation == orientation) | 103 if (m_orientation == orientation) |
| 105 return; | 104 return; |
| 106 | 105 |
| 107 // This synchronizes with panner's process(). | 106 // This synchronizes with panner's process(). |
| 108 MutexLocker listenerLocker(m_listenerLock); | 107 MutexLocker listenerLocker(m_listenerLock); |
| 109 m_orientation = orientation; | 108 m_orientation = orientation; |
| 110 markPannersAsDirty(PannerHandler::AzimuthElevationDirty); | 109 markPannersAsDirty(PannerHandler::AzimuthElevationDirty); |
| 111 } | 110 } |
| 112 | 111 |
| 113 void AudioListener::setUpVector(const FloatPoint3D& upVector) | 112 void AudioListener::setUpVector(const FloatPoint3D& upVector) |
| 114 { | 113 { |
| 115 if (m_upVector == upVector) | 114 if (m_upVector == upVector) |
| 116 return; | 115 return; |
| 117 | 116 |
| 118 // This synchronizes with panner's process(). | 117 // This synchronizes with panner's process(). |
| 119 MutexLocker listenerLocker(m_listenerLock); | 118 MutexLocker listenerLocker(m_listenerLock); |
| 120 m_upVector = upVector; | 119 m_upVector = upVector; |
| 121 markPannersAsDirty(PannerHandler::AzimuthElevationDirty); | 120 markPannersAsDirty(PannerHandler::AzimuthElevationDirty); |
| 122 } | 121 } |
| 123 | 122 |
| 124 void AudioListener::setVelocity(const FloatPoint3D& velocity) | 123 void AudioListener::setVelocity(float x, float y, float z) |
| 125 { | 124 { |
| 126 if (m_velocity == velocity) | 125 // The velocity is not used internally and cannot be read back by scripts, |
| 127 return; | 126 // so it can be ignored entirely. |
| 128 | |
| 129 // This synchronizes with panner's process(). | |
| 130 MutexLocker listenerLocker(m_listenerLock); | |
| 131 m_velocity = velocity; | |
| 132 markPannersAsDirty(PannerHandler::DopplerRateDirty); | |
| 133 } | 127 } |
| 134 | 128 |
| 135 void AudioListener::setDopplerFactor(double dopplerFactor) | 129 void AudioListener::setDopplerFactor(double dopplerFactor) |
| 136 { | 130 { |
| 137 if (m_dopplerFactor == dopplerFactor) | |
| 138 return; | |
| 139 | |
| 140 // This synchronizes with panner's process(). | |
| 141 MutexLocker listenerLocker(m_listenerLock); | |
| 142 m_dopplerFactor = dopplerFactor; | 131 m_dopplerFactor = dopplerFactor; |
| 143 markPannersAsDirty(PannerHandler::DopplerRateDirty); | |
| 144 } | 132 } |
| 145 | 133 |
| 146 void AudioListener::setSpeedOfSound(double speedOfSound) | 134 void AudioListener::setSpeedOfSound(double speedOfSound) |
| 147 { | 135 { |
| 148 if (m_speedOfSound == speedOfSound) | |
| 149 return; | |
| 150 | |
| 151 // This synchronizes with panner's process(). | |
| 152 MutexLocker listenerLocker(m_listenerLock); | |
| 153 m_speedOfSound = speedOfSound; | 136 m_speedOfSound = speedOfSound; |
| 154 markPannersAsDirty(PannerHandler::DopplerRateDirty); | |
| 155 } | 137 } |
| 156 | 138 |
| 157 } // namespace blink | 139 } // namespace blink |
| 158 | |
| OLD | NEW |