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

Unified Diff: media/audio/audio_output_controller.cc

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Changes based on comments Created 4 years, 4 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_controller.cc
diff --git a/media/audio/audio_output_controller.cc b/media/audio/audio_output_controller.cc
index 9b8f52387d8e7a4f638d73c7d1127ae2a2f394e2..3fe8db0ea6c299e35f5b25c2b4d44d1b8b5ec2f4 100644
--- a/media/audio/audio_output_controller.cc
+++ b/media/audio/audio_output_controller.cc
@@ -6,6 +6,7 @@
#include <stdint.h>
+#include <algorithm>
#include <limits>
#include "base/bind.h"
@@ -292,9 +293,9 @@ void AudioOutputController::DoReportError() {
handler_->OnError();
}
-int AudioOutputController::OnMoreData(AudioBus* dest,
- uint32_t total_bytes_delay,
- uint32_t frames_skipped) {
+int AudioOutputController::OnMoreData(base::TimeTicks target_playout_time,
+ int prior_frames_skipped,
+ AudioBus* dest) {
TRACE_EVENT0("audio", "AudioOutputController::OnMoreData");
// Indicate that we haven't wedged (at least not indefinitely, WedgeCheck()
@@ -306,9 +307,13 @@ int AudioOutputController::OnMoreData(AudioBus* dest,
sync_reader_->Read(dest);
+ const base::TimeDelta delay =
chcunningham 2016/08/27 00:36:18 Can you add a comment explaining why this guard is
miu 2016/08/31 23:26:54 Looks like this API change should propagate throug
jameswest 2016/09/07 21:52:16 When the number of bytes is passed to UpdatePendin
miu 2016/09/07 22:19:36 The consumer is media::AudioDeviceThread: https://
James West 2016/09/13 07:40:50 I'm happy to do this, but I think it should be a s
miu 2016/09/16 18:35:58 SGTM.
+ std::max(target_playout_time - base::TimeTicks::Now(), base::TimeDelta());
+ const int total_bytes_delay = delay.InSeconds() * params_.GetBytesPerSecond();
miu 2016/08/31 23:26:54 s/InSeconds/InSecondsF/ to prevent serious loss of
James West 2016/09/13 07:40:50 Done.
const int frames = dest->frames();
sync_reader_->UpdatePendingBytes(
- total_bytes_delay + frames * params_.GetBytesPerFrame(), frames_skipped);
+ total_bytes_delay + frames * params_.GetBytesPerFrame(),
+ prior_frames_skipped);
bool need_to_duplicate = false;
{
@@ -316,17 +321,12 @@ int AudioOutputController::OnMoreData(AudioBus* dest,
need_to_duplicate = !duplication_targets_.empty();
}
if (need_to_duplicate) {
- const base::TimeTicks reference_time =
- base::TimeTicks::Now() +
- base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond *
- total_bytes_delay /
- params_.GetBytesPerSecond());
std::unique_ptr<AudioBus> copy(AudioBus::Create(params_));
dest->CopyTo(copy.get());
message_loop_->PostTask(
FROM_HERE,
base::Bind(&AudioOutputController::BroadcastDataToDuplicationTargets,
- this, base::Passed(&copy), reference_time));
+ this, base::Passed(&copy), target_playout_time));
}
if (will_monitor_audio_levels())

Powered by Google App Engine
This is Rietveld 408576698