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_SINK_H_ | 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_SINK_H_ |
6 #define MEDIA_BASE_AUDIO_RENDERER_SINK_H_ | 6 #define MEDIA_BASE_AUDIO_RENDERER_SINK_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "media/audio/audio_parameters.h" | 11 #include "media/audio/audio_parameters.h" |
12 #include "media/base/audio_bus.h" | 12 #include "media/base/audio_bus.h" |
13 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 // AudioRendererSink is an interface representing the end-point for | 17 // AudioRendererSink is an interface representing the end-point for |
18 // rendered audio. An implementation is expected to | 18 // rendered audio. An implementation is expected to |
19 // periodically call Render() on a callback object. | 19 // periodically call Render() on a callback object. |
20 | 20 |
21 class AudioRendererSink | 21 class AudioRendererSink |
22 : public base::RefCountedThreadSafe<media::AudioRendererSink> { | 22 : public base::RefCountedThreadSafe<media::AudioRendererSink> { |
23 public: | 23 public: |
24 class RenderCallback { | 24 class RenderCallback { |
25 public: | 25 public: |
26 // Attempts to completely fill all channels of |audio_bus|, returns actual | 26 // Attempts to completely fill all channels of |dest|, returns actual |
27 // number of frames filled. | 27 // number of frames filled. |
28 virtual int Render(AudioBus* audio_bus, int audio_delay_milliseconds) = 0; | 28 virtual int Render(AudioBus* dest, int audio_delay_milliseconds) = 0; |
29 | |
30 // Synchronized audio I/O - see InitializeIO() below. | |
31 virtual void RenderIO(AudioBus* source, | |
henrika (OOO until Aug 14)
2012/09/11 21:44:48
Nit, are we OK with default implementations in int
| |
32 AudioBus* dest, | |
33 int audio_delay_milliseconds) {} | |
29 | 34 |
30 // Signals an error has occurred. | 35 // Signals an error has occurred. |
31 virtual void OnRenderError() = 0; | 36 virtual void OnRenderError() = 0; |
32 | 37 |
33 protected: | 38 protected: |
34 virtual ~RenderCallback() {} | 39 virtual ~RenderCallback() {} |
35 }; | 40 }; |
36 | 41 |
37 // Sets important information about the audio stream format. | 42 // Sets important information about the audio stream format. |
38 // It must be called before any of the other methods. | 43 // It must be called before any of the other methods. |
39 virtual void Initialize(const AudioParameters& params, | 44 virtual void Initialize(const AudioParameters& params, |
40 RenderCallback* callback) = 0; | 45 RenderCallback* callback) = 0; |
41 | 46 |
47 // InitializeIO() may be called instead of Initialize() for clients who wish | |
48 // to have synchronized input and output. |input_channels| specifies the | |
49 // number of input channels which will be at the same sample-rate | |
50 // and buffer-size as the output as specified in |params|. | |
51 // The callback's RenderIO() method will be called instead of Render(), | |
52 // providing the synchronized input data at the same time as when new | |
53 // output data is to be rendered. | |
54 virtual void InitializeIO(const AudioParameters& params, | |
henrika (OOO until Aug 14)
2012/09/11 21:44:48
It is not clear to me why we need inputy_channels.
| |
55 int input_channels, | |
56 RenderCallback* callback) {} | |
57 | |
42 // Starts audio playback. | 58 // Starts audio playback. |
43 virtual void Start() = 0; | 59 virtual void Start() = 0; |
44 | 60 |
45 // Stops audio playback. | 61 // Stops audio playback. |
46 virtual void Stop() = 0; | 62 virtual void Stop() = 0; |
47 | 63 |
48 // Pauses playback. | 64 // Pauses playback. |
49 virtual void Pause(bool flush) = 0; | 65 virtual void Pause(bool flush) = 0; |
50 | 66 |
51 // Resumes playback after calling Pause(). | 67 // Resumes playback after calling Pause(). |
52 virtual void Play() = 0; | 68 virtual void Play() = 0; |
53 | 69 |
54 // Sets the playback volume, with range [0.0, 1.0] inclusive. | 70 // Sets the playback volume, with range [0.0, 1.0] inclusive. |
55 // Returns |true| on success. | 71 // Returns |true| on success. |
56 virtual bool SetVolume(double volume) = 0; | 72 virtual bool SetVolume(double volume) = 0; |
57 | 73 |
58 protected: | 74 protected: |
59 friend class base::RefCountedThreadSafe<AudioRendererSink>; | 75 friend class base::RefCountedThreadSafe<AudioRendererSink>; |
60 virtual ~AudioRendererSink() {} | 76 virtual ~AudioRendererSink() {} |
61 }; | 77 }; |
62 | 78 |
63 } // namespace media | 79 } // namespace media |
64 | 80 |
65 #endif // MEDIA_BASE_AUDIO_RENDERER_SINK_H_ | 81 #endif // MEDIA_BASE_AUDIO_RENDERER_SINK_H_ |
OLD | NEW |