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

Side by Side Diff: webrtc/modules/audio_device/linux/audio_device_alsa_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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return 0; 200 return 0;
201 } 201 }
202 202
203 CriticalSectionScoped lock(&_critSect); 203 CriticalSectionScoped lock(&_critSect);
204 204
205 _mixerManager.Close(); 205 _mixerManager.Close();
206 206
207 // RECORDING 207 // RECORDING
208 if (_ptrThreadRec) 208 if (_ptrThreadRec)
209 { 209 {
210 PlatformThread* tmpThread = _ptrThreadRec.release(); 210 rtc::PlatformThread* tmpThread = _ptrThreadRec.release();
211 _critSect.Leave(); 211 _critSect.Leave();
212 212
213 tmpThread->Stop(); 213 tmpThread->Stop();
214 delete tmpThread; 214 delete tmpThread;
215 215
216 _critSect.Enter(); 216 _critSect.Enter();
217 } 217 }
218 218
219 // PLAYOUT 219 // PLAYOUT
220 if (_ptrThreadPlay) 220 if (_ptrThreadPlay)
221 { 221 {
222 PlatformThread* tmpThread = _ptrThreadPlay.release(); 222 rtc::PlatformThread* tmpThread = _ptrThreadPlay.release();
223 _critSect.Leave(); 223 _critSect.Leave();
224 224
225 tmpThread->Stop(); 225 tmpThread->Stop();
226 delete tmpThread; 226 delete tmpThread;
227 227
228 _critSect.Enter(); 228 _critSect.Enter();
229 } 229 }
230 #if defined(USE_X11) 230 #if defined(USE_X11)
231 if (_XDisplay) 231 if (_XDisplay)
232 { 232 {
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 if (!_recordingBuffer) 1356 if (!_recordingBuffer)
1357 _recordingBuffer = new int8_t[_recordingBufferSizeIn10MS]; 1357 _recordingBuffer = new int8_t[_recordingBufferSizeIn10MS];
1358 if (!_recordingBuffer) 1358 if (!_recordingBuffer)
1359 { 1359 {
1360 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, 1360 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
1361 " failed to alloc recording buffer"); 1361 " failed to alloc recording buffer");
1362 _recording = false; 1362 _recording = false;
1363 return -1; 1363 return -1;
1364 } 1364 }
1365 // RECORDING 1365 // RECORDING
1366 const char* threadName = "webrtc_audio_module_capture_thread"; 1366 _ptrThreadRec.reset(new rtc::PlatformThread(
1367 _ptrThreadRec = 1367 RecThreadFunc, this, "webrtc_audio_module_capture_thread"));
1368 PlatformThread::CreateThread(RecThreadFunc, this, threadName);
1369 1368
1370 if (!_ptrThreadRec->Start()) 1369 _ptrThreadRec->Start();
1371 { 1370 _ptrThreadRec->SetPriority(rtc::kRealtimePriority);
1372 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
1373 " failed to start the rec audio thread");
1374 _recording = false;
1375 _ptrThreadRec.reset();
1376 delete [] _recordingBuffer;
1377 _recordingBuffer = NULL;
1378 return -1;
1379 }
1380 _ptrThreadRec->SetPriority(kRealtimePriority);
1381 1371
1382 errVal = LATE(snd_pcm_prepare)(_handleRecord); 1372 errVal = LATE(snd_pcm_prepare)(_handleRecord);
1383 if (errVal < 0) 1373 if (errVal < 0)
1384 { 1374 {
1385 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, 1375 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
1386 " capture snd_pcm_prepare failed (%s)\n", 1376 " capture snd_pcm_prepare failed (%s)\n",
1387 LATE(snd_strerror)(errVal)); 1377 LATE(snd_strerror)(errVal));
1388 // just log error 1378 // just log error
1389 // if snd_pcm_open fails will return -1 1379 // if snd_pcm_open fails will return -1
1390 } 1380 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 _playoutBuffer = new int8_t[_playoutBufferSizeIn10MS]; 1500 _playoutBuffer = new int8_t[_playoutBufferSizeIn10MS];
1511 if (!_playoutBuffer) 1501 if (!_playoutBuffer)
1512 { 1502 {
1513 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, 1503 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
1514 " failed to alloc playout buf"); 1504 " failed to alloc playout buf");
1515 _playing = false; 1505 _playing = false;
1516 return -1; 1506 return -1;
1517 } 1507 }
1518 1508
1519 // PLAYOUT 1509 // PLAYOUT
1520 const char* threadName = "webrtc_audio_module_play_thread"; 1510 _ptrThreadPlay.reset(new rtc::PlatformThread(
1521 _ptrThreadPlay = 1511 PlayThreadFunc, this, "webrtc_audio_module_play_thread"));
1522 PlatformThread::CreateThread(PlayThreadFunc, this, threadName); 1512 _ptrThreadPlay->Start();
1523 if (!_ptrThreadPlay->Start()) 1513 _ptrThreadPlay->SetPriority(rtc::kRealtimePriority);
1524 {
1525 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
1526 " failed to start the play audio thread");
1527 _playing = false;
1528 _ptrThreadPlay.reset();
1529 delete [] _playoutBuffer;
1530 _playoutBuffer = NULL;
1531 return -1;
1532 }
1533 _ptrThreadPlay->SetPriority(kRealtimePriority);
1534 1514
1535 int errVal = LATE(snd_pcm_prepare)(_handlePlayout); 1515 int errVal = LATE(snd_pcm_prepare)(_handlePlayout);
1536 if (errVal < 0) 1516 if (errVal < 0)
1537 { 1517 {
1538 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, 1518 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
1539 " playout snd_pcm_prepare failed (%s)\n", 1519 " playout snd_pcm_prepare failed (%s)\n",
1540 LATE(snd_strerror)(errVal)); 1520 LATE(snd_strerror)(errVal));
1541 // just log error 1521 // just log error
1542 // if snd_pcm_open fails will return -1 1522 // if snd_pcm_open fails will return -1
1543 } 1523 }
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
2238 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i]; 2218 state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i];
2239 2219
2240 // Save old state 2220 // Save old state
2241 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState)); 2221 memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState));
2242 return (state != 0); 2222 return (state != 0);
2243 #else 2223 #else
2244 return false; 2224 return false;
2245 #endif 2225 #endif
2246 } 2226 }
2247 } // namespace webrtc 2227 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698