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

Side by Side Diff: media/filters/audio_clock.h

Issue 256163005: Introduce AudioClock to improve playback delay calculations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: AudioClock Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/filters/audio_clock.cc » ('j') | media/filters/audio_clock.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_AUDIO_CLOCK_H_
6 #define MEDIA_FILTERS_AUDIO_CLOCK_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 pipeline with large delay.
19 class MEDIA_EXPORT AudioClock {
20 public:
21 explicit AudioClock(int sample_rate);
22 ~AudioClock();
23
24 // |frames| amount of audio data scaled to |playback_rate| was written.
25 // |delay_frames| is the current amount of hardware delay.
26 // |timestamp| is the endpoint media timestamp of the audio data written.
27 void WroteAudio(int frames,
28 int delay_frames,
29 float playback_rate,
30 base::TimeDelta timestamp);
31
32 // |frames| amount of silence was written.
33 // |delay_frames| is the current amount of hardware delay.
34 void WroteSilence(int frames, int delay_frames);
scherkus (not reviewing) 2014/04/30 19:13:58 went with two separate APIs as it started to look
35
36 // Calculates the current media timestamp taking silence and changes in
37 // playback rate into account.
38 base::TimeDelta CurrentMediaTimestamp() const;
39
40 // Returns the last endpoint timestamp provided to WroteAudio().
41 base::TimeDelta LastEndpointTimestamp() const;
42
43 private:
44 void TrimBufferedAudioToMatchDelay(int delay_frames);
45 void PushBufferedAudio(int frames,
46 float playback_rate,
47 base::TimeDelta endpoint_timestamp);
48
49 int sample_rate_;
DaleCurtis 2014/04/30 20:36:33 const
scherkus (not reviewing) 2014/05/02 19:26:05 Done.
50
51 // Initially set to kNoTimestamp(), otherwise is the last endpoint timestamp
52 // delivered to WroteAudio(). A copy is kept outside of |buffered_audio_| to
53 // handle the case where all of |buffered_audio_| has been replaced with
54 // silence.
55 base::TimeDelta last_endpoint_timestamp_;
56
57 struct BufferedAudio {
58 BufferedAudio(int frames,
59 float playback_rate,
60 base::TimeDelta endpoint_timestamp);
61
62 int frames;
63 float playback_rate;
DaleCurtis 2014/04/30 20:36:33 Looks like this could be const?
scherkus (not reviewing) 2014/05/02 19:26:05 adding const interferes with the implicit copy ope
64 base::TimeDelta endpoint_timestamp;
65 };
66
67 std::deque<BufferedAudio> buffered_audio_;
68
69 DISALLOW_COPY_AND_ASSIGN(AudioClock);
70 };
71
72 } // namespace media
73
74 #endif // MEDIA_FILTERS_AUDIO_CLOCK_H_
OLDNEW
« no previous file with comments | « no previous file | media/filters/audio_clock.cc » ('j') | media/filters/audio_clock.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698