OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <assert.h> | 11 #include <assert.h> |
12 | 12 |
| 13 #include "webrtc/base/logging.h" |
13 #include "webrtc/modules/audio_device/audio_device_config.h" | 14 #include "webrtc/modules/audio_device/audio_device_config.h" |
14 #include "webrtc/modules/audio_device/linux/audio_device_alsa_linux.h" | 15 #include "webrtc/modules/audio_device/linux/audio_device_alsa_linux.h" |
15 | 16 |
16 #include "webrtc/system_wrappers/include/event_wrapper.h" | 17 #include "webrtc/system_wrappers/include/event_wrapper.h" |
17 #include "webrtc/system_wrappers/include/sleep.h" | 18 #include "webrtc/system_wrappers/include/sleep.h" |
18 #include "webrtc/system_wrappers/include/trace.h" | 19 #include "webrtc/system_wrappers/include/trace.h" |
19 | 20 |
20 webrtc_adm_linux_alsa::AlsaSymbolTable AlsaSymbolTable; | 21 webrtc_adm_linux_alsa::AlsaSymbolTable AlsaSymbolTable; |
21 | 22 |
22 // Accesses ALSA functions through our late-binding symbol table instead of | 23 // Accesses ALSA functions through our late-binding symbol table instead of |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 _ptrAudioBuffer->SetPlayoutChannels(0); | 149 _ptrAudioBuffer->SetPlayoutChannels(0); |
149 } | 150 } |
150 | 151 |
151 int32_t AudioDeviceLinuxALSA::ActiveAudioLayer( | 152 int32_t AudioDeviceLinuxALSA::ActiveAudioLayer( |
152 AudioDeviceModule::AudioLayer& audioLayer) const | 153 AudioDeviceModule::AudioLayer& audioLayer) const |
153 { | 154 { |
154 audioLayer = AudioDeviceModule::kLinuxAlsaAudio; | 155 audioLayer = AudioDeviceModule::kLinuxAlsaAudio; |
155 return 0; | 156 return 0; |
156 } | 157 } |
157 | 158 |
158 int32_t AudioDeviceLinuxALSA::Init() | 159 AudioDeviceGeneric::InitStatus AudioDeviceLinuxALSA::Init() { |
159 { | 160 CriticalSectionScoped lock(&_critSect); |
160 | 161 |
161 CriticalSectionScoped lock(&_critSect); | 162 // Load libasound |
| 163 if (!AlsaSymbolTable.Load()) { |
| 164 // Alsa is not installed on this system |
| 165 LOG(LS_ERROR) << "failed to load symbol table"; |
| 166 return InitStatus::OTHER_ERROR; |
| 167 } |
162 | 168 |
163 // Load libasound | 169 if (_initialized) { |
164 if (!AlsaSymbolTable.Load()) | 170 return InitStatus::OK; |
165 { | 171 } |
166 // Alsa is not installed on | |
167 // this system | |
168 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | |
169 " failed to load symbol table"); | |
170 return -1; | |
171 } | |
172 | |
173 if (_initialized) | |
174 { | |
175 return 0; | |
176 } | |
177 #if defined(USE_X11) | 172 #if defined(USE_X11) |
178 //Get X display handle for typing detection | 173 //Get X display handle for typing detection |
179 _XDisplay = XOpenDisplay(NULL); | 174 _XDisplay = XOpenDisplay(NULL); |
180 if (!_XDisplay) | 175 if (!_XDisplay) { |
181 { | 176 LOG(LS_WARNING) |
182 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, | 177 << "failed to open X display, typing detection will not work"; |
183 " failed to open X display, typing detection will not work"); | |
184 } | 178 } |
185 #endif | 179 #endif |
186 _playWarning = 0; | 180 _playWarning = 0; |
187 _playError = 0; | 181 _playError = 0; |
188 _recWarning = 0; | 182 _recWarning = 0; |
189 _recError = 0; | 183 _recError = 0; |
190 | 184 |
191 _initialized = true; | 185 _initialized = true; |
192 | 186 |
193 return 0; | 187 return InitStatus::OK; |
194 } | 188 } |
195 | 189 |
196 int32_t AudioDeviceLinuxALSA::Terminate() | 190 int32_t AudioDeviceLinuxALSA::Terminate() |
197 { | 191 { |
198 if (!_initialized) | 192 if (!_initialized) |
199 { | 193 { |
200 return 0; | 194 return 0; |
201 } | 195 } |
202 | 196 |
203 CriticalSectionScoped lock(&_critSect); | 197 CriticalSectionScoped lock(&_critSect); |
(...skipping 2014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2218 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; | 2212 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; |
2219 | 2213 |
2220 // Save old state | 2214 // Save old state |
2221 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); | 2215 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); |
2222 return (state != 0); | 2216 return (state != 0); |
2223 #else | 2217 #else |
2224 return false; | 2218 return false; |
2225 #endif | 2219 #endif |
2226 } | 2220 } |
2227 } // namespace webrtc | 2221 } // namespace webrtc |
OLD | NEW |