blob: d7025f9e671279fc73bd7152f55663228c8a005a [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>
aleloi311525e2016-09-07 06:13:12 -070015#include <utility>
aleloi77ad3942016-07-04 06:33:02 -070016
aleloi36542512016-10-07 05:28:32 -070017#include "webrtc/base/logging.h"
aleloi5bcc00e2016-08-15 03:01:31 -070018#include "webrtc/modules/audio_mixer/audio_frame_manipulator.h"
aleloi77ad3942016-07-04 06:33:02 -070019#include "webrtc/modules/utility/include/audio_frame_operations.h"
aleloi77ad3942016-07-04 06:33:02 -070020
21namespace webrtc {
22namespace {
23
aleloi4b8bfb82016-10-12 02:14:59 -070024struct SourceFrame {
25 SourceFrame(AudioMixerImpl::SourceStatus* source_status,
aleloi36542512016-10-07 05:28:32 -070026 AudioFrame* audio_frame,
27 bool muted)
aleloi4b8bfb82016-10-12 02:14:59 -070028 : source_status(source_status), audio_frame(audio_frame), muted(muted) {
29 RTC_DCHECK(source_status);
30 RTC_DCHECK(audio_frame);
31 if (!muted) {
32 energy = AudioMixerCalculateEnergy(*audio_frame);
aleloif3882572016-07-29 02:12:41 -070033 }
34 }
aleloi77ad3942016-07-04 06:33:02 -070035
aleloi4b8bfb82016-10-12 02:14:59 -070036 SourceFrame(AudioMixerImpl::SourceStatus* source_status,
aleloi36542512016-10-07 05:28:32 -070037 AudioFrame* audio_frame,
38 bool muted,
aleloi652ac892016-09-07 07:42:14 -070039 uint32_t energy)
aleloi4b8bfb82016-10-12 02:14:59 -070040 : source_status(source_status),
41 audio_frame(audio_frame),
42 muted(muted),
43 energy(energy) {
44 RTC_DCHECK(source_status);
45 RTC_DCHECK(audio_frame);
aleloif3882572016-07-29 02:12:41 -070046 }
47
aleloi4b8bfb82016-10-12 02:14:59 -070048 AudioMixerImpl::SourceStatus* source_status = nullptr;
49 AudioFrame* audio_frame = nullptr;
50 bool muted = true;
51 uint32_t energy = 0;
aleloif3882572016-07-29 02:12:41 -070052};
tereliusea4c1412016-07-29 01:36:14 -070053
aleloi4b8bfb82016-10-12 02:14:59 -070054// ShouldMixBefore(a, b) is used to select mixer sources.
55bool ShouldMixBefore(const SourceFrame& a, const SourceFrame& b) {
56 if (a.muted != b.muted) {
57 return b.muted;
58 }
aleloi44968092016-08-08 10:18:58 -070059
aleloi4b8bfb82016-10-12 02:14:59 -070060 const auto a_activity = a.audio_frame->vad_activity_;
61 const auto b_activity = b.audio_frame->vad_activity_;
62
63 if (a_activity != b_activity) {
64 return a_activity == AudioFrame::kVadActive;
65 }
66
67 return a.energy > b.energy;
68}
69
70void RampAndUpdateGain(
71 const std::vector<SourceFrame>& mixed_sources_and_frames) {
aleloi652ac892016-09-07 07:42:14 -070072 for (const auto& source_frame : mixed_sources_and_frames) {
aleloi4b8bfb82016-10-12 02:14:59 -070073 float target_gain = source_frame.source_status->is_mixed ? 1.0f : 0.0f;
74 Ramp(source_frame.source_status->gain, target_gain,
75 source_frame.audio_frame);
76 source_frame.source_status->gain = target_gain;
aleloi77ad3942016-07-04 06:33:02 -070077 }
aleloi77ad3942016-07-04 06:33:02 -070078}
79
aleloidc7669a2016-10-04 04:06:20 -070080// Mix the AudioFrames stored in audioFrameList into mixed_audio.
81int32_t MixFromList(AudioFrame* mixed_audio,
82 const AudioFrameList& audio_frame_list,
aleloidc7669a2016-10-04 04:06:20 -070083 bool use_limiter) {
aleloie97974d2016-10-12 03:06:09 -070084 if (audio_frame_list.empty()) {
aleloidc7669a2016-10-04 04:06:20 -070085 return 0;
aleloie97974d2016-10-12 03:06:09 -070086 }
aleloi77ad3942016-07-04 06:33:02 -070087
aleloidc7669a2016-10-04 04:06:20 -070088 if (audio_frame_list.size() == 1) {
89 mixed_audio->timestamp_ = audio_frame_list.front()->timestamp_;
90 mixed_audio->elapsed_time_ms_ = audio_frame_list.front()->elapsed_time_ms_;
91 } else {
92 // TODO(wu): Issue 3390.
93 // Audio frame timestamp is only supported in one channel case.
94 mixed_audio->timestamp_ = 0;
95 mixed_audio->elapsed_time_ms_ = -1;
96 }
aleloi77ad3942016-07-04 06:33:02 -070097
aleloidc7669a2016-10-04 04:06:20 -070098 for (const auto& frame : audio_frame_list) {
99 RTC_DCHECK_EQ(mixed_audio->sample_rate_hz_, frame->sample_rate_hz_);
100 RTC_DCHECK_EQ(
101 frame->samples_per_channel_,
102 static_cast<size_t>((mixed_audio->sample_rate_hz_ *
103 webrtc::AudioMixerImpl::kFrameDurationInMs) /
104 1000));
aleloi77ad3942016-07-04 06:33:02 -0700105
aleloidc7669a2016-10-04 04:06:20 -0700106 // Mix |f.frame| into |mixed_audio|, with saturation protection.
107 // These effect is applied to |f.frame| itself prior to mixing.
108 if (use_limiter) {
109 // Divide by two to avoid saturation in the mixing.
110 // This is only meaningful if the limiter will be used.
111 *frame >>= 1;
112 }
113 RTC_DCHECK_EQ(frame->num_channels_, mixed_audio->num_channels_);
114 *mixed_audio += *frame;
115 }
aleloi77ad3942016-07-04 06:33:02 -0700116 return 0;
117}
118
aleloi4b8bfb82016-10-12 02:14:59 -0700119AudioMixerImpl::SourceStatusList::const_iterator FindSourceInList(
aleloie8914152016-10-11 06:18:31 -0700120 AudioMixerImpl::Source const* audio_source,
aleloi4b8bfb82016-10-12 02:14:59 -0700121 AudioMixerImpl::SourceStatusList const* audio_source_list) {
aleloi6c278492016-10-20 14:24:39 -0700122 return std::find_if(
123 audio_source_list->begin(), audio_source_list->end(),
124 [audio_source](const std::unique_ptr<AudioMixerImpl::SourceStatus>& p) {
125 return p->audio_source == audio_source;
126 });
aleloi36542512016-10-07 05:28:32 -0700127}
128
aleloie97974d2016-10-12 03:06:09 -0700129// TODO(aleloi): remove non-const version when WEBRTC only supports modern STL.
aleloi4b8bfb82016-10-12 02:14:59 -0700130AudioMixerImpl::SourceStatusList::iterator FindSourceInList(
aleloie8914152016-10-11 06:18:31 -0700131 AudioMixerImpl::Source const* audio_source,
aleloi4b8bfb82016-10-12 02:14:59 -0700132 AudioMixerImpl::SourceStatusList* audio_source_list) {
aleloi6c278492016-10-20 14:24:39 -0700133 return std::find_if(
134 audio_source_list->begin(), audio_source_list->end(),
135 [audio_source](const std::unique_ptr<AudioMixerImpl::SourceStatus>& p) {
136 return p->audio_source == audio_source;
137 });
aleloi36542512016-10-07 05:28:32 -0700138}
139
aleloi95611832016-11-08 06:39:50 -0800140// Rounds the maximal audio source frequency up to an APM-native
141// frequency.
142int CalculateMixingFrequency(
143 const AudioMixerImpl::SourceStatusList& audio_source_list) {
144 if (audio_source_list.empty()) {
145 return AudioMixerImpl::kDefaultFrequency;
146 }
147 using NativeRate = AudioProcessing::NativeRate;
148 int maximal_frequency = 0;
149 for (const auto& source_status : audio_source_list) {
150 const int source_needed_frequency =
151 source_status->audio_source->PreferredSampleRate();
152 RTC_DCHECK_LE(NativeRate::kSampleRate8kHz, source_needed_frequency);
153 RTC_DCHECK_LE(source_needed_frequency, NativeRate::kSampleRate48kHz);
154 maximal_frequency = std::max(maximal_frequency, source_needed_frequency);
155 }
156
157 static constexpr NativeRate native_rates[] = {
158 NativeRate::kSampleRate8kHz, NativeRate::kSampleRate16kHz,
159 NativeRate::kSampleRate32kHz, NativeRate::kSampleRate48kHz};
160 const auto rounded_up_index = std::lower_bound(
161 std::begin(native_rates), std::end(native_rates), maximal_frequency);
162 RTC_DCHECK(rounded_up_index != std::end(native_rates));
163 return *rounded_up_index;
164}
165
aleloidc7669a2016-10-04 04:06:20 -0700166} // namespace
aleloi77ad3942016-07-04 06:33:02 -0700167
aleloie97974d2016-10-12 03:06:09 -0700168AudioMixerImpl::AudioMixerImpl(std::unique_ptr<AudioProcessing> limiter)
169 : audio_source_list_(),
aleloi77ad3942016-07-04 06:33:02 -0700170 use_limiter_(true),
aleloi311525e2016-09-07 06:13:12 -0700171 time_stamp_(0),
172 limiter_(std::move(limiter)) {
173 SetOutputFrequency(kDefaultFrequency);
aleloia0db81f2016-07-28 06:36:22 -0700174}
aleloi77ad3942016-07-04 06:33:02 -0700175
aleloi5d167d62016-08-24 02:20:54 -0700176AudioMixerImpl::~AudioMixerImpl() {}
aleloi70f866c2016-08-16 02:15:49 -0700177
aleloi116ec6d2016-10-12 06:07:07 -0700178rtc::scoped_refptr<AudioMixerImpl> AudioMixerImpl::Create() {
aleloi77ad3942016-07-04 06:33:02 -0700179 Config config;
180 config.Set<ExperimentalAgc>(new ExperimentalAgc(false));
aleloi311525e2016-09-07 06:13:12 -0700181 std::unique_ptr<AudioProcessing> limiter(AudioProcessing::Create(config));
aleloie97974d2016-10-12 03:06:09 -0700182 if (!limiter.get()) {
aleloi311525e2016-09-07 06:13:12 -0700183 return nullptr;
aleloie97974d2016-10-12 03:06:09 -0700184 }
aleloi77ad3942016-07-04 06:33:02 -0700185
aleloi311525e2016-09-07 06:13:12 -0700186 if (limiter->gain_control()->set_mode(GainControl::kFixedDigital) !=
aleloie97974d2016-10-12 03:06:09 -0700187 limiter->kNoError) {
aleloi311525e2016-09-07 06:13:12 -0700188 return nullptr;
aleloie97974d2016-10-12 03:06:09 -0700189 }
aleloi77ad3942016-07-04 06:33:02 -0700190
191 // We smoothly limit the mixed frame to -7 dbFS. -6 would correspond to the
192 // divide-by-2 but -7 is used instead to give a bit of headroom since the
193 // AGC is not a hard limiter.
aleloie97974d2016-10-12 03:06:09 -0700194 if (limiter->gain_control()->set_target_level_dbfs(7) != limiter->kNoError) {
aleloi311525e2016-09-07 06:13:12 -0700195 return nullptr;
aleloie97974d2016-10-12 03:06:09 -0700196 }
aleloi77ad3942016-07-04 06:33:02 -0700197
aleloie97974d2016-10-12 03:06:09 -0700198 if (limiter->gain_control()->set_compression_gain_db(0) !=
199 limiter->kNoError) {
aleloi311525e2016-09-07 06:13:12 -0700200 return nullptr;
aleloie97974d2016-10-12 03:06:09 -0700201 }
aleloi77ad3942016-07-04 06:33:02 -0700202
aleloie97974d2016-10-12 03:06:09 -0700203 if (limiter->gain_control()->enable_limiter(true) != limiter->kNoError) {
aleloi311525e2016-09-07 06:13:12 -0700204 return nullptr;
aleloie97974d2016-10-12 03:06:09 -0700205 }
aleloi77ad3942016-07-04 06:33:02 -0700206
aleloie97974d2016-10-12 03:06:09 -0700207 if (limiter->gain_control()->Enable(true) != limiter->kNoError) {
aleloi311525e2016-09-07 06:13:12 -0700208 return nullptr;
aleloie97974d2016-10-12 03:06:09 -0700209 }
aleloi77ad3942016-07-04 06:33:02 -0700210
aleloi116ec6d2016-10-12 06:07:07 -0700211 return rtc::scoped_refptr<AudioMixerImpl>(
212 new rtc::RefCountedObject<AudioMixerImpl>(std::move(limiter)));
aleloi77ad3942016-07-04 06:33:02 -0700213}
214
aleloi95611832016-11-08 06:39:50 -0800215void AudioMixerImpl::Mix(size_t number_of_channels,
aleloi5d167d62016-08-24 02:20:54 -0700216 AudioFrame* audio_frame_for_mixing) {
aleloi44968092016-08-08 10:18:58 -0700217 RTC_DCHECK(number_of_channels == 1 || number_of_channels == 2);
aleloi920d30b2016-10-20 14:23:24 -0700218 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
aleloi311525e2016-09-07 06:13:12 -0700219
aleloi95611832016-11-08 06:39:50 -0800220 const int sample_rate = [&]() {
221 rtc::CritScope lock(&crit_);
222 return CalculateMixingFrequency(audio_source_list_);
223 }();
224
aleloi311525e2016-09-07 06:13:12 -0700225 if (OutputFrequency() != sample_rate) {
aleloie97974d2016-10-12 03:06:09 -0700226 SetOutputFrequency(sample_rate);
aleloi311525e2016-09-07 06:13:12 -0700227 }
228
aleloi652ac892016-09-07 07:42:14 -0700229 AudioFrameList mix_list;
aleloi77ad3942016-07-04 06:33:02 -0700230 {
aleloi311525e2016-09-07 06:13:12 -0700231 rtc::CritScope lock(&crit_);
aleloi116ec6d2016-10-12 06:07:07 -0700232 mix_list = GetAudioFromSources();
aleloi1655e452016-10-24 06:56:56 -0700233
234 for (const auto& frame : mix_list) {
235 RemixFrame(number_of_channels, frame);
236 }
237
238 audio_frame_for_mixing->UpdateFrame(
239 -1, time_stamp_, NULL, 0, OutputFrequency(), AudioFrame::kNormalSpeech,
240 AudioFrame::kVadPassive, number_of_channels);
241
242 time_stamp_ += static_cast<uint32_t>(sample_size_);
243
244 use_limiter_ = mix_list.size() > 1;
245
246 // We only use the limiter if we're actually mixing multiple streams.
247 MixFromList(audio_frame_for_mixing, mix_list, use_limiter_);
aleloi77ad3942016-07-04 06:33:02 -0700248 }
249
aleloi311525e2016-09-07 06:13:12 -0700250 if (audio_frame_for_mixing->samples_per_channel_ == 0) {
251 // Nothing was mixed, set the audio samples to silence.
252 audio_frame_for_mixing->samples_per_channel_ = sample_size_;
253 audio_frame_for_mixing->Mute();
254 } else {
255 // Only call the limiter if we have something to mix.
256 LimitMixedAudio(audio_frame_for_mixing);
aleloi77ad3942016-07-04 06:33:02 -0700257 }
aleloi616df1e2016-08-24 01:17:12 -0700258
aleloi77ad3942016-07-04 06:33:02 -0700259 return;
260}
261
aleloie97974d2016-10-12 03:06:09 -0700262void AudioMixerImpl::SetOutputFrequency(int frequency) {
aleloi920d30b2016-10-20 14:23:24 -0700263 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
aleloi6382a192016-08-08 10:25:04 -0700264 output_frequency_ = frequency;
aleloidc7669a2016-10-04 04:06:20 -0700265 sample_size_ = (output_frequency_ * kFrameDurationInMs) / 1000;
aleloi77ad3942016-07-04 06:33:02 -0700266}
267
aleloie97974d2016-10-12 03:06:09 -0700268int AudioMixerImpl::OutputFrequency() const {
aleloi920d30b2016-10-20 14:23:24 -0700269 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
aleloi6382a192016-08-08 10:25:04 -0700270 return output_frequency_;
aleloi77ad3942016-07-04 06:33:02 -0700271}
272
aleloi116ec6d2016-10-12 06:07:07 -0700273bool AudioMixerImpl::AddSource(Source* audio_source) {
274 RTC_DCHECK(audio_source);
275 rtc::CritScope lock(&crit_);
276 RTC_DCHECK(FindSourceInList(audio_source, &audio_source_list_) ==
277 audio_source_list_.end())
278 << "Source already added to mixer";
aleloi6c278492016-10-20 14:24:39 -0700279 audio_source_list_.emplace_back(new SourceStatus(audio_source, false, 0));
aleloi116ec6d2016-10-12 06:07:07 -0700280 return true;
aleloi77ad3942016-07-04 06:33:02 -0700281}
282
aleloi116ec6d2016-10-12 06:07:07 -0700283bool AudioMixerImpl::RemoveSource(Source* audio_source) {
284 RTC_DCHECK(audio_source);
285 rtc::CritScope lock(&crit_);
286 const auto iter = FindSourceInList(audio_source, &audio_source_list_);
287 RTC_DCHECK(iter != audio_source_list_.end()) << "Source not present in mixer";
288 audio_source_list_.erase(iter);
289 return true;
290}
aleloi77ad3942016-07-04 06:33:02 -0700291
aleloi116ec6d2016-10-12 06:07:07 -0700292AudioFrameList AudioMixerImpl::GetAudioFromSources() {
aleloi920d30b2016-10-20 14:23:24 -0700293 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
aleloif3882572016-07-29 02:12:41 -0700294 AudioFrameList result;
aleloia4c21062016-09-08 01:25:46 -0700295 std::vector<SourceFrame> audio_source_mixing_data_list;
aleloi652ac892016-09-07 07:42:14 -0700296 std::vector<SourceFrame> ramp_list;
aleloi77ad3942016-07-04 06:33:02 -0700297
aleloi6c278492016-10-20 14:24:39 -0700298 // Get audio from the audio sources and put it in the SourceFrame vector.
aleloi36542512016-10-07 05:28:32 -0700299 for (auto& source_and_status : audio_source_list_) {
aleloi6c278492016-10-20 14:24:39 -0700300 const auto audio_frame_info =
301 source_and_status->audio_source->GetAudioFrameWithInfo(
302 OutputFrequency(), &source_and_status->audio_frame);
aleloif3882572016-07-29 02:12:41 -0700303
aleloie8914152016-10-11 06:18:31 -0700304 if (audio_frame_info == Source::AudioFrameInfo::kError) {
aleloie97974d2016-10-12 03:06:09 -0700305 LOG_F(LS_WARNING) << "failed to GetAudioFrameWithInfo() from source";
tereliusea4c1412016-07-29 01:36:14 -0700306 continue;
307 }
aleloia4c21062016-09-08 01:25:46 -0700308 audio_source_mixing_data_list.emplace_back(
aleloi6c278492016-10-20 14:24:39 -0700309 source_and_status.get(), &source_and_status->audio_frame,
aleloie8914152016-10-11 06:18:31 -0700310 audio_frame_info == Source::AudioFrameInfo::kMuted);
aleloif3882572016-07-29 02:12:41 -0700311 }
312
313 // Sort frames by sorting function.
aleloia4c21062016-09-08 01:25:46 -0700314 std::sort(audio_source_mixing_data_list.begin(),
aleloi4b8bfb82016-10-12 02:14:59 -0700315 audio_source_mixing_data_list.end(), ShouldMixBefore);
aleloif3882572016-07-29 02:12:41 -0700316
aleloia4c21062016-09-08 01:25:46 -0700317 int max_audio_frame_counter = kMaximumAmountOfMixedAudioSources;
318
319 // Go through list in order and put unmuted frames in result list.
aleloi36542512016-10-07 05:28:32 -0700320 for (const auto& p : audio_source_mixing_data_list) {
aleloif3882572016-07-29 02:12:41 -0700321 // Filter muted.
aleloi4b8bfb82016-10-12 02:14:59 -0700322 if (p.muted) {
323 p.source_status->is_mixed = false;
aleloif3882572016-07-29 02:12:41 -0700324 continue;
tereliusea4c1412016-07-29 01:36:14 -0700325 }
aleloi2942e242016-07-29 01:23:49 -0700326
aleloif3882572016-07-29 02:12:41 -0700327 // Add frame to result vector for mixing.
328 bool is_mixed = false;
aleloia4c21062016-09-08 01:25:46 -0700329 if (max_audio_frame_counter > 0) {
330 --max_audio_frame_counter;
aleloi4b8bfb82016-10-12 02:14:59 -0700331 result.push_back(p.audio_frame);
332 ramp_list.emplace_back(p.source_status, p.audio_frame, false, -1);
aleloif3882572016-07-29 02:12:41 -0700333 is_mixed = true;
tereliusea4c1412016-07-29 01:36:14 -0700334 }
aleloi4b8bfb82016-10-12 02:14:59 -0700335 p.source_status->is_mixed = is_mixed;
tereliusea4c1412016-07-29 01:36:14 -0700336 }
aleloi4b8bfb82016-10-12 02:14:59 -0700337 RampAndUpdateGain(ramp_list);
aleloif3882572016-07-29 02:12:41 -0700338 return result;
aleloi77ad3942016-07-04 06:33:02 -0700339}
340
aleloi77ad3942016-07-04 06:33:02 -0700341
aleloia4c21062016-09-08 01:25:46 -0700342bool AudioMixerImpl::LimitMixedAudio(AudioFrame* mixed_audio) const {
aleloi920d30b2016-10-20 14:23:24 -0700343 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
aleloi77ad3942016-07-04 06:33:02 -0700344 if (!use_limiter_) {
345 return true;
346 }
347
348 // Smoothly limit the mixed frame.
aleloia4c21062016-09-08 01:25:46 -0700349 const int error = limiter_->ProcessStream(mixed_audio);
aleloi77ad3942016-07-04 06:33:02 -0700350
351 // And now we can safely restore the level. This procedure results in
352 // some loss of resolution, deemed acceptable.
353 //
354 // It's possible to apply the gain in the AGC (with a target level of 0 dbFS
355 // and compression gain of 6 dB). However, in the transition frame when this
aleloi09f45102016-07-28 03:52:15 -0700356 // is enabled (moving from one to two audio sources) it has the potential to
aleloi77ad3942016-07-04 06:33:02 -0700357 // create discontinuities in the mixed frame.
358 //
359 // Instead we double the frame (with addition since left-shifting a
360 // negative value is undefined).
aleloia4c21062016-09-08 01:25:46 -0700361 *mixed_audio += *mixed_audio;
aleloi77ad3942016-07-04 06:33:02 -0700362
aleloi6382a192016-08-08 10:25:04 -0700363 if (error != limiter_->kNoError) {
aleloie97974d2016-10-12 03:06:09 -0700364 LOG_F(LS_ERROR) << "Error from AudioProcessing: " << error;
aleloi09f45102016-07-28 03:52:15 -0700365 RTC_NOTREACHED();
aleloi77ad3942016-07-04 06:33:02 -0700366 return false;
367 }
368 return true;
369}
aleloi616df1e2016-08-24 01:17:12 -0700370
aleloi36542512016-10-07 05:28:32 -0700371bool AudioMixerImpl::GetAudioSourceMixabilityStatusForTest(
aleloie97974d2016-10-12 03:06:09 -0700372 AudioMixerImpl::Source* audio_source) const {
aleloi920d30b2016-10-20 14:23:24 -0700373 RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
aleloi36542512016-10-07 05:28:32 -0700374 rtc::CritScope lock(&crit_);
375
aleloi6c278492016-10-20 14:24:39 -0700376 const auto iter = FindSourceInList(audio_source, &audio_source_list_);
377 if (iter != audio_source_list_.end()) {
378 return (*iter)->is_mixed;
aleloi36542512016-10-07 05:28:32 -0700379 }
380
aleloi36542512016-10-07 05:28:32 -0700381 LOG(LS_ERROR) << "Audio source unknown";
382 return false;
383}
aleloi77ad3942016-07-04 06:33:02 -0700384} // namespace webrtc