Changeset 2208 for pjproject/trunk
- Timestamp:
- Aug 13, 2008 1:50:19 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/echo_suppress.c
r2203 r2208 382 382 383 383 /* Set state */ 384 static void echo_supp_set_state(echo_supp *ec, enum talk_state state) 385 { 384 static void echo_supp_set_state(echo_supp *ec, enum talk_state state, 385 unsigned level) 386 { 387 PJ_UNUSED_ARG(level); 388 386 389 if (state != ec->talk_state) { 387 TRACE_((THIS_FILE, "[%03d.%03d] %s --> %s ",390 TRACE_((THIS_FILE, "[%03d.%03d] %s --> %s, level=%u", 388 391 (ec->update_cnt * SEGMENT_PTIME / 1000), 389 392 ((ec->update_cnt * SEGMENT_PTIME) % 1000), 390 393 state_names[ec->talk_state], 391 state_names[state] ));394 state_names[state], level)); 392 395 ec->talk_state = state; 393 396 } … … 466 469 ulaw = pjmedia_linear2ulaw(sum_play_level/ec->templ_cnt) ^ 0xFF; 467 470 if (ulaw < MIN_SIGNAL_ULAW) { 468 echo_supp_set_state(ec, ST_REM_SILENT );471 echo_supp_set_state(ec, ST_REM_SILENT, ulaw); 469 472 return; 470 473 } … … 472 475 /* Bail out if local user is talking */ 473 476 if (sum_rec_level >= sum_play_level) { 474 echo_supp_set_state(ec, ST_LOCAL_TALK );477 echo_supp_set_state(ec, ST_LOCAL_TALK, ulaw); 475 478 return; 476 479 } 477 480 481 #if 0 482 // disabled: not a good idea if mic throws out loud echo 478 483 /* Also bail out if we suspect there's a doubletalk */ 479 484 ulaw = pjmedia_linear2ulaw(sum_rec_level/ec->templ_cnt) ^ 0xFF; 480 485 if (ulaw > MIN_SIGNAL_ULAW) { 481 echo_supp_set_state(ec, ST_DOUBLETALK );486 echo_supp_set_state(ec, ST_DOUBLETALK, ulaw); 482 487 return; 483 488 } 489 #endif 484 490 485 491 /* Calculate correlation and save to temporary array */ … … 493 499 494 500 /* We seem to have good signal, we can update the EC state */ 495 echo_supp_set_state(ec, ST_REM_TALK );501 echo_supp_set_state(ec, ST_REM_TALK, MIN_SIGNAL_ULAW); 496 502 497 503 /* Accummulate the correlation value to the history and at the same … … 646 652 */ 647 653 factor = 1.0; 648 echo_supp_set_state(ec, ST_LOCAL_TALK );649 } else {654 echo_supp_set_state(ec, ST_LOCAL_TALK, rec_level); 655 } else if (rec_level >= play_level) { 650 656 /* Seems that both are talking. Scale the mic signal 651 657 * down a little bit to reduce echo, while allowing both … … 653 659 */ 654 660 factor = (float)(ec->avg_factor[ec->tail_index] * 2); 655 echo_supp_set_state(ec, ST_DOUBLETALK); 661 echo_supp_set_state(ec, ST_DOUBLETALK, rec_level); 662 } else { 663 /* Speaker is active, but we've picked up large signal in 664 * the microphone. Assume that this is an echo, so bring 665 * the level down to minimum too. 666 */ 667 factor = ec->min_factor[ec->tail_index] / 2; 668 echo_supp_set_state(ec, ST_REM_TALK, play_level); 656 669 } 657 670 } else { … … 662 675 */ 663 676 factor = ec->avg_factor[ec->tail_index] * 3 / 2; 664 echo_supp_set_state(ec, ST_REM_SILENT );677 echo_supp_set_state(ec, ST_REM_SILENT, rec_level); 665 678 } else { 666 679 /* Mic is idle, but there's something playing in speaker. … … 668 681 */ 669 682 factor = ec->min_factor[ec->tail_index] / 2; 670 echo_supp_set_state(ec, ST_REM_TALK );683 echo_supp_set_state(ec, ST_REM_TALK, play_level); 671 684 } 672 685 }
Note: See TracChangeset
for help on using the changeset viewer.