From 2512604705aad9e03daa622a30ffa7a29ea8da23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85hgren?= Date: Thu, 5 Dec 2019 07:32:32 +0100 Subject: [PATCH] Adding a copy constructor for the Config in AudioProcessing Bug: webrtc:11180 Change-Id: I4621f83c0441fda55d0f81606174c004668dd6c6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161325 Reviewed-by: Sam Zackrisson Reviewed-by: Mirko Bonadei Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/master@{#30015} --- .../include/audio_processing.h | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h index 2ec336719c..ba56684991 100644 --- a/modules/audio_processing/include/audio_processing.h +++ b/modules/audio_processing/include/audio_processing.h @@ -247,6 +247,23 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface { // submodule resets, affecting the audio quality. Use the RuntimeSetting // construct for runtime configuration. struct RTC_EXPORT Config { + Config() = default; + + // Explicit copy assignment implementation to avoid issues with memory + // sanitizer complaints in case of self-assignment. + // TODO(peah): Add buildflag to ensure that this is only included for memory + // sanitizer builds. + Config& operator=(const Config& config) { + if (this != &config) { + memcpy(this, &config, sizeof(*this)); + } + return *this; + } + + // Explicit copy constructor needed to avoid errors due to the above + // implemented copy assignment operator. + Config(const Config& config) { *this = config; } + // Sets the properties of the audio processing pipeline. struct RTC_EXPORT Pipeline { Pipeline(); @@ -387,17 +404,6 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface { bool enabled = false; } level_estimation; - // Explicit copy assignment implementation to avoid issues with memory - // sanitizer complaints in case of self-assignment. - // TODO(peah): Add buildflag to ensure that this is only included for memory - // sanitizer builds. - Config& operator=(const Config& config) { - if (this != &config) { - memcpy(this, &config, sizeof(*this)); - } - return *this; - } - std::string ToString() const; };