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/base/audio_renderer_mixer_input.h" | 5 #include "media/base/audio_renderer_mixer_input.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "media/base/audio_renderer_mixer.h" | 9 #include "media/base/audio_renderer_mixer.h" |
10 | 10 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 | 158 |
159 OutputDeviceStatus AudioRendererMixerInput::GetDeviceStatus() { | 159 OutputDeviceStatus AudioRendererMixerInput::GetDeviceStatus() { |
160 if (!mixer_) | 160 if (!mixer_) |
161 return OUTPUT_DEVICE_STATUS_ERROR_INTERNAL; | 161 return OUTPUT_DEVICE_STATUS_ERROR_INTERNAL; |
162 | 162 |
163 return mixer_->GetOutputDevice()->GetDeviceStatus(); | 163 return mixer_->GetOutputDevice()->GetDeviceStatus(); |
164 } | 164 } |
165 | 165 |
166 double AudioRendererMixerInput::ProvideInput(AudioBus* audio_bus, | 166 double AudioRendererMixerInput::ProvideInput(AudioBus* audio_bus, |
167 base::TimeDelta buffer_delay) { | 167 base::TimeDelta buffer_delay) { |
168 int frames_filled = callback_->Render( | 168 double microseconds_per_frame = |
DaleCurtis
2016/02/11 01:57:16
Ditto on the TODO.
chcunningham
2016/02/11 21:02:52
Done.
| |
169 audio_bus, static_cast<int>(buffer_delay.InMillisecondsF() + 0.5), 0); | 169 static_cast<double>(base::Time::kMicrosecondsPerSecond) / |
170 params_.sample_rate(); | |
171 uint32_t frames_delayed = | |
172 std::round(buffer_delay.InMicroseconds() / microseconds_per_frame); | |
173 | |
174 int frames_filled = callback_->Render(audio_bus, frames_delayed, 0); | |
170 | 175 |
171 // AudioConverter expects unfilled frames to be zeroed. | 176 // AudioConverter expects unfilled frames to be zeroed. |
172 if (frames_filled < audio_bus->frames()) { | 177 if (frames_filled < audio_bus->frames()) { |
173 audio_bus->ZeroFramesPartial( | 178 audio_bus->ZeroFramesPartial( |
174 frames_filled, audio_bus->frames() - frames_filled); | 179 frames_filled, audio_bus->frames() - frames_filled); |
175 } | 180 } |
176 | 181 |
177 return frames_filled > 0 ? volume_ : 0; | 182 return frames_filled > 0 ? volume_ : 0; |
178 } | 183 } |
179 | 184 |
180 void AudioRendererMixerInput::OnRenderError() { | 185 void AudioRendererMixerInput::OnRenderError() { |
181 callback_->OnRenderError(); | 186 callback_->OnRenderError(); |
182 } | 187 } |
183 | 188 |
184 } // namespace media | 189 } // namespace media |
OLD | NEW |