OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // AudioRendererBase takes care of the tricky queuing work and provides simple | 5 // AudioRendererBase takes care of the tricky queuing work and provides simple |
6 // methods for subclasses to peek and poke at audio data. In addition to | 6 // methods for subclasses to peek and poke at audio data. In addition to |
7 // AudioRenderer interface methods this classes doesn't implement, subclasses | 7 // AudioRenderer interface methods this classes doesn't implement, subclasses |
8 // must also implement the following methods: | 8 // must also implement the following methods: |
9 // OnInitialized | 9 // OnInitialized |
10 // OnStop | 10 // OnStop |
11 // OnRenderEndOfStream | 11 // OnRenderEndOfStream |
12 // | 12 // |
13 // The general assumption is that subclasses start a callback-based audio thread | 13 // The general assumption is that subclasses start a callback-based audio thread |
14 // which needs to be filled with decoded audio data. AudioDecoderBase provides | 14 // which needs to be filled with decoded audio data. AudioDecoderBase provides |
15 // FillBuffer which handles filling the provided buffer, dequeuing items, | 15 // FillBuffer which handles filling the provided buffer, dequeuing items, |
16 // scheduling additional reads and updating the clock. In a sense, | 16 // scheduling additional reads and updating the clock. In a sense, |
17 // AudioRendererBase is the producer and the subclass is the consumer. | 17 // AudioRendererBase is the producer and the subclass is the consumer. |
18 | 18 |
19 #ifndef MEDIA_FILTERS_AUDIO_RENDERER_BASE_H_ | 19 #ifndef MEDIA_FILTERS_AUDIO_RENDERER_BASE_H_ |
20 #define MEDIA_FILTERS_AUDIO_RENDERER_BASE_H_ | 20 #define MEDIA_FILTERS_AUDIO_RENDERER_BASE_H_ |
21 | 21 |
22 #include <deque> | 22 #include <deque> |
23 | 23 |
24 #include "base/synchronization/lock.h" | 24 #include "base/synchronization/lock.h" |
| 25 #include "media/base/audio_decoder.h" |
25 #include "media/base/buffers.h" | 26 #include "media/base/buffers.h" |
26 #include "media/base/filters.h" | 27 #include "media/base/filters.h" |
27 #include "media/filters/audio_renderer_algorithm_base.h" | 28 #include "media/filters/audio_renderer_algorithm_base.h" |
28 | 29 |
29 namespace media { | 30 namespace media { |
30 | 31 |
31 class MEDIA_EXPORT AudioRendererBase : public AudioRenderer { | 32 class MEDIA_EXPORT AudioRendererBase : public AudioRenderer { |
32 public: | 33 public: |
33 AudioRendererBase(); | 34 AudioRendererBase(); |
34 virtual ~AudioRendererBase(); | 35 virtual ~AudioRendererBase(); |
35 | 36 |
36 // Filter implementation. | 37 // Filter implementation. |
37 virtual void Play(const base::Closure& callback) OVERRIDE; | 38 virtual void Play(const base::Closure& callback) OVERRIDE; |
38 virtual void Pause(const base::Closure& callback) OVERRIDE; | 39 virtual void Pause(const base::Closure& callback) OVERRIDE; |
| 40 virtual void Flush(const base::Closure& callback) OVERRIDE; |
39 virtual void Stop(const base::Closure& callback) OVERRIDE; | 41 virtual void Stop(const base::Closure& callback) OVERRIDE; |
40 | |
41 virtual void Seek(base::TimeDelta time, const FilterStatusCB& cb) OVERRIDE; | 42 virtual void Seek(base::TimeDelta time, const FilterStatusCB& cb) OVERRIDE; |
42 | 43 |
43 // AudioRenderer implementation. | 44 // AudioRenderer implementation. |
44 virtual void Initialize(AudioDecoder* decoder, | 45 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder, |
45 const PipelineStatusCB& init_callback, | 46 const PipelineStatusCB& init_callback, |
46 const base::Closure& underflow_callback, | 47 const base::Closure& underflow_callback, |
47 const AudioTimeCB& audio_time_cb) OVERRIDE; | 48 const AudioTimeCB& audio_time_cb) OVERRIDE; |
48 virtual bool HasEnded() OVERRIDE; | 49 virtual bool HasEnded() OVERRIDE; |
49 virtual void ResumeAfterUnderflow(bool buffer_more_audio) OVERRIDE; | 50 virtual void ResumeAfterUnderflow(bool buffer_more_audio) OVERRIDE; |
50 | 51 |
51 protected: | 52 protected: |
52 FRIEND_TEST_ALL_PREFIXES(AudioRendererBaseTest, EndOfStream); | 53 FRIEND_TEST_ALL_PREFIXES(AudioRendererBaseTest, EndOfStream); |
53 FRIEND_TEST_ALL_PREFIXES(AudioRendererBaseTest, Underflow_EndOfStream); | 54 FRIEND_TEST_ALL_PREFIXES(AudioRendererBaseTest, Underflow_EndOfStream); |
54 | 55 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 base::TimeDelta seek_timestamp_; | 162 base::TimeDelta seek_timestamp_; |
162 | 163 |
163 AudioDecoder::ReadCB read_cb_; | 164 AudioDecoder::ReadCB read_cb_; |
164 | 165 |
165 DISALLOW_COPY_AND_ASSIGN(AudioRendererBase); | 166 DISALLOW_COPY_AND_ASSIGN(AudioRendererBase); |
166 }; | 167 }; |
167 | 168 |
168 } // namespace media | 169 } // namespace media |
169 | 170 |
170 #endif // MEDIA_FILTERS_AUDIO_RENDERER_BASE_H_ | 171 #endif // MEDIA_FILTERS_AUDIO_RENDERER_BASE_H_ |
OLD | NEW |