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 CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 // Accessors to the sink audio parameters. | 99 // Accessors to the sink audio parameters. |
100 int channels() const { return sink_params_.channels(); } | 100 int channels() const { return sink_params_.channels(); } |
101 int sample_rate() const { return sink_params_.sample_rate(); } | 101 int sample_rate() const { return sink_params_.sample_rate(); } |
102 int frames_per_buffer() const { return sink_params_.frames_per_buffer(); } | 102 int frames_per_buffer() const { return sink_params_.frames_per_buffer(); } |
103 | 103 |
104 private: | 104 private: |
105 // MediaStreamAudioRenderer implementation. This is private since we want | 105 // MediaStreamAudioRenderer implementation. This is private since we want |
106 // callers to use proxy objects. | 106 // callers to use proxy objects. |
107 // TODO(tommi): Make the MediaStreamAudioRenderer implementation a pimpl? | 107 // TODO(tommi): Make the MediaStreamAudioRenderer implementation a pimpl? |
108 virtual void Start() OVERRIDE; | 108 virtual void Start() override; |
109 virtual void Play() OVERRIDE; | 109 virtual void Play() override; |
110 virtual void Pause() OVERRIDE; | 110 virtual void Pause() override; |
111 virtual void Stop() OVERRIDE; | 111 virtual void Stop() override; |
112 virtual void SetVolume(float volume) OVERRIDE; | 112 virtual void SetVolume(float volume) override; |
113 virtual base::TimeDelta GetCurrentRenderTime() const OVERRIDE; | 113 virtual base::TimeDelta GetCurrentRenderTime() const override; |
114 virtual bool IsLocalRenderer() const OVERRIDE; | 114 virtual bool IsLocalRenderer() const override; |
115 | 115 |
116 // Called when an audio renderer, either the main or a proxy, starts playing. | 116 // Called when an audio renderer, either the main or a proxy, starts playing. |
117 // Here we maintain a reference count of how many renderers are currently | 117 // Here we maintain a reference count of how many renderers are currently |
118 // playing so that the shared play state of all the streams can be reflected | 118 // playing so that the shared play state of all the streams can be reflected |
119 // correctly. | 119 // correctly. |
120 void EnterPlayState(); | 120 void EnterPlayState(); |
121 | 121 |
122 // Called when an audio renderer, either the main or a proxy, is paused. | 122 // Called when an audio renderer, either the main or a proxy, is paused. |
123 // See EnterPlayState for more details. | 123 // See EnterPlayState for more details. |
124 void EnterPauseState(); | 124 void EnterPauseState(); |
(...skipping 18 matching lines...) Expand all Loading... |
143 | 143 |
144 // Used to DCHECK that we are called on the correct thread. | 144 // Used to DCHECK that we are called on the correct thread. |
145 base::ThreadChecker thread_checker_; | 145 base::ThreadChecker thread_checker_; |
146 | 146 |
147 // Flag to keep track the state of the renderer. | 147 // Flag to keep track the state of the renderer. |
148 State state_; | 148 State state_; |
149 | 149 |
150 // media::AudioRendererSink::RenderCallback implementation. | 150 // media::AudioRendererSink::RenderCallback implementation. |
151 // These two methods are called on the AudioOutputDevice worker thread. | 151 // These two methods are called on the AudioOutputDevice worker thread. |
152 virtual int Render(media::AudioBus* audio_bus, | 152 virtual int Render(media::AudioBus* audio_bus, |
153 int audio_delay_milliseconds) OVERRIDE; | 153 int audio_delay_milliseconds) override; |
154 virtual void OnRenderError() OVERRIDE; | 154 virtual void OnRenderError() override; |
155 | 155 |
156 // Called by AudioPullFifo when more data is necessary. | 156 // Called by AudioPullFifo when more data is necessary. |
157 // This method is called on the AudioOutputDevice worker thread. | 157 // This method is called on the AudioOutputDevice worker thread. |
158 void SourceCallback(int fifo_frame_delay, media::AudioBus* audio_bus); | 158 void SourceCallback(int fifo_frame_delay, media::AudioBus* audio_bus); |
159 | 159 |
160 // Goes through all renderers for the |source| and applies the proper | 160 // Goes through all renderers for the |source| and applies the proper |
161 // volume scaling for the source based on the volume(s) of the renderer(s). | 161 // volume scaling for the source based on the volume(s) of the renderer(s). |
162 void UpdateSourceVolume(webrtc::AudioSourceInterface* source); | 162 void UpdateSourceVolume(webrtc::AudioSourceInterface* source); |
163 | 163 |
164 // Tracks a playing state. The state must be playing when this method | 164 // Tracks a playing state. The state must be playing when this method |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // Used for triggering new UMA histogram. Counts number of render | 233 // Used for triggering new UMA histogram. Counts number of render |
234 // callbacks modulo |kNumCallbacksBetweenRenderTimeHistograms|. | 234 // callbacks modulo |kNumCallbacksBetweenRenderTimeHistograms|. |
235 int render_callback_count_; | 235 int render_callback_count_; |
236 | 236 |
237 DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioRenderer); | 237 DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioRenderer); |
238 }; | 238 }; |
239 | 239 |
240 } // namespace content | 240 } // namespace content |
241 | 241 |
242 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ | 242 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ |
OLD | NEW |