Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_FILTERS_BUFFERED_AUDIO_TRACKER_H_ | |
| 6 #define MEDIA_FILTERS_BUFFERED_AUDIO_TRACKER_H_ | |
| 7 | |
| 8 #include <deque> | |
| 9 | |
| 10 #include "base/time/time.h" | |
| 11 #include "media/base/media_export.h" | |
| 12 | |
| 13 namespace media { | |
| 14 | |
| 15 // Models a queue of buffered audio in a playback pipeline for use with | |
| 16 // estimating the amount of delay in wall clock time. Takes changes in playback | |
| 17 // rate into account to handle scenarios where multiple rates may be present in | |
| 18 // a playback pipelines with large delay. | |
| 19 class MEDIA_EXPORT BufferedAudioTracker { | |
| 20 public: | |
| 21 explicit BufferedAudioTracker(int sample_rate); | |
| 22 ~BufferedAudioTracker(); | |
| 23 | |
| 24 // Called each time an audio callback is fired. Excess buffered frames will be | |
| 25 // trimmed until the amount buffered is <= |delay_frames|. | |
| 26 void AudioCallbackFired(int delay_frames); | |
| 27 | |
| 28 // |frames| amount of audio data at |playback_rate| was written. | |
| 29 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(
| |
| 30 | |
| 31 // |frames| amount of silence was written. | |
| 32 void WroteSilence(int frames); | |
| 33 | |
| 34 // Returns the amount of wall time currently buffered. | |
| 35 base::TimeDelta BufferedTime() const; | |
| 36 | |
| 37 private: | |
| 38 int sample_rate_; | |
| 39 | |
| 40 struct BufferedAudio { | |
| 41 BufferedAudio(int frames, float playback_rate); | |
| 42 | |
| 43 int frames; | |
| 44 float playback_rate; | |
| 45 }; | |
| 46 | |
| 47 std::deque<BufferedAudio> buffered_audio_; | |
| 48 | |
| 49 DISALLOW_COPY_AND_ASSIGN(BufferedAudioTracker); | |
| 50 }; | |
| 51 | |
| 52 } // namespace media | |
| 53 | |
| 54 #endif // MEDIA_FILTERS_BUFFERED_AUDIO_TRACKER_H_ | |
| OLD | NEW |