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 #ifndef MEDIA_BASE_AUDIO_RENDERER_H_ | 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_H_ |
6 #define MEDIA_BASE_AUDIO_RENDERER_H_ | 6 #define MEDIA_BASE_AUDIO_RENDERER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
14 #include "media/base/pipeline_status.h" | 14 #include "media/base/pipeline_status.h" |
15 | 15 |
16 namespace media { | 16 namespace media { |
17 | 17 |
18 class AudioDecoder; | 18 class AudioDecoder; |
19 class DemuxerStream; | 19 class DemuxerStream; |
20 | 20 |
21 class MEDIA_EXPORT AudioRenderer { | 21 class MEDIA_EXPORT AudioRenderer |
| 22 : public base::RefCountedThreadSafe<AudioRenderer> { |
22 public: | 23 public: |
23 typedef std::list<scoped_refptr<AudioDecoder> > AudioDecoderList; | 24 typedef std::list<scoped_refptr<AudioDecoder> > AudioDecoderList; |
24 | 25 |
25 // First parameter is the current time that has been rendered. | 26 // First parameter is the current time that has been rendered. |
26 // Second parameter is the maximum time value that the clock cannot exceed. | 27 // Second parameter is the maximum time value that the clock cannot exceed. |
27 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; | 28 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; |
28 | 29 |
29 AudioRenderer(); | |
30 virtual ~AudioRenderer(); | |
31 | |
32 // Initialize a AudioRenderer with the given AudioDecoder, executing the | 30 // Initialize a AudioRenderer with the given AudioDecoder, executing the |
33 // |init_cb| upon completion. | 31 // |init_cb| upon completion. |
34 // | 32 // |
35 // |statistics_cb| is executed periodically with audio rendering stats. | 33 // |statistics_cb| is executed periodically with audio rendering stats. |
36 // | 34 // |
37 // |underflow_cb| is executed when the renderer runs out of data to pass to | 35 // |underflow_cb| is executed when the renderer runs out of data to pass to |
38 // the audio card during playback. ResumeAfterUnderflow() must be called | 36 // the audio card during playback. ResumeAfterUnderflow() must be called |
39 // to resume playback. Pause(), Preroll(), or Stop() cancels the underflow | 37 // to resume playback. Pause(), Preroll(), or Stop() cancels the underflow |
40 // condition. | 38 // condition. |
41 // | 39 // |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 83 |
86 // Sets the output volume. | 84 // Sets the output volume. |
87 virtual void SetVolume(float volume) = 0; | 85 virtual void SetVolume(float volume) = 0; |
88 | 86 |
89 // Resumes playback after underflow occurs. | 87 // Resumes playback after underflow occurs. |
90 // | 88 // |
91 // |buffer_more_audio| is set to true if you want to increase the size of the | 89 // |buffer_more_audio| is set to true if you want to increase the size of the |
92 // decoded audio buffer. | 90 // decoded audio buffer. |
93 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; | 91 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; |
94 | 92 |
| 93 protected: |
| 94 friend class base::RefCountedThreadSafe<AudioRenderer>; |
| 95 |
| 96 AudioRenderer(); |
| 97 virtual ~AudioRenderer(); |
| 98 |
95 private: | 99 private: |
96 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); | 100 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); |
97 }; | 101 }; |
98 | 102 |
99 } // namespace media | 103 } // namespace media |
100 | 104 |
101 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ | 105 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ |
OLD | NEW |