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

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

Issue 2286343002: Less lock acquisitions for AudioMixer. (Closed)
Patch Set: A huge pile of messy changes (left because of the comments) Created 4 years, 3 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 /* 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
(...skipping 12 matching lines...) Expand all
23 #include "webrtc/voice_engine/level_indicator.h" 23 #include "webrtc/voice_engine/level_indicator.h"
24 24
25 namespace webrtc { 25 namespace webrtc {
26 class AudioProcessing; 26 class AudioProcessing;
27 class CriticalSectionWrapper; 27 class CriticalSectionWrapper;
28 28
29 struct FrameAndMuteInfo { 29 struct FrameAndMuteInfo {
30 FrameAndMuteInfo(AudioFrame* f, bool m) : frame(f), muted(m) {} 30 FrameAndMuteInfo(AudioFrame* f, bool m) : frame(f), muted(m) {}
31 AudioFrame* frame; 31 AudioFrame* frame;
32 bool muted; 32 bool muted;
33 }; 33 };
kwiberg-webrtc 2016/08/30 16:29:45 Is this struct still used somewhere, or can you re
34 34
35 typedef std::list<FrameAndMuteInfo> AudioFrameList; 35 typedef std::list<AudioFrame*> AudioFrameList;
aleloi 2016/08/30 15:13:34 Mixing structure is a little simplified. Mute info
36 typedef std::list<MixerAudioSource*> MixerAudioSourceList; 36 typedef std::list<MixerAudioSource*> MixerAudioSourceList;
37 37
38 // Cheshire cat implementation of MixerAudioSource's non virtual functions. 38 // Cheshire cat implementation of MixerAudioSource's non virtual functions.
39 class NewMixHistory { 39 class NewMixHistory {
40 public: 40 public:
41 NewMixHistory(); 41 NewMixHistory();
42 ~NewMixHistory(); 42 ~NewMixHistory();
43 43
44 // Returns true if the audio source is being mixed. 44 // Returns true if the audio source is being mixed.
45 bool IsMixed() const; 45 bool IsMixed() const;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 bool AnonymousMixabilityStatus( 81 bool AnonymousMixabilityStatus(
82 const MixerAudioSource& audio_source) const override; 82 const MixerAudioSource& audio_source) const override;
83 83
84 private: 84 private:
85 // Set/get mix frequency 85 // Set/get mix frequency
86 int32_t SetOutputFrequency(const Frequency& frequency); 86 int32_t SetOutputFrequency(const Frequency& frequency);
87 Frequency OutputFrequency() const; 87 Frequency OutputFrequency() const;
88 88
89 // Compute what audio sources to mix from audio_source_list_. Ramp in 89 // Compute what audio sources to mix from audio_source_list_. Ramp in
90 // and out. Update mixed status. maxAudioFrameCounter specifies how 90 // and out. Update mixed status. maxAudioFrameCounter specifies how
91 // many participants are allowed to be mixed. 91 // many participants are allowed to be mixed.
kwiberg-webrtc 2016/08/30 16:29:45 This comment needs updating.
92 AudioFrameList UpdateToMix(size_t maxAudioFrameCounter) const; 92 AudioFrameList GetNonAnonymousAudio() const;
93 93
94 // Return the lowest mixing frequency that can be used without having to 94 // Return the AudioFrames that should be mixed anonymously. Ramp in
95 // downsample any audio. 95 // and out. Update mixed status.
96 int32_t GetLowestMixingFrequency() const; 96 AudioFrameList GetAnonymousAudio() const;
aleloi 2016/08/30 15:13:34 Made naming and signature more consistent between
97 int32_t GetLowestMixingFrequencyFromList(
98 const MixerAudioSourceList& mixList) const;
aleloi 2016/08/30 15:13:34 These two have not been used for the last 3-4 mixe
99
100 // Return the AudioFrames that should be mixed anonymously.
101 void GetAdditionalAudio(AudioFrameList* additionalFramesList) const;
102 97
103 // This function returns true if it finds the MixerAudioSource in the 98 // This function returns true if it finds the MixerAudioSource in the
104 // specified list of MixerAudioSources. 99 // specified list of MixerAudioSources.
105 bool IsAudioSourceInList(const MixerAudioSource& audio_source, 100 bool IsAudioSourceInList(const MixerAudioSource& audio_source,
106 const MixerAudioSourceList& audioSourceList) const; 101 const MixerAudioSourceList& audioSourceList) const;
107 102
108 // Add/remove the MixerAudioSource to the specified 103 // Add/remove the MixerAudioSource to the specified
109 // MixerAudioSource list. 104 // MixerAudioSource list.
110 bool AddAudioSourceToList(MixerAudioSource* audio_source, 105 bool AddAudioSourceToList(MixerAudioSource* audio_source,
111 MixerAudioSourceList* audioSourceList) const; 106 MixerAudioSourceList* audioSourceList) const;
112 bool RemoveAudioSourceFromList(MixerAudioSource* removeAudioSource, 107 bool RemoveAudioSourceFromList(MixerAudioSource* removeAudioSource,
113 MixerAudioSourceList* audioSourceList) const; 108 MixerAudioSourceList* audioSourceList) const;
114 109
115 // Mix the AudioFrames stored in audioFrameList into mixedAudio. 110 // Mix the AudioFrames stored in audioFrameList into mixedAudio.
116 static int32_t MixFromList(AudioFrame* mixedAudio, 111 static int32_t MixFromList(AudioFrame* mixedAudio,
117 const AudioFrameList& audioFrameList, 112 const AudioFrameList& audioFrameList,
118 int32_t id, 113 int32_t id,
119 bool use_limiter); 114 bool use_limiter);
120 115
121 // Mix the AudioFrames stored in audioFrameList into mixedAudio. No
122 // record will be kept of this mix (e.g. the corresponding MixerAudioSources
123 // will not be marked as IsMixed()
124 int32_t MixAnonomouslyFromList(AudioFrame* mixedAudio,
125 const AudioFrameList& audioFrameList) const;
126
aleloi 2016/08/30 15:13:34 Merged with MixFromList
127 bool LimitMixedAudio(AudioFrame* mixedAudio) const; 116 bool LimitMixedAudio(AudioFrame* mixedAudio) const;
128 117
129 // Output level functions for VoEVolumeControl. 118 // Output level functions for VoEVolumeControl.
130 int GetOutputAudioLevel() override; 119 int GetOutputAudioLevel() override;
131 120
132 int GetOutputAudioLevelFullRange() override; 121 int GetOutputAudioLevelFullRange() override;
133 122
134 std::unique_ptr<CriticalSectionWrapper> crit_; 123 std::unique_ptr<CriticalSectionWrapper> crit_;
135 std::unique_ptr<CriticalSectionWrapper> cb_crit_;
aleloi 2016/08/30 15:13:34 I think only one lock is needed. Adding/removing/q
136 124
137 int32_t id_; 125 int32_t id_;
138 126
139 // The current sample frequency and sample size when mixing. 127 // The current sample frequency and sample size when mixing.
140 Frequency output_frequency_; 128 Frequency output_frequency_;
141 size_t sample_size_; 129 size_t sample_size_;
142 130
143 // List of all audio sources. Note all lists are disjunct 131 // List of all audio sources. Note all lists are disjunct
144 MixerAudioSourceList audio_source_list_; // May be mixed. 132 MixerAudioSourceList audio_source_list_; // May be mixed.
145 133
146 // Always mixed, anonomously. 134 // Always mixed, anonymously.
147 MixerAudioSourceList additional_audio_source_list_; 135 MixerAudioSourceList additional_audio_source_list_;
148 136
149 size_t num_mixed_audio_sources_; 137 size_t num_mixed_audio_sources_;
150 // Determines if we will use a limiter for clipping protection during 138 // Determines if we will use a limiter for clipping protection during
151 // mixing. 139 // mixing.
152 bool use_limiter_; 140 bool use_limiter_;
153 141
154 uint32_t time_stamp_; 142 uint32_t time_stamp_;
155 143
156 // Ensures that Mix is called from the same thread. 144 // Ensures that Mix is called from the same thread.
157 rtc::ThreadChecker thread_checker_; 145 rtc::ThreadChecker thread_checker_;
158 146
159 // Used for inhibiting saturation in mixing. 147 // Used for inhibiting saturation in mixing.
160 std::unique_ptr<AudioProcessing> limiter_; 148 std::unique_ptr<AudioProcessing> limiter_;
161 149
162 // Measures audio level for the combined signal. 150 // Measures audio level for the combined signal.
163 voe::AudioLevel audio_level_; 151 voe::AudioLevel audio_level_;
152
153 RTC_DISALLOW_COPY_AND_ASSIGN(AudioMixerImpl);
164 }; 154 };
165 } // namespace webrtc 155 } // namespace webrtc
166 156
167 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_ 157 #endif // WEBRTC_MODULES_AUDIO_MIXER_AUDIO_MIXER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698