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

Side by Side Diff: webrtc/modules/audio_device/win/audio_device_wave_win.cc

Issue 1469013002: Move ThreadWrapper to ProcessThread in base. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: removed comment 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 _mixerManager.EnumerateAll(); 222 _mixerManager.EnumerateAll();
223 223
224 if (_ptrThread) 224 if (_ptrThread)
225 { 225 {
226 // thread is already created and active 226 // thread is already created and active
227 return 0; 227 return 0;
228 } 228 }
229 229
230 const char* threadName = "webrtc_audio_module_thread"; 230 const char* threadName = "webrtc_audio_module_thread";
231 _ptrThread = ThreadWrapper::CreateThread(ThreadFunc, this, threadName); 231 _ptrThread = PlatformThread::CreateThread(ThreadFunc, this, threadName);
232 if (!_ptrThread->Start()) 232 if (!_ptrThread->Start())
233 { 233 {
234 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, 234 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
235 "failed to start the audio thread"); 235 "failed to start the audio thread");
236 _ptrThread.reset(); 236 _ptrThread.reset();
237 return -1; 237 return -1;
238 } 238 }
239 _ptrThread->SetPriority(kRealtimePriority); 239 _ptrThread->SetPriority(kRealtimePriority);
240 240
241 const bool periodic(true); 241 const bool periodic(true);
242 if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS)) 242 if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS))
243 { 243 {
244 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, 244 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
245 "failed to start the timer event"); 245 "failed to start the timer event");
246 _ptrThread->Stop(); 246 _ptrThread->Stop();
247 _ptrThread.reset(); 247 _ptrThread.reset();
248 return -1; 248 return -1;
249 } 249 }
250 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, 250 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
251 "periodic timer (dT=%d) is now active", TIMER_PERIOD_MS); 251 "periodic timer (dT=%d) is now active", TIMER_PERIOD_MS);
252 252
253 _hGetCaptureVolumeThread = CreateThread(NULL, 253 _hGetCaptureVolumeThread =
254 0, 254 CreateThread(NULL, 0, GetCaptureVolumeThread, this, 0, NULL);
255 GetCaptureVolumeThread,
256 this,
257 0,
258 NULL);
259 if (_hGetCaptureVolumeThread == NULL) 255 if (_hGetCaptureVolumeThread == NULL)
260 { 256 {
261 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, 257 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
262 " failed to create the volume getter thread"); 258 " failed to create the volume getter thread");
263 return -1; 259 return -1;
264 } 260 }
265 261
266 SetThreadPriority(_hGetCaptureVolumeThread, THREAD_PRIORITY_NORMAL); 262 SetThreadPriority(_hGetCaptureVolumeThread, THREAD_PRIORITY_NORMAL);
267 263
268 _hSetCaptureVolumeThread = CreateThread(NULL, 264 _hSetCaptureVolumeThread =
269 0, 265 CreateThread(NULL, 0, SetCaptureVolumeThread, this, 0, NULL);
270 SetCaptureVolumeThread,
271 this,
272 0,
273 NULL);
274 if (_hSetCaptureVolumeThread == NULL) 266 if (_hSetCaptureVolumeThread == NULL)
275 { 267 {
276 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, 268 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
277 " failed to create the volume setter thread"); 269 " failed to create the volume setter thread");
278 return -1; 270 return -1;
279 } 271 }
280 272
281 SetThreadPriority(_hSetCaptureVolumeThread, THREAD_PRIORITY_NORMAL); 273 SetThreadPriority(_hSetCaptureVolumeThread, THREAD_PRIORITY_NORMAL);
282 274
283 _initialized = true; 275 _initialized = true;
(...skipping 12 matching lines...) Expand all
296 { 288 {
297 return 0; 289 return 0;
298 } 290 }
299 291
300 _critSect.Enter(); 292 _critSect.Enter();
301 293
302 _mixerManager.Close(); 294 _mixerManager.Close();
303 295
304 if (_ptrThread) 296 if (_ptrThread)
305 { 297 {
306 ThreadWrapper* tmpThread = _ptrThread.release(); 298 PlatformThread* tmpThread = _ptrThread.release();
307 _critSect.Leave(); 299 _critSect.Leave();
308 300
309 _timeEvent.Set(); 301 _timeEvent.Set();
310 302
311 tmpThread->Stop(); 303 tmpThread->Stop();
312 delete tmpThread; 304 delete tmpThread;
313 } 305 }
314 else 306 else
315 { 307 {
316 _critSect.Leave(); 308 _critSect.Leave();
(...skipping 3420 matching lines...) Expand 10 before | Expand all | Expand 10 after
3737 bool AudioDeviceWindowsWave::KeyPressed() const{ 3729 bool AudioDeviceWindowsWave::KeyPressed() const{
3738 3730
3739 int key_down = 0; 3731 int key_down = 0;
3740 for (int key = VK_SPACE; key < VK_NUMLOCK; key++) { 3732 for (int key = VK_SPACE; key < VK_NUMLOCK; key++) {
3741 short res = GetAsyncKeyState(key); 3733 short res = GetAsyncKeyState(key);
3742 key_down |= res & 0x1; // Get the LSB 3734 key_down |= res & 0x1; // Get the LSB
3743 } 3735 }
3744 return (key_down > 0); 3736 return (key_down > 0);
3745 } 3737 }
3746 } // namespace webrtc 3738 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698