Change echo detector to scoped_refptr

The echo detector is currently stored as a unique_ptr, but when injecting an echo detector, a scoped_refptr makes more sense since the ownership will be shared.

Bug: webrtc:8732
Change-Id: I2180014acb84f1cd5c361864a444b7b6574520f5
Reviewed-on: https://webrtc-review.googlesource.com/83325
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23610}
This commit is contained in:
Ivo Creusen
2018-06-14 11:02:03 +02:00
committed by Commit Bot
parent 4e952a3f44
commit d1f970dc43
5 changed files with 56 additions and 50 deletions

View File

@ -678,7 +678,7 @@ class AudioProcessingBuilder {
std::unique_ptr<NonlinearBeamformer> nonlinear_beamformer);
// The AudioProcessingBuilder takes ownership of the echo_detector.
AudioProcessingBuilder& SetEchoDetector(
std::unique_ptr<EchoDetector> echo_detector);
rtc::scoped_refptr<EchoDetector> echo_detector);
// This creates an APM instance using the previously set components. Calling
// the Create function resets the AudioProcessingBuilder to its initial state.
AudioProcessing* Create();
@ -689,7 +689,7 @@ class AudioProcessingBuilder {
std::unique_ptr<CustomProcessing> capture_post_processing_;
std::unique_ptr<CustomProcessing> render_pre_processing_;
std::unique_ptr<NonlinearBeamformer> nonlinear_beamformer_;
std::unique_ptr<EchoDetector> echo_detector_;
rtc::scoped_refptr<EchoDetector> echo_detector_;
RTC_DISALLOW_COPY_AND_ASSIGN(AudioProcessingBuilder);
};
@ -1135,7 +1135,7 @@ class CustomProcessing {
};
// Interface for an echo detector submodule.
class EchoDetector {
class EchoDetector : public rtc::RefCountInterface {
public:
// (Re-)Initializes the submodule.
virtual void Initialize(int capture_sample_rate_hz,
@ -1161,8 +1161,6 @@ class EchoDetector {
// Collect current metrics from the echo detector.
virtual Metrics GetMetrics() const = 0;
virtual ~EchoDetector() {}
};
// The voice activity detection (VAD) component analyzes the stream to