OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 } // namespace | 50 } // namespace |
51 | 51 |
52 class MockMixerAudioSource : public AudioMixer::Source { | 52 class MockMixerAudioSource : public AudioMixer::Source { |
53 public: | 53 public: |
54 MockMixerAudioSource() | 54 MockMixerAudioSource() |
55 : fake_audio_frame_info_(AudioMixer::Source::AudioFrameInfo::kNormal) { | 55 : fake_audio_frame_info_(AudioMixer::Source::AudioFrameInfo::kNormal) { |
56 ON_CALL(*this, GetAudioFrameWithInfo(_, _)) | 56 ON_CALL(*this, GetAudioFrameWithInfo(_, _)) |
57 .WillByDefault( | 57 .WillByDefault( |
58 Invoke(this, &MockMixerAudioSource::FakeAudioFrameWithInfo)); | 58 Invoke(this, &MockMixerAudioSource::FakeAudioFrameWithInfo)); |
| 59 ON_CALL(*this, PreferredSampleRate()) |
| 60 .WillByDefault(Return(kDefaultSampleRateHz)); |
59 } | 61 } |
60 | 62 |
61 MOCK_METHOD2(GetAudioFrameWithInfo, | 63 MOCK_METHOD2(GetAudioFrameWithInfo, |
62 AudioFrameInfo(int sample_rate_hz, AudioFrame* audio_frame)); | 64 AudioFrameInfo(int sample_rate_hz, AudioFrame* audio_frame)); |
63 | 65 |
64 MOCK_CONST_METHOD0(PreferredSampleRate, int()); | 66 MOCK_CONST_METHOD0(PreferredSampleRate, int()); |
65 MOCK_CONST_METHOD0(Ssrc, int()); | 67 MOCK_CONST_METHOD0(Ssrc, int()); |
66 | 68 |
67 AudioFrame* fake_frame() { return &fake_frame_; } | 69 AudioFrame* fake_frame() { return &fake_frame_; } |
68 AudioFrameInfo fake_info() { return fake_audio_frame_info_; } | 70 AudioFrameInfo fake_info() { return fake_audio_frame_info_; } |
69 void set_fake_info(const AudioFrameInfo audio_frame_info) { | 71 void set_fake_info(const AudioFrameInfo audio_frame_info) { |
70 fake_audio_frame_info_ = audio_frame_info; | 72 fake_audio_frame_info_ = audio_frame_info; |
71 } | 73 } |
72 | 74 |
73 private: | 75 private: |
74 AudioFrame fake_frame_; | |
75 AudioFrameInfo fake_audio_frame_info_; | |
76 AudioFrameInfo FakeAudioFrameWithInfo(int sample_rate_hz, | 76 AudioFrameInfo FakeAudioFrameWithInfo(int sample_rate_hz, |
77 AudioFrame* audio_frame) { | 77 AudioFrame* audio_frame) { |
78 audio_frame->CopyFrom(fake_frame_); | 78 audio_frame->CopyFrom(fake_frame_); |
| 79 audio_frame->sample_rate_hz_ = sample_rate_hz; |
| 80 audio_frame->samples_per_channel_ = sample_rate_hz / 100; |
79 return fake_info(); | 81 return fake_info(); |
80 } | 82 } |
| 83 |
| 84 AudioFrame fake_frame_; |
| 85 AudioFrameInfo fake_audio_frame_info_; |
81 }; | 86 }; |
82 | 87 |
83 // Creates participants from |frames| and |frame_info| and adds them | 88 // Creates participants from |frames| and |frame_info| and adds them |
84 // to the mixer. Compares mixed status with |expected_status| | 89 // to the mixer. Compares mixed status with |expected_status| |
85 void MixAndCompare( | 90 void MixAndCompare( |
86 const std::vector<AudioFrame>& frames, | 91 const std::vector<AudioFrame>& frames, |
87 const std::vector<AudioMixer::Source::AudioFrameInfo>& frame_info, | 92 const std::vector<AudioMixer::Source::AudioFrameInfo>& frame_info, |
88 const std::vector<bool>& expected_status) { | 93 const std::vector<bool>& expected_status) { |
89 int num_audio_sources = frames.size(); | 94 int num_audio_sources = frames.size(); |
90 RTC_DCHECK(frames.size() == frame_info.size()); | 95 RTC_DCHECK(frames.size() == frame_info.size()); |
91 RTC_DCHECK(frame_info.size() == expected_status.size()); | 96 RTC_DCHECK(frame_info.size() == expected_status.size()); |
92 | 97 |
93 const auto mixer = AudioMixerImpl::Create(); | 98 const auto mixer = AudioMixerImpl::Create(); |
94 std::vector<MockMixerAudioSource> participants(num_audio_sources); | 99 std::vector<MockMixerAudioSource> participants(num_audio_sources); |
95 | 100 |
96 for (int i = 0; i < num_audio_sources; i++) { | 101 for (int i = 0; i < num_audio_sources; i++) { |
97 participants[i].fake_frame()->CopyFrom(frames[i]); | 102 participants[i].fake_frame()->CopyFrom(frames[i]); |
98 participants[i].set_fake_info(frame_info[i]); | 103 participants[i].set_fake_info(frame_info[i]); |
99 } | 104 } |
100 | 105 |
101 for (int i = 0; i < num_audio_sources; i++) { | 106 for (int i = 0; i < num_audio_sources; i++) { |
102 EXPECT_TRUE(mixer->AddSource(&participants[i])); | 107 EXPECT_TRUE(mixer->AddSource(&participants[i])); |
103 EXPECT_CALL(participants[i], GetAudioFrameWithInfo(kDefaultSampleRateHz, _)) | 108 EXPECT_CALL(participants[i], GetAudioFrameWithInfo(kDefaultSampleRateHz, _)) |
104 .Times(Exactly(1)); | 109 .Times(Exactly(1)); |
105 } | 110 } |
106 | 111 |
107 mixer->Mix(kDefaultSampleRateHz, 1, &frame_for_mixing); | 112 mixer->Mix(1, &frame_for_mixing); |
108 | 113 |
109 for (int i = 0; i < num_audio_sources; i++) { | 114 for (int i = 0; i < num_audio_sources; i++) { |
110 EXPECT_EQ(expected_status[i], | 115 EXPECT_EQ(expected_status[i], |
111 mixer->GetAudioSourceMixabilityStatusForTest(&participants[i])) | 116 mixer->GetAudioSourceMixabilityStatusForTest(&participants[i])) |
112 << "Mixed status of AudioSource #" << i << " wrong."; | 117 << "Mixed status of AudioSource #" << i << " wrong."; |
113 } | 118 } |
114 } | 119 } |
115 | 120 |
| 121 void MixMonoAtGivenNativeRate(int native_sample_rate, |
| 122 AudioFrame* mix_frame, |
| 123 rtc::scoped_refptr<AudioMixer> mixer, |
| 124 MockMixerAudioSource* audio_source) { |
| 125 ON_CALL(*audio_source, PreferredSampleRate()) |
| 126 .WillByDefault(Return(native_sample_rate)); |
| 127 audio_source->fake_frame()->sample_rate_hz_ = native_sample_rate; |
| 128 audio_source->fake_frame()->samples_per_channel_ = native_sample_rate / 100; |
| 129 |
| 130 mixer->Mix(1, mix_frame); |
| 131 } |
| 132 |
116 TEST(AudioMixer, LargestEnergyVadActiveMixed) { | 133 TEST(AudioMixer, LargestEnergyVadActiveMixed) { |
117 constexpr int kAudioSources = | 134 constexpr int kAudioSources = |
118 AudioMixerImpl::kMaximumAmountOfMixedAudioSources + 3; | 135 AudioMixerImpl::kMaximumAmountOfMixedAudioSources + 3; |
119 | 136 |
120 const auto mixer = AudioMixerImpl::Create(); | 137 const auto mixer = AudioMixerImpl::Create(); |
121 | 138 |
122 MockMixerAudioSource participants[kAudioSources]; | 139 MockMixerAudioSource participants[kAudioSources]; |
123 | 140 |
124 for (int i = 0; i < kAudioSources; ++i) { | 141 for (int i = 0; i < kAudioSources; ++i) { |
125 ResetFrame(participants[i].fake_frame()); | 142 ResetFrame(participants[i].fake_frame()); |
126 | 143 |
127 // We set the 80-th sample value since the first 80 samples may be | 144 // We set the 80-th sample value since the first 80 samples may be |
128 // modified by a ramped-in window. | 145 // modified by a ramped-in window. |
129 participants[i].fake_frame()->data_[80] = i; | 146 participants[i].fake_frame()->data_[80] = i; |
130 | 147 |
131 EXPECT_TRUE(mixer->AddSource(&participants[i])); | 148 EXPECT_TRUE(mixer->AddSource(&participants[i])); |
132 EXPECT_CALL(participants[i], GetAudioFrameWithInfo(_, _)).Times(Exactly(1)); | 149 EXPECT_CALL(participants[i], GetAudioFrameWithInfo(_, _)).Times(Exactly(1)); |
133 } | 150 } |
134 | 151 |
135 // Last participant gives audio frame with passive VAD, although it has the | 152 // Last participant gives audio frame with passive VAD, although it has the |
136 // largest energy. | 153 // largest energy. |
137 participants[kAudioSources - 1].fake_frame()->vad_activity_ = | 154 participants[kAudioSources - 1].fake_frame()->vad_activity_ = |
138 AudioFrame::kVadPassive; | 155 AudioFrame::kVadPassive; |
139 | 156 |
140 AudioFrame audio_frame; | 157 AudioFrame audio_frame; |
141 mixer->Mix(kDefaultSampleRateHz, | 158 mixer->Mix(1, // number of channels |
142 1, // number of channels | |
143 &audio_frame); | 159 &audio_frame); |
144 | 160 |
145 for (int i = 0; i < kAudioSources; ++i) { | 161 for (int i = 0; i < kAudioSources; ++i) { |
146 bool is_mixed = | 162 bool is_mixed = |
147 mixer->GetAudioSourceMixabilityStatusForTest(&participants[i]); | 163 mixer->GetAudioSourceMixabilityStatusForTest(&participants[i]); |
148 if (i == kAudioSources - 1 || | 164 if (i == kAudioSources - 1 || |
149 i < kAudioSources - 1 - | 165 i < kAudioSources - 1 - |
150 AudioMixerImpl::kMaximumAmountOfMixedAudioSources) { | 166 AudioMixerImpl::kMaximumAmountOfMixedAudioSources) { |
151 EXPECT_FALSE(is_mixed) << "Mixing status of AudioSource #" << i | 167 EXPECT_FALSE(is_mixed) << "Mixing status of AudioSource #" << i |
152 << " wrong."; | 168 << " wrong."; |
(...skipping 16 matching lines...) Expand all Loading... |
169 for (int j = 0; j < n_samples; j++) { | 185 for (int j = 0; j < n_samples; j++) { |
170 participant.fake_frame()->data_[j] = j; | 186 participant.fake_frame()->data_[j] = j; |
171 } | 187 } |
172 | 188 |
173 EXPECT_TRUE(mixer->AddSource(&participant)); | 189 EXPECT_TRUE(mixer->AddSource(&participant)); |
174 EXPECT_CALL(participant, GetAudioFrameWithInfo(_, _)).Times(Exactly(2)); | 190 EXPECT_CALL(participant, GetAudioFrameWithInfo(_, _)).Times(Exactly(2)); |
175 | 191 |
176 AudioFrame audio_frame; | 192 AudioFrame audio_frame; |
177 // Two mix iteration to compare after the ramp-up step. | 193 // Two mix iteration to compare after the ramp-up step. |
178 for (int i = 0; i < 2; i++) { | 194 for (int i = 0; i < 2; i++) { |
179 mixer->Mix(kDefaultSampleRateHz, | 195 mixer->Mix(1, // number of channels |
180 1, // number of channels | |
181 &audio_frame); | 196 &audio_frame); |
182 } | 197 } |
183 | 198 |
184 EXPECT_EQ( | 199 EXPECT_EQ( |
185 0, memcmp(participant.fake_frame()->data_, audio_frame.data_, n_samples)); | 200 0, memcmp(participant.fake_frame()->data_, audio_frame.data_, n_samples)); |
186 } | 201 } |
187 | 202 |
188 TEST(AudioMixer, ParticipantSampleRate) { | 203 TEST(AudioMixer, SourceAtNativeRateShouldNeverResample) { |
| 204 const auto mixer = AudioMixerImpl::Create(); |
| 205 |
| 206 MockMixerAudioSource audio_source; |
| 207 ResetFrame(audio_source.fake_frame()); |
| 208 |
| 209 mixer->AddSource(&audio_source); |
| 210 |
| 211 for (auto frequency : {8000, 16000, 32000, 48000}) { |
| 212 EXPECT_CALL(audio_source, GetAudioFrameWithInfo(frequency, _)) |
| 213 .Times(Exactly(1)); |
| 214 |
| 215 MixMonoAtGivenNativeRate(frequency, &frame_for_mixing, mixer, |
| 216 &audio_source); |
| 217 } |
| 218 } |
| 219 |
| 220 TEST(AudioMixer, MixerShouldMixAtNativeSourceRate) { |
| 221 const auto mixer = AudioMixerImpl::Create(); |
| 222 |
| 223 MockMixerAudioSource audio_source; |
| 224 ResetFrame(audio_source.fake_frame()); |
| 225 |
| 226 mixer->AddSource(&audio_source); |
| 227 |
| 228 for (auto frequency : {8000, 16000, 32000, 48000}) { |
| 229 MixMonoAtGivenNativeRate(frequency, &frame_for_mixing, mixer, |
| 230 &audio_source); |
| 231 |
| 232 EXPECT_EQ(frequency, frame_for_mixing.sample_rate_hz_); |
| 233 } |
| 234 } |
| 235 |
| 236 TEST(AudioMixer, MixerShouldAlwaysMixAtNativeRate) { |
189 const auto mixer = AudioMixerImpl::Create(); | 237 const auto mixer = AudioMixerImpl::Create(); |
190 | 238 |
191 MockMixerAudioSource participant; | 239 MockMixerAudioSource participant; |
192 ResetFrame(participant.fake_frame()); | 240 ResetFrame(participant.fake_frame()); |
| 241 mixer->AddSource(&participant); |
193 | 242 |
194 EXPECT_TRUE(mixer->AddSource(&participant)); | 243 const int needed_frequency = 44100; |
195 for (auto frequency : {8000, 16000, 32000, 48000}) { | 244 ON_CALL(participant, PreferredSampleRate()) |
196 EXPECT_CALL(participant, GetAudioFrameWithInfo(frequency, _)) | 245 .WillByDefault(Return(needed_frequency)); |
197 .Times(Exactly(1)); | 246 |
198 participant.fake_frame()->sample_rate_hz_ = frequency; | 247 // We expect mixing frequency to be native and >= needed_frequency. |
199 participant.fake_frame()->samples_per_channel_ = frequency / 100; | 248 const int expected_mix_frequency = 48000; |
200 mixer->Mix(frequency, 1, &frame_for_mixing); | 249 EXPECT_CALL(participant, GetAudioFrameWithInfo(expected_mix_frequency, _)) |
201 EXPECT_EQ(frequency, frame_for_mixing.sample_rate_hz_); | 250 .Times(Exactly(1)); |
| 251 participant.fake_frame()->sample_rate_hz_ = expected_mix_frequency; |
| 252 participant.fake_frame()->samples_per_channel_ = expected_mix_frequency / 100; |
| 253 |
| 254 mixer->Mix(1, &frame_for_mixing); |
| 255 |
| 256 EXPECT_EQ(48000, frame_for_mixing.sample_rate_hz_); |
| 257 } |
| 258 |
| 259 // Check that the mixing rate is always >= participants preferred rate. |
| 260 TEST(AudioMixer, ShouldNotCauseQualityLossForMultipleSources) { |
| 261 const auto mixer = AudioMixerImpl::Create(); |
| 262 |
| 263 std::vector<MockMixerAudioSource> audio_sources(2); |
| 264 const std::vector<int> source_sample_rates = {8000, 16000}; |
| 265 for (int i = 0; i < 2; ++i) { |
| 266 auto& source = audio_sources[i]; |
| 267 ResetFrame(source.fake_frame()); |
| 268 mixer->AddSource(&source); |
| 269 const auto sample_rate = source_sample_rates[i]; |
| 270 EXPECT_CALL(source, PreferredSampleRate()).WillOnce(Return(sample_rate)); |
| 271 |
| 272 EXPECT_CALL(source, GetAudioFrameWithInfo(testing::Ge(sample_rate), _)); |
202 } | 273 } |
| 274 mixer->Mix(1, &frame_for_mixing); |
203 } | 275 } |
204 | 276 |
205 TEST(AudioMixer, ParticipantNumberOfChannels) { | 277 TEST(AudioMixer, ParticipantNumberOfChannels) { |
206 const auto mixer = AudioMixerImpl::Create(); | 278 const auto mixer = AudioMixerImpl::Create(); |
207 | 279 |
208 MockMixerAudioSource participant; | 280 MockMixerAudioSource participant; |
209 ResetFrame(participant.fake_frame()); | 281 ResetFrame(participant.fake_frame()); |
210 | 282 |
211 EXPECT_TRUE(mixer->AddSource(&participant)); | 283 EXPECT_TRUE(mixer->AddSource(&participant)); |
212 for (size_t number_of_channels : {1, 2}) { | 284 for (size_t number_of_channels : {1, 2}) { |
213 EXPECT_CALL(participant, GetAudioFrameWithInfo(kDefaultSampleRateHz, _)) | 285 EXPECT_CALL(participant, GetAudioFrameWithInfo(kDefaultSampleRateHz, _)) |
214 .Times(Exactly(1)); | 286 .Times(Exactly(1)); |
215 mixer->Mix(kDefaultSampleRateHz, number_of_channels, &frame_for_mixing); | 287 mixer->Mix(number_of_channels, &frame_for_mixing); |
216 EXPECT_EQ(number_of_channels, frame_for_mixing.num_channels_); | 288 EXPECT_EQ(number_of_channels, frame_for_mixing.num_channels_); |
217 } | 289 } |
218 } | 290 } |
219 | 291 |
220 // Maximal amount of participants are mixed one iteration, then | 292 // Maximal amount of participants are mixed one iteration, then |
221 // another participant with higher energy is added. | 293 // another participant with higher energy is added. |
222 TEST(AudioMixer, RampedOutSourcesShouldNotBeMarkedMixed) { | 294 TEST(AudioMixer, RampedOutSourcesShouldNotBeMarkedMixed) { |
223 constexpr int kAudioSources = | 295 constexpr int kAudioSources = |
224 AudioMixerImpl::kMaximumAmountOfMixedAudioSources + 1; | 296 AudioMixerImpl::kMaximumAmountOfMixedAudioSources + 1; |
225 | 297 |
226 const auto mixer = AudioMixerImpl::Create(); | 298 const auto mixer = AudioMixerImpl::Create(); |
227 MockMixerAudioSource participants[kAudioSources]; | 299 MockMixerAudioSource participants[kAudioSources]; |
228 | 300 |
229 for (int i = 0; i < kAudioSources; i++) { | 301 for (int i = 0; i < kAudioSources; i++) { |
230 ResetFrame(participants[i].fake_frame()); | 302 ResetFrame(participants[i].fake_frame()); |
231 // Set the participant audio energy to increase with the index | 303 // Set the participant audio energy to increase with the index |
232 // |i|. | 304 // |i|. |
233 participants[i].fake_frame()->data_[0] = 100 * i; | 305 participants[i].fake_frame()->data_[0] = 100 * i; |
234 } | 306 } |
235 | 307 |
236 // Add all participants but the loudest for mixing. | 308 // Add all participants but the loudest for mixing. |
237 for (int i = 0; i < kAudioSources - 1; i++) { | 309 for (int i = 0; i < kAudioSources - 1; i++) { |
238 EXPECT_TRUE(mixer->AddSource(&participants[i])); | 310 EXPECT_TRUE(mixer->AddSource(&participants[i])); |
239 EXPECT_CALL(participants[i], GetAudioFrameWithInfo(kDefaultSampleRateHz, _)) | 311 EXPECT_CALL(participants[i], GetAudioFrameWithInfo(kDefaultSampleRateHz, _)) |
240 .Times(Exactly(1)); | 312 .Times(Exactly(1)); |
241 } | 313 } |
242 | 314 |
243 // First mixer iteration | 315 // First mixer iteration |
244 mixer->Mix(kDefaultSampleRateHz, 1, &frame_for_mixing); | 316 mixer->Mix(1, &frame_for_mixing); |
245 | 317 |
246 // All participants but the loudest should have been mixed. | 318 // All participants but the loudest should have been mixed. |
247 for (int i = 0; i < kAudioSources - 1; i++) { | 319 for (int i = 0; i < kAudioSources - 1; i++) { |
248 EXPECT_TRUE(mixer->GetAudioSourceMixabilityStatusForTest(&participants[i])) | 320 EXPECT_TRUE(mixer->GetAudioSourceMixabilityStatusForTest(&participants[i])) |
249 << "Mixed status of AudioSource #" << i << " wrong."; | 321 << "Mixed status of AudioSource #" << i << " wrong."; |
250 } | 322 } |
251 | 323 |
252 // Add new participant with higher energy. | 324 // Add new participant with higher energy. |
253 EXPECT_TRUE(mixer->AddSource(&participants[kAudioSources - 1])); | 325 EXPECT_TRUE(mixer->AddSource(&participants[kAudioSources - 1])); |
254 for (int i = 0; i < kAudioSources; i++) { | 326 for (int i = 0; i < kAudioSources; i++) { |
255 EXPECT_CALL(participants[i], GetAudioFrameWithInfo(kDefaultSampleRateHz, _)) | 327 EXPECT_CALL(participants[i], GetAudioFrameWithInfo(kDefaultSampleRateHz, _)) |
256 .Times(Exactly(1)); | 328 .Times(Exactly(1)); |
257 } | 329 } |
258 | 330 |
259 mixer->Mix(kDefaultSampleRateHz, 1, &frame_for_mixing); | 331 mixer->Mix(1, &frame_for_mixing); |
260 | 332 |
261 // The most quiet participant should not have been mixed. | 333 // The most quiet participant should not have been mixed. |
262 EXPECT_FALSE(mixer->GetAudioSourceMixabilityStatusForTest(&participants[0])) | 334 EXPECT_FALSE(mixer->GetAudioSourceMixabilityStatusForTest(&participants[0])) |
263 << "Mixed status of AudioSource #0 wrong."; | 335 << "Mixed status of AudioSource #0 wrong."; |
264 | 336 |
265 // The loudest participants should have been mixed. | 337 // The loudest participants should have been mixed. |
266 for (int i = 1; i < kAudioSources; i++) { | 338 for (int i = 1; i < kAudioSources; i++) { |
267 EXPECT_EQ(true, | 339 EXPECT_EQ(true, |
268 mixer->GetAudioSourceMixabilityStatusForTest(&participants[i])) | 340 mixer->GetAudioSourceMixabilityStatusForTest(&participants[i])) |
269 << "Mixed status of AudioSource #" << i << " wrong."; | 341 << "Mixed status of AudioSource #" << i << " wrong."; |
(...skipping 14 matching lines...) Expand all Loading... |
284 | 356 |
285 participant_thread->Start(); | 357 participant_thread->Start(); |
286 EXPECT_TRUE(participant_thread->Invoke<int>( | 358 EXPECT_TRUE(participant_thread->Invoke<int>( |
287 RTC_FROM_HERE, | 359 RTC_FROM_HERE, |
288 rtc::Bind(&AudioMixer::AddSource, mixer.get(), &participant))); | 360 rtc::Bind(&AudioMixer::AddSource, mixer.get(), &participant))); |
289 | 361 |
290 EXPECT_CALL(participant, GetAudioFrameWithInfo(kDefaultSampleRateHz, _)) | 362 EXPECT_CALL(participant, GetAudioFrameWithInfo(kDefaultSampleRateHz, _)) |
291 .Times(Exactly(1)); | 363 .Times(Exactly(1)); |
292 | 364 |
293 // Do one mixer iteration | 365 // Do one mixer iteration |
294 mixer->Mix(kDefaultSampleRateHz, 1, &frame_for_mixing); | 366 mixer->Mix(1, &frame_for_mixing); |
295 } | 367 } |
296 | 368 |
297 TEST(AudioMixer, MutedShouldMixAfterUnmuted) { | 369 TEST(AudioMixer, MutedShouldMixAfterUnmuted) { |
298 constexpr int kAudioSources = | 370 constexpr int kAudioSources = |
299 AudioMixerImpl::kMaximumAmountOfMixedAudioSources + 1; | 371 AudioMixerImpl::kMaximumAmountOfMixedAudioSources + 1; |
300 | 372 |
301 std::vector<AudioFrame> frames(kAudioSources); | 373 std::vector<AudioFrame> frames(kAudioSources); |
302 for (auto& frame : frames) { | 374 for (auto& frame : frames) { |
303 ResetFrame(&frame); | 375 ResetFrame(&frame); |
304 } | 376 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 kAudioSources, AudioMixer::Source::AudioFrameInfo::kNormal); | 435 kAudioSources, AudioMixer::Source::AudioFrameInfo::kNormal); |
364 frame_info[0] = AudioMixer::Source::AudioFrameInfo::kMuted; | 436 frame_info[0] = AudioMixer::Source::AudioFrameInfo::kMuted; |
365 std::fill(frames[0].data_, frames[0].data_ + kDefaultSampleRateHz / 100, | 437 std::fill(frames[0].data_, frames[0].data_ + kDefaultSampleRateHz / 100, |
366 std::numeric_limits<int16_t>::max()); | 438 std::numeric_limits<int16_t>::max()); |
367 std::vector<bool> expected_status(kAudioSources, true); | 439 std::vector<bool> expected_status(kAudioSources, true); |
368 expected_status[0] = false; | 440 expected_status[0] = false; |
369 | 441 |
370 MixAndCompare(frames, frame_info, expected_status); | 442 MixAndCompare(frames, frame_info, expected_status); |
371 } | 443 } |
372 } // namespace webrtc | 444 } // namespace webrtc |
OLD | NEW |