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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 // ActiveAudioLayer | 156 // ActiveAudioLayer |
157 // ---------------------------------------------------------------------------- | 157 // ---------------------------------------------------------------------------- |
158 | 158 |
159 int32_t AudioDeviceLinuxPulse::ActiveAudioLayer( | 159 int32_t AudioDeviceLinuxPulse::ActiveAudioLayer( |
160 AudioDeviceModule::AudioLayer& audioLayer) const | 160 AudioDeviceModule::AudioLayer& audioLayer) const |
161 { | 161 { |
162 audioLayer = AudioDeviceModule::kLinuxPulseAudio; | 162 audioLayer = AudioDeviceModule::kLinuxPulseAudio; |
163 return 0; | 163 return 0; |
164 } | 164 } |
165 | 165 |
166 int32_t AudioDeviceLinuxPulse::Init() | 166 AudioDeviceGeneric::InitStatus AudioDeviceLinuxPulse::Init() { |
167 { | 167 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
168 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 168 if (_initialized) { |
169 if (_initialized) | 169 return InitStatus::kOk; |
170 { | 170 } |
171 return 0; | 171 |
172 // Initialize PulseAudio | |
173 if (InitPulseAudio() < 0) { | |
174 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | |
henrika_webrtc
2016/06/30 08:44:20
Could you fix these as well. I.e., don't use WEBRT
Max Morin WebRTC
2016/06/30 10:56:04
Done.
| |
175 " failed to initialize PulseAudio"); | |
176 if (TerminatePulseAudio() < 0) { | |
177 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | |
178 " failed to terminate PulseAudio"); | |
172 } | 179 } |
180 return InitStatus::kOtherError; | |
181 } | |
173 | 182 |
174 // Initialize PulseAudio | 183 _playWarning = 0; |
175 if (InitPulseAudio() < 0) | 184 _playError = 0; |
176 { | 185 _recWarning = 0; |
177 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 186 _recError = 0; |
178 " failed to initialize PulseAudio"); | |
179 | 187 |
180 if (TerminatePulseAudio() < 0) | 188 // Get X display handle for typing detection |
181 { | 189 _XDisplay = XOpenDisplay(NULL); |
182 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, | 190 if (!_XDisplay) { |
183 " failed to terminate PulseAudio"); | 191 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, |
184 } | 192 " failed to open X display, typing detection will not work"); |
193 } | |
185 | 194 |
186 return -1; | 195 // RECORDING |
187 } | 196 _ptrThreadRec.reset(new rtc::PlatformThread( |
197 RecThreadFunc, this, "webrtc_audio_module_rec_thread")); | |
188 | 198 |
189 _playWarning = 0; | 199 _ptrThreadRec->Start(); |
190 _playError = 0; | 200 _ptrThreadRec->SetPriority(rtc::kRealtimePriority); |
191 _recWarning = 0; | |
192 _recError = 0; | |
193 | 201 |
194 //Get X display handle for typing detection | 202 // PLAYOUT |
195 _XDisplay = XOpenDisplay(NULL); | 203 _ptrThreadPlay.reset(new rtc::PlatformThread( |
196 if (!_XDisplay) | 204 PlayThreadFunc, this, "webrtc_audio_module_play_thread")); |
197 { | 205 _ptrThreadPlay->Start(); |
198 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, | 206 _ptrThreadPlay->SetPriority(rtc::kRealtimePriority); |
199 " failed to open X display, typing detection will not work"); | |
200 } | |
201 | 207 |
202 // RECORDING | 208 _initialized = true; |
203 _ptrThreadRec.reset(new rtc::PlatformThread( | |
204 RecThreadFunc, this, "webrtc_audio_module_rec_thread")); | |
205 | 209 |
206 _ptrThreadRec->Start(); | 210 return InitStatus::kOk; |
207 _ptrThreadRec->SetPriority(rtc::kRealtimePriority); | |
208 | |
209 // PLAYOUT | |
210 _ptrThreadPlay.reset(new rtc::PlatformThread( | |
211 PlayThreadFunc, this, "webrtc_audio_module_play_thread")); | |
212 _ptrThreadPlay->Start(); | |
213 _ptrThreadPlay->SetPriority(rtc::kRealtimePriority); | |
214 | |
215 _initialized = true; | |
216 | |
217 return 0; | |
218 } | 211 } |
219 | 212 |
220 int32_t AudioDeviceLinuxPulse::Terminate() | 213 int32_t AudioDeviceLinuxPulse::Terminate() |
221 { | 214 { |
222 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 215 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
223 if (!_initialized) | 216 if (!_initialized) |
224 { | 217 { |
225 return 0; | 218 return 0; |
226 } | 219 } |
227 | 220 |
(...skipping 2769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2997 | 2990 |
2998 // A bit change in keymap means a key is pressed | 2991 // A bit change in keymap means a key is pressed |
2999 for (i = 0; i < sizeof(szKey); i++) | 2992 for (i = 0; i < sizeof(szKey); i++) |
3000 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; | 2993 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; |
3001 | 2994 |
3002 // Save old state | 2995 // Save old state |
3003 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); | 2996 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); |
3004 return (state != 0); | 2997 return (state != 0); |
3005 } | 2998 } |
3006 } | 2999 } |
OLD | NEW |