Moved the file aec_resampler.c to be built using C++.
The steps involved were:
1) Change file name to .cc from .c.
2) Update the build files accordingly.
3) Remove the extern header file inclusion.
4) Change the casts in aec_resampler.cc to static_cast
and reinterpret_cast.
The changes are bitexact.
The CL will be followed with another CL where a proper (webrtc) namespace is introduced. The reason for not having it in this CL is that this was missed in the corresponding
CL that did the above for aec_core.c, ..., and if the
namespaces in all the aec_core -related files can be changed
at the same time that will simplify things.
BUG=webrtc:5201
Review URL: https://codereview.webrtc.org/1754223004
Cr-Commit-Position: refs/heads/master@{#11867}
diff --git a/webrtc/modules/audio_processing/BUILD.gn b/webrtc/modules/audio_processing/BUILD.gn
index 454d1be..6f5a046 100644
--- a/webrtc/modules/audio_processing/BUILD.gn
+++ b/webrtc/modules/audio_processing/BUILD.gn
@@ -27,7 +27,7 @@
"aec/aec_core_internal.h",
"aec/aec_rdft.c",
"aec/aec_rdft.h",
- "aec/aec_resampler.c",
+ "aec/aec_resampler.cc",
"aec/aec_resampler.h",
"aec/echo_cancellation.cc",
"aec/echo_cancellation.h",
diff --git a/webrtc/modules/audio_processing/aec/aec_resampler.c b/webrtc/modules/audio_processing/aec/aec_resampler.cc
similarity index 88%
rename from webrtc/modules/audio_processing/aec/aec_resampler.c
rename to webrtc/modules/audio_processing/aec/aec_resampler.cc
index ae64ddf..8528fa6 100644
--- a/webrtc/modules/audio_processing/aec/aec_resampler.c
+++ b/webrtc/modules/audio_processing/aec/aec_resampler.cc
@@ -43,7 +43,7 @@
}
int WebRtcAec_InitResampler(void* resampInst, int deviceSampleRateHz) {
- AecResampler* obj = (AecResampler*)resampInst;
+ AecResampler* obj = static_cast<AecResampler*>(resampInst);
memset(obj->buffer, 0, sizeof(obj->buffer));
obj->position = 0.0;
@@ -56,7 +56,7 @@
}
void WebRtcAec_FreeResampler(void* resampInst) {
- AecResampler* obj = (AecResampler*)resampInst;
+ AecResampler* obj = static_cast<AecResampler*>(resampInst);
free(obj);
}
@@ -66,7 +66,7 @@
float skew,
float* outspeech,
size_t* size_out) {
- AecResampler* obj = (AecResampler*)resampInst;
+ AecResampler* obj = static_cast<AecResampler*>(resampInst);
float* y;
float be, tnew;
@@ -98,7 +98,7 @@
mm++;
tnew = be * mm + obj->position;
- tn = (int)tnew;
+ tn = static_cast<int>(tnew);
}
*size_out = mm;
@@ -110,7 +110,7 @@
}
int WebRtcAec_GetSkew(void* resampInst, int rawSkew, float* skewEst) {
- AecResampler* obj = (AecResampler*)resampInst;
+ AecResampler* obj = static_cast<AecResampler*>(resampInst);
int err = 0;
if (obj->skewDataIndex < kEstimateLengthFrames) {
@@ -132,8 +132,8 @@
int size,
int deviceSampleRateHz,
float* skewEst) {
- const int absLimitOuter = (int)(0.04f * deviceSampleRateHz);
- const int absLimitInner = (int)(0.0025f * deviceSampleRateHz);
+ const int absLimitOuter = static_cast<int>(0.04f * deviceSampleRateHz);
+ const int absLimitInner = static_cast<int>(0.0025f * deviceSampleRateHz);
int i = 0;
int n = 0;
float rawAvg = 0;
@@ -172,8 +172,8 @@
}
assert(n > 0);
rawAbsDev /= n;
- upperLimit = (int)(rawAvg + 5 * rawAbsDev + 1); // +1 for ceiling.
- lowerLimit = (int)(rawAvg - 5 * rawAbsDev - 1); // -1 for floor.
+ upperLimit = static_cast<int>(rawAvg + 5 * rawAbsDev + 1); // +1 for ceiling.
+ lowerLimit = static_cast<int>(rawAvg - 5 * rawAbsDev - 1); // -1 for floor.
n = 0;
for (i = 0; i < size; i++) {
diff --git a/webrtc/modules/audio_processing/aec/echo_cancellation.cc b/webrtc/modules/audio_processing/aec/echo_cancellation.cc
index 8bbf151..c6f95a5 100644
--- a/webrtc/modules/audio_processing/aec/echo_cancellation.cc
+++ b/webrtc/modules/audio_processing/aec/echo_cancellation.cc
@@ -25,9 +25,7 @@
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
}
#include "webrtc/modules/audio_processing/aec/aec_core.h"
-extern "C" {
#include "webrtc/modules/audio_processing/aec/aec_resampler.h"
-}
#include "webrtc/modules/audio_processing/aec/echo_cancellation_internal.h"
#include "webrtc/typedefs.h"
diff --git a/webrtc/modules/audio_processing/audio_processing.gypi b/webrtc/modules/audio_processing/audio_processing.gypi
index 85698cf..7a04358 100644
--- a/webrtc/modules/audio_processing/audio_processing.gypi
+++ b/webrtc/modules/audio_processing/audio_processing.gypi
@@ -37,7 +37,7 @@
'aec/aec_core_internal.h',
'aec/aec_rdft.c',
'aec/aec_rdft.h',
- 'aec/aec_resampler.c',
+ 'aec/aec_resampler.cc',
'aec/aec_resampler.h',
'aec/echo_cancellation.cc',
'aec/echo_cancellation_internal.h',