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

Unified Diff: media/audio/alsa/alsa_output.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/alsa/alsa_output.cc
diff --git a/media/audio/alsa/alsa_output.cc b/media/audio/alsa/alsa_output.cc
index 27ab0d1fd2002cd7d38ba86de355a1f8abd6f1f2..d3b2ccee873678e2ce5efaaee2785dc39affd1f8 100644
--- a/media/audio/alsa/alsa_output.cc
+++ b/media/audio/alsa/alsa_output.cc
@@ -125,7 +125,7 @@ std::ostream& operator<<(std::ostream& os,
case AlsaPcmOutputStream::kIsClosed:
os << "kIsClosed";
break;
- };
+ }
return os;
}
@@ -361,13 +361,14 @@ void AlsaPcmOutputStream::BufferPacket(bool* source_exhausted) {
// WritePacket() consumes only the current chunk of data.
if (!buffer_->forward_bytes()) {
// Before making a request to source for data we need to determine the
- // delay (in bytes) for the requested data to be played.
- const uint32_t hardware_delay = GetCurrentDelay() * bytes_per_frame_;
+ // time when the requested data will be played.
+ const base::TimeTicks target_playout_time =
+ base::TimeTicks::Now() +
+ FramesToTimeDelta(GetCurrentDelay(), sample_rate_);
scoped_refptr<media::DataBuffer> packet =
new media::DataBuffer(packet_size_);
- int frames_filled = RunDataCallback(
- audio_bus_.get(), hardware_delay);
+ int frames_filled = RunDataCallback(target_playout_time, audio_bus_.get());
size_t packet_size = frames_filled * bytes_per_frame_;
DCHECK_LE(packet_size, packet_size_);
@@ -777,12 +778,12 @@ AlsaPcmOutputStream::InternalState AlsaPcmOutputStream::state() {
return state_;
}
-int AlsaPcmOutputStream::RunDataCallback(AudioBus* audio_bus,
- uint32_t total_bytes_delay) {
+int AlsaPcmOutputStream::RunDataCallback(base::TimeTicks target_playout_time,
+ AudioBus* audio_bus) {
TRACE_EVENT0("audio", "AlsaPcmOutputStream::RunDataCallback");
if (source_callback_)
- return source_callback_->OnMoreData(audio_bus, total_bytes_delay, 0);
+ return source_callback_->OnMoreData(target_playout_time, 0, audio_bus);
return 0;
}

Powered by Google App Engine
This is Rietveld 408576698