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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/environment.h" | 6 #include "base/environment.h" |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // enough to handle the current sample test scenario. | 219 // enough to handle the current sample test scenario. |
220 // buffer_->set_forward_capacity(2 * buffer_->forward_capacity()); | 220 // buffer_->set_forward_capacity(2 * buffer_->forward_capacity()); |
221 // buffer_->Clear(); | 221 // buffer_->Clear(); |
222 // } | 222 // } |
223 } | 223 } |
224 | 224 |
225 virtual void OnError(AudioInputStream* stream) OVERRIDE {} | 225 virtual void OnError(AudioInputStream* stream) OVERRIDE {} |
226 | 226 |
227 // AudioOutputStream::AudioSourceCallback. | 227 // AudioOutputStream::AudioSourceCallback. |
228 virtual int OnMoreData(AudioBus* audio_bus, | 228 virtual int OnMoreData(AudioBus* audio_bus, |
229 AudioBuffersState buffers_state) OVERRIDE { | 229 uint32 total_bytes_delay) OVERRIDE { |
230 base::AutoLock lock(lock_); | 230 base::AutoLock lock(lock_); |
231 | 231 |
232 // Update one component in the AudioDelayState for the packet | 232 // Update one component in the AudioDelayState for the packet |
233 // which is about to be played out. | 233 // which is about to be played out. |
234 if (output_elements_to_write_ < kMaxDelayMeasurements) { | 234 if (output_elements_to_write_ < kMaxDelayMeasurements) { |
235 int output_delay_bytes = buffers_state.hardware_delay_bytes; | |
236 #if defined(OS_WIN) | |
237 // Special fix for Windows in combination with Wave where the | |
238 // pending bytes field of the audio buffer state is used to | |
239 // report the delay. | |
240 if (!CoreAudioUtil::IsSupported()) { | |
241 output_delay_bytes = buffers_state.pending_bytes; | |
242 } | |
243 #endif | |
244 delay_states_[output_elements_to_write_].output_delay_ms = | 235 delay_states_[output_elements_to_write_].output_delay_ms = |
245 BytesToMilliseconds(output_delay_bytes); | 236 BytesToMilliseconds(total_bytes_delay); |
246 ++output_elements_to_write_; | 237 ++output_elements_to_write_; |
247 } | 238 } |
248 | 239 |
249 int size; | 240 int size; |
250 const uint8* source; | 241 const uint8* source; |
251 // Read the data from the seekable media buffer which contains | 242 // Read the data from the seekable media buffer which contains |
252 // captured data at the same size and sample rate as the output side. | 243 // captured data at the same size and sample rate as the output side. |
253 if (buffer_->GetCurrentChunk(&source, &size) && size > 0) { | 244 if (buffer_->GetCurrentChunk(&source, &size) && size > 0) { |
254 EXPECT_EQ(channels_, audio_bus->channels()); | 245 EXPECT_EQ(channels_, audio_bus->channels()); |
255 size = std::min(audio_bus->frames() * frame_size_, size); | 246 size = std::min(audio_bus->frames() * frame_size_, size); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 437 |
447 // All Close() operations that run on the mocked audio thread, | 438 // All Close() operations that run on the mocked audio thread, |
448 // should be synchronous and not post additional close tasks to | 439 // should be synchronous and not post additional close tasks to |
449 // mocked the audio thread. Hence, there is no need to call | 440 // mocked the audio thread. Hence, there is no need to call |
450 // message_loop()->RunUntilIdle() after the Close() methods. | 441 // message_loop()->RunUntilIdle() after the Close() methods. |
451 aos->Close(); | 442 aos->Close(); |
452 ais->Close(); | 443 ais->Close(); |
453 } | 444 } |
454 | 445 |
455 } // namespace media | 446 } // namespace media |
OLD | NEW |