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 |
11 #include "webrtc/modules/audio_processing/test/wav_based_simulator.h" | 11 #include "webrtc/modules/audio_processing/test/wav_based_simulator.h" |
12 | 12 |
13 #include <stdio.h> | 13 #include <stdio.h> |
14 #include <iostream> | 14 #include <iostream> |
15 #include <memory> | |
16 #include <utility> | |
15 | 17 |
16 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
17 #include "webrtc/modules/audio_processing/test/test_utils.h" | 19 #include "webrtc/modules/audio_processing/test/test_utils.h" |
18 #include "webrtc/test/testsupport/trace_to_stderr.h" | 20 #include "webrtc/test/testsupport/trace_to_stderr.h" |
19 | 21 |
20 namespace webrtc { | 22 namespace webrtc { |
21 namespace test { | 23 namespace test { |
22 | 24 |
23 std::vector<WavBasedSimulator::SimulationEventType> | 25 std::vector<WavBasedSimulator::SimulationEventType> |
24 WavBasedSimulator::GetCustomEventChain(const std::string& filename) { | 26 WavBasedSimulator::GetCustomEventChain(const std::string& filename) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 | 77 |
76 RTC_CHECK_EQ(AudioProcessing::kNoError, | 78 RTC_CHECK_EQ(AudioProcessing::kNoError, |
77 ap_->set_stream_delay_ms( | 79 ap_->set_stream_delay_ms( |
78 settings_.stream_delay ? *settings_.stream_delay : 0)); | 80 settings_.stream_delay ? *settings_.stream_delay : 0)); |
79 | 81 |
80 ap_->echo_cancellation()->set_stream_drift_samples( | 82 ap_->echo_cancellation()->set_stream_drift_samples( |
81 settings_.stream_drift_samples ? *settings_.stream_drift_samples : 0); | 83 settings_.stream_drift_samples ? *settings_.stream_drift_samples : 0); |
82 | 84 |
83 RTC_CHECK_EQ(AudioProcessing::kNoError, | 85 RTC_CHECK_EQ(AudioProcessing::kNoError, |
84 ap_->gain_control()->set_stream_analog_level( | 86 ap_->gain_control()->set_stream_analog_level( |
85 last_specified_microphone_level_)); | 87 last_specified_microphone_level_)); |
88 // TODO(aleloi): No undo level to set, i.e., no call to | |
peah-webrtc
2017/05/02 21:27:33
Is this todo really needed? It is a todo about not
| |
89 // FakeRecordingDevice::NotifyAudioDeviceLevel(). | |
86 } | 90 } |
87 | 91 |
88 void WavBasedSimulator::PrepareReverseProcessStreamCall() { | 92 void WavBasedSimulator::PrepareReverseProcessStreamCall() { |
89 if (settings_.fixed_interface) { | 93 if (settings_.fixed_interface) { |
90 CopyToAudioFrame(*reverse_in_buf_, &rev_frame_); | 94 CopyToAudioFrame(*reverse_in_buf_, &rev_frame_); |
91 } | 95 } |
92 } | 96 } |
93 | 97 |
94 void WavBasedSimulator::Process() { | 98 void WavBasedSimulator::Process() { |
95 std::unique_ptr<test::TraceToStderr> trace_to_stderr; | 99 std::unique_ptr<test::TraceToStderr> trace_to_stderr; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 } | 140 } |
137 | 141 |
138 DestroyAudioProcessor(); | 142 DestroyAudioProcessor(); |
139 } | 143 } |
140 | 144 |
141 bool WavBasedSimulator::HandleProcessStreamCall() { | 145 bool WavBasedSimulator::HandleProcessStreamCall() { |
142 bool samples_left_to_process = buffer_reader_->Read(in_buf_.get()); | 146 bool samples_left_to_process = buffer_reader_->Read(in_buf_.get()); |
143 if (samples_left_to_process) { | 147 if (samples_left_to_process) { |
144 PrepareProcessStreamCall(); | 148 PrepareProcessStreamCall(); |
145 ProcessStream(settings_.fixed_interface); | 149 ProcessStream(settings_.fixed_interface); |
146 // Call stream analog level to ensure that any side-effects are triggered. | |
147 (void)ap_->gain_control()->stream_analog_level(); | |
148 last_specified_microphone_level_ = | 150 last_specified_microphone_level_ = |
149 ap_->gain_control()->stream_analog_level(); | 151 ap_->gain_control()->stream_analog_level(); |
152 // TODO(aleloi): If settings_.simulate_mic_gain, set the returned value into | |
peah-webrtc
2017/05/02 21:27:33
This makes sense. What about putting that into Aud
| |
153 // a FakeRecordingDevice instance via | |
154 // FakeRecordingDevice::set_analog_level() instead of using | |
155 // last_specified_microphone_level_. | |
150 } | 156 } |
151 return samples_left_to_process; | 157 return samples_left_to_process; |
152 } | 158 } |
153 | 159 |
154 bool WavBasedSimulator::HandleProcessReverseStreamCall() { | 160 bool WavBasedSimulator::HandleProcessReverseStreamCall() { |
155 bool samples_left_to_process = | 161 bool samples_left_to_process = |
156 reverse_buffer_reader_->Read(reverse_in_buf_.get()); | 162 reverse_buffer_reader_->Read(reverse_in_buf_.get()); |
157 if (samples_left_to_process) { | 163 if (samples_left_to_process) { |
158 PrepareReverseProcessStreamCall(); | 164 PrepareReverseProcessStreamCall(); |
159 ProcessReverseStream(settings_.fixed_interface); | 165 ProcessReverseStream(settings_.fixed_interface); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 } | 203 } |
198 | 204 |
199 SetupBuffersConfigsOutputs( | 205 SetupBuffersConfigsOutputs( |
200 input_sample_rate_hz, output_sample_rate_hz, reverse_sample_rate_hz, | 206 input_sample_rate_hz, output_sample_rate_hz, reverse_sample_rate_hz, |
201 reverse_output_sample_rate_hz, input_num_channels, output_num_channels, | 207 reverse_output_sample_rate_hz, input_num_channels, output_num_channels, |
202 reverse_num_channels, reverse_output_num_channels); | 208 reverse_num_channels, reverse_output_num_channels); |
203 } | 209 } |
204 | 210 |
205 } // namespace test | 211 } // namespace test |
206 } // namespace webrtc | 212 } // namespace webrtc |
OLD | NEW |