diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-08 20:13:38 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-08 20:13:38 +0000 |
commit | e8ee7e0b6a90dbf7f0fa9c66935f5479be5d58b6 (patch) | |
tree | 4641356afbf60c4c4a346da6e7851837188adf4c | |
parent | 1132436ee7d63e3f6391a3b4982c06e760fc5ca7 (diff) | |
download | chromium_src-e8ee7e0b6a90dbf7f0fa9c66935f5479be5d58b6.zip chromium_src-e8ee7e0b6a90dbf7f0fa9c66935f5479be5d58b6.tar.gz chromium_src-e8ee7e0b6a90dbf7f0fa9c66935f5479be5d58b6.tar.bz2 |
Use histogram in AudioRendererHost to measure IPC audio latency
Measure ICP audio latency using histogram.
Review URL: http://codereview.chromium.org/63128
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13378 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/renderer_host/audio_renderer_host.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/chrome/browser/renderer_host/audio_renderer_host.cc b/chrome/browser/renderer_host/audio_renderer_host.cc index 8ee88e6..71bcff5 100644 --- a/chrome/browser/renderer_host/audio_renderer_host.cc +++ b/chrome/browser/renderer_host/audio_renderer_host.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/histogram.h" #include "base/lock.h" #include "base/message_loop.h" #include "base/process.h" @@ -10,6 +11,17 @@ #include "chrome/browser/renderer_host/audio_renderer_host.h" #include "chrome/common/render_messages.h" +namespace { + +void RecordIPCAudioLatency(base::TimeDelta latency) { + // Create a histogram of minimum 1ms and maximum 1000ms with 100 buckets. + static ThreadSafeHistogram histogram("Audio.IPCTransportLatency", + 1, 1000, 100); + histogram.AddTime(latency); +} + +} // namespace + //----------------------------------------------------------------------------- // AudioRendererHost::IPCAudioSource implementations. @@ -140,6 +152,7 @@ void AudioRendererHost::IPCAudioSource::GetVolume() { size_t AudioRendererHost::IPCAudioSource::OnMoreData(AudioOutputStream* stream, void* dest, size_t max_size) { + base::TimeTicks tick_start = base::TimeTicks::HighResNow(); { AutoLock auto_lock(lock_); // If we are ever stopped, don't ask for more audio packet from the @@ -180,8 +193,10 @@ size_t AudioRendererHost::IPCAudioSource::OnMoreData(AudioOutputStream* stream, last_packet_size = last_packet_size_; } - return SafeCopyBuffer(dest, max_size, - shared_memory_.memory(), last_packet_size); + size_t copied = SafeCopyBuffer(dest, max_size, + shared_memory_.memory(), last_packet_size); + RecordIPCAudioLatency(base::TimeTicks::HighResNow() - tick_start); + return copied; } void AudioRendererHost::IPCAudioSource::OnClose(AudioOutputStream* stream) { |