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

Unified Diff: content/renderer/media/webrtc_audio_renderer.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 | « content/renderer/media/webrtc_audio_renderer.h ('k') | media/audio/audio_device_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc_audio_renderer.cc
diff --git a/content/renderer/media/webrtc_audio_renderer.cc b/content/renderer/media/webrtc_audio_renderer.cc
index 49fc1857f83b3771212249d1dc3dec6efa067201..5f859c3754648c8f21b3a34c583da1e445717eea 100644
--- a/content/renderer/media/webrtc_audio_renderer.cc
+++ b/content/renderer/media/webrtc_audio_renderer.cc
@@ -423,13 +423,21 @@ media::OutputDeviceStatus WebRtcAudioRenderer::GetDeviceStatus() {
}
int WebRtcAudioRenderer::Render(media::AudioBus* audio_bus,
- uint32_t audio_delay_milliseconds,
+ uint32_t frames_delayed,
uint32_t frames_skipped) {
DCHECK(audio_renderer_thread_checker_.CalledOnValidThread());
base::AutoLock auto_lock(lock_);
if (!source_)
return 0;
+ // TODO(grunell): Converting from frames to milliseconds will potentially lose
+ // hundreds of microseconds which may cause audio video drift. Update
+ // this class and all usage of render delay msec -> frames (possibly even
+ // using a double type for frames). See http://crbug.com/586540
+ uint32_t audio_delay_milliseconds = static_cast<double>(frames_delayed) *
+ base::Time::kMillisecondsPerSecond /
+ sink_params_.sample_rate();
+
DVLOG(2) << "WebRtcAudioRenderer::Render()";
DVLOG(2) << "audio_delay_milliseconds: " << audio_delay_milliseconds;
@@ -481,6 +489,8 @@ void WebRtcAudioRenderer::SourceCallback(
<< audio_bus->frames() << ")";
int output_delay_milliseconds = audio_delay_milliseconds_;
+ // TODO(grunell): This integer division by sample_rate will cause loss of
+ // partial milliseconds, and may cause avsync drift. http://crbug.com/586540
output_delay_milliseconds += fifo_frame_delay *
base::Time::kMillisecondsPerSecond /
sink_params_.sample_rate();
« no previous file with comments | « content/renderer/media/webrtc_audio_renderer.h ('k') | media/audio/audio_device_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698