Changeset 648 for pjproject/trunk/pjmedia/src/pjmedia/sound_port.c
- Timestamp:
- Aug 4, 2006 6:27:19 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/sound_port.c
r646 r648 35 35 36 36 //#define SIMULATE_LOST_PCT 20 37 #define AEC_TAIL 500 /*in ms */37 #define AEC_TAIL 128 /* default AEC length in ms */ 38 38 39 39 #define THIS_FILE "sound_port.c" … … 58 58 59 59 pjmedia_aec *aec; 60 unsigned aec_tail_len; 60 61 pjmedia_plc *plc; 61 62 … … 136 137 137 138 138 if (snd_port->aec) {139 pjmedia_aec_playback(snd_port->aec, output);140 }141 142 139 return PJ_SUCCESS; 143 140 } … … 156 153 pjmedia_port *port; 157 154 pjmedia_frame frame; 158 159 /* Cancel echo */160 if (snd_port->aec) {161 pjmedia_aec_capture(snd_port->aec, input, 0);162 }163 155 164 156 /* We're risking accessing the port without holding any mutex. … … 171 163 if (port == NULL) 172 164 return PJ_SUCCESS; 165 166 /* Cancel echo */ 167 if (snd_port->aec) { 168 pjmedia_aec_capture(snd_port->aec, input, 0); 169 } 173 170 174 171 frame.buf = (void*)input; … … 247 244 snd_port->channel_count, 248 245 0, &snd_port->plc); 249 if (status != PJ_SUCCESS) 246 if (status != PJ_SUCCESS) { 247 PJ_LOG(4,(THIS_FILE, "Unable to create PLC")); 250 248 snd_port->plc = NULL; 249 } 251 250 } 252 251 253 252 /* Create AEC only when direction is full duplex */ 254 253 if (snd_port->dir == PJMEDIA_DIR_CAPTURE_PLAYBACK) { 255 status = pjmedia_aec_create(pool, snd_port->clock_rate, 256 snd_port->samples_per_frame, 257 snd_port->clock_rate * AEC_TAIL / 1000, 258 0, &snd_port->aec); 259 if (status != PJ_SUCCESS) 254 status = pjmedia_snd_port_set_aec(snd_port, pool, AEC_TAIL); 255 if (status != PJ_SUCCESS) { 256 PJ_LOG(4,(THIS_FILE, "Unable to create AEC")); 260 257 snd_port->aec = NULL; 258 } 261 259 } 262 260 … … 433 431 434 432 /* 433 * Enable AEC 434 */ 435 PJ_DEF(pj_status_t) pjmedia_snd_port_set_aec( pjmedia_snd_port *snd_port, 436 pj_pool_t *pool, 437 unsigned tail_ms) 438 { 439 pj_status_t status; 440 441 /* Sound must be opened in full-duplex mode */ 442 PJ_ASSERT_RETURN(snd_port && 443 snd_port->dir == PJMEDIA_DIR_CAPTURE_PLAYBACK, 444 PJ_EINVALIDOP); 445 446 /* Destroy AEC */ 447 if (snd_port->aec) { 448 pjmedia_aec_destroy(snd_port->aec); 449 snd_port->aec = NULL; 450 } 451 452 snd_port->aec_tail_len = tail_ms; 453 454 if (tail_ms != 0) { 455 status = pjmedia_aec_create(pool, snd_port->clock_rate, 456 snd_port->samples_per_frame, 457 snd_port->clock_rate * tail_ms / 1000, 458 0, &snd_port->aec); 459 if (status != PJ_SUCCESS) 460 snd_port->aec = NULL; 461 } else { 462 status = PJ_SUCCESS; 463 } 464 465 return status; 466 } 467 468 469 /* Get AEC tail length */ 470 PJ_DEF(pj_status_t) pjmedia_snd_port_get_aec_tail( pjmedia_snd_port *snd_port, 471 unsigned *p_length) 472 { 473 PJ_ASSERT_RETURN(snd_port && p_length, PJ_EINVAL); 474 *p_length = snd_port->aec ? snd_port->aec_tail_len : 0; 475 return PJ_SUCCESS; 476 } 477 478 479 480 /* 435 481 * Connect a port. 436 482 */
Note: See TracChangeset
for help on using the changeset viewer.