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

Side by Side Diff: webrtc/modules/audio_mixer/audio_mixer_impl.h

Issue 2437913003: Replaced thread checker with race checker in AudioMixer. (Closed)
Patch Set: Rebase after landing dependencies. 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
« no previous file with comments | « no previous file | webrtc/modules/audio_mixer/audio_mixer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_
12 #define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ 12 #define WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_
13 13
14 #include <memory> 14 #include <memory>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/api/audio/audio_mixer.h" 17 #include "webrtc/api/audio/audio_mixer.h"
18 #include "webrtc/base/scoped_ref_ptr.h" 18 #include "webrtc/base/scoped_ref_ptr.h"
19 #include "webrtc/base/thread_annotations.h" 19 #include "webrtc/base/thread_annotations.h"
20 #include "webrtc/base/thread_checker.h" 20 #include "webrtc/base/race_checker.h"
21 #include "webrtc/modules/audio_processing/include/audio_processing.h" 21 #include "webrtc/modules/audio_processing/include/audio_processing.h"
22 #include "webrtc/modules/include/module_common_types.h" 22 #include "webrtc/modules/include/module_common_types.h"
23 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 23 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
24 #include "webrtc/voice_engine_configurations.h" 24 #include "webrtc/voice_engine_configurations.h"
25 25
26 namespace webrtc { 26 namespace webrtc {
27 27
28 typedef std::vector<AudioFrame*> AudioFrameList; 28 typedef std::vector<AudioFrame*> AudioFrameList;
29 29
30 class AudioMixerImpl : public AudioMixer { 30 class AudioMixerImpl : public AudioMixer {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 // Add/remove the MixerAudioSource to the specified 77 // Add/remove the MixerAudioSource to the specified
78 // MixerAudioSource list. 78 // MixerAudioSource list.
79 bool AddAudioSourceToList(Source* audio_source, 79 bool AddAudioSourceToList(Source* audio_source,
80 SourceStatusList* audio_source_list) const; 80 SourceStatusList* audio_source_list) const;
81 bool RemoveAudioSourceFromList(Source* remove_audio_source, 81 bool RemoveAudioSourceFromList(Source* remove_audio_source,
82 SourceStatusList* audio_source_list) const; 82 SourceStatusList* audio_source_list) const;
83 83
84 bool LimitMixedAudio(AudioFrame* mixed_audio) const; 84 bool LimitMixedAudio(AudioFrame* mixed_audio) const;
85 85
86 86 // The critical section lock guards audio source insertion and
87 // removal, which can be done from any thread. The race checker
88 // checks that mixing is done sequentially.
87 rtc::CriticalSection crit_; 89 rtc::CriticalSection crit_;
90 rtc::RaceChecker race_checker_;
88 91
89 // The current sample frequency and sample size when mixing. 92 // The current sample frequency and sample size when mixing.
90 int output_frequency_ ACCESS_ON(&thread_checker_); 93 int output_frequency_ GUARDED_BY(race_checker_);
91 size_t sample_size_ ACCESS_ON(&thread_checker_); 94 size_t sample_size_ GUARDED_BY(race_checker_);
92 95
93 // List of all audio sources. Note all lists are disjunct 96 // List of all audio sources. Note all lists are disjunct
94 SourceStatusList audio_source_list_ GUARDED_BY(crit_); // May be mixed. 97 SourceStatusList audio_source_list_ GUARDED_BY(crit_); // May be mixed.
95 98
96 // Determines if we will use a limiter for clipping protection during 99 // Determines if we will use a limiter for clipping protection during
97 // mixing. 100 // mixing.
98 bool use_limiter_ ACCESS_ON(&thread_checker_); 101 bool use_limiter_ GUARDED_BY(race_checker_);
99 102
100 uint32_t time_stamp_ ACCESS_ON(&thread_checker_); 103 uint32_t time_stamp_ GUARDED_BY(race_checker_);
101
102 // Ensures that Mix is called from the same thread.
103 rtc::ThreadChecker thread_checker_;
104 104
105 // Used for inhibiting saturation in mixing. 105 // Used for inhibiting saturation in mixing.
106 std::unique_ptr<AudioProcessing> limiter_ ACCESS_ON(&thread_checker_); 106 std::unique_ptr<AudioProcessing> limiter_ GUARDED_BY(race_checker_);
107 107
108 RTC_DISALLOW_COPY_AND_ASSIGN(AudioMixerImpl); 108 RTC_DISALLOW_COPY_AND_ASSIGN(AudioMixerImpl);
109 }; 109 };
110 } // namespace webrtc 110 } // namespace webrtc
111 111
112 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ 112 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_mixer/audio_mixer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698