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

Unified Diff: media/audio/mac/audio_low_latency_input_mac.cc

Issue 1864483002: Forward output glitch information from stream WebRTC log (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 7 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: media/audio/mac/audio_low_latency_input_mac.cc
diff --git a/media/audio/mac/audio_low_latency_input_mac.cc b/media/audio/mac/audio_low_latency_input_mac.cc
index 2429dd1a442d3dc90e539924aaa6790bc6169913..e8008c433df9f9baaa9536460af6545892b137d7 100644
--- a/media/audio/mac/audio_low_latency_input_mac.cc
+++ b/media/audio/mac/audio_low_latency_input_mac.cc
@@ -12,6 +12,7 @@
#include "base/mac/mac_logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/sparse_histogram.h"
+#include "base/strings/stringprintf.h"
#include "base/sys_info.h"
#include "base/time/time.h"
#include "media/audio/mac/audio_manager_mac.h"
@@ -236,9 +237,11 @@ static void AddSystemInfoToUMA(bool is_on_battery, int num_resumes) {
// http://developer.apple.com/library/mac/#technotes/tn2091/_index.html
// for more details and background regarding this implementation.
-AUAudioInputStream::AUAudioInputStream(AudioManagerMac* manager,
- const AudioParameters& input_params,
- AudioDeviceID audio_device_id)
+AUAudioInputStream::AUAudioInputStream(
+ AudioManagerMac* manager,
+ const AudioParameters& input_params,
+ AudioDeviceID audio_device_id,
+ const AudioManager::LogCallback& log_callback)
: manager_(manager),
number_of_frames_(input_params.frames_per_buffer()),
number_of_frames_provided_(0),
@@ -264,6 +267,7 @@ AUAudioInputStream::AUAudioInputStream(AudioManagerMac* manager,
number_of_restart_indications_(0),
number_of_restart_attempts_(0),
total_number_of_restart_attempts_(0),
+ log_callback_(log_callback),
weak_factory_(this) {
DCHECK(manager_);
@@ -1645,8 +1649,13 @@ void AUAudioInputStream::ReportAndResetStats() {
// how often we get no glitches vs the alternative.
UMA_HISTOGRAM_COUNTS("Media.Audio.Capture.Glitches", glitches_detected_);
+ auto lost_frames_ms = (total_lost_frames_ * 1000) / format_.mSampleRate;
+ std::string log_message = base::StringPrintf(
+ "AU in: Total glitches=%d. Total frames lost=%d (%.0lf ms).",
+ glitches_detected_, total_lost_frames_, lost_frames_ms);
+ log_callback_.Run(log_message);
+
if (glitches_detected_ != 0) {
- auto lost_frames_ms = (total_lost_frames_ * 1000) / format_.mSampleRate;
UMA_HISTOGRAM_LONG_TIMES("Media.Audio.Capture.LostFramesInMs",
base::TimeDelta::FromMilliseconds(lost_frames_ms));
auto largest_glitch_ms =
@@ -1656,9 +1665,7 @@ void AUAudioInputStream::ReportAndResetStats() {
base::TimeDelta::FromMilliseconds(largest_glitch_ms),
base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromMinutes(1),
50);
- DLOG(WARNING) << "Total glitches=" << glitches_detected_
- << ". Total frames lost=" << total_lost_frames_ << " ("
- << lost_frames_ms << ")";
+ DLOG(WARNING) << log_message;
}
number_of_frames_provided_ = 0;
« no previous file with comments | « media/audio/mac/audio_low_latency_input_mac.h ('k') | media/audio/mac/audio_low_latency_input_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698