blob: 3da1be227071da85ea62b08f4ec3cdf3611286e5 [file] [log] [blame]
aleloi77ad3942016-07-04 06:33:02 -07001/*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
aleloi5d167d62016-08-24 02:20:54 -070011#include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
aleloi77ad3942016-07-04 06:33:02 -070012
13#include <algorithm>
aleloif3882572016-07-29 02:12:41 -070014#include <functional>
aleloi623427c2016-12-08 02:37:58 -080015#include <iterator>
aleloi311525e2016-09-07 06:13:12 -070016#include <utility>
aleloi77ad3942016-07-04 06:33:02 -070017
aleloi6321b492016-12-05 01:46:09 -080018#include "webrtc/audio/utility/audio_frame_operations.h"
aleloi36542512016-10-07 05:28:32 -070019#include "webrtc/base/logging.h"
aleloi5bcc00e2016-08-15 03:01:31 -070020#include "webrtc/modules/audio_mixer/audio_frame_manipulator.h"
aleloi623427c2016-12-08 02:37:58 -080021#include "webrtc/modules/audio_mixer/default_output_rate_calculator.h"
aleloi77ad3942016-07-04 06:33:02 -070022
23namespace webrtc {
24namespace {
25
aleloi4b8bfb82016-10-12 02:14:59 -070026struct SourceFrame {
27 SourceFrame(AudioMixerImpl::SourceStatus* source_status,
aleloi36542512016-10-07 05:28:32 -070028 AudioFrame* audio_frame,
29 bool muted)
aleloi4b8bfb82016-10-12 02:14:59 -070030 : source_status(source_status), audio_frame(audio_frame), muted(muted) {
31 RTC_DCHECK(source_status);
32 RTC_DCHECK(audio_frame);
33 if (!muted) {
34 energy = AudioMixerCalculateEnergy(*audio_frame);
aleloif3882572016-07-29 02:12:41 -070035 }
36 }
aleloi77ad3942016-07-04 06:33:02 -070037
aleloi4b8bfb82016-10-12 02:14:59 -070038 SourceFrame(AudioMixerImpl::SourceStatus* source_status,
aleloi36542512016-10-07 05:28:32 -070039 AudioFrame* audio_frame,
40 bool muted,
aleloi652ac892016-09-07 07:42:14 -070041 uint32_t energy)
aleloi4b8bfb82016-10-12 02:14:59 -070042 : source_status(source_status),
43 audio_frame(audio_frame),
44 muted(muted),
45 energy(energy) {
46 RTC_DCHECK(source_status);
47 RTC_DCHECK(audio_frame);
aleloif3882572016-07-29 02:12:41 -070048 }
49
aleloi4b8bfb82016-10-12 02:14:59 -070050 AudioMixerImpl::SourceStatus* source_status = nullptr;
51 AudioFrame* audio_frame = nullptr;
52 bool muted = true;
53 uint32_t energy = 0;
aleloif3882572016-07-29 02:12:41 -070054};
tereliusea4c1412016-07-29 01:36:14 -070055
aleloi4b8bfb82016-10-12 02:14:59 -070056// ShouldMixBefore(a, b) is used to select mixer sources.
57bool ShouldMixBefore(const SourceFrame& a, const SourceFrame& b) {
58 if (a.muted != b.muted) {
59 return b.muted;
60 }
aleloi44968092016-08-08 10:18:58 -070061
aleloi4b8bfb82016-10-12 02:14:59 -070062 const auto a_activity = a.audio_frame->vad_activity_;
63 const auto b_activity = b.audio_frame->vad_activity_;
64
65 if (a_activity != b_activity) {
66 return a_activity == AudioFrame::kVadActive;
67 }
68
69 return a.energy > b.energy;
70}
71
72void RampAndUpdateGain(
73 const std::vector<SourceFrame>& mixed_sources_and_frames) {
aleloi652ac892016-09-07 07:42:14 -070074 for (const auto& source_frame : mixed_sources_and_frames) {
aleloi4b8bfb82016-10-12 02:14:59 -070075 float target_gain = source_frame.source_status->is_mixed ? 1.0f : 0.0f;
76 Ramp(source_frame.source_status->gain, target_gain,
77 source_frame.audio_frame);
78 source_frame.source_status->gain = target_gain;
aleloi77ad3942016-07-04 06:33:02 -070079 }
aleloi77ad3942016-07-04 06:33:02 -070080}
81
aleloidc7669a2016-10-04 04:06:20 -070082// Mix the AudioFrames stored in audioFrameList into mixed_audio.
83int32_t MixFromList(AudioFrame* mixed_audio,
84 const AudioFrameList& audio_frame_list,
aleloidc7669a2016-10-04 04:06:20 -070085 bool use_limiter) {
aleloie97974d2016-10-12 03:06:09 -070086 if (audio_frame_list.empty()) {
aleloidc7669a2016-10-04 04:06:20 -070087 return 0;
aleloie97974d2016-10-12 03:06:09 -070088 }
aleloi77ad3942016-07-04 06:33:02 -070089
aleloidc7669a2016-10-04 04:06:20 -070090 if (audio_frame_list.size() == 1) {
91 mixed_audio->timestamp_ = audio_frame_list.front()->timestamp_;
92 mixed_audio->elapsed_time_ms_ = audio_frame_list.front()->elapsed_time_ms_;
93 } else {
94 // TODO(wu): Issue 3390.
95 // Audio frame timestamp is only supported in one channel case.
96 mixed_audio->timestamp_ = 0;
97 mixed_audio->elapsed_time_ms_ = -1;
98 }
aleloi77ad3942016-07-04 06:33:02 -070099
aleloidc7669a2016-10-04 04:06:20 -0700100 for (const auto& frame : audio_frame_list) {
101 RTC_DCHECK_EQ(mixed_audio->sample_rate_hz_, frame->sample_rate_hz_);
102 RTC_DCHECK_EQ(
103 frame->samples_per_channel_,
104 static_cast<size_t>((mixed_audio->sample_rate_hz_ *
105 webrtc::AudioMixerImpl::kFrameDurationInMs) /
106 1000));
aleloi77ad3942016-07-04 06:33:02 -0700107
aleloidc7669a2016-10-04 04:06:20 -0700108 // Mix |f.frame| into |mixed_audio|, with saturation protection.
109 // These effect is applied to |f.frame| itself prior to mixing.
110 if (use_limiter) {
aleloi6321b492016-12-05 01:46:09 -0800111 // This is to avoid saturation in the mixing. It is only
112 // meaningful if the limiter will be used.
113 AudioFrameOperations::ApplyHalfGain(frame);
aleloidc7669a2016-10-04 04:06:20 -0700114 }
115 RTC_DCHECK_EQ(frame->num_channels_, mixed_audio->num_channels_);
aleloi6321b492016-12-05 01:46:09 -0800116 AudioFrameOperations::Add(*frame, mixed_audio);
aleloidc7669a2016-10-04 04:06:20 -0700117 }
aleloi77ad3942016-07-04 06:33:02 -0700118 return 0;
119}
120
aleloi4b8bfb82016-10-12 02:14:59 -0700121AudioMixerImpl::SourceStatusList::const_iterator FindSourceInList(
aleloie8914152016-10-11 06:18:31 -0700122 AudioMixerImpl::Source const* audio_source,
aleloi4b8bfb82016-10-12 02:14:59 -0700123 AudioMixerImpl::SourceStatusList const* audio_source_list) {
aleloi6c278492016-10-20 14:24:39 -0700124 return std::find_if(
125 audio_source_list->begin(), audio_source_list->end(),
126 [audio_source](const std::unique_ptr<AudioMixerImpl::SourceStatus>& p) {
127 return p->audio_source == audio_source;
128 });
aleloi36542512016-10-07 05:28:32 -0700129}
130
aleloie97974d2016-10-12 03:06:09 -0700131// TODO(aleloi): remove non-const version when WEBRTC only supports modern STL.
aleloi4b8bfb82016-10-12 02:14:59 -0700132AudioMixerImpl::SourceStatusList::iterator FindSourceInList(
aleloie8914152016-10-11 06:18:31 -0700133 AudioMixerImpl::Source const* audio_source,
aleloi4b8bfb82016-10-12 02:14:59 -0700134 AudioMixerImpl::SourceStatusList* audio_source_list) {
aleloi6c278492016-10-20 14:24:39 -0700135 return std::find_if(
136 audio_source_list->begin(), audio_source_list->end(),
137 [audio_source](const std::unique_ptr<AudioMixerImpl::SourceStatus>& p) {
138 return p->audio_source == audio_source;
139 });
aleloi36542512016-10-07 05:28:32 -0700140}
141
aleloi623427c2016-12-08 02:37:58 -0800142std::unique_ptr<AudioProcessing> CreateLimiter() {
aleloi77ad3942016-07-04 06:33:02 -0700143 Config config;
144 config.Set<ExperimentalAgc>(new ExperimentalAgc(false));
aleloi311525e2016-09-07 06:13:12 -0700145 std::unique_ptr<AudioProcessing> limiter(AudioProcessing::Create(config));
aleloie97974d2016-10-12 03:06:09 -0700146 if (!limiter.get()) {
aleloi311525e2016-09-07 06:13:12 -0700147 return nullptr;
aleloie97974d2016-10-12 03:06:09 -0700148 }
aleloi77ad3942016-07-04 06:33:02 -0700149
aleloi311525e2016-09-07 06:13:12 -0700150 if (limiter->gain_control()->set_mode(GainControl::kFixedDigital) !=
aleloie97974d2016-10-12 03:06:09 -0700151 limiter->kNoError) {
aleloi311525e2016-09-07 06:13:12 -0700152 return nullptr;
aleloie97974d2016-10-12 03:06:09 -0700153 }
aleloi77ad3942016-07-04 06:33:02 -0700154
155 // We smoothly limit the mixed frame to -7 dbFS. -6 would correspond to the
156 // divide-by-2 but -7 is used instead to give a bit of headroom since the
157 // AGC is not a hard limiter.
aleloie97974d2016-10-12 03:06:09 -0700158 if (limiter->gain_control()->set_target_level_dbfs(7) != limiter->kNoError) {
aleloi311525e2016-09-07 06:13:12 -0700159 return nullptr;
aleloie97974d2016-10-12 03:06:09 -0700160 }
aleloi77ad3942016-07-04 06:33:02 -0700161
aleloie97974d2016-10-12 03:06:09 -0700162 if (limiter->gain_control()->set_compression_gain_db(0) !=
163 limiter->kNoError) {
aleloi311525e2016-09-07 06:13:12 -0700164 return nullptr;
aleloie97974d2016-10-12 03:06:09 -0700165 }
aleloi77ad3942016-07-04 06:33:02 -0700166
aleloie97974d2016-10-12 03:06:09 -0700167 if (limiter->gain_control()->enable_limiter(true) != limiter->kNoError) {
aleloi311525e2016-09-07 06:13:12 -0700168 return nullptr;
aleloie97974d2016-10-12 03:06:09 -0700169 }
aleloi77ad3942016-07-04 06:33:02 -0700170
aleloie97974d2016-10-12 03:06:09 -0700171 if (limiter->gain_control()->Enable(true) != limiter->kNoError) {
aleloi311525e2016-09-07 06:13:12 -0700172 return nullptr;
aleloie97974d2016-10-12 03:06:09 -0700173 }
aleloi623427c2016-12-08 02:37:58 -0800174 return limiter;
175}
aleloi77ad3942016-07-04 06:33:02 -0700176
aleloi623427c2016-12-08 02:37:58 -0800177} // namespace
178
179AudioMixerImpl::AudioMixerImpl(
180 std::unique_ptr<AudioProcessing> limiter,
181 std::unique_ptr<OutputRateCalculator> output_rate_calculator)
182 : output_rate_calculator_(std::move(output_rate_calculator)),
183 output_frequency_(0),
184 sample_size_(0),
185 audio_source_list_(),
186 use_limiter_(true),
187 time_stamp_(0),
188 limiter_(std::move(limiter)) {}
189
190AudioMixerImpl::~AudioMixerImpl() {}
191
192rtc::scoped_refptr<AudioMixerImpl> AudioMixerImpl::Create() {
193 return CreateWithOutputRateCalculator(
194 std::unique_ptr<DefaultOutputRateCalculator>(
195 new DefaultOutputRateCalculator()));
196}
197
198rtc::scoped_refptr<AudioMixerImpl>
199AudioMixerImpl::CreateWithOutputRateCalculator(
200 std::unique_ptr<OutputRateCalculator> output_rate_calculator) {
aleloi116ec6d2016-10-12 06:07:07 -0700201 return rtc::scoped_refptr<AudioMixerImpl>(
aleloi623427c2016-12-08 02:37:58 -0800202 new rtc::RefCountedObject<AudioMixerImpl>(
203 CreateLimiter(), std::move(output_rate_calculator)));
aleloi77ad3942016-07-04 06:33:02 -0700204}
205
aleloi95611832016-11-08 06:39:50 -0800206void AudioMixerImpl::Mix(size_t number_of_channels,
aleloi5d167d62016-08-24 02:20:54 -0700207 AudioFrame* audio_frame_for_mixing) {
aleloi44968092016-08-08 10:18:58 -0700208 RTC_DCHECK(number_of_channels == 1 || number_of_channels == 2);
aleloi920d30b2016-10-20 14:23:24 -0700209 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
aleloi311525e2016-09-07 06:13:12 -0700210
aleloi623427c2016-12-08 02:37:58 -0800211 CalculateOutputFrequency();
aleloi311525e2016-09-07 06:13:12 -0700212
aleloi652ac892016-09-07 07:42:14 -0700213 AudioFrameList mix_list;
aleloi77ad3942016-07-04 06:33:02 -0700214 {
aleloi311525e2016-09-07 06:13:12 -0700215 rtc::CritScope lock(&crit_);
aleloi116ec6d2016-10-12 06:07:07 -0700216 mix_list = GetAudioFromSources();
aleloi1655e452016-10-24 06:56:56 -0700217
218 for (const auto& frame : mix_list) {
219 RemixFrame(number_of_channels, frame);
220 }
221
222 audio_frame_for_mixing->UpdateFrame(
223 -1, time_stamp_, NULL, 0, OutputFrequency(), AudioFrame::kNormalSpeech,
224 AudioFrame::kVadPassive, number_of_channels);
225
226 time_stamp_ += static_cast<uint32_t>(sample_size_);
227
228 use_limiter_ = mix_list.size() > 1;
229
230 // We only use the limiter if we're actually mixing multiple streams.
231 MixFromList(audio_frame_for_mixing, mix_list, use_limiter_);
aleloi77ad3942016-07-04 06:33:02 -0700232 }
233
aleloi311525e2016-09-07 06:13:12 -0700234 if (audio_frame_for_mixing->samples_per_channel_ == 0) {
235 // Nothing was mixed, set the audio samples to silence.
236 audio_frame_for_mixing->samples_per_channel_ = sample_size_;
aleloi6321b492016-12-05 01:46:09 -0800237 AudioFrameOperations::Mute(audio_frame_for_mixing);
aleloi311525e2016-09-07 06:13:12 -0700238 } else {
239 // Only call the limiter if we have something to mix.
240 LimitMixedAudio(audio_frame_for_mixing);
aleloi77ad3942016-07-04 06:33:02 -0700241 }
aleloi616df1e2016-08-24 01:17:12 -0700242
aleloi77ad3942016-07-04 06:33:02 -0700243 return;
244}
245
aleloi623427c2016-12-08 02:37:58 -0800246void AudioMixerImpl::CalculateOutputFrequency() {
aleloi920d30b2016-10-20 14:23:24 -0700247 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
aleloi623427c2016-12-08 02:37:58 -0800248 rtc::CritScope lock(&crit_);
249
250 std::vector<int> preferred_rates;
251 std::transform(audio_source_list_.begin(), audio_source_list_.end(),
252 std::back_inserter(preferred_rates),
253 [&](std::unique_ptr<SourceStatus>& a) {
254 return a->audio_source->PreferredSampleRate();
255 });
256
257 output_frequency_ =
258 output_rate_calculator_->CalculateOutputRate(preferred_rates);
aleloidc7669a2016-10-04 04:06:20 -0700259 sample_size_ = (output_frequency_ * kFrameDurationInMs) / 1000;
aleloi77ad3942016-07-04 06:33:02 -0700260}
261
aleloie97974d2016-10-12 03:06:09 -0700262int AudioMixerImpl::OutputFrequency() const {
aleloi920d30b2016-10-20 14:23:24 -0700263 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
aleloi6382a192016-08-08 10:25:04 -0700264 return output_frequency_;
aleloi77ad3942016-07-04 06:33:02 -0700265}
266
aleloi116ec6d2016-10-12 06:07:07 -0700267bool AudioMixerImpl::AddSource(Source* audio_source) {
268 RTC_DCHECK(audio_source);
269 rtc::CritScope lock(&crit_);
270 RTC_DCHECK(FindSourceInList(audio_source, &audio_source_list_) ==
271 audio_source_list_.end())
272 << "Source already added to mixer";
aleloi6c278492016-10-20 14:24:39 -0700273 audio_source_list_.emplace_back(new SourceStatus(audio_source, false, 0));
aleloi116ec6d2016-10-12 06:07:07 -0700274 return true;
aleloi77ad3942016-07-04 06:33:02 -0700275}
276
aleloi76b30492016-11-18 02:03:04 -0800277void AudioMixerImpl::RemoveSource(Source* audio_source) {
aleloi116ec6d2016-10-12 06:07:07 -0700278 RTC_DCHECK(audio_source);
279 rtc::CritScope lock(&crit_);
280 const auto iter = FindSourceInList(audio_source, &audio_source_list_);
281 RTC_DCHECK(iter != audio_source_list_.end()) << "Source not present in mixer";
282 audio_source_list_.erase(iter);
aleloi116ec6d2016-10-12 06:07:07 -0700283}
aleloi77ad3942016-07-04 06:33:02 -0700284
aleloi116ec6d2016-10-12 06:07:07 -0700285AudioFrameList AudioMixerImpl::GetAudioFromSources() {
aleloi920d30b2016-10-20 14:23:24 -0700286 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
aleloif3882572016-07-29 02:12:41 -0700287 AudioFrameList result;
aleloia4c21062016-09-08 01:25:46 -0700288 std::vector<SourceFrame> audio_source_mixing_data_list;
aleloi652ac892016-09-07 07:42:14 -0700289 std::vector<SourceFrame> ramp_list;
aleloi77ad3942016-07-04 06:33:02 -0700290
aleloi6c278492016-10-20 14:24:39 -0700291 // Get audio from the audio sources and put it in the SourceFrame vector.
aleloi36542512016-10-07 05:28:32 -0700292 for (auto& source_and_status : audio_source_list_) {
aleloi6c278492016-10-20 14:24:39 -0700293 const auto audio_frame_info =
294 source_and_status->audio_source->GetAudioFrameWithInfo(
295 OutputFrequency(), &source_and_status->audio_frame);
aleloif3882572016-07-29 02:12:41 -0700296
aleloie8914152016-10-11 06:18:31 -0700297 if (audio_frame_info == Source::AudioFrameInfo::kError) {
aleloie97974d2016-10-12 03:06:09 -0700298 LOG_F(LS_WARNING) << "failed to GetAudioFrameWithInfo() from source";
tereliusea4c1412016-07-29 01:36:14 -0700299 continue;
300 }
aleloia4c21062016-09-08 01:25:46 -0700301 audio_source_mixing_data_list.emplace_back(
aleloi6c278492016-10-20 14:24:39 -0700302 source_and_status.get(), &source_and_status->audio_frame,
aleloie8914152016-10-11 06:18:31 -0700303 audio_frame_info == Source::AudioFrameInfo::kMuted);
aleloif3882572016-07-29 02:12:41 -0700304 }
305
306 // Sort frames by sorting function.
aleloia4c21062016-09-08 01:25:46 -0700307 std::sort(audio_source_mixing_data_list.begin(),
aleloi4b8bfb82016-10-12 02:14:59 -0700308 audio_source_mixing_data_list.end(), ShouldMixBefore);
aleloif3882572016-07-29 02:12:41 -0700309
aleloia4c21062016-09-08 01:25:46 -0700310 int max_audio_frame_counter = kMaximumAmountOfMixedAudioSources;
311
312 // Go through list in order and put unmuted frames in result list.
aleloi36542512016-10-07 05:28:32 -0700313 for (const auto& p : audio_source_mixing_data_list) {
aleloif3882572016-07-29 02:12:41 -0700314 // Filter muted.
aleloi4b8bfb82016-10-12 02:14:59 -0700315 if (p.muted) {
316 p.source_status->is_mixed = false;
aleloif3882572016-07-29 02:12:41 -0700317 continue;
tereliusea4c1412016-07-29 01:36:14 -0700318 }
aleloi2942e242016-07-29 01:23:49 -0700319
aleloif3882572016-07-29 02:12:41 -0700320 // Add frame to result vector for mixing.
321 bool is_mixed = false;
aleloia4c21062016-09-08 01:25:46 -0700322 if (max_audio_frame_counter > 0) {
323 --max_audio_frame_counter;
aleloi4b8bfb82016-10-12 02:14:59 -0700324 result.push_back(p.audio_frame);
325 ramp_list.emplace_back(p.source_status, p.audio_frame, false, -1);
aleloif3882572016-07-29 02:12:41 -0700326 is_mixed = true;
tereliusea4c1412016-07-29 01:36:14 -0700327 }
aleloi4b8bfb82016-10-12 02:14:59 -0700328 p.source_status->is_mixed = is_mixed;
tereliusea4c1412016-07-29 01:36:14 -0700329 }
aleloi4b8bfb82016-10-12 02:14:59 -0700330 RampAndUpdateGain(ramp_list);
aleloif3882572016-07-29 02:12:41 -0700331 return result;
aleloi77ad3942016-07-04 06:33:02 -0700332}
333
aleloi77ad3942016-07-04 06:33:02 -0700334
aleloia4c21062016-09-08 01:25:46 -0700335bool AudioMixerImpl::LimitMixedAudio(AudioFrame* mixed_audio) const {
aleloi920d30b2016-10-20 14:23:24 -0700336 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
aleloi77ad3942016-07-04 06:33:02 -0700337 if (!use_limiter_) {
338 return true;
339 }
340
341 // Smoothly limit the mixed frame.
aleloia4c21062016-09-08 01:25:46 -0700342 const int error = limiter_->ProcessStream(mixed_audio);
aleloi77ad3942016-07-04 06:33:02 -0700343
344 // And now we can safely restore the level. This procedure results in
345 // some loss of resolution, deemed acceptable.
346 //
347 // It's possible to apply the gain in the AGC (with a target level of 0 dbFS
348 // and compression gain of 6 dB). However, in the transition frame when this
aleloi09f45102016-07-28 03:52:15 -0700349 // is enabled (moving from one to two audio sources) it has the potential to
aleloi77ad3942016-07-04 06:33:02 -0700350 // create discontinuities in the mixed frame.
351 //
352 // Instead we double the frame (with addition since left-shifting a
353 // negative value is undefined).
aleloi6321b492016-12-05 01:46:09 -0800354 AudioFrameOperations::Add(*mixed_audio, mixed_audio);
aleloi77ad3942016-07-04 06:33:02 -0700355
aleloi6382a192016-08-08 10:25:04 -0700356 if (error != limiter_->kNoError) {
aleloie97974d2016-10-12 03:06:09 -0700357 LOG_F(LS_ERROR) << "Error from AudioProcessing: " << error;
aleloi09f45102016-07-28 03:52:15 -0700358 RTC_NOTREACHED();
aleloi77ad3942016-07-04 06:33:02 -0700359 return false;
360 }
361 return true;
362}
aleloi616df1e2016-08-24 01:17:12 -0700363
aleloi36542512016-10-07 05:28:32 -0700364bool AudioMixerImpl::GetAudioSourceMixabilityStatusForTest(
aleloie97974d2016-10-12 03:06:09 -0700365 AudioMixerImpl::Source* audio_source) const {
aleloi920d30b2016-10-20 14:23:24 -0700366 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
aleloi36542512016-10-07 05:28:32 -0700367 rtc::CritScope lock(&crit_);
368
aleloi6c278492016-10-20 14:24:39 -0700369 const auto iter = FindSourceInList(audio_source, &audio_source_list_);
370 if (iter != audio_source_list_.end()) {
371 return (*iter)->is_mixed;
aleloi36542512016-10-07 05:28:32 -0700372 }
373
aleloi36542512016-10-07 05:28:32 -0700374 LOG(LS_ERROR) << "Audio source unknown";
375 return false;
376}
aleloi77ad3942016-07-04 06:33:02 -0700377} // namespace webrtc