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

Unified 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: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/audio_renderer_mixer.cc ('k') | media/base/audio_renderer_sink.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_renderer_mixer_input.cc
diff --git a/media/base/audio_renderer_mixer_input.cc b/media/base/audio_renderer_mixer_input.cc
index d0d38d3b8eef902f69b9a342cdaffcbe0109235b..7c6ba2635802f89390220daa2235f43881b348d7 100644
--- a/media/base/audio_renderer_mixer_input.cc
+++ b/media/base/audio_renderer_mixer_input.cc
@@ -4,6 +4,8 @@
#include "media/base/audio_renderer_mixer_input.h"
+#include <cmath>
+
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "media/base/audio_renderer_mixer.h"
@@ -165,8 +167,13 @@ OutputDeviceStatus AudioRendererMixerInput::GetDeviceStatus() {
double AudioRendererMixerInput::ProvideInput(AudioBus* audio_bus,
base::TimeDelta buffer_delay) {
- int frames_filled = callback_->Render(
- audio_bus, static_cast<int>(buffer_delay.InMillisecondsF() + 0.5), 0);
+ // TODO(chcunningham): Delete this conversion and change ProvideInput to more
+ // precisely describe delay as a count of frames delayed instead of TimeDelta.
+ // See http://crbug.com/587522.
+ uint32_t frames_delayed = std::round(buffer_delay.InMicroseconds() /
+ params_.GetMicrosecondsPerFrame());
+
+ int frames_filled = callback_->Render(audio_bus, frames_delayed, 0);
// AudioConverter expects unfilled frames to be zeroed.
if (frames_filled < audio_bus->frames()) {
« no previous file with comments | « media/base/audio_renderer_mixer.cc ('k') | media/base/audio_renderer_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698