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/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 LogAudioGlitchResult(AUDIO_RENDERER_AUDIO_GLITCHES) : | 99 LogAudioGlitchResult(AUDIO_RENDERER_AUDIO_GLITCHES) : |
100 LogAudioGlitchResult(AUDIO_RENDERER_NO_AUDIO_GLITCHES); | 100 LogAudioGlitchResult(AUDIO_RENDERER_NO_AUDIO_GLITCHES); |
101 std::string log_string = | 101 std::string log_string = |
102 base::StringPrintf("ASR: number of detected audio glitches=%d", | 102 base::StringPrintf("ASR: number of detected audio glitches=%d", |
103 static_cast<int>(renderer_missed_callback_count_)); | 103 static_cast<int>(renderer_missed_callback_count_)); |
104 MediaStreamManager::SendMessageToNativeLog(log_string); | 104 MediaStreamManager::SendMessageToNativeLog(log_string); |
105 DVLOG(1) << log_string; | 105 DVLOG(1) << log_string; |
106 } | 106 } |
107 | 107 |
108 // media::AudioOutputController::SyncReader implementations. | 108 // media::AudioOutputController::SyncReader implementations. |
109 void AudioSyncReader::UpdatePendingBytes(uint32_t bytes, | 109 void AudioSyncReader::UpdatePendingBytes( |
110 uint32_t frames_skipped) { | 110 uint32_t bytes, |
| 111 uint32_t frames_skipped, |
| 112 const media::AudioTimestamp& output_timestamp) { |
111 // 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 |
112 // 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 |
113 // descheduled. The reading side will zero it when consumed. | 115 // descheduled. The reading side will zero it when consumed. |
114 AudioOutputBuffer* buffer = | 116 AudioOutputBuffer* buffer = |
115 reinterpret_cast<AudioOutputBuffer*>(shared_memory_->memory()); | 117 reinterpret_cast<AudioOutputBuffer*>(shared_memory_->memory()); |
116 buffer->params.frames_skipped += frames_skipped; | 118 buffer->params.frames_skipped += frames_skipped; |
117 | 119 |
118 // Zero out the entire output buffer to avoid stuttering/repeating-buffers | 120 // Zero out the entire output buffer to avoid stuttering/repeating-buffers |
119 // in the anomalous case if the renderer is unable to keep up with real-time. | 121 // in the anomalous case if the renderer is unable to keep up with real-time. |
120 output_bus_->Zero(); | 122 output_bus_->Zero(); |
121 | 123 |
122 socket_->Send(&bytes, sizeof(bytes)); | 124 socket_->Send(&bytes, sizeof(bytes)); |
| 125 socket_->Send(&output_timestamp, sizeof(output_timestamp)); |
123 ++buffer_index_; | 126 ++buffer_index_; |
124 } | 127 } |
125 | 128 |
126 void AudioSyncReader::Read(AudioBus* dest) { | 129 void AudioSyncReader::Read(AudioBus* dest) { |
127 ++renderer_callback_count_; | 130 ++renderer_callback_count_; |
128 if (!WaitUntilDataIsReady()) { | 131 if (!WaitUntilDataIsReady()) { |
129 ++trailing_renderer_missed_callback_count_; | 132 ++trailing_renderer_missed_callback_count_; |
130 ++renderer_missed_callback_count_; | 133 ++renderer_missed_callback_count_; |
131 if (renderer_missed_callback_count_ <= 100) { | 134 if (renderer_missed_callback_count_ <= 100) { |
132 LOG(WARNING) << "AudioSyncReader::Read timed out, audio glitch count=" | 135 LOG(WARNING) << "AudioSyncReader::Read timed out, audio glitch count=" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 base::TimeDelta::FromMilliseconds(1), | 212 base::TimeDelta::FromMilliseconds(1), |
210 base::TimeDelta::FromMilliseconds(1000), | 213 base::TimeDelta::FromMilliseconds(1000), |
211 50); | 214 50); |
212 return false; | 215 return false; |
213 } | 216 } |
214 | 217 |
215 return true; | 218 return true; |
216 } | 219 } |
217 | 220 |
218 } // namespace content | 221 } // namespace content |
OLD | NEW |