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 16 matching lines...) Expand all Loading... |
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" | 35 #include "modules/webaudio/PannerNode.h" |
36 #include "platform/audio/AudioBus.h" | 36 #include "platform/audio/AudioBus.h" |
| 37 #include "platform/audio/HRTFDatabaseLoader.h" |
37 | 38 |
38 namespace blink { | 39 namespace blink { |
39 | 40 |
40 AudioListener::AudioListener() | 41 AudioListener::AudioListener() |
41 : m_position(0, 0, 0) | 42 : m_position(0, 0, 0) |
42 , m_orientation(0, 0, -1) | 43 , m_orientation(0, 0, -1) |
43 , m_upVector(0, 1, 0) | 44 , m_upVector(0, 1, 0) |
44 , m_velocity(0, 0, 0) | 45 , m_velocity(0, 0, 0) |
45 , m_dopplerFactor(1) | 46 , m_dopplerFactor(1) |
46 , m_speedOfSound(343.3) | 47 , m_speedOfSound(343.3) |
(...skipping 17 matching lines...) Expand all Loading... |
64 void AudioListener::removePanner(PannerNode* panner) | 65 void AudioListener::removePanner(PannerNode* panner) |
65 { | 66 { |
66 for (unsigned i = 0; i < m_panners.size(); ++i) { | 67 for (unsigned i = 0; i < m_panners.size(); ++i) { |
67 if (panner == m_panners[i]) { | 68 if (panner == m_panners[i]) { |
68 m_panners.remove(i); | 69 m_panners.remove(i); |
69 break; | 70 break; |
70 } | 71 } |
71 } | 72 } |
72 } | 73 } |
73 | 74 |
| 75 void AudioListener::createAndLoadHRTFDatabaseLoader(float sampleRate) |
| 76 { |
| 77 if (!m_hrtfDatabaseLoader) |
| 78 m_hrtfDatabaseLoader = HRTFDatabaseLoader::createAndLoadAsynchronouslyIf
Necessary(sampleRate); |
| 79 } |
| 80 |
| 81 bool AudioListener::isHRTFDatabaseLoaded() |
| 82 { |
| 83 return m_hrtfDatabaseLoader->isLoaded(); |
| 84 } |
| 85 |
| 86 void AudioListener::waitForHRTFDatabaseLoaderThreadCompletion() |
| 87 { |
| 88 m_hrtfDatabaseLoader->waitForLoaderThreadCompletion(); |
| 89 } |
| 90 |
74 void AudioListener::markPannersAsDirty(unsigned type) | 91 void AudioListener::markPannersAsDirty(unsigned type) |
75 { | 92 { |
76 for (unsigned i = 0; i < m_panners.size(); ++i) | 93 for (unsigned i = 0; i < m_panners.size(); ++i) |
77 m_panners[i]->markPannerAsDirty(type); | 94 m_panners[i]->markPannerAsDirty(type); |
78 } | 95 } |
79 | 96 |
80 void AudioListener::setPosition(const FloatPoint3D &position) | 97 void AudioListener::setPosition(const FloatPoint3D &position) |
81 { | 98 { |
82 if (m_position == position) | 99 if (m_position == position) |
83 return; | 100 return; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 156 |
140 // This synchronizes with panner's process(). | 157 // This synchronizes with panner's process(). |
141 MutexLocker listenerLocker(m_listenerLock); | 158 MutexLocker listenerLocker(m_listenerLock); |
142 m_speedOfSound = speedOfSound; | 159 m_speedOfSound = speedOfSound; |
143 markPannersAsDirty(PannerNode::DopplerRateDirty); | 160 markPannersAsDirty(PannerNode::DopplerRateDirty); |
144 } | 161 } |
145 | 162 |
146 } // namespace blink | 163 } // namespace blink |
147 | 164 |
148 #endif // ENABLE(WEB_AUDIO) | 165 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |