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

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: docs 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/composite_filter.cc » ('j') | media/base/pipeline.h » ('J')
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 // TODO(scherkus): replace this interface with additional callbacks passed to
20 // Initialize() similar to the underflow and time update callbacks.
21 class MEDIA_EXPORT AudioRendererHost {
20 public: 22 public:
21 // Used to update the pipeline's clock time. The first parameter is the 23 virtual ~AudioRendererHost() {};
22 // current time, and the second parameter is the time that the clock must not 24
23 // exceed. 25 // Notifcation that audio rendering has reached the end of the stream.
acolwell GONE FROM CHROMIUM 2012/07/10 16:34:37 nit: s/Notifcation/Notification
scherkus (not reviewing) 2012/07/17 03:43:00 Done.
26 virtual void AudioRendererEnded() = 0;
27
28 // Notification that audio rendering has been disabled due to external factors
29 // (i.e., device was removed). Time update callbacks will no longer be
30 // executed.
31 virtual void AudioRendererDisabled() = 0;
32 };
33
34 class MEDIA_EXPORT AudioRenderer
35 : public base::RefCountedThreadSafe<AudioRenderer> {
36 public:
37 // Assigns the host object responsible for this AudioRenderer. Must be set
38 // prior to calling Initialize(). The host is expected to outlive the
39 // lifetime of an AudioRenderer.
40 virtual void SetHost(AudioRendererHost* host) = 0;
41
42 // Called whenever time has advanced by way of audio rendering. The first
43 // parameter is the current time, and the second parameter is the time that
44 // the clock must not exceed.
24 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; 45 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB;
25 46
26 // Initialize a AudioRenderer with the given AudioDecoder, executing the 47 // Initialize a AudioRenderer with the given AudioDecoder, executing the
27 // |init_cb| upon completion. |underflow_cb| is called when the 48 // |init_cb| upon completion. |underflow_cb| is called when the
28 // renderer runs out of data to pass to the audio card during playback. 49 // renderer runs out of data to pass to the audio card during playback.
29 // If the |underflow_cb| is called ResumeAfterUnderflow() must be called 50 // If the |underflow_cb| is called ResumeAfterUnderflow() must be called
30 // to resume playback. Pause(), Seek(), or Stop() cancels the underflow 51 // to resume playback. Pause(), Seek(), or Stop() cancels the underflow
31 // condition. 52 // condition.
32 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder, 53 virtual void Initialize(const scoped_refptr<AudioDecoder>& decoder,
33 const PipelineStatusCB& init_cb, 54 const PipelineStatusCB& init_cb,
34 const base::Closure& underflow_cb, 55 const base::Closure& underflow_cb,
35 const TimeCB& time_cb) = 0; 56 const TimeCB& time_cb) = 0;
36 57
37 // Returns true if this filter has received and processed an end-of-stream 58 // Start audio decoding and rendering at the current playback rate, executing
38 // buffer. 59 // |callback| when playback is underway.
60 virtual void Play(const base::Closure& callback) = 0;
61
62 // Temporarily suspend decoding and rendering audio, executing |callback| when
63 // playback has been suspended.
64 virtual void Pause(const base::Closure& callback) = 0;
65
66 // Discard any audio data, executing |callback| when completed.
67 virtual void Flush(const base::Closure& callback) = 0;
68
69 // Start prerolling audio data for samples starting at |time|, executing
70 // |callback| when completed.
71 //
72 // Only valid to call after a successful Initialize() or Flush().
73 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& callback) = 0;
scherkus (not reviewing) 2012/07/10 03:58:22 think it's time to finally call this Preroll()? :)
scherkus (not reviewing) 2012/07/17 03:43:00 making it a TODO
74
75 // Stop all operations in preparation for being deleted, executing |callback|
76 // when complete.
77 virtual void Stop(const base::Closure& callback) = 0;
78
79 // Updates the current playback rate.
80 virtual void SetPlaybackRate(float playback_rate) = 0;
81
82 // Returns true if all audio data has been played back by the audio device.
39 virtual bool HasEnded() = 0; 83 virtual bool HasEnded() = 0;
40 84
41 // Sets the output volume. 85 // Sets the output volume.
42 virtual void SetVolume(float volume) = 0; 86 virtual void SetVolume(float volume) = 0;
43 87
44 // Resumes playback after underflow occurs. 88 // Resumes playback after underflow occurs.
89 //
45 // |buffer_more_audio| is set to true if you want to increase the size of the 90 // |buffer_more_audio| is set to true if you want to increase the size of the
46 // decoded audio buffer. 91 // decoded audio buffer.
47 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; 92 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0;
48 93
49 protected: 94 protected:
95 friend class base::RefCountedThreadSafe<AudioRenderer>;
50 virtual ~AudioRenderer() {} 96 virtual ~AudioRenderer() {}
51 }; 97 };
52 98
53 } // namespace media 99 } // namespace media
54 100
55 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ 101 #endif // MEDIA_BASE_AUDIO_RENDERER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/composite_filter.cc » ('j') | media/base/pipeline.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698