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

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

Issue 1487983002: Forward the number of skipped frames by the OS in audio playout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
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"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 LogAudioGlitchResult(AUDIO_RENDERER_AUDIO_GLITCHES) : 74 LogAudioGlitchResult(AUDIO_RENDERER_AUDIO_GLITCHES) :
75 LogAudioGlitchResult(AUDIO_RENDERER_NO_AUDIO_GLITCHES); 75 LogAudioGlitchResult(AUDIO_RENDERER_NO_AUDIO_GLITCHES);
76 std::string log_string = 76 std::string log_string =
77 base::StringPrintf("ASR: number of detected audio glitches=%d", 77 base::StringPrintf("ASR: number of detected audio glitches=%d",
78 static_cast<int>(renderer_missed_callback_count_)); 78 static_cast<int>(renderer_missed_callback_count_));
79 MediaStreamManager::SendMessageToNativeLog(log_string); 79 MediaStreamManager::SendMessageToNativeLog(log_string);
80 DVLOG(1) << log_string; 80 DVLOG(1) << log_string;
81 } 81 }
82 82
83 // media::AudioOutputController::SyncReader implementations. 83 // media::AudioOutputController::SyncReader implementations.
84 void AudioSyncReader::UpdatePendingBytes(uint32 bytes) { 84 void AudioSyncReader::UpdatePendingBytes(uint32_t bytes,
85 uint32_t frames_skipped) {
85 // Zero out the entire output buffer to avoid stuttering/repeating-buffers 86 // Zero out the entire output buffer to avoid stuttering/repeating-buffers
86 // 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.
87 output_bus_->Zero(); 88 output_bus_->Zero();
88 socket_->Send(&bytes, sizeof(bytes)); 89 uint64_t data = (static_cast<uint64_t>(bytes) << 32) | frames_skipped;
tommi (sloooow) - chröme 2015/12/01 13:34:25 can we use a struct with two uint32_t's instead?
90 socket_->Send(&data, sizeof(data));
89 ++buffer_index_; 91 ++buffer_index_;
90 } 92 }
91 93
92 void AudioSyncReader::Read(AudioBus* dest) { 94 void AudioSyncReader::Read(AudioBus* dest) {
93 ++renderer_callback_count_; 95 ++renderer_callback_count_;
94 if (!WaitUntilDataIsReady()) { 96 if (!WaitUntilDataIsReady()) {
95 ++renderer_missed_callback_count_; 97 ++renderer_missed_callback_count_;
96 if (renderer_missed_callback_count_ <= 100) { 98 if (renderer_missed_callback_count_ <= 100) {
97 LOG(WARNING) << "AudioSyncReader::Read timed out, audio glitch count=" 99 LOG(WARNING) << "AudioSyncReader::Read timed out, audio glitch count="
98 << renderer_missed_callback_count_; 100 << renderer_missed_callback_count_;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 base::TimeDelta::FromMilliseconds(1), 174 base::TimeDelta::FromMilliseconds(1),
173 base::TimeDelta::FromMilliseconds(1000), 175 base::TimeDelta::FromMilliseconds(1000),
174 50); 176 50);
175 return false; 177 return false;
176 } 178 }
177 179
178 return true; 180 return true;
179 } 181 }
180 182
181 } // namespace content 183 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698