| 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 "media/audio/virtual_audio_output_stream.h" | 5 #include "media/audio/virtual_audio_output_stream.h" |
| 6 | 6 |
| 7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
| 8 #include "media/audio/virtual_audio_input_stream.h" | 8 #include "media/audio/virtual_audio_input_stream.h" |
| 9 | 9 |
| 10 namespace media { | 10 namespace media { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 void VirtualAudioOutputStream::GetVolume(double* volume) { | 67 void VirtualAudioOutputStream::GetVolume(double* volume) { |
| 68 DCHECK(message_loop_->BelongsToCurrentThread()); | 68 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 69 *volume = volume_; | 69 *volume = volume_; |
| 70 } | 70 } |
| 71 | 71 |
| 72 double VirtualAudioOutputStream::ProvideInput(AudioBus* audio_bus, | 72 double VirtualAudioOutputStream::ProvideInput(AudioBus* audio_bus, |
| 73 base::TimeDelta buffer_delay) { | 73 base::TimeDelta buffer_delay) { |
| 74 DCHECK(message_loop_->BelongsToCurrentThread()); | 74 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 75 DCHECK(callback_); | 75 DCHECK(callback_); |
| 76 | 76 |
| 77 // A VirtualAudioInputStream with a larger buffer size may be calling this | |
| 78 // multiple times without waiting, so we need to block and ensure the data is | |
| 79 // ready to prevent glitching. | |
| 80 callback_->WaitTillDataReady(); | |
| 81 const int frames = callback_->OnMoreData(audio_bus, AudioBuffersState()); | 77 const int frames = callback_->OnMoreData(audio_bus, AudioBuffersState()); |
| 82 if (frames < audio_bus->frames()) | 78 if (frames < audio_bus->frames()) |
| 83 audio_bus->ZeroFramesPartial(frames, audio_bus->frames() - frames); | 79 audio_bus->ZeroFramesPartial(frames, audio_bus->frames() - frames); |
| 84 | 80 |
| 85 return frames > 0 ? volume_ : 0; | 81 return frames > 0 ? volume_ : 0; |
| 86 } | 82 } |
| 87 | 83 |
| 88 } // namespace media | 84 } // namespace media |
| OLD | NEW |