diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc index ba85fc5403..02a82f4c78 100644 --- a/modules/audio_processing/audio_processing_impl.cc +++ b/modules/audio_processing/audio_processing_impl.cc @@ -1235,7 +1235,7 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() { if (submodules_.echo_control_mobile) { // Ensure that the stream delay was set before the call to the // AECM ProcessCaptureAudio function. - if (!was_stream_delay_set()) { + if (!capture_.was_stream_delay_set) { return AudioProcessing::kStreamParameterNotSetError; } @@ -1252,7 +1252,7 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() { if (submodules_.echo_controller) { data_dumper_->DumpRaw("stream_delay", stream_delay_ms()); - if (was_stream_delay_set()) { + if (capture_.was_stream_delay_set) { submodules_.echo_controller->SetAudioBufferDelay(stream_delay_ms()); } @@ -1553,7 +1553,6 @@ int AudioProcessingImpl::set_stream_delay_ms(int delay) { rtc::CritScope cs(&crit_capture_); Error retval = kNoError; capture_.was_stream_delay_set = true; - delay += capture_.delay_offset_ms; if (delay < 0) { delay = 0; @@ -1600,26 +1599,11 @@ int AudioProcessingImpl::stream_delay_ms() const { return capture_nonlocked_.stream_delay_ms; } -bool AudioProcessingImpl::was_stream_delay_set() const { - // Used as callback from submodules, hence locking is not allowed. - return capture_.was_stream_delay_set; -} - void AudioProcessingImpl::set_stream_key_pressed(bool key_pressed) { rtc::CritScope cs(&crit_capture_); capture_.key_pressed = key_pressed; } -void AudioProcessingImpl::set_delay_offset_ms(int offset) { - rtc::CritScope cs(&crit_capture_); - capture_.delay_offset_ms = offset; -} - -int AudioProcessingImpl::delay_offset_ms() const { - rtc::CritScope cs(&crit_capture_); - return capture_.delay_offset_ms; -} - void AudioProcessingImpl::set_stream_analog_level(int level) { rtc::CritScope cs_capture(&crit_capture_); @@ -2107,8 +2091,7 @@ void AudioProcessingImpl::RecordAudioProcessingState() { } AudioProcessingImpl::ApmCaptureState::ApmCaptureState() - : delay_offset_ms(0), - was_stream_delay_set(false), + : was_stream_delay_set(false), output_will_be_muted(false), key_pressed(false), capture_processing_format(kSampleRate16kHz), diff --git a/modules/audio_processing/audio_processing_impl.h b/modules/audio_processing/audio_processing_impl.h index af5a0f63c4..c74d7ca89e 100644 --- a/modules/audio_processing/audio_processing_impl.h +++ b/modules/audio_processing/audio_processing_impl.h @@ -89,8 +89,6 @@ class AudioProcessingImpl : public AudioProcessing { rtc::ArrayView> linear_output) const override; void set_output_will_be_muted(bool muted) override; int set_stream_delay_ms(int delay) override; - void set_delay_offset_ms(int offset) override; - int delay_offset_ms() const override; void set_stream_key_pressed(bool key_pressed) override; void set_stream_analog_level(int level) override; int recommended_stream_analog_level() const override; @@ -115,8 +113,6 @@ class AudioProcessingImpl : public AudioProcessing { size_t num_output_channels() const override; size_t num_reverse_channels() const override; int stream_delay_ms() const override; - bool was_stream_delay_set() const override - RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); AudioProcessingStats GetStatistics(bool has_remote_tracks) override { return GetStatistics(); @@ -394,7 +390,6 @@ class AudioProcessingImpl : public AudioProcessing { struct ApmCaptureState { ApmCaptureState(); ~ApmCaptureState(); - int delay_offset_ms; bool was_stream_delay_set; bool output_will_be_muted; bool key_pressed; diff --git a/modules/audio_processing/audio_processing_impl_locking_unittest.cc b/modules/audio_processing/audio_processing_impl_locking_unittest.cc index d9a8741bf8..50747a732d 100644 --- a/modules/audio_processing/audio_processing_impl_locking_unittest.cc +++ b/modules/audio_processing/audio_processing_impl_locking_unittest.cc @@ -816,15 +816,10 @@ void CaptureProcessor::ApplyRuntimeSettingScheme() { ASSERT_EQ(AudioProcessing::Error::kNoError, apm_->set_stream_delay_ms(30)); apm_->set_stream_key_pressed(true); - apm_->set_delay_offset_ms(15); - EXPECT_EQ(apm_->delay_offset_ms(), 15); } else { ASSERT_EQ(AudioProcessing::Error::kNoError, apm_->set_stream_delay_ms(50)); apm_->set_stream_key_pressed(false); - apm_->set_delay_offset_ms(20); - EXPECT_EQ(apm_->delay_offset_ms(), 20); - apm_->delay_offset_ms(); } break; default: diff --git a/modules/audio_processing/audio_processing_unittest.cc b/modules/audio_processing/audio_processing_unittest.cc index f83efe66f0..2f557e5c70 100644 --- a/modules/audio_processing/audio_processing_unittest.cc +++ b/modules/audio_processing/audio_processing_unittest.cc @@ -732,30 +732,6 @@ TEST_F(ApmTest, StreamParametersFloat) { StreamParametersTest(kFloatFormat); } -TEST_F(ApmTest, DefaultDelayOffsetIsZero) { - EXPECT_EQ(0, apm_->delay_offset_ms()); - EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(50)); - EXPECT_EQ(50, apm_->stream_delay_ms()); -} - -TEST_F(ApmTest, DelayOffsetWithLimitsIsSetProperly) { - // High limit of 500 ms. - apm_->set_delay_offset_ms(100); - EXPECT_EQ(100, apm_->delay_offset_ms()); - EXPECT_EQ(apm_->kBadStreamParameterWarning, apm_->set_stream_delay_ms(450)); - EXPECT_EQ(500, apm_->stream_delay_ms()); - EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100)); - EXPECT_EQ(200, apm_->stream_delay_ms()); - - // Low limit of 0 ms. - apm_->set_delay_offset_ms(-50); - EXPECT_EQ(-50, apm_->delay_offset_ms()); - EXPECT_EQ(apm_->kBadStreamParameterWarning, apm_->set_stream_delay_ms(20)); - EXPECT_EQ(0, apm_->stream_delay_ms()); - EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100)); - EXPECT_EQ(50, apm_->stream_delay_ms()); -} - void ApmTest::TestChangingChannelsInt16Interface( size_t num_channels, AudioProcessing::Error expected_return) { diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h index a41dfa116c..f5d37b9d8c 100644 --- a/modules/audio_processing/include/audio_processing.h +++ b/modules/audio_processing/include/audio_processing.h @@ -611,20 +611,11 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface { // ProcessStream(). virtual int set_stream_delay_ms(int delay) = 0; virtual int stream_delay_ms() const = 0; - virtual bool was_stream_delay_set() const = 0; // Call to signal that a key press occurred (true) or did not occur (false) // with this chunk of audio. virtual void set_stream_key_pressed(bool key_pressed) = 0; - // Sets a delay |offset| in ms to add to the values passed in through - // set_stream_delay_ms(). May be positive or negative. - // - // Note that this could cause an otherwise valid value passed to - // set_stream_delay_ms() to return an error. - virtual void set_delay_offset_ms(int offset) = 0; - virtual int delay_offset_ms() const = 0; - // Attaches provided webrtc::AecDump for recording debugging // information. Log file and maximum file size logic is supposed to // be handled by implementing instance of AecDump. Calling this