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

Side by Side Diff: content/renderer/media/webrtc_audio_capturer.h

Issue 12220063: Possible solution to synchronization problems in webrtc audio capturer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed potential update issues Created 7 years, 10 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
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 CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_ 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 bool is_recording() const { return running_; } 129 bool is_recording() const { return running_; }
130 130
131 // Returns true if a local renderer has called PrepareLoopback() and it can 131 // Returns true if a local renderer has called PrepareLoopback() and it can
132 // be utilized to prevent more than one local renderer. 132 // be utilized to prevent more than one local renderer.
133 // Called on the main render thread. 133 // Called on the main render thread.
134 bool IsInLoopbackMode(); 134 bool IsInLoopbackMode();
135 135
136 // Audio parameters utilized by the audio capturer. Can be utilized by 136 // Audio parameters utilized by the audio capturer. Can be utilized by
137 // a local renderer to set up a renderer using identical parameters as the 137 // a local renderer to set up a renderer using identical parameters as the
138 // capturer. 138 // capturer.
phoglund_chromium 2013/02/08 16:10:38 Removing const looks silly, but I actually have to
tommi (sloooow) - chröme 2013/02/08 16:32:04 You could make the lock mutable which is common in
phoglund_chromium 2013/02/08 17:06:00 Yeah, I wrote a TODO on the accessor.
139 const media::AudioParameters& audio_parameter() const { return params_; } 139 const media::AudioParameters& audio_parameter();
tommi (sloooow) - chröme 2013/02/08 16:32:04 nit: audio_parameters() (plural) or just params()
phoglund_chromium 2013/02/08 17:06:00 Done.
140 140
141 // AudioCapturerSource::CaptureCallback implementation. 141 // AudioCapturerSource::CaptureCallback implementation.
142 // Called on the AudioInputDevice audio thread. 142 // Called on the AudioInputDevice audio thread.
143 virtual void Capture(media::AudioBus* audio_source, 143 virtual void Capture(media::AudioBus* audio_source,
144 int audio_delay_milliseconds, 144 int audio_delay_milliseconds,
145 double volume) OVERRIDE; 145 double volume) OVERRIDE;
146 virtual void OnCaptureError() OVERRIDE; 146 virtual void OnCaptureError() OVERRIDE;
147 147
148 // AudioCapturerSource::CaptureEventHandler implementation. 148 // AudioCapturerSource::CaptureEventHandler implementation.
149 // Called on the IO thread. 149 // Called on the IO thread.
150 virtual void OnDeviceStarted(const std::string& device_id) OVERRIDE; 150 virtual void OnDeviceStarted(const std::string& device_id) OVERRIDE;
151 virtual void OnDeviceStopped() OVERRIDE; 151 virtual void OnDeviceStopped() OVERRIDE;
152 152
153 // WebRtcLocalAudioRenderer::LocalRenderCallback implementation. 153 // WebRtcLocalAudioRenderer::LocalRenderCallback implementation.
154 // Reads stored captured data from a local FIFO. This method is used in 154 // Reads stored captured data from a local FIFO. This method is used in
155 // combination with a local sink to render captured audio in loopback. 155 // combination with a local sink to render captured audio in loopback.
156 // This method is called on the AudioOutputDevice worker thread. 156 // This method is called on the AudioOutputDevice worker thread.
157 virtual void ProvideInput(media::AudioBus* dest) OVERRIDE; 157 virtual void ProvideInput(media::AudioBus* dest) OVERRIDE;
158 158
159 protected: 159 protected:
160 friend class base::RefCountedThreadSafe<WebRtcAudioCapturer>; 160 friend class base::RefCountedThreadSafe<WebRtcAudioCapturer>;
161 virtual ~WebRtcAudioCapturer(); 161 virtual ~WebRtcAudioCapturer();
162 162
163 private: 163 private:
164 typedef std::list<WebRtcAudioCapturerSink*> SinkList; 164 typedef std::list<WebRtcAudioCapturerSink*> SinkList;
165 165
166 WebRtcAudioCapturer(); 166 WebRtcAudioCapturer();
167 167
168 // Reconfigures the capturer with a new buffer size and capture parameters.
169 // Must be called without holding the lock. Returns true on success.
170 bool Reconfigure(int sample_rate, media::AudioParameters::Format format,
171 media::ChannelLayout channel_layout);
172
168 // Used to DCHECK that we are called on the correct thread. 173 // Used to DCHECK that we are called on the correct thread.
169 base::ThreadChecker thread_checker_; 174 base::ThreadChecker thread_checker_;
170 175
171 // Protects |source_|, |sinks_|, |running_|, |on_device_stopped_cb_|, 176 // Protects |source_|, |sinks_|, |running_|, |on_device_stopped_cb_|,
172 // |loopback_fifo_| and |buffering_|. 177 // |loopback_fifo_|, |params_| and |buffering_|.
173 base::Lock lock_; 178 base::Lock lock_;
174 179
175 // A list of sinks that the audio data is fed to. 180 // A list of sinks that the audio data is fed to.
176 SinkList sinks_; 181 SinkList sinks_;
177 182
178 // The audio data source from the browser process. 183 // The audio data source from the browser process.
179 scoped_refptr<media::AudioCapturerSource> source_; 184 scoped_refptr<media::AudioCapturerSource> source_;
180 185
181 // Cached values of utilized audio parameters. Platform dependent.
182 media::AudioParameters params_;
183
184 // Buffers used for temporary storage during capture callbacks. 186 // Buffers used for temporary storage during capture callbacks.
185 // Allocated during initialization. 187 // Allocated during initialization.
186 scoped_array<int16> buffer_; 188 class ConfiguredBuffer;
189 scoped_refptr<ConfiguredBuffer> buffer_;
187 std::string device_id_; 190 std::string device_id_;
188 bool running_; 191 bool running_;
189 192
190 // Callback object which is called during OnDeviceStopped(). 193 // Callback object which is called during OnDeviceStopped().
191 // Informs a local sink that it should stop asking for data. 194 // Informs a local sink that it should stop asking for data.
192 base::Closure on_device_stopped_cb_; 195 base::Closure on_device_stopped_cb_;
193 196
194 // Contains copies of captured audio frames. Only utilized in loopback 197 // Contains copies of captured audio frames. Only utilized in loopback
195 // mode when a local sink has been set. 198 // mode when a local sink has been set.
196 scoped_ptr<media::AudioFifo> loopback_fifo_; 199 scoped_ptr<media::AudioFifo> loopback_fifo_;
197 200
198 // True when FIFO is utilized, false otherwise. 201 // True when FIFO is utilized, false otherwise.
199 bool buffering_; 202 bool buffering_;
200 203
201 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioCapturer); 204 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioCapturer);
202 }; 205 };
203 206
204 } // namespace content 207 } // namespace content
205 208
206 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_ 209 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/webrtc_audio_capturer.cc » ('j') | content/renderer/media/webrtc_audio_capturer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698