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

Side by Side Diff: webrtc/modules/audio_processing/test/wav_based_simulator.cc

Issue 2834643002: audioproc_f with simulated mic analog gain (Closed)
Patch Set: Comments from Alex addressed Created 3 years, 8 months 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
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 if (settings_.fixed_interface) { 73 if (settings_.fixed_interface) {
72 CopyToAudioFrame(*in_buf_, &fwd_frame_); 74 CopyToAudioFrame(*in_buf_, &fwd_frame_);
73 } 75 }
74 ap_->set_stream_key_pressed(settings_.use_ts && (*settings_.use_ts)); 76 ap_->set_stream_key_pressed(settings_.use_ts && (*settings_.use_ts));
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);
peah-webrtc 2017/04/26 12:54:44 What you do here is that you move the set_stream_a
82
83 RTC_CHECK_EQ(AudioProcessing::kNoError,
84 ap_->gain_control()->set_stream_analog_level(
85 last_specified_microphone_level_));
86 } 84 }
87 85
88 void WavBasedSimulator::PrepareReverseProcessStreamCall() { 86 void WavBasedSimulator::PrepareReverseProcessStreamCall() {
89 if (settings_.fixed_interface) { 87 if (settings_.fixed_interface) {
90 CopyToAudioFrame(*reverse_in_buf_, &rev_frame_); 88 CopyToAudioFrame(*reverse_in_buf_, &rev_frame_);
91 } 89 }
92 } 90 }
93 91
94 void WavBasedSimulator::Process() { 92 void WavBasedSimulator::Process() {
95 std::unique_ptr<test::TraceToStderr> trace_to_stderr; 93 std::unique_ptr<test::TraceToStderr> trace_to_stderr;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 134 }
137 135
138 DestroyAudioProcessor(); 136 DestroyAudioProcessor();
139 } 137 }
140 138
141 bool WavBasedSimulator::HandleProcessStreamCall() { 139 bool WavBasedSimulator::HandleProcessStreamCall() {
142 bool samples_left_to_process = buffer_reader_->Read(in_buf_.get()); 140 bool samples_left_to_process = buffer_reader_->Read(in_buf_.get());
143 if (samples_left_to_process) { 141 if (samples_left_to_process) {
144 PrepareProcessStreamCall(); 142 PrepareProcessStreamCall();
145 ProcessStream(settings_.fixed_interface); 143 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_ =
149 ap_->gain_control()->stream_analog_level();
150 } 144 }
151 return samples_left_to_process; 145 return samples_left_to_process;
152 } 146 }
153 147
154 bool WavBasedSimulator::HandleProcessReverseStreamCall() { 148 bool WavBasedSimulator::HandleProcessReverseStreamCall() {
155 bool samples_left_to_process = 149 bool samples_left_to_process =
156 reverse_buffer_reader_->Read(reverse_in_buf_.get()); 150 reverse_buffer_reader_->Read(reverse_in_buf_.get());
157 if (samples_left_to_process) { 151 if (samples_left_to_process) {
158 PrepareReverseProcessStreamCall(); 152 PrepareReverseProcessStreamCall();
159 ProcessReverseStream(settings_.fixed_interface); 153 ProcessReverseStream(settings_.fixed_interface);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 191 }
198 192
199 SetupBuffersConfigsOutputs( 193 SetupBuffersConfigsOutputs(
200 input_sample_rate_hz, output_sample_rate_hz, reverse_sample_rate_hz, 194 input_sample_rate_hz, output_sample_rate_hz, reverse_sample_rate_hz,
201 reverse_output_sample_rate_hz, input_num_channels, output_num_channels, 195 reverse_output_sample_rate_hz, input_num_channels, output_num_channels,
202 reverse_num_channels, reverse_output_num_channels); 196 reverse_num_channels, reverse_output_num_channels);
203 } 197 }
204 198
205 } // namespace test 199 } // namespace test
206 } // namespace webrtc 200 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698