| 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/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 if (!buffer_->Append(src, size)) { | 202 if (!buffer_->Append(src, size)) { |
| 203 // An attempt to write outside the buffer limits has been made. | 203 // An attempt to write outside the buffer limits has been made. |
| 204 // Double the buffer capacity to ensure that we have a buffer large | 204 // Double the buffer capacity to ensure that we have a buffer large |
| 205 // enough to handle the current sample test scenario. | 205 // enough to handle the current sample test scenario. |
| 206 buffer_->set_forward_capacity(2 * buffer_->forward_capacity()); | 206 buffer_->set_forward_capacity(2 * buffer_->forward_capacity()); |
| 207 buffer_->Clear(); | 207 buffer_->Clear(); |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 virtual void OnClose(AudioInputStream* stream) OVERRIDE {} | 211 virtual void OnClose(AudioInputStream* stream) OVERRIDE {} |
| 212 virtual void OnError(AudioInputStream* stream, int code) OVERRIDE {} | 212 virtual void OnError(AudioInputStream* stream) OVERRIDE {} |
| 213 | 213 |
| 214 // AudioOutputStream::AudioSourceCallback. | 214 // AudioOutputStream::AudioSourceCallback. |
| 215 virtual int OnMoreData(AudioBus* audio_bus, | 215 virtual int OnMoreData(AudioBus* audio_bus, |
| 216 AudioBuffersState buffers_state) OVERRIDE { | 216 AudioBuffersState buffers_state) OVERRIDE { |
| 217 base::AutoLock lock(lock_); | 217 base::AutoLock lock(lock_); |
| 218 | 218 |
| 219 // Update one component in the AudioDelayState for the packet | 219 // Update one component in the AudioDelayState for the packet |
| 220 // which is about to be played out. | 220 // which is about to be played out. |
| 221 if (output_elements_to_write_ < kMaxDelayMeasurements) { | 221 if (output_elements_to_write_ < kMaxDelayMeasurements) { |
| 222 int output_delay_bytes = buffers_state.hardware_delay_bytes; | 222 int output_delay_bytes = buffers_state.hardware_delay_bytes; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 250 return 0; | 250 return 0; |
| 251 } | 251 } |
| 252 | 252 |
| 253 virtual int OnMoreIOData(AudioBus* source, | 253 virtual int OnMoreIOData(AudioBus* source, |
| 254 AudioBus* dest, | 254 AudioBus* dest, |
| 255 AudioBuffersState buffers_state) OVERRIDE { | 255 AudioBuffersState buffers_state) OVERRIDE { |
| 256 NOTREACHED(); | 256 NOTREACHED(); |
| 257 return 0; | 257 return 0; |
| 258 } | 258 } |
| 259 | 259 |
| 260 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE {} | 260 virtual void OnError(AudioOutputStream* stream) OVERRIDE {} |
| 261 virtual void WaitTillDataReady() OVERRIDE {} | 261 virtual void WaitTillDataReady() OVERRIDE {} |
| 262 | 262 |
| 263 protected: | 263 protected: |
| 264 // Converts from bytes to milliseconds taking the sample rate and size | 264 // Converts from bytes to milliseconds taking the sample rate and size |
| 265 // of an audio frame into account. | 265 // of an audio frame into account. |
| 266 int BytesToMilliseconds(uint32 delay_bytes) const { | 266 int BytesToMilliseconds(uint32 delay_bytes) const { |
| 267 return static_cast<int>((delay_bytes / frame_size_) * frames_to_ms_ + 0.5); | 267 return static_cast<int>((delay_bytes / frame_size_) * frames_to_ms_ + 0.5); |
| 268 } | 268 } |
| 269 | 269 |
| 270 private: | 270 private: |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 | 441 |
| 442 // All Close() operations that run on the mocked audio thread, | 442 // All Close() operations that run on the mocked audio thread, |
| 443 // should be synchronous and not post additional close tasks to | 443 // should be synchronous and not post additional close tasks to |
| 444 // mocked the audio thread. Hence, there is no need to call | 444 // mocked the audio thread. Hence, there is no need to call |
| 445 // message_loop()->RunUntilIdle() after the Close() methods. | 445 // message_loop()->RunUntilIdle() after the Close() methods. |
| 446 aos->Close(); | 446 aos->Close(); |
| 447 ais->Close(); | 447 ais->Close(); |
| 448 } | 448 } |
| 449 | 449 |
| 450 } // namespace media | 450 } // namespace media |
| OLD | NEW |