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

Unified Diff: media/audio/audio_output_device.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/audio/audio_input_device.cc ('k') | media/audio/audio_output_stream_sink.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_output_device.cc
diff --git a/media/audio/audio_output_device.cc b/media/audio/audio_output_device.cc
index 3af32b7835f8f1f8a23c98b0a0a16f7fa4deb31c..7044e9ae770649c0477b9b37af56eca6fff01abb 100644
--- a/media/audio/audio_output_device.cc
+++ b/media/audio/audio_output_device.cc
@@ -6,6 +6,8 @@
#include <stddef.h>
#include <stdint.h>
+
+#include <cmath>
#include <utility>
#include "base/callback_helpers.h"
@@ -413,8 +415,8 @@ void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() {
// Called whenever we receive notifications about pending data.
void AudioOutputDevice::AudioThreadCallback::Process(uint32_t pending_data) {
- // Convert the number of pending bytes in the render buffer into milliseconds.
- uint32_t audio_delay_milliseconds = pending_data / bytes_per_ms_;
+ // Convert the number of pending bytes in the render buffer into frames.
+ double frames_delayed = static_cast<double>(pending_data) / bytes_per_frame_;
callback_num_++;
TRACE_EVENT1("audio", "AudioOutputDevice::FireRenderCallback",
@@ -433,11 +435,15 @@ void AudioOutputDevice::AudioThreadCallback::Process(uint32_t pending_data) {
uint32_t frames_skipped = buffer->params.frames_skipped;
buffer->params.frames_skipped = 0;
+ DVLOG(4) << __FUNCTION__ << " pending_data:" << pending_data
+ << " frames_delayed(pre-round):" << frames_delayed
+ << " frames_skipped:" << frames_skipped;
+
// Update the audio-delay measurement, inform about the number of skipped
// frames, and ask client to render audio. Since |output_bus_| is wrapping
// the shared memory the Render() call is writing directly into the shared
// memory.
- render_callback_->Render(output_bus_.get(), audio_delay_milliseconds,
+ render_callback_->Render(output_bus_.get(), std::round(frames_delayed),
frames_skipped);
}
« no previous file with comments | « media/audio/audio_input_device.cc ('k') | media/audio/audio_output_stream_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698