Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: media/base/audio_renderer_mixer_input.cc

Issue 1687213002: Express audio delay more precisely in frames rather than milliseconds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698