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

Side by Side Diff: media/base/audio_renderer.h

Issue 10753021: Move AudioRenderer out of Filter heirarchy. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: error_cb Created 8 years, 5 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/base/callback_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.
41 //
42 // |error_cb| is executed if an error was encountered.
32 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder, 43 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder,
33 const PipelineStatusCB& init_cb, 44 const PipelineStatusCB& init_cb,
34 const base::Closure& underflow_cb, 45 const base::Closure& underflow_cb,
35 const TimeCB& time_cb) = 0; 46 const TimeCB& time_cb,
47 const base::Closure& ended_cb,
48 const base::Closure& disabled_cb,
49 const PipelineStatusCB& error_cb) = 0;
36 50
37 // Returns true if this filter has received and processed an end-of-stream 51 // Start audio decoding and rendering at the current playback rate, executing
38 // buffer. 52 // |callback| when playback is underway.
53 virtual void Play(const base::Closure& callback) = 0;
54
55 // Temporarily suspend decoding and rendering audio, executing |callback| when
56 // playback has been suspended.
57 virtual void Pause(const base::Closure& callback) = 0;
58
59 // Discard any audio data, executing |callback| when completed.
60 virtual void Flush(const base::Closure& callback) = 0;
61
62 // Start prerolling audio data for samples starting at |time|, executing
63 // |callback| when completed.
64 //
65 // Only valid to call after a successful Initialize() or Flush().
66 //
67 // TODO(scherkus): rename this to Preroll().
68 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& callback) = 0;
69
70 // Stop all operations in preparation for being deleted, executing |callback|
71 // when complete.
72 virtual void Stop(const base::Closure& callback) = 0;
73
74 // Updates the current playback rate.
75 virtual void SetPlaybackRate(float playback_rate) = 0;
76
77 // Returns true if all audio data has been played back by the audio device.
39 virtual bool HasEnded() = 0; 78 virtual bool HasEnded() = 0;
40 79
41 // Sets the output volume. 80 // Sets the output volume.
42 virtual void SetVolume(float volume) = 0; 81 virtual void SetVolume(float volume) = 0;
43 82
44 // Resumes playback after underflow occurs. 83 // Resumes playback after underflow occurs.
84 //
45 // |buffer_more_audio| is set to true if you want to increase the size of the 85 // |buffer_more_audio| is set to true if you want to increase the size of the
46 // decoded audio buffer. 86 // decoded audio buffer.
47 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; 87 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0;
48 88
49 protected: 89 protected:
90 friend class base::RefCountedThreadSafe<AudioRenderer>;
50 virtual ~AudioRenderer() {} 91 virtual ~AudioRenderer() {}
51 }; 92 };
52 93
53 } // namespace media 94 } // namespace media
54 95
55 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ 96 #endif // MEDIA_BASE_AUDIO_RENDERER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/callback_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698