Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: webrtc/modules/audio_processing/aec/echo_cancellation.c

Issue 1175903002: audio_processing: Create now returns a pointer to the object (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed review comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 int16_t reported_delay_ms, 111 int16_t reported_delay_ms,
112 int32_t skew); 112 int32_t skew);
113 static void ProcessExtended(Aec* self, 113 static void ProcessExtended(Aec* self,
114 const float* const* near, 114 const float* const* near,
115 int num_bands, 115 int num_bands,
116 float* const* out, 116 float* const* out,
117 int16_t num_samples, 117 int16_t num_samples,
118 int16_t reported_delay_ms, 118 int16_t reported_delay_ms,
119 int32_t skew); 119 int32_t skew);
120 120
121 int32_t WebRtcAec_Create(void** aecInst) { 121 void* WebRtcAec_Create() {
122 Aec* aecpc; 122 Aec* aecpc = malloc(sizeof(Aec));
123 if (aecInst == NULL) { 123
124 return -1; 124 if (!aecpc) {
125 return NULL;
125 } 126 }
126 127
127 aecpc = malloc(sizeof(Aec)); 128 aecpc->aec = WebRtcAec_CreateAec();
128 *aecInst = aecpc; 129 if (!aecpc->aec) {
129 if (aecpc == NULL) { 130 WebRtcAec_Free(aecpc);
130 return -1; 131 return NULL;
131 } 132 }
132 133 aecpc->resampler = WebRtcAec_CreateResampler();
133 if (WebRtcAec_CreateAec(&aecpc->aec) == -1) { 134 if (!aecpc->resampler) {
134 WebRtcAec_Free(aecpc); 135 WebRtcAec_Free(aecpc);
135 aecpc = NULL; 136 return NULL;
136 return -1;
137 }
138
139 if (WebRtcAec_CreateResampler(&aecpc->resampler) == -1) {
140 WebRtcAec_Free(aecpc);
141 aecpc = NULL;
142 return -1;
143 } 137 }
144 // Create far-end pre-buffer. The buffer size has to be large enough for 138 // Create far-end pre-buffer. The buffer size has to be large enough for
145 // largest possible drift compensation (kResamplerBufferSize) + "almost" an 139 // largest possible drift compensation (kResamplerBufferSize) + "almost" an
146 // FFT buffer (PART_LEN2 - 1). 140 // FFT buffer (PART_LEN2 - 1).
147 aecpc->far_pre_buf = 141 aecpc->far_pre_buf =
148 WebRtc_CreateBuffer(PART_LEN2 + kResamplerBufferSize, sizeof(float)); 142 WebRtc_CreateBuffer(PART_LEN2 + kResamplerBufferSize, sizeof(float));
149 if (!aecpc->far_pre_buf) { 143 if (!aecpc->far_pre_buf) {
150 WebRtcAec_Free(aecpc); 144 WebRtcAec_Free(aecpc);
151 aecpc = NULL; 145 return NULL;
152 return -1;
153 } 146 }
154 147
155 aecpc->initFlag = 0; 148 aecpc->initFlag = 0;
156 aecpc->lastError = 0; 149 aecpc->lastError = 0;
157 150
158 #ifdef WEBRTC_AEC_DEBUG_DUMP 151 #ifdef WEBRTC_AEC_DEBUG_DUMP
159 { 152 {
160 char filename[64]; 153 char filename[64];
161 sprintf(filename, "aec_buf%d.dat", webrtc_aec_instance_count); 154 sprintf(filename, "aec_buf%d.dat", webrtc_aec_instance_count);
162 aecpc->bufFile = fopen(filename, "wb"); 155 aecpc->bufFile = fopen(filename, "wb");
163 sprintf(filename, "aec_skew%d.dat", webrtc_aec_instance_count); 156 sprintf(filename, "aec_skew%d.dat", webrtc_aec_instance_count);
164 aecpc->skewFile = fopen(filename, "wb"); 157 aecpc->skewFile = fopen(filename, "wb");
165 sprintf(filename, "aec_delay%d.dat", webrtc_aec_instance_count); 158 sprintf(filename, "aec_delay%d.dat", webrtc_aec_instance_count);
166 aecpc->delayFile = fopen(filename, "wb"); 159 aecpc->delayFile = fopen(filename, "wb");
167 webrtc_aec_instance_count++; 160 webrtc_aec_instance_count++;
168 } 161 }
169 #endif 162 #endif
170 163
171 return 0; 164 return aecpc;
172 } 165 }
173 166
174 void WebRtcAec_Free(void* aecInst) { 167 void WebRtcAec_Free(void* aecInst) {
175 Aec* aecpc = aecInst; 168 Aec* aecpc = aecInst;
176 169
177 if (aecpc == NULL) { 170 if (aecpc == NULL) {
178 return; 171 return;
179 } 172 }
180 173
181 WebRtc_FreeBuffer(aecpc->far_pre_buf); 174 WebRtc_FreeBuffer(aecpc->far_pre_buf);
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 } 914 }
922 } else { 915 } else {
923 self->timeForDelayChange = 0; 916 self->timeForDelayChange = 0;
924 } 917 }
925 self->lastDelayDiff = delay_difference; 918 self->lastDelayDiff = delay_difference;
926 919
927 if (self->timeForDelayChange > 25) { 920 if (self->timeForDelayChange > 25) {
928 self->knownDelay = WEBRTC_SPL_MAX((int)self->filtDelay - 256, 0); 921 self->knownDelay = WEBRTC_SPL_MAX((int)self->filtDelay - 256, 0);
929 } 922 }
930 } 923 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/aec/aec_resampler.c ('k') | webrtc/modules/audio_processing/aec/echo_cancellation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698