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 "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 #include "media/base/filters.h" | 11 #include "media/base/filters.h" |
12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
13 #include "media/base/pipeline_status.h" | 13 #include "media/base/pipeline_status.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 class AudioDecoder; | 17 class AudioDecoder; |
18 | 18 |
19 class MEDIA_EXPORT AudioRenderer : public Filter { | 19 class MEDIA_EXPORT AudioRenderer |
20 : public base::RefCountedThreadSafe<AudioRenderer> { | |
20 public: | 21 public: |
21 // Used to update the pipeline's clock time. The first parameter is the | 22 // First parameter is the current time that has been rendered. |
22 // current time, and the second parameter is the time that the clock must not | 23 // Second parameter is the maximum time value that the clock cannot exceed. |
23 // exceed. | |
24 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; | 24 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; |
25 | 25 |
26 // Initialize a AudioRenderer with the given AudioDecoder, executing the | 26 // Initialize a AudioRenderer with the given AudioDecoder, executing the |
27 // |init_cb| upon completion. |underflow_cb| is called when the | 27 // |init_cb| upon completion. |
28 // renderer runs out of data to pass to the audio card during playback. | 28 // |
29 // If the |underflow_cb| is called ResumeAfterUnderflow() must be called | 29 // |underflow_cb| is executed when the renderer runs out of data to pass to |
30 // the audio card during playback. ResumeAfterUnderflow() must be called | |
30 // to resume playback. Pause(), Seek(), or Stop() cancels the underflow | 31 // to resume playback. Pause(), Seek(), or Stop() cancels the underflow |
31 // condition. | 32 // condition. |
33 // | |
34 // |time_cb| is executed whenever time has advanced by way of audio rendering. | |
35 // | |
36 // |ended_cb| is executed when audio rendering has reached the end of stream. | |
37 // | |
38 // |disabled_cb| is executed when audio rendering has been disabled due to | |
39 // external factors (i.e., device was removed). |time_cb| will no longer be | |
40 // executed. | |
32 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder, | 41 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder, |
33 const PipelineStatusCB& init_cb, | 42 const PipelineStatusCB& init_cb, |
34 const base::Closure& underflow_cb, | 43 const base::Closure& underflow_cb, |
35 const TimeCB& time_cb) = 0; | 44 const TimeCB& time_cb, |
45 const base::Closure& ended_cb, | |
acolwell GONE FROM CHROMIUM
2012/07/19 00:58:18
WDYT of moving this to Play() since it only makes
scherkus (not reviewing)
2012/07/19 21:29:02
I tried it out but the only difference seemed to b
| |
46 const base::Closure& disabled_cb) = 0; | |
36 | 47 |
37 // Returns true if this filter has received and processed an end-of-stream | 48 // Start audio decoding and rendering at the current playback rate, executing |
38 // buffer. | 49 // |callback| when playback is underway. |
50 virtual void Play(const base::Closure& callback) = 0; | |
51 | |
52 // Temporarily suspend decoding and rendering audio, executing |callback| when | |
53 // playback has been suspended. | |
54 virtual void Pause(const base::Closure& callback) = 0; | |
55 | |
56 // Discard any audio data, executing |callback| when completed. | |
57 virtual void Flush(const base::Closure& callback) = 0; | |
58 | |
59 // Start prerolling audio data for samples starting at |time|, executing | |
60 // |callback| when completed. | |
61 // | |
62 // Only valid to call after a successful Initialize() or Flush(). | |
63 // | |
64 // TODO(scherkus): rename this to Preroll(). | |
65 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& callback) = 0; | |
66 | |
67 // Stop all operations in preparation for being deleted, executing |callback| | |
68 // when complete. | |
69 virtual void Stop(const base::Closure& callback) = 0; | |
70 | |
71 // Updates the current playback rate. | |
72 virtual void SetPlaybackRate(float playback_rate) = 0; | |
73 | |
74 // Returns true if all audio data has been played back by the audio device. | |
39 virtual bool HasEnded() = 0; | 75 virtual bool HasEnded() = 0; |
40 | 76 |
41 // Sets the output volume. | 77 // Sets the output volume. |
42 virtual void SetVolume(float volume) = 0; | 78 virtual void SetVolume(float volume) = 0; |
43 | 79 |
44 // Resumes playback after underflow occurs. | 80 // Resumes playback after underflow occurs. |
81 // | |
45 // |buffer_more_audio| is set to true if you want to increase the size of the | 82 // |buffer_more_audio| is set to true if you want to increase the size of the |
46 // decoded audio buffer. | 83 // decoded audio buffer. |
47 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; | 84 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; |
48 | 85 |
49 protected: | 86 protected: |
87 friend class base::RefCountedThreadSafe<AudioRenderer>; | |
50 virtual ~AudioRenderer() {} | 88 virtual ~AudioRenderer() {} |
51 }; | 89 }; |
52 | 90 |
53 } // namespace media | 91 } // namespace media |
54 | 92 |
55 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ | 93 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ |
OLD | NEW |