Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 | 61 |
| 62 #ifdef AEC_DEBUG | 62 #ifdef AEC_DEBUG |
| 63 FILE *bufFile; | 63 FILE *bufFile; |
| 64 FILE *delayFile; | 64 FILE *delayFile; |
| 65 FILE *preCompFile; | 65 FILE *preCompFile; |
| 66 FILE *postCompFile; | 66 FILE *postCompFile; |
| 67 #endif // AEC_DEBUG | 67 #endif // AEC_DEBUG |
| 68 // Structures | 68 // Structures |
| 69 RingBuffer *farendBuf; | 69 RingBuffer *farendBuf; |
| 70 | 70 |
| 71 int lastError; | |
| 72 | |
| 73 AecmCore* aecmCore; | 71 AecmCore* aecmCore; |
| 74 } AecMobile; | 72 } AecMobile; |
| 75 | 73 |
| 76 // Estimates delay to set the position of the farend buffer read pointer | 74 // Estimates delay to set the position of the farend buffer read pointer |
| 77 // (controlled by knownDelay) | 75 // (controlled by knownDelay) |
| 78 static int WebRtcAecm_EstBufDelay(AecMobile* aecmInst, short msInSndCardBuf); | 76 static int WebRtcAecm_EstBufDelay(AecMobile* aecmInst, short msInSndCardBuf); |
| 79 | 77 |
| 80 // Stuffs the farend buffer if the estimated delay is too large | 78 // Stuffs the farend buffer if the estimated delay is too large |
| 81 static int WebRtcAecm_DelayComp(AecMobile* aecmInst); | 79 static int WebRtcAecm_DelayComp(AecMobile* aecmInst); |
| 82 | 80 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 93 | 91 |
| 94 aecm->farendBuf = WebRtc_CreateBuffer(kBufSizeSamp, | 92 aecm->farendBuf = WebRtc_CreateBuffer(kBufSizeSamp, |
| 95 sizeof(int16_t)); | 93 sizeof(int16_t)); |
| 96 if (!aecm->farendBuf) | 94 if (!aecm->farendBuf) |
| 97 { | 95 { |
| 98 WebRtcAecm_Free(aecm); | 96 WebRtcAecm_Free(aecm); |
| 99 return NULL; | 97 return NULL; |
| 100 } | 98 } |
| 101 | 99 |
| 102 aecm->initFlag = 0; | 100 aecm->initFlag = 0; |
| 103 aecm->lastError = 0; | |
| 104 | 101 |
| 105 #ifdef AEC_DEBUG | 102 #ifdef AEC_DEBUG |
| 106 aecm->aecmCore->farFile = fopen("aecFar.pcm","wb"); | 103 aecm->aecmCore->farFile = fopen("aecFar.pcm","wb"); |
| 107 aecm->aecmCore->nearFile = fopen("aecNear.pcm","wb"); | 104 aecm->aecmCore->nearFile = fopen("aecNear.pcm","wb"); |
| 108 aecm->aecmCore->outFile = fopen("aecOut.pcm","wb"); | 105 aecm->aecmCore->outFile = fopen("aecOut.pcm","wb"); |
| 109 //aecm->aecmCore->outLpFile = fopen("aecOutLp.pcm","wb"); | 106 //aecm->aecmCore->outLpFile = fopen("aecOutLp.pcm","wb"); |
| 110 | 107 |
| 111 aecm->bufFile = fopen("aecBuf.dat", "wb"); | 108 aecm->bufFile = fopen("aecBuf.dat", "wb"); |
| 112 aecm->delayFile = fopen("aecDelay.dat", "wb"); | 109 aecm->delayFile = fopen("aecDelay.dat", "wb"); |
| 113 aecm->preCompFile = fopen("preComp.pcm", "wb"); | 110 aecm->preCompFile = fopen("preComp.pcm", "wb"); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 144 AecMobile* aecm = aecmInst; | 141 AecMobile* aecm = aecmInst; |
| 145 AecmConfig aecConfig; | 142 AecmConfig aecConfig; |
| 146 | 143 |
| 147 if (aecm == NULL) | 144 if (aecm == NULL) |
| 148 { | 145 { |
| 149 return -1; | 146 return -1; |
| 150 } | 147 } |
| 151 | 148 |
| 152 if (sampFreq != 8000 && sampFreq != 16000) | 149 if (sampFreq != 8000 && sampFreq != 16000) |
| 153 { | 150 { |
| 154 aecm->lastError = AECM_BAD_PARAMETER_ERROR; | 151 return AECM_BAD_PARAMETER_ERROR; |
| 155 return -1; | |
| 156 } | 152 } |
| 157 aecm->sampFreq = sampFreq; | 153 aecm->sampFreq = sampFreq; |
| 158 | 154 |
| 159 // Initialize AECM core | 155 // Initialize AECM core |
| 160 if (WebRtcAecm_InitCore(aecm->aecmCore, aecm->sampFreq) == -1) | 156 if (WebRtcAecm_InitCore(aecm->aecmCore, aecm->sampFreq) == -1) |
| 161 { | 157 { |
| 162 aecm->lastError = AECM_UNSPECIFIED_ERROR; | 158 return AECM_UNSPECIFIED_ERROR; |
| 163 return -1; | |
| 164 } | 159 } |
| 165 | 160 |
| 166 // Initialize farend buffer | 161 // Initialize farend buffer |
| 167 WebRtc_InitBuffer(aecm->farendBuf); | 162 WebRtc_InitBuffer(aecm->farendBuf); |
| 168 | 163 |
| 169 aecm->initFlag = kInitCheck; // indicates that initialization has been done | 164 aecm->initFlag = kInitCheck; // indicates that initialization has been done |
| 170 | 165 |
| 171 aecm->delayChange = 1; | 166 aecm->delayChange = 1; |
| 172 | 167 |
| 173 aecm->sum = 0; | 168 aecm->sum = 0; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 184 aecm->lastDelayDiff = 0; | 179 aecm->lastDelayDiff = 0; |
| 185 | 180 |
| 186 memset(&aecm->farendOld[0][0], 0, 160); | 181 memset(&aecm->farendOld[0][0], 0, 160); |
| 187 | 182 |
| 188 // Default settings. | 183 // Default settings. |
| 189 aecConfig.cngMode = AecmTrue; | 184 aecConfig.cngMode = AecmTrue; |
| 190 aecConfig.echoMode = 3; | 185 aecConfig.echoMode = 3; |
| 191 | 186 |
| 192 if (WebRtcAecm_set_config(aecm, aecConfig) == -1) | 187 if (WebRtcAecm_set_config(aecm, aecConfig) == -1) |
| 193 { | 188 { |
| 194 aecm->lastError = AECM_UNSPECIFIED_ERROR; | 189 return AECM_UNSPECIFIED_ERROR; |
| 195 return -1; | |
| 196 } | 190 } |
| 197 | 191 |
| 198 return 0; | 192 return 0; |
| 199 } | 193 } |
| 200 | 194 |
| 195 // Returns any error that is caused when buffering the | |
| 196 // farend signal. | |
| 197 int32_t WebRtcAecm_GetBufferFarendError(void *aecmInst, const int16_t *farend, | |
| 198 size_t nrOfSamples) { | |
| 199 AecMobile* aecm = aecmInst; | |
| 200 | |
| 201 if (aecm == NULL) | |
| 202 return -1; | |
| 203 | |
| 204 if (farend == NULL) | |
| 205 return AECM_NULL_POINTER_ERROR; | |
| 206 | |
| 207 if (aecm->initFlag != kInitCheck) | |
| 208 return AECM_UNINITIALIZED_ERROR; | |
| 209 | |
| 210 if (nrOfSamples != 80 && nrOfSamples != 160) | |
| 211 return AECM_BAD_PARAMETER_ERROR; | |
| 212 | |
| 213 return 0; | |
| 214 } | |
| 215 | |
| 216 | |
| 201 int32_t WebRtcAecm_BufferFarend(void *aecmInst, const int16_t *farend, | 217 int32_t WebRtcAecm_BufferFarend(void *aecmInst, const int16_t *farend, |
| 202 size_t nrOfSamples) | 218 size_t nrOfSamples) { |
| 203 { | |
| 204 AecMobile* aecm = aecmInst; | 219 AecMobile* aecm = aecmInst; |
| 205 int32_t retVal = 0; | |
| 206 | 220 |
| 207 if (aecm == NULL) | 221 int32_t err = WebRtcAecm_GetBufferFarendError(aecmInst, farend, nrOfSamples); |
|
hlundin-webrtc
2015/10/14 14:34:49
const
peah-webrtc
2015/10/14 17:57:36
Done.
| |
| 208 { | |
| 209 return -1; | |
| 210 } | |
| 211 | 222 |
| 212 if (farend == NULL) | 223 if (err != 0) |
| 213 { | 224 return err; |
| 214 aecm->lastError = AECM_NULL_POINTER_ERROR; | |
| 215 return -1; | |
| 216 } | |
| 217 | 225 |
| 218 if (aecm->initFlag != kInitCheck) | 226 // TODO(unknown): Is this really a good idea? |
| 219 { | 227 if (!aecm->ECstartup) |
| 220 aecm->lastError = AECM_UNINITIALIZED_ERROR; | 228 { |
| 221 return -1; | 229 WebRtcAecm_DelayComp(aecm); |
| 222 } | 230 } |
| 223 | 231 |
| 224 if (nrOfSamples != 80 && nrOfSamples != 160) | 232 WebRtc_WriteBuffer(aecm->farendBuf, farend, nrOfSamples); |
| 225 { | |
| 226 aecm->lastError = AECM_BAD_PARAMETER_ERROR; | |
| 227 return -1; | |
| 228 } | |
| 229 | 233 |
| 230 // TODO: Is this really a good idea? | 234 return 0; |
| 231 if (!aecm->ECstartup) | |
| 232 { | |
| 233 WebRtcAecm_DelayComp(aecm); | |
| 234 } | |
| 235 | |
| 236 WebRtc_WriteBuffer(aecm->farendBuf, farend, nrOfSamples); | |
| 237 | |
| 238 return retVal; | |
| 239 } | 235 } |
| 240 | 236 |
| 241 int32_t WebRtcAecm_Process(void *aecmInst, const int16_t *nearendNoisy, | 237 int32_t WebRtcAecm_Process(void *aecmInst, const int16_t *nearendNoisy, |
| 242 const int16_t *nearendClean, int16_t *out, | 238 const int16_t *nearendClean, int16_t *out, |
| 243 size_t nrOfSamples, int16_t msInSndCardBuf) | 239 size_t nrOfSamples, int16_t msInSndCardBuf) |
| 244 { | 240 { |
| 245 AecMobile* aecm = aecmInst; | 241 AecMobile* aecm = aecmInst; |
| 246 int32_t retVal = 0; | 242 int32_t retVal = 0; |
| 247 size_t i; | 243 size_t i; |
| 248 short nmbrOfFilledBuffers; | 244 short nmbrOfFilledBuffers; |
| 249 size_t nBlocks10ms; | 245 size_t nBlocks10ms; |
| 250 size_t nFrames; | 246 size_t nFrames; |
| 251 #ifdef AEC_DEBUG | 247 #ifdef AEC_DEBUG |
| 252 short msInAECBuf; | 248 short msInAECBuf; |
| 253 #endif | 249 #endif |
| 254 | 250 |
| 255 if (aecm == NULL) | 251 if (aecm == NULL) |
| 256 { | 252 { |
| 257 return -1; | 253 return -1; |
| 258 } | 254 } |
| 259 | 255 |
| 260 if (nearendNoisy == NULL) | 256 if (nearendNoisy == NULL) |
| 261 { | 257 { |
| 262 aecm->lastError = AECM_NULL_POINTER_ERROR; | 258 return AECM_NULL_POINTER_ERROR; |
| 263 return -1; | |
| 264 } | 259 } |
| 265 | 260 |
| 266 if (out == NULL) | 261 if (out == NULL) |
| 267 { | 262 { |
| 268 aecm->lastError = AECM_NULL_POINTER_ERROR; | 263 return AECM_NULL_POINTER_ERROR; |
| 269 return -1; | |
| 270 } | 264 } |
| 271 | 265 |
| 272 if (aecm->initFlag != kInitCheck) | 266 if (aecm->initFlag != kInitCheck) |
| 273 { | 267 { |
| 274 aecm->lastError = AECM_UNINITIALIZED_ERROR; | 268 return AECM_UNINITIALIZED_ERROR; |
| 275 return -1; | |
| 276 } | 269 } |
| 277 | 270 |
| 278 if (nrOfSamples != 80 && nrOfSamples != 160) | 271 if (nrOfSamples != 80 && nrOfSamples != 160) |
| 279 { | 272 { |
| 280 aecm->lastError = AECM_BAD_PARAMETER_ERROR; | 273 return AECM_BAD_PARAMETER_ERROR; |
| 281 return -1; | |
| 282 } | 274 } |
| 283 | 275 |
| 284 if (msInSndCardBuf < 0) | 276 if (msInSndCardBuf < 0) |
| 285 { | 277 { |
| 286 msInSndCardBuf = 0; | 278 msInSndCardBuf = 0; |
| 287 aecm->lastError = AECM_BAD_PARAMETER_WARNING; | 279 retVal = AECM_BAD_PARAMETER_WARNING; |
| 288 retVal = -1; | |
| 289 } else if (msInSndCardBuf > 500) | 280 } else if (msInSndCardBuf > 500) |
| 290 { | 281 { |
| 291 msInSndCardBuf = 500; | 282 msInSndCardBuf = 500; |
| 292 aecm->lastError = AECM_BAD_PARAMETER_WARNING; | 283 retVal = AECM_BAD_PARAMETER_WARNING; |
| 293 retVal = -1; | |
| 294 } | 284 } |
| 295 msInSndCardBuf += 10; | 285 msInSndCardBuf += 10; |
| 296 aecm->msInSndCardBuf = msInSndCardBuf; | 286 aecm->msInSndCardBuf = msInSndCardBuf; |
| 297 | 287 |
| 298 nFrames = nrOfSamples / FRAME_LEN; | 288 nFrames = nrOfSamples / FRAME_LEN; |
| 299 nBlocks10ms = nFrames / aecm->aecmCore->mult; | 289 nBlocks10ms = nFrames / aecm->aecmCore->mult; |
| 300 | 290 |
| 301 if (aecm->ECstartup) | 291 if (aecm->ECstartup) |
| 302 { | 292 { |
| 303 if (nearendClean == NULL) | 293 if (nearendClean == NULL) |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 { | 436 { |
| 447 AecMobile* aecm = aecmInst; | 437 AecMobile* aecm = aecmInst; |
| 448 | 438 |
| 449 if (aecm == NULL) | 439 if (aecm == NULL) |
| 450 { | 440 { |
| 451 return -1; | 441 return -1; |
| 452 } | 442 } |
| 453 | 443 |
| 454 if (aecm->initFlag != kInitCheck) | 444 if (aecm->initFlag != kInitCheck) |
| 455 { | 445 { |
| 456 aecm->lastError = AECM_UNINITIALIZED_ERROR; | 446 return AECM_UNINITIALIZED_ERROR; |
| 457 return -1; | |
| 458 } | 447 } |
| 459 | 448 |
| 460 if (config.cngMode != AecmFalse && config.cngMode != AecmTrue) | 449 if (config.cngMode != AecmFalse && config.cngMode != AecmTrue) |
| 461 { | 450 { |
| 462 aecm->lastError = AECM_BAD_PARAMETER_ERROR; | 451 return AECM_BAD_PARAMETER_ERROR; |
| 463 return -1; | |
| 464 } | 452 } |
| 465 aecm->aecmCore->cngMode = config.cngMode; | 453 aecm->aecmCore->cngMode = config.cngMode; |
| 466 | 454 |
| 467 if (config.echoMode < 0 || config.echoMode > 4) | 455 if (config.echoMode < 0 || config.echoMode > 4) |
| 468 { | 456 { |
| 469 aecm->lastError = AECM_BAD_PARAMETER_ERROR; | 457 return AECM_BAD_PARAMETER_ERROR; |
| 470 return -1; | |
| 471 } | 458 } |
| 472 aecm->echoMode = config.echoMode; | 459 aecm->echoMode = config.echoMode; |
| 473 | 460 |
| 474 if (aecm->echoMode == 0) | 461 if (aecm->echoMode == 0) |
| 475 { | 462 { |
| 476 aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 3; | 463 aecm->aecmCore->supGain = SUPGAIN_DEFAULT >> 3; |
| 477 aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 3; | 464 aecm->aecmCore->supGainOld = SUPGAIN_DEFAULT >> 3; |
| 478 aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 3; | 465 aecm->aecmCore->supGainErrParamA = SUPGAIN_ERROR_PARAM_A >> 3; |
| 479 aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 3; | 466 aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D >> 3; |
| 480 aecm->aecmCore->supGainErrParamDiffAB = (SUPGAIN_ERROR_PARAM_A >> 3) | 467 aecm->aecmCore->supGainErrParamDiffAB = (SUPGAIN_ERROR_PARAM_A >> 3) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 517 aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D << 1; | 504 aecm->aecmCore->supGainErrParamD = SUPGAIN_ERROR_PARAM_D << 1; |
| 518 aecm->aecmCore->supGainErrParamDiffAB = (SUPGAIN_ERROR_PARAM_A << 1) | 505 aecm->aecmCore->supGainErrParamDiffAB = (SUPGAIN_ERROR_PARAM_A << 1) |
| 519 - (SUPGAIN_ERROR_PARAM_B << 1); | 506 - (SUPGAIN_ERROR_PARAM_B << 1); |
| 520 aecm->aecmCore->supGainErrParamDiffBD = (SUPGAIN_ERROR_PARAM_B << 1) | 507 aecm->aecmCore->supGainErrParamDiffBD = (SUPGAIN_ERROR_PARAM_B << 1) |
| 521 - (SUPGAIN_ERROR_PARAM_D << 1); | 508 - (SUPGAIN_ERROR_PARAM_D << 1); |
| 522 } | 509 } |
| 523 | 510 |
| 524 return 0; | 511 return 0; |
| 525 } | 512 } |
| 526 | 513 |
| 527 int32_t WebRtcAecm_get_config(void *aecmInst, AecmConfig *config) | |
|
hlundin-webrtc
2015/10/14 14:34:49
Why is this function deleted?
peah-webrtc
2015/10/14 17:57:36
I removed it as it was not used anywhere. It is ba
hlundin-webrtc
2015/10/20 13:01:54
OK. So it is slightly out-of-scope for this CL. Bu
peah-webrtc
2015/10/26 09:02:17
Acknowledged.
| |
| 528 { | |
| 529 AecMobile* aecm = aecmInst; | |
| 530 | |
| 531 if (aecm == NULL) | |
| 532 { | |
| 533 return -1; | |
| 534 } | |
| 535 | |
| 536 if (config == NULL) | |
| 537 { | |
| 538 aecm->lastError = AECM_NULL_POINTER_ERROR; | |
| 539 return -1; | |
| 540 } | |
| 541 | |
| 542 if (aecm->initFlag != kInitCheck) | |
| 543 { | |
| 544 aecm->lastError = AECM_UNINITIALIZED_ERROR; | |
| 545 return -1; | |
| 546 } | |
| 547 | |
| 548 config->cngMode = aecm->aecmCore->cngMode; | |
| 549 config->echoMode = aecm->echoMode; | |
| 550 | |
| 551 return 0; | |
| 552 } | |
| 553 | |
| 554 int32_t WebRtcAecm_InitEchoPath(void* aecmInst, | 514 int32_t WebRtcAecm_InitEchoPath(void* aecmInst, |
| 555 const void* echo_path, | 515 const void* echo_path, |
| 556 size_t size_bytes) | 516 size_t size_bytes) |
| 557 { | 517 { |
| 558 AecMobile* aecm = aecmInst; | 518 AecMobile* aecm = aecmInst; |
| 559 const int16_t* echo_path_ptr = echo_path; | 519 const int16_t* echo_path_ptr = echo_path; |
| 560 | 520 |
| 561 if (aecmInst == NULL) { | 521 if (aecmInst == NULL) { |
| 562 return -1; | 522 return -1; |
| 563 } | 523 } |
| 564 if (echo_path == NULL) { | 524 if (echo_path == NULL) { |
| 565 aecm->lastError = AECM_NULL_POINTER_ERROR; | 525 return AECM_NULL_POINTER_ERROR; |
| 566 return -1; | |
| 567 } | 526 } |
| 568 if (size_bytes != WebRtcAecm_echo_path_size_bytes()) | 527 if (size_bytes != WebRtcAecm_echo_path_size_bytes()) |
| 569 { | 528 { |
| 570 // Input channel size does not match the size of AECM | 529 // Input channel size does not match the size of AECM |
| 571 aecm->lastError = AECM_BAD_PARAMETER_ERROR; | 530 return AECM_BAD_PARAMETER_ERROR; |
| 572 return -1; | |
| 573 } | 531 } |
| 574 if (aecm->initFlag != kInitCheck) | 532 if (aecm->initFlag != kInitCheck) |
| 575 { | 533 { |
| 576 aecm->lastError = AECM_UNINITIALIZED_ERROR; | 534 return AECM_UNINITIALIZED_ERROR; |
| 577 return -1; | |
| 578 } | 535 } |
| 579 | 536 |
| 580 WebRtcAecm_InitEchoPathCore(aecm->aecmCore, echo_path_ptr); | 537 WebRtcAecm_InitEchoPathCore(aecm->aecmCore, echo_path_ptr); |
| 581 | 538 |
| 582 return 0; | 539 return 0; |
| 583 } | 540 } |
| 584 | 541 |
| 585 int32_t WebRtcAecm_GetEchoPath(void* aecmInst, | 542 int32_t WebRtcAecm_GetEchoPath(void* aecmInst, |
| 586 void* echo_path, | 543 void* echo_path, |
| 587 size_t size_bytes) | 544 size_t size_bytes) |
| 588 { | 545 { |
| 589 AecMobile* aecm = aecmInst; | 546 AecMobile* aecm = aecmInst; |
| 590 int16_t* echo_path_ptr = echo_path; | 547 int16_t* echo_path_ptr = echo_path; |
| 591 | 548 |
| 592 if (aecmInst == NULL) { | 549 if (aecmInst == NULL) { |
| 593 return -1; | 550 return -1; |
| 594 } | 551 } |
| 595 if (echo_path == NULL) { | 552 if (echo_path == NULL) { |
| 596 aecm->lastError = AECM_NULL_POINTER_ERROR; | 553 return AECM_NULL_POINTER_ERROR; |
| 597 return -1; | |
| 598 } | 554 } |
| 599 if (size_bytes != WebRtcAecm_echo_path_size_bytes()) | 555 if (size_bytes != WebRtcAecm_echo_path_size_bytes()) |
| 600 { | 556 { |
| 601 // Input channel size does not match the size of AECM | 557 // Input channel size does not match the size of AECM |
| 602 aecm->lastError = AECM_BAD_PARAMETER_ERROR; | 558 return AECM_BAD_PARAMETER_ERROR; |
| 603 return -1; | |
| 604 } | 559 } |
| 605 if (aecm->initFlag != kInitCheck) | 560 if (aecm->initFlag != kInitCheck) |
| 606 { | 561 { |
| 607 aecm->lastError = AECM_UNINITIALIZED_ERROR; | 562 return AECM_UNINITIALIZED_ERROR; |
| 608 return -1; | |
| 609 } | 563 } |
| 610 | 564 |
| 611 memcpy(echo_path_ptr, aecm->aecmCore->channelStored, size_bytes); | 565 memcpy(echo_path_ptr, aecm->aecmCore->channelStored, size_bytes); |
| 612 return 0; | 566 return 0; |
| 613 } | 567 } |
| 614 | 568 |
| 615 size_t WebRtcAecm_echo_path_size_bytes() | 569 size_t WebRtcAecm_echo_path_size_bytes() |
| 616 { | 570 { |
| 617 return (PART_LEN1 * sizeof(int16_t)); | 571 return (PART_LEN1 * sizeof(int16_t)); |
| 618 } | 572 } |
| 619 | 573 |
| 620 int32_t WebRtcAecm_get_error_code(void *aecmInst) | |
| 621 { | |
| 622 AecMobile* aecm = aecmInst; | |
| 623 | |
| 624 if (aecm == NULL) | |
| 625 { | |
| 626 return -1; | |
| 627 } | |
| 628 | |
| 629 return aecm->lastError; | |
| 630 } | |
| 631 | 574 |
| 632 static int WebRtcAecm_EstBufDelay(AecMobile* aecm, short msInSndCardBuf) { | 575 static int WebRtcAecm_EstBufDelay(AecMobile* aecm, short msInSndCardBuf) { |
| 633 short delayNew, nSampSndCard; | 576 short delayNew, nSampSndCard; |
| 634 short nSampFar = (short) WebRtc_available_read(aecm->farendBuf); | 577 short nSampFar = (short) WebRtc_available_read(aecm->farendBuf); |
| 635 short diff; | 578 short diff; |
| 636 | 579 |
| 637 nSampSndCard = msInSndCardBuf * kSampMsNb * aecm->aecmCore->mult; | 580 nSampSndCard = msInSndCardBuf * kSampMsNb * aecm->aecmCore->mult; |
| 638 | 581 |
| 639 delayNew = nSampSndCard - nSampFar; | 582 delayNew = nSampSndCard - nSampFar; |
| 640 | 583 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 693 nSampAdd = (int)(WEBRTC_SPL_MAX(((nSampSndCard >> 1) - nSampFar), | 636 nSampAdd = (int)(WEBRTC_SPL_MAX(((nSampSndCard >> 1) - nSampFar), |
| 694 FRAME_LEN)); | 637 FRAME_LEN)); |
| 695 nSampAdd = WEBRTC_SPL_MIN(nSampAdd, maxStuffSamp); | 638 nSampAdd = WEBRTC_SPL_MIN(nSampAdd, maxStuffSamp); |
| 696 | 639 |
| 697 WebRtc_MoveReadPtr(aecm->farendBuf, -nSampAdd); | 640 WebRtc_MoveReadPtr(aecm->farendBuf, -nSampAdd); |
| 698 aecm->delayChange = 1; // the delay needs to be updated | 641 aecm->delayChange = 1; // the delay needs to be updated |
| 699 } | 642 } |
| 700 | 643 |
| 701 return 0; | 644 return 0; |
| 702 } | 645 } |
| OLD | NEW |