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

Unified Diff: media/filters/buffered_audio_tracker.h

Issue 256163005: Introduce AudioClock to improve playback delay calculations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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/filters/buffered_audio_tracker.h
diff --git a/media/filters/buffered_audio_tracker.h b/media/filters/buffered_audio_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..230b81b1b591e1cb3c28daf2d37ea985c73c3a85
--- /dev/null
+++ b/media/filters/buffered_audio_tracker.h
@@ -0,0 +1,54 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_FILTERS_BUFFERED_AUDIO_TRACKER_H_
+#define MEDIA_FILTERS_BUFFERED_AUDIO_TRACKER_H_
+
+#include <deque>
+
+#include "base/time/time.h"
+#include "media/base/media_export.h"
+
+namespace media {
+
+// Models a queue of buffered audio in a playback pipeline for use with
+// estimating the amount of delay in wall clock time. Takes changes in playback
+// rate into account to handle scenarios where multiple rates may be present in
+// a playback pipelines with large delay.
+class MEDIA_EXPORT BufferedAudioTracker {
+ public:
+ explicit BufferedAudioTracker(int sample_rate);
+ ~BufferedAudioTracker();
+
+ // Called each time an audio callback is fired. Excess buffered frames will be
+ // trimmed until the amount buffered is <= |delay_frames|.
+ void AudioCallbackFired(int delay_frames);
+
+ // |frames| amount of audio data at |playback_rate| was written.
+ void WroteAudio(int frames, float playback_rate);
scherkus (not reviewing) 2014/04/29 17:22:06 I need to think about it some more ... but an alte
DaleCurtis 2014/04/29 17:55:54 I like the idea of a single function API. Can't y
scherkus (not reviewing) 2014/04/29 18:19:03 yeah I played around with that .. the key thing is
DaleCurtis 2014/04/29 18:31:01 Ah, that's a bit awkward then. Merging the Wrote(
+
+ // |frames| amount of silence was written.
+ void WroteSilence(int frames);
+
+ // Returns the amount of wall time currently buffered.
+ base::TimeDelta BufferedTime() const;
+
+ private:
+ int sample_rate_;
+
+ struct BufferedAudio {
+ BufferedAudio(int frames, float playback_rate);
+
+ int frames;
+ float playback_rate;
+ };
+
+ std::deque<BufferedAudio> buffered_audio_;
+
+ DISALLOW_COPY_AND_ASSIGN(BufferedAudioTracker);
+};
+
+} // namespace media
+
+#endif // MEDIA_FILTERS_BUFFERED_AUDIO_TRACKER_H_

Powered by Google App Engine
This is Rietveld 408576698