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

Unified Diff: media/audio/audio_output_stream_sink.cc

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Pass target playout time to AudioSourceCallback::OnMoreData. Created 4 years, 5 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
Index: media/audio/audio_output_stream_sink.cc
diff --git a/media/audio/audio_output_stream_sink.cc b/media/audio/audio_output_stream_sink.cc
index b94e2d265847d33f2a93cab9dc3e8a90a7cbd140..d06c215807a7ce300db77467c5ac1a5ec871641f 100644
--- a/media/audio/audio_output_stream_sink.cc
+++ b/media/audio/audio_output_stream_sink.cc
@@ -82,18 +82,19 @@ bool AudioOutputStreamSink::CurrentThreadIsRenderingThread() {
return false;
}
-int AudioOutputStreamSink::OnMoreData(AudioBus* dest,
- uint32_t total_bytes_delay,
- uint32_t frames_skipped) {
+int AudioOutputStreamSink::OnMoreData(base::TimeTicks target_playout_time,
+ int prior_frames_skipped,
+ AudioBus* dest) {
// Note: Runs on the audio thread created by the OS.
base::AutoLock al(callback_lock_);
if (!active_render_callback_)
return 0;
- uint32_t frames_delayed = std::round(static_cast<double>(total_bytes_delay) /
- active_params_.GetBytesPerFrame());
+ base::TimeDelta delay = target_playout_time - base::TimeTicks::Now();
+ uint32_t frames_delayed = delay.InSeconds() * active_params_.sample_rate();
- return active_render_callback_->Render(dest, frames_delayed, frames_skipped);
+ return active_render_callback_->Render(dest, frames_delayed,
+ prior_frames_skipped);
}
void AudioOutputStreamSink::OnError(AudioOutputStream* stream) {
@@ -154,4 +155,4 @@ void AudioOutputStreamSink::ClearCallback() {
active_render_callback_ = NULL;
}
-} // namepace media
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698