Commit 29ab72b2 authored by henrika's avatar henrika Committed by Commit Bot

Adds native WebRTC logs to media::InputController.

These changes will make it possible to track down issues related to
audio input streams (create/open/close) using native logs.

Focusing on AudioServiceAudioStreams since old streams are going away.

Tbr: olka
Bug: 1017219
Change-Id: Iffbc1880d9eea1868ce1a5e17e298c03328949e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1886676
Commit-Queue: Henrik Andreasson <henrika@chromium.org>
Reviewed-by: default avatarHenrik Andreasson <henrika@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711176}
parent 7b08262d
......@@ -579,6 +579,9 @@ void InputController::SetVolume(double volume) {
if (!stream_)
return;
std::string log_string = base::StringPrintf("AIC::SetVolume: %.2f", volume);
handler_->OnLog(log_string);
// Only ask for the maximum volume at first call and use cached value
// for remaining function calls.
if (!max_volume_) {
......@@ -646,7 +649,10 @@ void InputController::DoCreate(media::AudioManager* audio_manager,
DCHECK_CALLED_ON_VALID_THREAD(owning_thread_);
DCHECK(!stream_);
SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioInputController.CreateTime");
handler_->OnLog("AIC::DoCreate");
std::string log_string = base::StringPrintf(
"AIC::DoCreate: device_id=%s, enable_agc=%d, params=%s",
device_id.c_str(), enable_agc, params.AsHumanReadableString().c_str());
handler_->OnLog(log_string);
#if defined(AUDIO_POWER_MONITORING)
// We only do power measurements for UMA stats for low latency streams, and
......@@ -692,6 +698,8 @@ void InputController::DoCreate(media::AudioManager* audio_manager,
// Send initial muted state along with OnCreated, to avoid races.
is_muted_ = stream_->IsMuted();
handler_->OnCreated(is_muted_);
log_string = base::StringPrintf("AIC::OnCreated: is_muted=%d", is_muted_);
handler_->OnLog(log_string);
check_muted_state_timer_.Start(FROM_HERE, kCheckMutedStateInterval, this,
&InputController::CheckMutedState);
......@@ -717,7 +725,7 @@ void InputController::DoLogAudioLevels(float level_dbfs,
LogMicrophoneMuteResult(MICROPHONE_IS_MUTED);
handler_->OnLog("AIC::OnData: microphone is muted!");
// Return early if microphone is muted. No need to adding logs and UMA stats
// of audio levels if we know that the micropone is muted.
// of audio levels if we know that the microphone is muted.
return;
}
......@@ -860,6 +868,9 @@ void InputController::CheckMutedState() {
if (new_state != is_muted_) {
is_muted_ = new_state;
handler_->OnMuted(is_muted_);
std::string log_string =
base::StringPrintf("AIC::OnMuted: is_muted=%d", is_muted_);
handler_->OnLog(log_string);
}
}
......
......@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/trace_event.h"
#include "media/audio/audio_manager.h"
#include "media/base/audio_parameters.h"
......@@ -199,8 +200,11 @@ void InputStream::OnError(InputController::ErrorCode error_code) {
TRACE_EVENT_NESTABLE_ASYNC_INSTANT0("audio", "Error", this);
client_->OnError();
if (log_)
if (log_) {
log_->OnError();
log_->OnLogMessage(
base::StringPrintf("AIC::OnError: %d", error_code).c_str());
}
OnStreamError(true);
}
......@@ -226,6 +230,10 @@ void InputStream::OnStreamError(bool signalPlatformError) {
std::string());
}
if (signalPlatformError && log_) {
log_->OnLogMessage(base::StringPrintf("IC::OnStreamError").c_str());
}
// Defer callback so we're not destructed while in the constructor.
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
......
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