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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "media/base/audio_bus.h" | 14 #include "media/base/audio_bus.h" |
15 #include "media/base/audio_parameters.h" | 15 #include "media/base/audio_parameters.h" |
16 #include "media/base/output_device_info.h" | 16 #include "media/base/output_device_info.h" |
17 #include "url/origin.h" | 17 #include "url/origin.h" |
18 | 18 |
19 namespace media { | 19 namespace media { |
20 | 20 |
21 // AudioRendererSink is an interface representing the end-point for | 21 // AudioRendererSink is an interface representing the end-point for |
22 // rendered audio. An implementation is expected to | 22 // rendered audio. An implementation is expected to |
23 // periodically call Render() on a callback object. | 23 // periodically call Render() on a callback object. |
24 | 24 |
25 class AudioRendererSink | 25 class AudioRendererSink |
26 : public base::RefCountedThreadSafe<media::AudioRendererSink> { | 26 : public base::RefCountedThreadSafe<media::AudioRendererSink> { |
27 public: | 27 public: |
28 class RenderCallback { | 28 class RenderCallback { |
29 public: | 29 public: |
30 // Informs that rendering has been initialized and will start soon. This | |
31 // means that a new rendering thread has been started. | |
32 virtual void OnInitialized() = 0; | |
Henrik Grunell
2016/06/03 13:53:42
Only WebRTC will care about this function, and wil
DaleCurtis
2016/06/03 20:54:13
Why not always detach until the first render call?
Henrik Grunell
2016/06/08 09:19:06
The mixer in the upcoming mixing changes will rest
| |
33 | |
30 // Attempts to completely fill all channels of |dest|, returns actual | 34 // Attempts to completely fill all channels of |dest|, returns actual |
31 // number of frames filled. |frames_skipped| contains the number of frames | 35 // number of frames filled. |frames_skipped| contains the number of frames |
32 // the consumer has skipped, if any. | 36 // the consumer has skipped, if any. |
33 virtual int Render(AudioBus* dest, | 37 virtual int Render(AudioBus* dest, |
34 uint32_t frames_delayed, | 38 uint32_t frames_delayed, |
35 uint32_t frames_skipped) = 0; | 39 uint32_t frames_skipped) = 0; |
36 | 40 |
37 // Signals an error has occurred. | 41 // Signals an error has occurred. |
38 virtual void OnRenderError() = 0; | 42 virtual void OnRenderError() = 0; |
39 | 43 |
(...skipping 23 matching lines...) Expand all Loading... | |
63 // Returns |true| on success. | 67 // Returns |true| on success. |
64 virtual bool SetVolume(double volume) = 0; | 68 virtual bool SetVolume(double volume) = 0; |
65 | 69 |
66 // Returns current output device information. If the information is not | 70 // Returns current output device information. If the information is not |
67 // available yet, this method may block until it becomes available. | 71 // available yet, this method may block until it becomes available. |
68 // If the sink is not associated with any output device, |device_status| of | 72 // If the sink is not associated with any output device, |device_status| of |
69 // OutputDeviceInfo should be set to OUTPUT_DEVICE_STATUS_ERROR_INTERNAL. | 73 // OutputDeviceInfo should be set to OUTPUT_DEVICE_STATUS_ERROR_INTERNAL. |
70 // Must never be called on the IO thread. | 74 // Must never be called on the IO thread. |
71 virtual OutputDeviceInfo GetOutputDeviceInfo() = 0; | 75 virtual OutputDeviceInfo GetOutputDeviceInfo() = 0; |
72 | 76 |
77 // Returns true if called on rendering thread, otherwise false. | |
78 virtual bool BelongsToRenderingThread() = 0; | |
Henrik Grunell
2016/06/03 13:53:42
If we go for the above OnInitialized(), we don't n
DaleCurtis
2016/06/03 20:54:13
What do you mean about detaching? This would repla
Henrik Grunell
2016/06/08 09:19:06
In the case above, when the mixer restarts AOD, wi
DaleCurtis
2016/06/08 18:10:13
The corollary to my question is that if this repla
| |
79 | |
73 protected: | 80 protected: |
74 friend class base::RefCountedThreadSafe<AudioRendererSink>; | 81 friend class base::RefCountedThreadSafe<AudioRendererSink>; |
75 virtual ~AudioRendererSink() {} | 82 virtual ~AudioRendererSink() {} |
76 }; | 83 }; |
77 | 84 |
78 // Same as AudioRendererSink except that Initialize() and Start() can be called | 85 // Same as AudioRendererSink except that Initialize() and Start() can be called |
79 // again after Stop(). | 86 // again after Stop(). |
80 // TODO(sandersd): Fold back into AudioRendererSink once all subclasses support | 87 // TODO(sandersd): Fold back into AudioRendererSink once all subclasses support |
81 // this. | 88 // this. |
82 | 89 |
(...skipping 13 matching lines...) Expand all Loading... | |
96 const url::Origin& security_origin, | 103 const url::Origin& security_origin, |
97 const OutputDeviceStatusCB& callback) = 0; | 104 const OutputDeviceStatusCB& callback) = 0; |
98 | 105 |
99 protected: | 106 protected: |
100 ~SwitchableAudioRendererSink() override {} | 107 ~SwitchableAudioRendererSink() override {} |
101 }; | 108 }; |
102 | 109 |
103 } // namespace media | 110 } // namespace media |
104 | 111 |
105 #endif // MEDIA_BASE_AUDIO_RENDERER_SINK_H_ | 112 #endif // MEDIA_BASE_AUDIO_RENDERER_SINK_H_ |
OLD | NEW |