Commit 804afc69 authored by grunell@chromium.org's avatar grunell@chromium.org

Add UMA stats for open audio input device failure.

* Change UMA stats for capture startup to an enum. It retains the meanings of the current (bool) values 0 and 1.
* Add values for fail to create and open stream (device).
* Remove |enable_nodata_timer| which doesn't have any use.

BUG=399835

Review URL: https://codereview.chromium.org/460993002

Cr-Commit-Position: refs/heads/master@{#289288}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289288 0039d316-1c4b-4281-b951-d872f2087c98
parent 57fe1701
......@@ -47,6 +47,27 @@ const int kPowerMonitorLogIntervalSeconds = 5;
#endif
}
// Used to log the result of capture startup.
// This was previously logged as a boolean with only the no callback and OK
// options. The enum order is kept to ensure backwards compatibility.
// Elements in this enum should not be deleted or rearranged; the only
// permitted operation is to add new elements before CAPTURE_STARTUP_RESULT_MAX
// and update CAPTURE_STARTUP_RESULT_MAX.
enum CaptureStartupResult {
CAPTURE_STARTUP_NO_DATA_CALLBACK = 0,
CAPTURE_STARTUP_OK = 1,
CAPTURE_STARTUP_CREATE_STREAM_FAILED = 2,
CAPTURE_STARTUP_OPEN_STREAM_FAILED = 3,
CAPTURE_STARTUP_RESULT_MAX = CAPTURE_STARTUP_OPEN_STREAM_FAILED
};
void LogCaptureStartupResult(CaptureStartupResult result) {
UMA_HISTOGRAM_ENUMERATION("Media.AudioInputControllerCaptureStartupSuccess",
result,
CAPTURE_STARTUP_RESULT_MAX + 1);
}
namespace media {
// static
......@@ -157,8 +178,9 @@ scoped_refptr<AudioInputController> AudioInputController::CreateForStream(
// mirroring use case only.
if (!controller->task_runner_->PostTask(
FROM_HERE,
base::Bind(&AudioInputController::DoCreateForStream, controller,
stream, false))) {
base::Bind(&AudioInputController::DoCreateForStream,
controller,
stream))) {
controller = NULL;
}
......@@ -209,12 +231,11 @@ void AudioInputController::DoCreate(AudioManager* audio_manager,
// platform audio input requires the |no_data_timer_| be used to auto-detect
// errors. In reality, probably only Windows needs to be treated as
// unreliable here.
DoCreateForStream(audio_manager->MakeAudioInputStream(params, device_id),
true);
DoCreateForStream(audio_manager->MakeAudioInputStream(params, device_id));
}
void AudioInputController::DoCreateForStream(
AudioInputStream* stream_to_control, bool enable_nodata_timer) {
AudioInputStream* stream_to_control) {
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(!stream_);
......@@ -223,6 +244,7 @@ void AudioInputController::DoCreateForStream(
if (!stream_) {
if (handler_)
handler_->OnError(this, STREAM_CREATE_ERROR);
LogCaptureStartupResult(CAPTURE_STARTUP_CREATE_STREAM_FAILED);
return;
}
......@@ -231,29 +253,24 @@ void AudioInputController::DoCreateForStream(
stream_ = NULL;
if (handler_)
handler_->OnError(this, STREAM_OPEN_ERROR);
LogCaptureStartupResult(CAPTURE_STARTUP_OPEN_STREAM_FAILED);
return;
}
DCHECK(!no_data_timer_.get());
// Create the data timer which will call FirstCheckForNoData(). The timer
// is started in DoRecord() and restarted in each DoCheckForNoData()
// callback.
// The timer is enabled for logging purposes. The NO_DATA_ERROR triggered
// from the timer must be ignored by the EventHandler.
// TODO(henrika): remove usage of timer when it has been verified on Canary
// that we are safe doing so. Goal is to get rid of |no_data_timer_| and
// everything that is tied to it. crbug.com/357569.
enable_nodata_timer = true;
if (enable_nodata_timer) {
// Create the data timer which will call FirstCheckForNoData(). The timer
// is started in DoRecord() and restarted in each DoCheckForNoData()
// callback.
no_data_timer_.reset(new base::Timer(
FROM_HERE, base::TimeDelta::FromSeconds(kTimerInitialIntervalSeconds),
base::Bind(&AudioInputController::FirstCheckForNoData,
base::Unretained(this)), false));
} else {
DVLOG(1) << "Disabled: timer check for no data.";
}
no_data_timer_.reset(new base::Timer(
FROM_HERE, base::TimeDelta::FromSeconds(kTimerInitialIntervalSeconds),
base::Bind(&AudioInputController::FirstCheckForNoData,
base::Unretained(this)), false));
state_ = CREATED;
if (handler_)
......@@ -352,8 +369,9 @@ void AudioInputController::DoSetAutomaticGainControl(bool enabled) {
void AudioInputController::FirstCheckForNoData() {
DCHECK(task_runner_->BelongsToCurrentThread());
UMA_HISTOGRAM_BOOLEAN("Media.AudioInputControllerCaptureStartupSuccess",
GetDataIsActive());
LogCaptureStartupResult(GetDataIsActive() ?
CAPTURE_STARTUP_OK :
CAPTURE_STARTUP_NO_DATA_CALLBACK);
DoCheckForNoData();
}
......
......@@ -254,8 +254,7 @@ class MEDIA_EXPORT AudioInputController
// Methods called on the audio thread (owned by the AudioManager).
void DoCreate(AudioManager* audio_manager, const AudioParameters& params,
const std::string& device_id);
void DoCreateForStream(AudioInputStream* stream_to_control,
bool enable_nodata_timer);
void DoCreateForStream(AudioInputStream* stream_to_control);
void DoRecord();
void DoClose();
void DoReportError();
......
......@@ -10730,7 +10730,7 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</histogram>
<histogram name="Media.AudioInputControllerCaptureStartupSuccess"
enum="BooleanSuccess">
enum="CaptureStartupResult">
<summary>
Whether capture started successfully after an input stream startup was
requested.
......@@ -37538,6 +37538,13 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="8" label="YV12"/>
</enum>
<enum name="CaptureStartupResult" type="int">
<int value="0" label="No data callback"/>
<int value="1" label="OK"/>
<int value="2" label="Failed to create stream"/>
<int value="3" label="Failed to open stream"/>
</enum>
<enum name="CastPlayBackState" type="int">
<int value="0" label="YT_PLAYER_SUCCESS"/>
<int value="1" label="YT_PLAYER_FAILURE"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment