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

Unified 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: Rename variable. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_device/win/audio_device_wave_win.cc
diff --git a/webrtc/modules/audio_device/win/audio_device_wave_win.cc b/webrtc/modules/audio_device/win/audio_device_wave_win.cc
index c14970899262ea2a61926946cad5663792603138..7874575e7ce166259801f1aa34bfe8f603d9ff9d 100644
--- a/webrtc/modules/audio_device/win/audio_device_wave_win.cc
+++ b/webrtc/modules/audio_device/win/audio_device_wave_win.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "webrtc/base/logging.h"
#include "webrtc/base/timeutils.h"
#include "webrtc/modules/audio_device/audio_device_config.h"
#include "webrtc/modules/audio_device/win/audio_device_wave_win.h"
@@ -196,79 +197,69 @@ int32_t AudioDeviceWindowsWave::ActiveAudioLayer(AudioDeviceModule::AudioLayer&
// Init
// ----------------------------------------------------------------------------
-int32_t AudioDeviceWindowsWave::Init()
-{
-
- CriticalSectionScoped lock(&_critSect);
+AudioDeviceGeneric::InitStatus AudioDeviceWindowsWave::Init() {
+ CriticalSectionScoped lock(&_critSect);
- if (_initialized)
- {
- return 0;
- }
-
- const uint32_t nowTime(rtc::TimeMillis());
-
- _recordedBytes = 0;
- _prevRecByteCheckTime = nowTime;
- _prevRecTime = nowTime;
- _prevPlayTime = nowTime;
- _prevTimerCheckTime = nowTime;
+ if (_initialized) {
+ return InitStatus::OK;
+ }
- _playWarning = 0;
- _playError = 0;
- _recWarning = 0;
- _recError = 0;
+ const uint32_t nowTime(rtc::TimeMillis());
- _mixerManager.EnumerateAll();
+ _recordedBytes = 0;
+ _prevRecByteCheckTime = nowTime;
+ _prevRecTime = nowTime;
+ _prevPlayTime = nowTime;
+ _prevTimerCheckTime = nowTime;
- if (_ptrThread)
- {
- // thread is already created and active
- return 0;
- }
+ _playWarning = 0;
+ _playError = 0;
+ _recWarning = 0;
+ _recError = 0;
- const char* threadName = "webrtc_audio_module_thread";
- _ptrThread.reset(new rtc::PlatformThread(ThreadFunc, this, threadName));
- _ptrThread->Start();
- _ptrThread->SetPriority(rtc::kRealtimePriority);
+ _mixerManager.EnumerateAll();
- const bool periodic(true);
- if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS))
- {
- WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
- "failed to start the timer event");
- _ptrThread->Stop();
- _ptrThread.reset();
- return -1;
- }
- WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
- "periodic timer (dT=%d) is now active", TIMER_PERIOD_MS);
+ if (_ptrThread) {
+ // thread is already created and active
+ return InitStatus::OK;
+ }
- _hGetCaptureVolumeThread =
- CreateThread(NULL, 0, GetCaptureVolumeThread, this, 0, NULL);
- if (_hGetCaptureVolumeThread == NULL)
- {
- WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
- " failed to create the volume getter thread");
- return -1;
- }
+ const char* threadName = "webrtc_audio_module_thread";
+ _ptrThread.reset(new rtc::PlatformThread(ThreadFunc, this, threadName));
+ _ptrThread->Start();
+ _ptrThread->SetPriority(rtc::kRealtimePriority);
+
+ const bool periodic(true);
+ if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS)) {
+ LOG(LS_ERROR) << "failed to start the timer event";
+ _ptrThread->Stop();
+ _ptrThread.reset();
+ return InitStatus::OTHER_ERROR;
+ }
+ WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
+ "periodic timer (dT=%d) is now active", TIMER_PERIOD_MS);
+
+ _hGetCaptureVolumeThread =
+ CreateThread(NULL, 0, GetCaptureVolumeThread, this, 0, NULL);
+ if (_hGetCaptureVolumeThread == NULL) {
+ LOG(LS_ERROR) << " failed to create the volume getter thread";
+ return InitStatus::OTHER_ERROR;
+ }
- SetThreadPriority(_hGetCaptureVolumeThread, THREAD_PRIORITY_NORMAL);
+ SetThreadPriority(_hGetCaptureVolumeThread, THREAD_PRIORITY_NORMAL);
- _hSetCaptureVolumeThread =
- CreateThread(NULL, 0, SetCaptureVolumeThread, this, 0, NULL);
- if (_hSetCaptureVolumeThread == NULL)
- {
- WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
- " failed to create the volume setter thread");
- return -1;
- }
+ _hSetCaptureVolumeThread =
+ CreateThread(NULL, 0, SetCaptureVolumeThread, this, 0, NULL);
+ if (_hSetCaptureVolumeThread == NULL) {
+ LOG(LS_ERROR) << " failed to create the volume setter thread";
+ return InitStatus::OTHER_ERROR;
+ }
- SetThreadPriority(_hSetCaptureVolumeThread, THREAD_PRIORITY_NORMAL);
+ SetThreadPriority(_hSetCaptureVolumeThread, THREAD_PRIORITY_NORMAL);
- _initialized = true;
+ _initialized = true;
- return 0;
+ return InitStatus::OK;
}
// ----------------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698