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/file_util.h" | 7 #include "base/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 int total_bytes_delay) OVERRIDE { | 229 AudioBuffersState buffers_state) 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 |
235 delay_states_[output_elements_to_write_].output_delay_ms = | 244 delay_states_[output_elements_to_write_].output_delay_ms = |
236 BytesToMilliseconds(total_bytes_delay); | 245 BytesToMilliseconds(output_delay_bytes); |
237 ++output_elements_to_write_; | 246 ++output_elements_to_write_; |
238 } | 247 } |
239 | 248 |
240 int size; | 249 int size; |
241 const uint8* source; | 250 const uint8* source; |
242 // Read the data from the seekable media buffer which contains | 251 // Read the data from the seekable media buffer which contains |
243 // captured data at the same size and sample rate as the output side. | 252 // captured data at the same size and sample rate as the output side. |
244 if (buffer_->GetCurrentChunk(&source, &size) && size > 0) { | 253 if (buffer_->GetCurrentChunk(&source, &size) && size > 0) { |
245 EXPECT_EQ(channels_, audio_bus->channels()); | 254 EXPECT_EQ(channels_, audio_bus->channels()); |
246 size = std::min(audio_bus->frames() * frame_size_, size); | 255 size = std::min(audio_bus->frames() * frame_size_, size); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 446 |
438 // All Close() operations that run on the mocked audio thread, | 447 // All Close() operations that run on the mocked audio thread, |
439 // should be synchronous and not post additional close tasks to | 448 // should be synchronous and not post additional close tasks to |
440 // mocked the audio thread. Hence, there is no need to call | 449 // mocked the audio thread. Hence, there is no need to call |
441 // message_loop()->RunUntilIdle() after the Close() methods. | 450 // message_loop()->RunUntilIdle() after the Close() methods. |
442 aos->Close(); | 451 aos->Close(); |
443 ais->Close(); | 452 ais->Close(); |
444 } | 453 } |
445 | 454 |
446 } // namespace media | 455 } // namespace media |
OLD | NEW |