Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc

Issue 1476453002: Clean up PlatformThread. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: IsRunning DCHECK Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 193
194 //Get X display handle for typing detection 194 //Get X display handle for typing detection
195 _XDisplay = XOpenDisplay(NULL); 195 _XDisplay = XOpenDisplay(NULL);
196 if (!_XDisplay) 196 if (!_XDisplay)
197 { 197 {
198 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, 198 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
199 " failed to open X display, typing detection will not work"); 199 " failed to open X display, typing detection will not work");
200 } 200 }
201 201
202 // RECORDING 202 // RECORDING
203 const char* threadName = "webrtc_audio_module_rec_thread"; 203 _ptrThreadRec.reset(new rtc::PlatformThread(
204 _ptrThreadRec = 204 RecThreadFunc, this, "webrtc_audio_module_rec_thread"));
205 PlatformThread::CreateThread(RecThreadFunc, this, threadName);
206 if (!_ptrThreadRec->Start())
207 {
208 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
209 " failed to start the rec audio thread");
210 205
211 _ptrThreadRec.reset(); 206 _ptrThreadRec->Start();
212 return -1; 207 _ptrThreadRec->SetPriority(rtc::kRealtimePriority);
213 }
214
215 _ptrThreadRec->SetPriority(kRealtimePriority);
216 208
217 // PLAYOUT 209 // PLAYOUT
218 threadName = "webrtc_audio_module_play_thread"; 210 _ptrThreadPlay.reset(new rtc::PlatformThread(
219 _ptrThreadPlay = 211 PlayThreadFunc, this, "webrtc_audio_module_play_thread"));
220 PlatformThread::CreateThread(PlayThreadFunc, this, threadName); 212 _ptrThreadPlay->Start();
221 if (!_ptrThreadPlay->Start()) 213 _ptrThreadPlay->SetPriority(rtc::kRealtimePriority);
222 {
223 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
224 " failed to start the play audio thread");
225
226 _ptrThreadPlay.reset();
227 return -1;
228 }
229 _ptrThreadPlay->SetPriority(kRealtimePriority);
230 214
231 _initialized = true; 215 _initialized = true;
232 216
233 return 0; 217 return 0;
234 } 218 }
235 219
236 int32_t AudioDeviceLinuxPulse::Terminate() 220 int32_t AudioDeviceLinuxPulse::Terminate()
237 { 221 {
238 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 222 RTC_DCHECK(thread_checker_.CalledOnValidThread());
239 if (!_initialized) 223 if (!_initialized)
240 { 224 {
241 return 0; 225 return 0;
242 } 226 }
243 227
244 _mixerManager.Close(); 228 _mixerManager.Close();
245 229
246 // RECORDING 230 // RECORDING
247 if (_ptrThreadRec) 231 if (_ptrThreadRec)
248 { 232 {
249 PlatformThread* tmpThread = _ptrThreadRec.release(); 233 rtc::PlatformThread* tmpThread = _ptrThreadRec.release();
250 234
251 _timeEventRec.Set(); 235 _timeEventRec.Set();
252 tmpThread->Stop(); 236 tmpThread->Stop();
253 delete tmpThread; 237 delete tmpThread;
254 } 238 }
255 239
256 // PLAYOUT 240 // PLAYOUT
257 if (_ptrThreadPlay) 241 if (_ptrThreadPlay)
258 { 242 {
259 PlatformThread* tmpThread = _ptrThreadPlay.release(); 243 rtc::PlatformThread* tmpThread = _ptrThreadPlay.release();
260 244
261 _timeEventPlay.Set(); 245 _timeEventPlay.Set();
262 tmpThread->Stop(); 246 tmpThread->Stop();
263 delete tmpThread; 247 delete tmpThread;
264 } 248 }
265 249
266 // Terminate PulseAudio 250 // Terminate PulseAudio
267 if (TerminatePulseAudio() < 0) 251 if (TerminatePulseAudio() < 0)
268 { 252 {
269 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, 253 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
(...skipping 2743 matching lines...) Expand 10 before | Expand all | Expand 10 after
3013 2997
3014 // A bit change in keymap means a key is pressed 2998 // A bit change in keymap means a key is pressed
3015 for (i = 0; i < sizeof(szKey); i++) 2999 for (i = 0; i < sizeof(szKey); i++)
3016 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; 3000 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i];
3017 3001
3018 // Save old state 3002 // Save old state
3019 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); 3003 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState));
3020 return (state != 0); 3004 return (state != 0);
3021 } 3005 }
3022 } 3006 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/linux/audio_device_pulse_linux.h ('k') | webrtc/modules/audio_device/mac/audio_device_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698