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

Side by Side Diff: content/browser/renderer_host/media/audio_sync_reader.cc

Issue 534533002: Adding more detailed UMA histogram for detection of output audio glitches (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 6 years, 3 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/media/audio_sync_reader.h" 5 #include "content/browser/renderer_host/media/audio_sync_reader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/strings/stringprintf.h"
13 #include "content/browser/renderer_host/media/media_stream_manager.h"
12 #include "content/public/common/content_switches.h" 14 #include "content/public/common/content_switches.h"
13 #include "media/audio/audio_buffers_state.h" 15 #include "media/audio/audio_buffers_state.h"
14 #include "media/audio/audio_parameters.h" 16 #include "media/audio/audio_parameters.h"
15 17
16 using media::AudioBus; 18 using media::AudioBus;
17 19
20 namespace {
21
22 // Used to log if any audio glitches have been detected during an audio session.
23 // Elements in this enum should not be added, deleted or rearranged.
24 enum AudioGlitchResult {
25 AUDIO_RENDERER_NO_AUDIO_GLITCHES = 0,
26 AUDIO_RENDERER_AUDIO_GLITCHES = 1,
27 AUDIO_RENDERER_AUDIO_GLITCHES_MAX = AUDIO_RENDERER_AUDIO_GLITCHES
28 };
29
30 void LogAudioGlitchResult(AudioGlitchResult result) {
31 UMA_HISTOGRAM_ENUMERATION("Media.AudioRendererAudioGlitches",
32 result,
33 AUDIO_RENDERER_AUDIO_GLITCHES_MAX + 1);
34 }
35
36 } // namespace
37
18 namespace content { 38 namespace content {
19 39
20 AudioSyncReader::AudioSyncReader(base::SharedMemory* shared_memory, 40 AudioSyncReader::AudioSyncReader(base::SharedMemory* shared_memory,
21 const media::AudioParameters& params) 41 const media::AudioParameters& params)
22 : shared_memory_(shared_memory), 42 : shared_memory_(shared_memory),
23 mute_audio_(CommandLine::ForCurrentProcess()->HasSwitch( 43 mute_audio_(CommandLine::ForCurrentProcess()->HasSwitch(
24 switches::kMuteAudio)), 44 switches::kMuteAudio)),
25 packet_size_(shared_memory_->requested_size()), 45 packet_size_(shared_memory_->requested_size()),
26 renderer_callback_count_(0), 46 renderer_callback_count_(0),
27 renderer_missed_callback_count_(0), 47 renderer_missed_callback_count_(0),
(...skipping 12 matching lines...) Expand all
40 AudioSyncReader::~AudioSyncReader() { 60 AudioSyncReader::~AudioSyncReader() {
41 if (!renderer_callback_count_) 61 if (!renderer_callback_count_)
42 return; 62 return;
43 63
44 // Recording the percentage of deadline misses gives us a rough overview of 64 // Recording the percentage of deadline misses gives us a rough overview of
45 // how many users might be running into audio glitches. 65 // how many users might be running into audio glitches.
46 int percentage_missed = 66 int percentage_missed =
47 100.0 * renderer_missed_callback_count_ / renderer_callback_count_; 67 100.0 * renderer_missed_callback_count_ / renderer_callback_count_;
48 UMA_HISTOGRAM_PERCENTAGE( 68 UMA_HISTOGRAM_PERCENTAGE(
49 "Media.AudioRendererMissedDeadline", percentage_missed); 69 "Media.AudioRendererMissedDeadline", percentage_missed);
70
71 // Add more detailed information regarding detected audio glitches where
72 // a non-zero value of |renderer_missed_callback_count_| is added to the
73 // AUDIO_RENDERER_AUDIO_GLITCHES bin.
74 renderer_missed_callback_count_ > 0 ?
75 LogAudioGlitchResult(AUDIO_RENDERER_AUDIO_GLITCHES) :
76 LogAudioGlitchResult(AUDIO_RENDERER_NO_AUDIO_GLITCHES);
77 std::string log_string = base::StringPrintf(
78 "ASR: number of detected audio glitches=%ld",
79 renderer_missed_callback_count_);
80 MediaStreamManager::SendMessageToNativeLog(log_string);
81 DVLOG(1) << log_string;
50 } 82 }
51 83
52 // media::AudioOutputController::SyncReader implementations. 84 // media::AudioOutputController::SyncReader implementations.
53 void AudioSyncReader::UpdatePendingBytes(uint32 bytes) { 85 void AudioSyncReader::UpdatePendingBytes(uint32 bytes) {
54 // Zero out the entire output buffer to avoid stuttering/repeating-buffers 86 // Zero out the entire output buffer to avoid stuttering/repeating-buffers
55 // in the anomalous case if the renderer is unable to keep up with real-time. 87 // in the anomalous case if the renderer is unable to keep up with real-time.
56 output_bus_->Zero(); 88 output_bus_->Zero();
57 socket_->Send(&bytes, sizeof(bytes)); 89 socket_->Send(&bytes, sizeof(bytes));
58 ++buffer_index_; 90 ++buffer_index_;
59 } 91 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 base::TimeDelta::FromMilliseconds(1), 179 base::TimeDelta::FromMilliseconds(1),
148 base::TimeDelta::FromMilliseconds(1000), 180 base::TimeDelta::FromMilliseconds(1000),
149 50); 181 50);
150 return false; 182 return false;
151 } 183 }
152 184
153 return true; 185 return true;
154 } 186 }
155 187
156 } // namespace content 188 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698