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

Unified Diff: media/base/audio_timestamp_helper.cc

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix Mac CQ errors. Created 4 years, 3 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/base/audio_timestamp_helper.cc
diff --git a/media/base/audio_timestamp_helper.cc b/media/base/audio_timestamp_helper.cc
index 8429a3eb81ea0eb4336b5ef550b4906101c60237..8694ae329a003aed933cccba44429941c7305457 100644
--- a/media/base/audio_timestamp_helper.cc
+++ b/media/base/audio_timestamp_helper.cc
@@ -9,6 +9,20 @@
namespace media {
+// static
+base::TimeDelta AudioTimestampHelper::FramesToTime(int64_t frames,
+ int samples_per_second) {
+ DCHECK_GE(samples_per_second, 0);
+ return base::TimeDelta::FromMicroseconds(
+ frames * base::Time::kMicrosecondsPerSecond / samples_per_second);
+}
+
+// static
+int64_t AudioTimestampHelper::TimeToFrames(base::TimeDelta time,
+ int samples_per_second) {
+ return time.InSecondsF() * samples_per_second;
+}
+
AudioTimestampHelper::AudioTimestampHelper(int samples_per_second)
: base_timestamp_(kNoTimestamp), frame_count_(0) {
DCHECK_GT(samples_per_second, 0);

Powered by Google App Engine
This is Rietveld 408576698