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

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

Issue 2425353002: Data race fix: Replace use of MessageLoop raw pointer in MSAudioProcessor. (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_MEDIA_STREAM_AUDIO_PROCESSOR_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_
7 7
8 #include "base/atomicops.h" 8 #include "base/atomicops.h"
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/single_thread_task_runner.h"
12 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
13 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
14 #include "base/time/time.h" 16 #include "base/time/time.h"
15 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
16 #include "content/public/common/media_stream_request.h" 18 #include "content/public/common/media_stream_request.h"
17 #include "content/renderer/media/aec_dump_message_filter.h" 19 #include "content/renderer/media/aec_dump_message_filter.h"
18 #include "content/renderer/media/audio_repetition_detector.h" 20 #include "content/renderer/media/audio_repetition_detector.h"
19 #include "content/renderer/media/webrtc_audio_device_impl.h" 21 #include "content/renderer/media/webrtc_audio_device_impl.h"
20 #include "media/base/audio_converter.h" 22 #include "media/base/audio_converter.h"
21 #include "third_party/webrtc/api/mediastreaminterface.h" 23 #include "third_party/webrtc/api/mediastreaminterface.h"
(...skipping 27 matching lines...) Expand all
49 // on the getUserMedia constraints, processes the data and outputs it in a unit 51 // on the getUserMedia constraints, processes the data and outputs it in a unit
50 // of 10 ms data chunk. 52 // of 10 ms data chunk.
51 class CONTENT_EXPORT MediaStreamAudioProcessor : 53 class CONTENT_EXPORT MediaStreamAudioProcessor :
52 NON_EXPORTED_BASE(public WebRtcPlayoutDataSource::Sink), 54 NON_EXPORTED_BASE(public WebRtcPlayoutDataSource::Sink),
53 NON_EXPORTED_BASE(public AudioProcessorInterface), 55 NON_EXPORTED_BASE(public AudioProcessorInterface),
54 NON_EXPORTED_BASE(public AecDumpMessageFilter::AecDumpDelegate) { 56 NON_EXPORTED_BASE(public AecDumpMessageFilter::AecDumpDelegate) {
55 public: 57 public:
56 // |playout_data_source| is used to register this class as a sink to the 58 // |playout_data_source| is used to register this class as a sink to the
57 // WebRtc playout data for processing AEC. If clients do not enable AEC, 59 // WebRtc playout data for processing AEC. If clients do not enable AEC,
58 // |playout_data_source| won't be used. 60 // |playout_data_source| won't be used.
61 //
62 // Threading note: The constructor assumes it is being run on the main render
63 // thread.
59 MediaStreamAudioProcessor( 64 MediaStreamAudioProcessor(
60 const blink::WebMediaConstraints& constraints, 65 const blink::WebMediaConstraints& constraints,
61 const MediaStreamDevice::AudioDeviceParameters& input_params, 66 const MediaStreamDevice::AudioDeviceParameters& input_params,
62 WebRtcPlayoutDataSource* playout_data_source); 67 WebRtcPlayoutDataSource* playout_data_source);
63 68
64 // Called when the format of the capture data has changed. 69 // Called when the format of the capture data has changed.
65 // Called on the main render thread. The caller is responsible for stopping 70 // Called on the main render thread. The caller is responsible for stopping
66 // the capture thread before calling this method. 71 // the capture thread before calling this method.
67 // After this method, the capture thread will be changed to a new capture 72 // After this method, the capture thread will be changed to a new capture
68 // thread. 73 // thread.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // capture audio thread. 195 // capture audio thread.
191 media::AudioParameters input_format_; 196 media::AudioParameters input_format_;
192 media::AudioParameters output_format_; 197 media::AudioParameters output_format_;
193 // Only used on the render audio thread. 198 // Only used on the render audio thread.
194 media::AudioParameters render_format_; 199 media::AudioParameters render_format_;
195 200
196 // Raw pointer to the WebRtcPlayoutDataSource, which is valid for the 201 // Raw pointer to the WebRtcPlayoutDataSource, which is valid for the
197 // lifetime of RenderThread. 202 // lifetime of RenderThread.
198 WebRtcPlayoutDataSource* playout_data_source_; 203 WebRtcPlayoutDataSource* playout_data_source_;
199 204
200 // Used to DCHECK that some methods are called on the main render thread. 205 // Task runner for the main render thread.
201 base::ThreadChecker main_thread_checker_; 206 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner_;
207
202 // Used to DCHECK that some methods are called on the capture audio thread. 208 // Used to DCHECK that some methods are called on the capture audio thread.
203 base::ThreadChecker capture_thread_checker_; 209 base::ThreadChecker capture_thread_checker_;
204 // Used to DCHECK that some methods are called on the render audio thread. 210 // Used to DCHECK that some methods are called on the render audio thread.
205 base::ThreadChecker render_thread_checker_; 211 base::ThreadChecker render_thread_checker_;
206 212
207 // Message loop for the main render thread. We're assuming that we're created
208 // on the main render thread.
209 base::MessageLoop* main_thread_message_loop_;
210
211 // Flag to enable stereo channel mirroring. 213 // Flag to enable stereo channel mirroring.
212 bool audio_mirroring_; 214 bool audio_mirroring_;
213 215
214 // Typing detector. |typing_detected_| is used to show the result of typing 216 // Typing detector. |typing_detected_| is used to show the result of typing
215 // detection. It can be accessed by the capture audio thread and by the 217 // detection. It can be accessed by the capture audio thread and by the
216 // libjingle thread which calls GetStats(). 218 // libjingle thread which calls GetStats().
217 std::unique_ptr<webrtc::TypingDetection> typing_detector_; 219 std::unique_ptr<webrtc::TypingDetection> typing_detector_;
218 base::subtle::Atomic32 typing_detected_; 220 base::subtle::Atomic32 typing_detected_;
219 221
220 // Communication with browser for AEC dump. 222 // Communication with browser for AEC dump.
221 scoped_refptr<AecDumpMessageFilter> aec_dump_message_filter_; 223 scoped_refptr<AecDumpMessageFilter> aec_dump_message_filter_;
222 224
223 // Flag to avoid executing Stop() more than once. 225 // Flag to avoid executing Stop() more than once.
224 bool stopped_; 226 bool stopped_;
225 227
226 // Object for logging UMA stats for echo information when the AEC is enabled. 228 // Object for logging UMA stats for echo information when the AEC is enabled.
227 // Accessed on the main render thread. 229 // Accessed on the main render thread.
228 std::unique_ptr<EchoInformation> echo_information_; 230 std::unique_ptr<EchoInformation> echo_information_;
229 231
230 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioProcessor); 232 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioProcessor);
231 }; 233 };
232 234
233 } // namespace content 235 } // namespace content
234 236
235 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ 237 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698