From cf62d28f8094f22cbe2a5ac24aa0b468cde0d25c Mon Sep 17 00:00:00 2001 From: smorlat Date: Tue, 24 Mar 2009 22:08:35 +0000 Subject: [PATCH] be more intelligent. git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@364 3f6dc0c8-ddfe-455d-9043-3cd528dc4637 --- linphone/mediastreamer2/src/msvolume.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/linphone/mediastreamer2/src/msvolume.c b/linphone/mediastreamer2/src/msvolume.c index ab9566818..b30f35789 100644 --- a/linphone/mediastreamer2/src/msvolume.c +++ b/linphone/mediastreamer2/src/msvolume.c @@ -79,7 +79,6 @@ static inline float compute_gain(float static_gain, float energy, float weight){ static void volume_echo_avoider_process(Volume *v){ float peer_e; float gain; - float gain_k2; ms_filter_call_method(v->peer,MS_VOLUME_GET_LINEAR,&peer_e); peer_e=sqrt(peer_e); if (v->ea_active){ @@ -90,6 +89,7 @@ static void volume_echo_avoider_process(Volume *v){ gain=v->static_gain; v->ea_active=FALSE; } + v->gain=(v->gain*(1-v->gain_k)) + (v->gain_k*gain); }else{ int peer_active=FALSE; ms_filter_call_method(v->peer,MS_VOLUME_GET_EA_STATE,&peer_active); @@ -97,12 +97,13 @@ static void volume_echo_avoider_process(Volume *v){ /*lower our output*/ gain=compute_gain(v->static_gain,peer_e,v->force); v->ea_active=TRUE; - }else gain=v->static_gain; + v->gain=gain; + }else { + gain=v->static_gain; + v->gain=(v->gain*(1-v->gain_k)) + (v->gain_k*gain); + } } - if (v->ea_active){ - gain_k2=1; - }else gain_k2=v->gain_k; - v->gain=(v->gain*(1-gain_k2)) + (gain_k2*gain); + ms_message("ea_active=%i, peer_e=%f gain=%f gain_k=%f",v->ea_active,peer_e,v->gain, v->gain_k); }