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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } | 48 } |
49 | 49 |
50 num_read = fread(&c, sizeof(char), 1, stream); | 50 num_read = fread(&c, sizeof(char), 1, stream); |
51 } | 51 } |
52 | 52 |
53 fclose(stream); | 53 fclose(stream); |
54 return call_chain; | 54 return call_chain; |
55 } | 55 } |
56 | 56 |
57 WavBasedSimulator::WavBasedSimulator(const SimulationSettings& settings) | 57 WavBasedSimulator::WavBasedSimulator(const SimulationSettings& settings) |
58 : AudioProcessingSimulator(settings) {} | 58 : AudioProcessingSimulator(settings) {} |
59 | 59 |
60 WavBasedSimulator::~WavBasedSimulator() = default; | 60 WavBasedSimulator::~WavBasedSimulator() = default; |
61 | 61 |
62 std::vector<WavBasedSimulator::SimulationEventType> | 62 std::vector<WavBasedSimulator::SimulationEventType> |
63 WavBasedSimulator::GetDefaultEventChain() { | 63 WavBasedSimulator::GetDefaultEventChain() { |
64 std::vector<WavBasedSimulator::SimulationEventType> call_chain(2); | 64 std::vector<WavBasedSimulator::SimulationEventType> call_chain(2); |
65 call_chain[0] = SimulationEventType::kProcessStream; | 65 call_chain[0] = SimulationEventType::kProcessStream; |
66 call_chain[1] = SimulationEventType::kProcessReverseStream; | 66 call_chain[1] = SimulationEventType::kProcessReverseStream; |
67 return call_chain; | 67 return call_chain; |
68 } | 68 } |
69 | 69 |
70 void WavBasedSimulator::PrepareProcessStreamCall() { | 70 void WavBasedSimulator::PrepareProcessStreamCall() { |
71 if (settings_.fixed_interface) { | 71 if (settings_.fixed_interface) { |
72 CopyToAudioFrame(*in_buf_, &fwd_frame_); | 72 CopyToAudioFrame(*in_buf_, &fwd_frame_); |
73 } | 73 } |
74 ap_->set_stream_key_pressed(settings_.use_ts && (*settings_.use_ts)); | 74 ap_->set_stream_key_pressed(settings_.use_ts && (*settings_.use_ts)); |
75 | 75 |
76 RTC_CHECK_EQ(AudioProcessing::kNoError, | 76 RTC_CHECK_EQ(AudioProcessing::kNoError, |
77 ap_->set_stream_delay_ms( | 77 ap_->set_stream_delay_ms( |
78 settings_.stream_delay ? *settings_.stream_delay : 0)); | 78 settings_.stream_delay ? *settings_.stream_delay : 0)); |
79 | 79 |
80 ap_->echo_cancellation()->set_stream_drift_samples( | 80 ap_->echo_cancellation()->set_stream_drift_samples( |
81 settings_.stream_drift_samples ? *settings_.stream_drift_samples : 0); | 81 settings_.stream_drift_samples ? *settings_.stream_drift_samples : 0); |
82 | |
83 RTC_CHECK_EQ(AudioProcessing::kNoError, | |
84 ap_->gain_control()->set_stream_analog_level( | |
85 last_specified_microphone_level_)); | |
86 } | 82 } |
87 | 83 |
88 void WavBasedSimulator::PrepareReverseProcessStreamCall() { | 84 void WavBasedSimulator::PrepareReverseProcessStreamCall() { |
89 if (settings_.fixed_interface) { | 85 if (settings_.fixed_interface) { |
90 CopyToAudioFrame(*reverse_in_buf_, &rev_frame_); | 86 CopyToAudioFrame(*reverse_in_buf_, &rev_frame_); |
91 } | 87 } |
92 } | 88 } |
93 | 89 |
94 void WavBasedSimulator::Process() { | 90 void WavBasedSimulator::Process() { |
95 std::unique_ptr<test::TraceToStderr> trace_to_stderr; | 91 std::unique_ptr<test::TraceToStderr> trace_to_stderr; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 132 } |
137 | 133 |
138 DestroyAudioProcessor(); | 134 DestroyAudioProcessor(); |
139 } | 135 } |
140 | 136 |
141 bool WavBasedSimulator::HandleProcessStreamCall() { | 137 bool WavBasedSimulator::HandleProcessStreamCall() { |
142 bool samples_left_to_process = buffer_reader_->Read(in_buf_.get()); | 138 bool samples_left_to_process = buffer_reader_->Read(in_buf_.get()); |
143 if (samples_left_to_process) { | 139 if (samples_left_to_process) { |
144 PrepareProcessStreamCall(); | 140 PrepareProcessStreamCall(); |
145 ProcessStream(settings_.fixed_interface); | 141 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 } | 142 } |
151 return samples_left_to_process; | 143 return samples_left_to_process; |
152 } | 144 } |
153 | 145 |
154 bool WavBasedSimulator::HandleProcessReverseStreamCall() { | 146 bool WavBasedSimulator::HandleProcessReverseStreamCall() { |
155 bool samples_left_to_process = | 147 bool samples_left_to_process = |
156 reverse_buffer_reader_->Read(reverse_in_buf_.get()); | 148 reverse_buffer_reader_->Read(reverse_in_buf_.get()); |
157 if (samples_left_to_process) { | 149 if (samples_left_to_process) { |
158 PrepareReverseProcessStreamCall(); | 150 PrepareReverseProcessStreamCall(); |
159 ProcessReverseStream(settings_.fixed_interface); | 151 ProcessReverseStream(settings_.fixed_interface); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 189 } |
198 | 190 |
199 SetupBuffersConfigsOutputs( | 191 SetupBuffersConfigsOutputs( |
200 input_sample_rate_hz, output_sample_rate_hz, reverse_sample_rate_hz, | 192 input_sample_rate_hz, output_sample_rate_hz, reverse_sample_rate_hz, |
201 reverse_output_sample_rate_hz, input_num_channels, output_num_channels, | 193 reverse_output_sample_rate_hz, input_num_channels, output_num_channels, |
202 reverse_num_channels, reverse_output_num_channels); | 194 reverse_num_channels, reverse_output_num_channels); |
203 } | 195 } |
204 | 196 |
205 } // namespace test | 197 } // namespace test |
206 } // namespace webrtc | 198 } // namespace webrtc |
OLD | NEW |