Move stream_delay check to ProcessStream().
- was_stream_delay_set_ was being incorrectly reset in AnalyzeReverseStream(). - Added tests to catch this case. BUG= TEST=audioproc_unittest Review URL: http://webrtc-codereview.appspot.com/291011 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1054 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
0bf2ca2eed
commit
1e91693fe2
@ -371,6 +371,7 @@ int AudioProcessingImpl::ProcessStream(AudioFrame* frame) {
|
||||
}
|
||||
}
|
||||
|
||||
was_stream_delay_set_ = false;
|
||||
return kNoError;
|
||||
}
|
||||
|
||||
@ -437,7 +438,6 @@ int AudioProcessingImpl::AnalyzeReverseStream(AudioFrame* frame) {
|
||||
return err;
|
||||
}
|
||||
|
||||
was_stream_delay_set_ = false;
|
||||
return err; // TODO(ajm): this is for returning warnings; necessary?
|
||||
}
|
||||
|
||||
|
@ -352,54 +352,77 @@ TEST_F(ApmTest, StreamParameters) {
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->ProcessStream(frame_));
|
||||
|
||||
// Missing agc level
|
||||
// -- Missing AGC level --
|
||||
EXPECT_EQ(apm_->kNoError, apm_->Initialize());
|
||||
EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(true));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError,
|
||||
apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100));
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->echo_cancellation()->set_stream_drift_samples(0));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError,
|
||||
apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(false));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError, apm_->ProcessStream(frame_));
|
||||
|
||||
// Missing delay
|
||||
EXPECT_EQ(apm_->kNoError, apm_->Initialize());
|
||||
EXPECT_EQ(apm_->kNoError, apm_->echo_cancellation()->Enable(true));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError,
|
||||
apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(true));
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->echo_cancellation()->set_stream_drift_samples(0));
|
||||
// Resets after successful ProcessStream().
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->gain_control()->set_stream_analog_level(127));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError,
|
||||
apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(false));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError, apm_->ProcessStream(frame_));
|
||||
|
||||
// Missing drift
|
||||
EXPECT_EQ(apm_->kNoError, apm_->Initialize());
|
||||
// Other stream parameters set correctly.
|
||||
EXPECT_EQ(apm_->kNoError, apm_->echo_cancellation()->Enable(true));
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->echo_cancellation()->enable_drift_compensation(true));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100));
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->echo_cancellation()->set_stream_drift_samples(0));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError,
|
||||
apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(false));
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->echo_cancellation()->enable_drift_compensation(false));
|
||||
|
||||
// -- Missing delay --
|
||||
EXPECT_EQ(apm_->kNoError, apm_->Initialize());
|
||||
EXPECT_EQ(apm_->kNoError, apm_->echo_cancellation()->Enable(true));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError, apm_->ProcessStream(frame_));
|
||||
|
||||
// Resets after successful ProcessStream().
|
||||
EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError, apm_->ProcessStream(frame_));
|
||||
|
||||
// Other stream parameters set correctly.
|
||||
EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(true));
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->echo_cancellation()->enable_drift_compensation(true));
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->echo_cancellation()->set_stream_drift_samples(0));
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->gain_control()->set_stream_analog_level(127));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError, apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(false));
|
||||
|
||||
// -- Missing drift --
|
||||
EXPECT_EQ(apm_->kNoError, apm_->Initialize());
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError, apm_->ProcessStream(frame_));
|
||||
|
||||
// Resets after successful ProcessStream().
|
||||
EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100));
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->echo_cancellation()->set_stream_drift_samples(0));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError, apm_->ProcessStream(frame_));
|
||||
|
||||
// Other stream parameters set correctly.
|
||||
EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(true));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100));
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->gain_control()->set_stream_analog_level(127));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError,
|
||||
apm_->ProcessStream(frame_));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError, apm_->ProcessStream(frame_));
|
||||
|
||||
// No stream parameters
|
||||
// -- No stream parameters --
|
||||
EXPECT_EQ(apm_->kNoError, apm_->Initialize());
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->AnalyzeReverseStream(revframe_));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError,
|
||||
apm_->ProcessStream(frame_));
|
||||
|
||||
// All there
|
||||
EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(true));
|
||||
// -- All there --
|
||||
EXPECT_EQ(apm_->kNoError, apm_->Initialize());
|
||||
EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100));
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
|
Loading…
x
Reference in New Issue
Block a user