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 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 maximum_wait_time_(base::TimeDelta::FromMilliseconds(20)), | 67 maximum_wait_time_(base::TimeDelta::FromMilliseconds(20)), |
68 #endif | 68 #endif |
69 buffer_index_(0) { | 69 buffer_index_(0) { |
70 DCHECK_EQ(static_cast<size_t>(packet_size_), | 70 DCHECK_EQ(static_cast<size_t>(packet_size_), |
71 sizeof(media::AudioOutputBufferParameters) + | 71 sizeof(media::AudioOutputBufferParameters) + |
72 AudioBus::CalculateMemorySize(params)); | 72 AudioBus::CalculateMemorySize(params)); |
73 AudioOutputBuffer* buffer = | 73 AudioOutputBuffer* buffer = |
74 reinterpret_cast<AudioOutputBuffer*>(shared_memory_->memory()); | 74 reinterpret_cast<AudioOutputBuffer*>(shared_memory_->memory()); |
75 output_bus_ = AudioBus::WrapMemory(params, buffer->audio); | 75 output_bus_ = AudioBus::WrapMemory(params, buffer->audio); |
76 output_bus_->Zero(); | 76 output_bus_->Zero(); |
77 output_bus_->set_is_bitstream_format(params.IsBitstreamFormat()); | |
77 } | 78 } |
78 | 79 |
79 AudioSyncReader::~AudioSyncReader() { | 80 AudioSyncReader::~AudioSyncReader() { |
80 if (!renderer_callback_count_) | 81 if (!renderer_callback_count_) |
81 return; | 82 return; |
82 | 83 |
83 DVLOG(1) << "Trailing glitch count on destruction: " | 84 DVLOG(1) << "Trailing glitch count on destruction: " |
84 << trailing_renderer_missed_callback_count_; | 85 << trailing_renderer_missed_callback_count_; |
85 | 86 |
86 // Subtract 'trailing' count of callbacks missed just before the destructor | 87 // Subtract 'trailing' count of callbacks missed just before the destructor |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 << renderer_missed_callback_count_; | 204 << renderer_missed_callback_count_; |
204 if (renderer_missed_callback_count_ == 100) | 205 if (renderer_missed_callback_count_ == 100) |
205 LOG(WARNING) << "(log cap reached, suppressing further logs)"; | 206 LOG(WARNING) << "(log cap reached, suppressing further logs)"; |
206 } | 207 } |
207 dest->Zero(); | 208 dest->Zero(); |
208 return; | 209 return; |
209 } | 210 } |
210 | 211 |
211 trailing_renderer_missed_callback_count_ = 0; | 212 trailing_renderer_missed_callback_count_ = 0; |
212 | 213 |
213 if (mute_audio_) | 214 if (mute_audio_) |
DaleCurtis
2017/06/15 21:46:31
Just return instead of having else block.
AndyWu
2017/08/02 01:43:38
Done.
| |
214 dest->Zero(); | 215 dest->Zero(); |
215 else | 216 else { |
217 if (output_bus_->is_bitstream_format()) { | |
218 AudioOutputBuffer* buffer = | |
219 reinterpret_cast<AudioOutputBuffer*>(shared_memory_->memory()); | |
220 output_bus_->set_frames(buffer->params.frames); | |
221 output_bus_->set_data_size(buffer->params.data_size); | |
222 } | |
216 output_bus_->CopyTo(dest); | 223 output_bus_->CopyTo(dest); |
224 } | |
217 } | 225 } |
218 | 226 |
219 void AudioSyncReader::Close() { | 227 void AudioSyncReader::Close() { |
220 socket_->Close(); | 228 socket_->Close(); |
221 } | 229 } |
222 | 230 |
223 bool AudioSyncReader::WaitUntilDataIsReady() { | 231 bool AudioSyncReader::WaitUntilDataIsReady() { |
224 TRACE_EVENT0("audio", "AudioSyncReader::WaitUntilDataIsReady"); | 232 TRACE_EVENT0("audio", "AudioSyncReader::WaitUntilDataIsReady"); |
225 base::TimeDelta timeout = maximum_wait_time_; | 233 base::TimeDelta timeout = maximum_wait_time_; |
226 const base::TimeTicks start_time = base::TimeTicks::Now(); | 234 const base::TimeTicks start_time = base::TimeTicks::Now(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 base::TimeDelta::FromMilliseconds(1), | 276 base::TimeDelta::FromMilliseconds(1), |
269 base::TimeDelta::FromMilliseconds(1000), | 277 base::TimeDelta::FromMilliseconds(1000), |
270 50); | 278 50); |
271 return false; | 279 return false; |
272 } | 280 } |
273 | 281 |
274 return true; | 282 return true; |
275 } | 283 } |
276 | 284 |
277 } // namespace content | 285 } // namespace content |
OLD | NEW |