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

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

Issue 2103863004: UMA log for audio_device Init and Start(Playout|Recording). Make Init return a more specific error … (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix more silly errors. Created 4 years, 5 months 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 int32_t AudioDeviceWindowsWave::ActiveAudioLayer(AudioDeviceModule::AudioLayer& audioLayer) const 189 int32_t AudioDeviceWindowsWave::ActiveAudioLayer(AudioDeviceModule::AudioLayer& audioLayer) const
190 { 190 {
191 audioLayer = AudioDeviceModule::kWindowsWaveAudio; 191 audioLayer = AudioDeviceModule::kWindowsWaveAudio;
192 return 0; 192 return 0;
193 } 193 }
194 194
195 // ---------------------------------------------------------------------------- 195 // ----------------------------------------------------------------------------
196 // Init 196 // Init
197 // ---------------------------------------------------------------------------- 197 // ----------------------------------------------------------------------------
198 198
199 int32_t AudioDeviceWindowsWave::Init() 199 AudioDeviceGeneric::InitStatus AudioDeviceWindowsWave::Init() {
200 { 200 CriticalSectionScoped lock(&_critSect);
201 201
202 CriticalSectionScoped lock(&_critSect); 202 if (_initialized) {
203 return InitStatus::kOk;
204 }
203 205
204 if (_initialized) 206 const uint32_t nowTime(rtc::TimeMillis());
205 {
206 return 0;
207 }
208 207
209 const uint32_t nowTime(rtc::TimeMillis()); 208 _recordedBytes = 0;
209 _prevRecByteCheckTime = nowTime;
210 _prevRecTime = nowTime;
211 _prevPlayTime = nowTime;
212 _prevTimerCheckTime = nowTime;
210 213
211 _recordedBytes = 0; 214 _playWarning = 0;
212 _prevRecByteCheckTime = nowTime; 215 _playError = 0;
213 _prevRecTime = nowTime; 216 _recWarning = 0;
214 _prevPlayTime = nowTime; 217 _recError = 0;
215 _prevTimerCheckTime = nowTime;
216 218
217 _playWarning = 0; 219 _mixerManager.EnumerateAll();
218 _playError = 0;
219 _recWarning = 0;
220 _recError = 0;
221 220
222 _mixerManager.EnumerateAll(); 221 if (_ptrThread) {
222 // thread is already created and active
223 return InitStatus::kOk;
224 }
223 225
224 if (_ptrThread) 226 const char* threadName = "webrtc_audio_module_thread";
225 { 227 _ptrThread.reset(new rtc::PlatformThread(ThreadFunc, this, threadName));
226 // thread is already created and active 228 _ptrThread->Start();
227 return 0; 229 _ptrThread->SetPriority(rtc::kRealtimePriority);
228 }
229 230
230 const char* threadName = "webrtc_audio_module_thread"; 231 const bool periodic(true);
231 _ptrThread.reset(new rtc::PlatformThread(ThreadFunc, this, threadName)); 232 if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS)) {
232 _ptrThread->Start(); 233 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
233 _ptrThread->SetPriority(rtc::kRealtimePriority); 234 "failed to start the timer event");
235 _ptrThread->Stop();
236 _ptrThread.reset();
237 return InitStatus::kOtherError;
238 }
239 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
240 "periodic timer (dT=%d) is now active", TIMER_PERIOD_MS);
234 241
235 const bool periodic(true); 242 _hGetCaptureVolumeThread =
236 if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS)) 243 CreateThread(NULL, 0, GetCaptureVolumeThread, this, 0, NULL);
237 { 244 if (_hGetCaptureVolumeThread == NULL) {
238 WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, 245 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
239 "failed to start the timer event"); 246 " failed to create the volume getter thread");
240 _ptrThread->Stop(); 247 return InitStatus::kOtherError;
241 _ptrThread.reset(); 248 }
242 return -1;
243 }
244 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
245 "periodic timer (dT=%d) is now active", TIMER_PERIOD_MS);
246 249
247 _hGetCaptureVolumeThread = 250 SetThreadPriority(_hGetCaptureVolumeThread, THREAD_PRIORITY_NORMAL);
248 CreateThread(NULL, 0, GetCaptureVolumeThread, this, 0, NULL);
249 if (_hGetCaptureVolumeThread == NULL)
250 {
251 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
252 " failed to create the volume getter thread");
253 return -1;
254 }
255 251
256 SetThreadPriority(_hGetCaptureVolumeThread, THREAD_PRIORITY_NORMAL); 252 _hSetCaptureVolumeThread =
253 CreateThread(NULL, 0, SetCaptureVolumeThread, this, 0, NULL);
254 if (_hSetCaptureVolumeThread == NULL) {
255 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
256 " failed to create the volume setter thread");
257 return InitStatus::kOtherError;
258 }
257 259
258 _hSetCaptureVolumeThread = 260 SetThreadPriority(_hSetCaptureVolumeThread, THREAD_PRIORITY_NORMAL);
259 CreateThread(NULL, 0, SetCaptureVolumeThread, this, 0, NULL);
260 if (_hSetCaptureVolumeThread == NULL)
261 {
262 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
263 " failed to create the volume setter thread");
264 return -1;
265 }
266 261
267 SetThreadPriority(_hSetCaptureVolumeThread, THREAD_PRIORITY_NORMAL); 262 _initialized = true;
268 263
269 _initialized = true; 264 return InitStatus::kOk;
270
271 return 0;
272 } 265 }
273 266
274 // ---------------------------------------------------------------------------- 267 // ----------------------------------------------------------------------------
275 // Terminate 268 // Terminate
276 // ---------------------------------------------------------------------------- 269 // ----------------------------------------------------------------------------
277 270
278 int32_t AudioDeviceWindowsWave::Terminate() 271 int32_t AudioDeviceWindowsWave::Terminate()
279 { 272 {
280 273
281 if (!_initialized) 274 if (!_initialized)
(...skipping 3441 matching lines...) Expand 10 before | Expand all | Expand 10 after
3723 bool AudioDeviceWindowsWave::KeyPressed() const{ 3716 bool AudioDeviceWindowsWave::KeyPressed() const{
3724 3717
3725 int key_down = 0; 3718 int key_down = 0;
3726 for (int key = VK_SPACE; key < VK_NUMLOCK; key++) { 3719 for (int key = VK_SPACE; key < VK_NUMLOCK; key++) {
3727 short res = GetAsyncKeyState(key); 3720 short res = GetAsyncKeyState(key);
3728 key_down |= res & 0x1; // Get the LSB 3721 key_down |= res & 0x1; // Get the LSB
3729 } 3722 }
3730 return (key_down > 0); 3723 return (key_down > 0);
3731 } 3724 }
3732 } // namespace webrtc 3725 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698