Chromium Code Reviews| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "media/audio/virtual_audio_input_stream.h" | 10 #include "media/audio/virtual_audio_input_stream.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 DCHECK(thread_checker_.CalledOnValidThread()); | 67 DCHECK(thread_checker_.CalledOnValidThread()); |
| 68 volume_ = volume; | 68 volume_ = volume; |
| 69 } | 69 } |
| 70 | 70 |
| 71 void VirtualAudioOutputStream::GetVolume(double* volume) { | 71 void VirtualAudioOutputStream::GetVolume(double* volume) { |
| 72 DCHECK(thread_checker_.CalledOnValidThread()); | 72 DCHECK(thread_checker_.CalledOnValidThread()); |
| 73 *volume = volume_; | 73 *volume = volume_; |
| 74 } | 74 } |
| 75 | 75 |
| 76 double VirtualAudioOutputStream::ProvideInput(AudioBus* audio_bus, | 76 double VirtualAudioOutputStream::ProvideInput(AudioBus* audio_bus, |
| 77 base::TimeDelta buffer_delay) { | 77 uint32_t frames_delayed) { |
| 78 // Note: This method may be invoked on any one thread, depending on the | 78 // Note: This method may be invoked on any one thread, depending on the |
| 79 // platform. | 79 // platform. |
| 80 DCHECK(callback_); | 80 DCHECK(callback_); |
| 81 | 81 |
| 82 DCHECK_GE(buffer_delay, base::TimeDelta()); | 82 const uint32_t upstream_delay_in_bytes = |
| 83 const int64_t upstream_delay_in_bytes = params_.GetBytesPerSecond() * | 83 std::round(params_.GetBytesPerFrame() * frames_delayed); |
|
miu
2016/05/25 21:41:06
Doesn't seem that std::round() is required since t
chcunningham
2016/05/25 22:10:43
Done.
| |
| 84 buffer_delay / | 84 const int frames = |
| 85 base::TimeDelta::FromSeconds(1); | 85 callback_->OnMoreData(audio_bus, upstream_delay_in_bytes, 0); |
|
miu
2016/05/25 21:41:06
I can't wait for OnMoreData() to take |frames_dela
chcunningham
2016/05/25 22:10:43
Woot, me neither.
| |
| 86 const int frames = callback_->OnMoreData( | |
| 87 audio_bus, static_cast<uint32_t>(upstream_delay_in_bytes), 0); | |
| 88 if (frames < audio_bus->frames()) | 86 if (frames < audio_bus->frames()) |
| 89 audio_bus->ZeroFramesPartial(frames, audio_bus->frames() - frames); | 87 audio_bus->ZeroFramesPartial(frames, audio_bus->frames() - frames); |
| 90 | 88 |
| 91 return frames > 0 ? volume_ : 0; | 89 return frames > 0 ? volume_ : 0; |
| 92 } | 90 } |
| 93 | 91 |
| 94 } // namespace media | 92 } // namespace media |
| OLD | NEW |