| OLD | NEW |
| 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/format_macros.h" |
| 10 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
| 11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 13 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 #include "content/browser/renderer_host/media/media_stream_manager.h" | 16 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 16 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 17 #include "media/base/audio_parameters.h" | 18 #include "media/base/audio_parameters.h" |
| 18 | 19 |
| 19 using media::AudioBus; | 20 using media::AudioBus; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 100.0 * renderer_missed_callback_count_ / renderer_callback_count_; | 93 100.0 * renderer_missed_callback_count_ / renderer_callback_count_; |
| 93 UMA_HISTOGRAM_PERCENTAGE( | 94 UMA_HISTOGRAM_PERCENTAGE( |
| 94 "Media.AudioRendererMissedDeadline", percentage_missed); | 95 "Media.AudioRendererMissedDeadline", percentage_missed); |
| 95 | 96 |
| 96 // Add more detailed information regarding detected audio glitches where | 97 // Add more detailed information regarding detected audio glitches where |
| 97 // a non-zero value of |renderer_missed_callback_count_| is added to the | 98 // a non-zero value of |renderer_missed_callback_count_| is added to the |
| 98 // AUDIO_RENDERER_AUDIO_GLITCHES bin. | 99 // AUDIO_RENDERER_AUDIO_GLITCHES bin. |
| 99 renderer_missed_callback_count_ > 0 ? | 100 renderer_missed_callback_count_ > 0 ? |
| 100 LogAudioGlitchResult(AUDIO_RENDERER_AUDIO_GLITCHES) : | 101 LogAudioGlitchResult(AUDIO_RENDERER_AUDIO_GLITCHES) : |
| 101 LogAudioGlitchResult(AUDIO_RENDERER_NO_AUDIO_GLITCHES); | 102 LogAudioGlitchResult(AUDIO_RENDERER_NO_AUDIO_GLITCHES); |
| 102 std::string log_string = | 103 std::string log_string = base::StringPrintf( |
| 103 base::StringPrintf("ASR: number of detected audio glitches=%d", | 104 "ASR: number of detected audio glitches: %" PRIuS " out of %" PRIuS, |
| 104 static_cast<int>(renderer_missed_callback_count_)); | 105 renderer_missed_callback_count_, renderer_callback_count_); |
| 105 MediaStreamManager::SendMessageToNativeLog(log_string); | 106 MediaStreamManager::SendMessageToNativeLog(log_string); |
| 106 DVLOG(1) << log_string; | 107 DVLOG(1) << log_string; |
| 107 } | 108 } |
| 108 | 109 |
| 109 // media::AudioOutputController::SyncReader implementations. | 110 // media::AudioOutputController::SyncReader implementations. |
| 110 void AudioSyncReader::UpdatePendingBytes(uint32_t bytes, | 111 void AudioSyncReader::UpdatePendingBytes(uint32_t bytes, |
| 111 uint32_t frames_skipped) { | 112 uint32_t frames_skipped) { |
| 112 // Increase the number of skipped frames stored in shared memory. We don't | 113 // Increase the number of skipped frames stored in shared memory. We don't |
| 113 // send it over the socket since sending more than 4 bytes might lead to being | 114 // send it over the socket since sending more than 4 bytes might lead to being |
| 114 // descheduled. The reading side will zero it when consumed. | 115 // descheduled. The reading side will zero it when consumed. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 base::TimeDelta::FromMilliseconds(1), | 213 base::TimeDelta::FromMilliseconds(1), |
| 213 base::TimeDelta::FromMilliseconds(1000), | 214 base::TimeDelta::FromMilliseconds(1000), |
| 214 50); | 215 50); |
| 215 return false; | 216 return false; |
| 216 } | 217 } |
| 217 | 218 |
| 218 return true; | 219 return true; |
| 219 } | 220 } |
| 220 | 221 |
| 221 } // namespace content | 222 } // namespace content |
| OLD | NEW |