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 "base/time/time.h" |
10 #include "media/audio/virtual_audio_input_stream.h" | 11 #include "media/audio/virtual_audio_input_stream.h" |
11 | 12 |
12 namespace media { | 13 namespace media { |
13 | 14 |
14 VirtualAudioOutputStream::VirtualAudioOutputStream( | 15 VirtualAudioOutputStream::VirtualAudioOutputStream( |
15 const AudioParameters& params, VirtualAudioInputStream* target, | 16 const AudioParameters& params, VirtualAudioInputStream* target, |
16 const AfterCloseCallback& after_close_cb) | 17 const AfterCloseCallback& after_close_cb) |
17 : params_(params), target_input_stream_(target), | 18 : params_(params), target_input_stream_(target), |
18 after_close_cb_(after_close_cb), callback_(NULL), volume_(1.0f) { | 19 after_close_cb_(after_close_cb), callback_(NULL), volume_(1.0f) { |
19 DCHECK(params_.IsValid()); | 20 DCHECK(params_.IsValid()); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 75 } |
75 | 76 |
76 double VirtualAudioOutputStream::ProvideInput(AudioBus* audio_bus, | 77 double VirtualAudioOutputStream::ProvideInput(AudioBus* audio_bus, |
77 uint32_t frames_delayed) { | 78 uint32_t frames_delayed) { |
78 // Note: This method may be invoked on any one thread, depending on the | 79 // Note: This method may be invoked on any one thread, depending on the |
79 // platform. | 80 // platform. |
80 DCHECK(callback_); | 81 DCHECK(callback_); |
81 | 82 |
82 const uint32_t upstream_delay_in_bytes = | 83 const uint32_t upstream_delay_in_bytes = |
83 params_.GetBytesPerFrame() * frames_delayed; | 84 params_.GetBytesPerFrame() * frames_delayed; |
84 const int frames = | 85 const int frames = callback_->OnMoreData(audio_bus, upstream_delay_in_bytes, |
85 callback_->OnMoreData(audio_bus, upstream_delay_in_bytes, 0); | 86 base::TimeDelta(), 0); |
86 if (frames < audio_bus->frames()) | 87 if (frames < audio_bus->frames()) |
87 audio_bus->ZeroFramesPartial(frames, audio_bus->frames() - frames); | 88 audio_bus->ZeroFramesPartial(frames, audio_bus->frames() - frames); |
88 | 89 |
89 return frames > 0 ? volume_ : 0; | 90 return frames > 0 ? volume_ : 0; |
90 } | 91 } |
91 | 92 |
92 } // namespace media | 93 } // namespace media |
OLD | NEW |