Changeset 823 for pjproject/trunk/pjmedia/src/pjmedia/echo_speex.c
- Timestamp:
- Nov 23, 2006 10:19:46 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/echo_speex.c
r822 r823 31 31 32 32 #define THIS_FILE "echo_speex.c" 33 #define BUF_COUNT 2034 #define MIN_PREFETCH 435 #define MAX_PREFETCH 1233 #define BUF_COUNT 16 34 #define MIN_PREFETCH 2 35 #define MAX_PREFETCH (BUF_COUNT*2/3) 36 36 37 37 … … 148 148 "[count=%d, seq=%d]", 149 149 fq->max_count, timestamp / fq->samples_per_frame)); 150 //pjmedia_frame_queue_init(fq, fq->seq_delay, fq->prefetch_count); 150 151 return PJ_ETOOMANY; 151 152 } … … 290 291 speex_ec *echo; 291 292 int sampling_rate; 292 int disabled, enabled;293 293 pj_status_t status; 294 294 … … 323 323 } 324 324 325 /* Set sampling rate */ 326 sampling_rate = clock_rate; 327 speex_echo_ctl(echo->state, SPEEX_ECHO_SET_SAMPLING_RATE, 328 &sampling_rate); 329 325 330 echo->preprocess = speex_preprocess_state_init(samples_per_frame, 326 331 clock_rate); … … 332 337 333 338 /* Disable all preprocessing, we only want echo cancellation */ 339 #if 0 334 340 disabled = 0; 335 341 enabled = 1; … … 342 348 speex_preprocess_ctl(echo->preprocess, SPEEX_PREPROCESS_SET_DEREVERB, 343 349 &disabled); 344 345 /* Set sampling rate */ 346 sampling_rate = clock_rate; 347 speex_echo_ctl(echo->state, SPEEX_ECHO_SET_SAMPLING_RATE, 348 &sampling_rate); 350 #endif 351 352 /* Control echo cancellation in the preprocessor */ 353 speex_preprocess_ctl(echo->preprocess, SPEEX_PREPROCESS_SET_ECHO_STATE, 354 echo->state); 355 349 356 350 357 /* Create temporary frame for echo cancellation */ … … 444 451 } 445 452 446 pjmedia_frame_queue_put(echo->frame_queue, play_frm, 447 echo->samples_per_frame*2, echo->play_ts); 453 if (pjmedia_frame_queue_put(echo->frame_queue, play_frm, 454 echo->samples_per_frame*2, 455 echo->play_ts) != PJ_SUCCESS) 456 { 457 int seq_delay; 458 459 /* On full reset frame queue */ 460 seq_delay = ((int)echo->play_ts - (int)echo->rec_ts) / 461 (int)echo->samples_per_frame; 462 pjmedia_frame_queue_init(echo->frame_queue, seq_delay, 463 echo->prefetch); 464 465 /* And re-put */ 466 pjmedia_frame_queue_put(echo->frame_queue, play_frm, 467 echo->samples_per_frame*2, 468 echo->play_ts); 469 } 448 470 449 471 pj_lock_release(echo->lock); … … 495 517 496 518 if (pjmedia_frame_queue_empty(echo->frame_queue)) { 497 int seq_delay , prefetch;519 int seq_delay; 498 520 499 521 seq_delay = ((int)echo->play_ts - (int)echo->rec_ts) / 500 522 (int)echo->samples_per_frame; 501 prefetch = pjmedia_frame_queue_get_prefetch(echo->frame_queue); 502 //++prefetch; 503 pjmedia_frame_queue_init(echo->frame_queue, seq_delay, prefetch); 523 pjmedia_frame_queue_init(echo->frame_queue, seq_delay, 524 echo->prefetch); 504 525 status = -1; 505 526 … … 538 559 539 560 /* Cancel echo, put output in temporary buffer */ 540 speex_echo_cancel(echo->state, (const spx_int16_t*)rec_frm, 541 (const spx_int16_t*)play_frm, 542 (spx_int16_t*)echo->tmp_frame, 543 echo->residue); 561 speex_echo_cancellation(echo->state, (const spx_int16_t*)rec_frm, 562 (const spx_int16_t*)play_frm, 563 (spx_int16_t*)echo->tmp_frame); 544 564 545 565 546 566 /* Preprocess output */ 547 speex_preprocess(echo->preprocess, (spx_int16_t*)echo->tmp_frame, 548 echo->residue); 567 speex_preprocess_run(echo->preprocess, (spx_int16_t*)echo->tmp_frame); 549 568 550 569 /* Copy temporary buffer back to original rec_frm */
Note: See TracChangeset
for help on using the changeset viewer.