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

@ -17,6 +17,7 @@
#include "modules/audio_processing/residual_echo_detector.h"
#include "rtc_base/checks.h"
#include "rtc_base/refcountedobject.h"
namespace webrtc {
@ -42,10 +43,11 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
read_idx += 2;
std::bitset<16> call_order(call_order_int);
ResidualEchoDetector echo_detector;
rtc::scoped_refptr<ResidualEchoDetector> echo_detector =
new rtc::RefCountedObject<ResidualEchoDetector>();
std::vector<float> input(1);
// Call AnalyzeCaptureAudio once to prevent the flushing of the buffer.
echo_detector.AnalyzeCaptureAudio(input);
echo_detector->AnalyzeCaptureAudio(input);
for (size_t i = 0; i < 2 * kNrOfUpdates; ++i) {
// Convert 4 input bytes to a float.
RTC_DCHECK_LE(read_idx + sizeof(float), size);
@ -56,9 +58,9 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
continue;
}
if (call_order[i]) {
echo_detector.AnalyzeRenderAudio(input);
echo_detector->AnalyzeRenderAudio(input);
} else {
echo_detector.AnalyzeCaptureAudio(input);
echo_detector->AnalyzeCaptureAudio(input);
}
}
}