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

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

Issue 2439283002: Elimiteted race condition in the AudioMixer. (Closed)
Patch Set: Removed previous change, now holding lock a little longer. Created 4 years, 1 month 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 | « webrtc/modules/audio_mixer/audio_mixer_impl.h ('k') | no next file » | 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
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_); 193 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
194 194
195 if (OutputFrequency() != sample_rate) { 195 if (OutputFrequency() != sample_rate) {
196 SetOutputFrequency(sample_rate); 196 SetOutputFrequency(sample_rate);
197 } 197 }
198 198
199 AudioFrameList mix_list; 199 AudioFrameList mix_list;
200 { 200 {
201 rtc::CritScope lock(&crit_); 201 rtc::CritScope lock(&crit_);
202 mix_list = GetAudioFromSources(); 202 mix_list = GetAudioFromSources();
203
204 for (const auto& frame : mix_list) {
205 RemixFrame(number_of_channels, frame);
206 }
207
208 audio_frame_for_mixing->UpdateFrame(
209 -1, time_stamp_, NULL, 0, OutputFrequency(), AudioFrame::kNormalSpeech,
210 AudioFrame::kVadPassive, number_of_channels);
211
212 time_stamp_ += static_cast<uint32_t>(sample_size_);
213
214 use_limiter_ = mix_list.size() > 1;
215
216 // We only use the limiter if we're actually mixing multiple streams.
217 MixFromList(audio_frame_for_mixing, mix_list, use_limiter_);
203 } 218 }
204 219
205 for (const auto& frame : mix_list) {
206 RemixFrame(number_of_channels, frame);
207 }
208
209 audio_frame_for_mixing->UpdateFrame(
210 -1, time_stamp_, NULL, 0, OutputFrequency(), AudioFrame::kNormalSpeech,
211 AudioFrame::kVadPassive, number_of_channels);
212
213 time_stamp_ += static_cast<uint32_t>(sample_size_);
214
215 use_limiter_ = mix_list.size() > 1;
216
217 // We only use the limiter if we're actually mixing multiple streams.
218 MixFromList(audio_frame_for_mixing, mix_list, use_limiter_);
219
220 if (audio_frame_for_mixing->samples_per_channel_ == 0) { 220 if (audio_frame_for_mixing->samples_per_channel_ == 0) {
221 // Nothing was mixed, set the audio samples to silence. 221 // Nothing was mixed, set the audio samples to silence.
222 audio_frame_for_mixing->samples_per_channel_ = sample_size_; 222 audio_frame_for_mixing->samples_per_channel_ = sample_size_;
223 audio_frame_for_mixing->Mute(); 223 audio_frame_for_mixing->Mute();
224 } else { 224 } else {
225 // Only call the limiter if we have something to mix. 225 // Only call the limiter if we have something to mix.
226 LimitMixedAudio(audio_frame_for_mixing); 226 LimitMixedAudio(audio_frame_for_mixing);
227 } 227 }
228 228
229 return; 229 return;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 345
346 const auto iter = FindSourceInList(audio_source, &audio_source_list_); 346 const auto iter = FindSourceInList(audio_source, &audio_source_list_);
347 if (iter != audio_source_list_.end()) { 347 if (iter != audio_source_list_.end()) {
348 return (*iter)->is_mixed; 348 return (*iter)->is_mixed;
349 } 349 }
350 350
351 LOG(LS_ERROR) << "Audio source unknown"; 351 LOG(LS_ERROR) << "Audio source unknown";
352 return false; 352 return false;
353 } 353 }
354 } // namespace webrtc 354 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_mixer/audio_mixer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698