Refactor to clarify band split rate is always 16k This is a no-op refactor: The code is a leftover from when APM supported 8 kHz processing. Bug: b/452621275 Change-Id: Ib42176fd8568addfcbb982b1ab2e61a9cf9188de Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/418021 Commit-Queue: Sam Zackrisson <saza@webrtc.org> Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org> Cr-Commit-Position: refs/heads/main@{#45973}
diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc index 8241b7d..7b7f497 100644 --- a/modules/audio_processing/audio_processing_impl.cc +++ b/modules/audio_processing/audio_processing_impl.cc
@@ -88,6 +88,7 @@ } // Identify the native processing rate that best handles a sample rate. +// Always returns one of 16000, 32000 and 48000 Hz. int SuitableProcessRate(int minimum_rate, int max_splitting_rate, bool band_splitting_required) { @@ -342,6 +343,7 @@ } constexpr int kUnspecifiedDataDumpInputVolume = -100; +constexpr int kBandSplitRate = AudioProcessing::kSampleRate16kHz; } // namespace @@ -643,7 +645,9 @@ max_splitting_rate, submodule_states_.CaptureMultiBandSubModulesActive() || submodule_states_.RenderMultiBandSubModulesActive()); - RTC_DCHECK_NE(8000, capture_processing_rate); + RTC_DCHECK(capture_processing_rate == 16000 || + capture_processing_rate == 32000 || + capture_processing_rate == 48000); capture_nonlocked_.capture_processing_format = StreamConfig(capture_processing_rate); @@ -659,18 +663,9 @@ } else { render_processing_rate = capture_processing_rate; } - - // If the forward sample rate is 8 kHz, the render stream is also processed - // at this rate. - if (capture_nonlocked_.capture_processing_format.sample_rate_hz() == - kSampleRate8kHz) { - render_processing_rate = kSampleRate8kHz; - } else { - render_processing_rate = - std::max(render_processing_rate, static_cast<int>(kSampleRate16kHz)); - } - - RTC_DCHECK_NE(8000, render_processing_rate); + RTC_DCHECK(render_processing_rate == 16000 || + render_processing_rate == 32000 || + render_processing_rate == 48000); if (submodule_states_.RenderMultiBandSubModulesActive()) { // By default, downmix the render stream to mono for analysis. This has been @@ -689,16 +684,6 @@ formats_.api_format.reverse_input_stream().num_channels()); } - if (capture_nonlocked_.capture_processing_format.sample_rate_hz() == - kSampleRate32kHz || - capture_nonlocked_.capture_processing_format.sample_rate_hz() == - kSampleRate48kHz) { - capture_nonlocked_.split_rate = kSampleRate16kHz; - } else { - capture_nonlocked_.split_rate = - capture_nonlocked_.capture_processing_format.sample_rate_hz(); - } - InitializeLocked(); } @@ -793,8 +778,7 @@ } int AudioProcessingImpl::proc_split_sample_rate_hz() const { - // Used as callback from submodules, hence locking is not allowed. - return capture_nonlocked_.split_rate; + return kBandSplitRate; } size_t AudioProcessingImpl::num_reverse_channels() const { @@ -2304,7 +2288,6 @@ capture_output_used_last_frame(true), key_pressed(false), capture_processing_format(kSampleRate16kHz), - split_rate(kSampleRate16kHz), echo_path_gain_change(false), prev_pre_adjustment_gain(-1.0f), playout_volume(-1),
diff --git a/modules/audio_processing/audio_processing_impl.h b/modules/audio_processing/audio_processing_impl.h index 3348f66..ee36a8c 100644 --- a/modules/audio_processing/audio_processing_impl.h +++ b/modules/audio_processing/audio_processing_impl.h
@@ -452,7 +452,6 @@ // because the capture processing number of channels is mutable and is // tracked by the capture_audio_. StreamConfig capture_processing_format; - int split_rate; bool echo_path_gain_change; float prev_pre_adjustment_gain; int playout_volume; @@ -471,13 +470,11 @@ struct ApmCaptureNonLockedState { ApmCaptureNonLockedState() : capture_processing_format(kSampleRate16kHz), - split_rate(kSampleRate16kHz), stream_delay_ms(0) {} // Only the rate and samples fields of capture_processing_format_ are used // because the forward processing number of channels is mutable and is // tracked by the capture_audio_. StreamConfig capture_processing_format; - int split_rate; int stream_delay_ms; } capture_nonlocked_;