From 7267ffde56f13fbcdd71c04ae6aad1d7390a05ae Mon Sep 17 00:00:00 2001 From: "bjornv@webrtc.org" Date: Thu, 14 Feb 2013 17:56:23 +0000 Subject: [PATCH] Moved debug file handling to aec_core from echo_cancellation.c. This removes dependency on low level member variables. TEST=audioproc_unittest, trybots BUG=None Review URL: https://webrtc-codereview.appspot.com/1093010 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3515 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../modules/audio_processing/aec/aec_core.c | 19 ++++++++++++++++ .../audio_processing/aec/echo_cancellation.c | 22 +++++-------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/webrtc/modules/audio_processing/aec/aec_core.c b/webrtc/modules/audio_processing/aec/aec_core.c index 191a5058c5..931afb9b0d 100644 --- a/webrtc/modules/audio_processing/aec/aec_core.c +++ b/webrtc/modules/audio_processing/aec/aec_core.c @@ -105,6 +105,10 @@ const float WebRtcAec_overDriveCurve[65] = { 1.9682f, 1.9763f, 1.9843f, 1.9922f, 2.0000f }; +#ifdef WEBRTC_AEC_DEBUG_DUMP +extern int webrtc_aec_instance_count; +#endif + // "Private" function prototypes. static void ProcessBlock(aec_t* aec); @@ -205,6 +209,17 @@ int WebRtcAec_CreateAec(aec_t **aecInst) aec = NULL; return -1; } + { + char filename[64]; + sprintf(filename, "aec_far%d.pcm", webrtc_aec_instance_count); + aec->farFile = fopen(filename, "wb"); + sprintf(filename, "aec_near%d.pcm", webrtc_aec_instance_count); + aec->nearFile = fopen(filename, "wb"); + sprintf(filename, "aec_out%d.pcm", webrtc_aec_instance_count); + aec->outFile = fopen(filename, "wb"); + sprintf(filename, "aec_out_linear%d.pcm", webrtc_aec_instance_count); + aec->outLinearFile = fopen(filename, "wb"); + } #endif aec->delay_estimator_farend = WebRtc_CreateDelayEstimatorFarend(PART_LEN1, kHistorySizeBlocks); @@ -241,6 +256,10 @@ int WebRtcAec_FreeAec(aec_t *aec) WebRtc_FreeBuffer(aec->far_buf_windowed); #ifdef WEBRTC_AEC_DEBUG_DUMP WebRtc_FreeBuffer(aec->far_time_buf); + fclose(aec->farFile); + fclose(aec->nearFile); + fclose(aec->outFile); + fclose(aec->outLinearFile); #endif WebRtc_FreeDelayEstimator(aec->delay_estimator); WebRtc_FreeDelayEstimatorFarend(aec->delay_estimator_farend); diff --git a/webrtc/modules/audio_processing/aec/echo_cancellation.c b/webrtc/modules/audio_processing/aec/echo_cancellation.c index b5728b8d60..5e079c5121 100644 --- a/webrtc/modules/audio_processing/aec/echo_cancellation.c +++ b/webrtc/modules/audio_processing/aec/echo_cancellation.c @@ -42,7 +42,7 @@ static const float minOverDrive[3] = {1.0f, 2.0f, 5.0f}; static const int initCheck = 42; #ifdef WEBRTC_AEC_DEBUG_DUMP -static int instance_count = 0; +int webrtc_aec_instance_count = 0; #endif // Estimates delay to set the position of the far-end buffer read pointer @@ -97,21 +97,13 @@ WebRtc_Word32 WebRtcAec_Create(void **aecInst) } { char filename[64]; - sprintf(filename, "aec_far%d.pcm", instance_count); - aecpc->aec->farFile = fopen(filename, "wb"); - sprintf(filename, "aec_near%d.pcm", instance_count); - aecpc->aec->nearFile = fopen(filename, "wb"); - sprintf(filename, "aec_out%d.pcm", instance_count); - aecpc->aec->outFile = fopen(filename, "wb"); - sprintf(filename, "aec_out_linear%d.pcm", instance_count); - aecpc->aec->outLinearFile = fopen(filename, "wb"); - sprintf(filename, "aec_buf%d.dat", instance_count); + sprintf(filename, "aec_buf%d.dat", webrtc_aec_instance_count); aecpc->bufFile = fopen(filename, "wb"); - sprintf(filename, "aec_skew%d.dat", instance_count); + sprintf(filename, "aec_skew%d.dat", webrtc_aec_instance_count); aecpc->skewFile = fopen(filename, "wb"); - sprintf(filename, "aec_delay%d.dat", instance_count); + sprintf(filename, "aec_delay%d.dat", webrtc_aec_instance_count); aecpc->delayFile = fopen(filename, "wb"); - instance_count++; + webrtc_aec_instance_count++; } #endif @@ -130,10 +122,6 @@ WebRtc_Word32 WebRtcAec_Free(void *aecInst) #ifdef WEBRTC_AEC_DEBUG_DUMP WebRtc_FreeBuffer(aecpc->far_pre_buf_s16); - fclose(aecpc->aec->farFile); - fclose(aecpc->aec->nearFile); - fclose(aecpc->aec->outFile); - fclose(aecpc->aec->outLinearFile); fclose(aecpc->bufFile); fclose(aecpc->skewFile); fclose(aecpc->delayFile);