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 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 _ptrAudioBuffer->SetPlayoutChannels(0); | 148 _ptrAudioBuffer->SetPlayoutChannels(0); |
149 } | 149 } |
150 | 150 |
151 int32_t AudioDeviceLinuxALSA::ActiveAudioLayer( | 151 int32_t AudioDeviceLinuxALSA::ActiveAudioLayer( |
152 AudioDeviceModule::AudioLayer& audioLayer) const | 152 AudioDeviceModule::AudioLayer& audioLayer) const |
153 { | 153 { |
154 audioLayer = AudioDeviceModule::kLinuxAlsaAudio; | 154 audioLayer = AudioDeviceModule::kLinuxAlsaAudio; |
155 return 0; | 155 return 0; |
156 } | 156 } |
157 | 157 |
158 int32_t AudioDeviceLinuxALSA::Init() | 158 AudioDeviceGeneric::InitStatus AudioDeviceLinuxALSA::Init() { |
159 { | 159 CriticalSectionScoped lock(&_critSect); |
160 | 160 |
161 CriticalSectionScoped lock(&_critSect); | 161 // Load libasound |
| 162 if (!AlsaSymbolTable.Load()) { |
| 163 // Alsa is not installed on |
| 164 // this system |
| 165 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, |
| 166 " failed to load symbol table"); |
| 167 return InitStatus::kOtherError; |
| 168 } |
162 | 169 |
163 // Load libasound | 170 if (_initialized) { |
164 if (!AlsaSymbolTable.Load()) | 171 return InitStatus::kOk; |
165 { | 172 } |
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) | 173 #if defined(USE_X11) |
178 //Get X display handle for typing detection | 174 //Get X display handle for typing detection |
179 _XDisplay = XOpenDisplay(NULL); | 175 _XDisplay = XOpenDisplay(NULL); |
180 if (!_XDisplay) | 176 if (!_XDisplay) |
181 { | 177 { |
182 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, | 178 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
183 " failed to open X display, typing detection will not work"); | 179 " failed to open X display, typing detection will not work"); |
184 } | 180 } |
185 #endif | 181 #endif |
186 _playWarning = 0; | 182 _playWarning = 0; |
187 _playError = 0; | 183 _playError = 0; |
188 _recWarning = 0; | 184 _recWarning = 0; |
189 _recError = 0; | 185 _recError = 0; |
190 | 186 |
191 _initialized = true; | 187 _initialized = true; |
192 | 188 |
193 return 0; | 189 return InitStatus::kOk; |
194 } | 190 } |
195 | 191 |
196 int32_t AudioDeviceLinuxALSA::Terminate() | 192 int32_t AudioDeviceLinuxALSA::Terminate() |
197 { | 193 { |
198 if (!_initialized) | 194 if (!_initialized) |
199 { | 195 { |
200 return 0; | 196 return 0; |
201 } | 197 } |
202 | 198 |
203 CriticalSectionScoped lock(&_critSect); | 199 CriticalSectionScoped lock(&_critSect); |
(...skipping 2014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2218 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; | 2214 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; |
2219 | 2215 |
2220 // Save old state | 2216 // Save old state |
2221 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); | 2217 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); |
2222 return (state != 0); | 2218 return (state != 0); |
2223 #else | 2219 #else |
2224 return false; | 2220 return false; |
2225 #endif | 2221 #endif |
2226 } | 2222 } |
2227 } // namespace webrtc | 2223 } // namespace webrtc |
OLD | NEW |