add new force parameter.

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@361 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
This commit is contained in:
smorlat 2009-03-24 20:36:22 +00:00
parent 9322a761d8
commit 9d15680561
3 changed files with 17 additions and 2 deletions

View file

@ -1439,6 +1439,7 @@ static void post_configure_audio_streams(LinphoneCore *lc){
if (st->volrecv && st->volsend){
float speed=lp_config_get_float(lc->config,"sound","el_speed",-1);
float thres=lp_config_get_float(lc->config,"sound","el_thres",-1);
float force=lp_config_get_float(lc->config,"sound","el_force",-1);
MSFilter *f;
if (st->el_type==ELControlMic)
f=st->volrecv;
@ -1447,6 +1448,8 @@ static void post_configure_audio_streams(LinphoneCore *lc){
ms_filter_call_method(f,MS_VOLUME_SET_EA_SPEED,&speed);
if (thres!=-1)
ms_filter_call_method(f,MS_VOLUME_SET_EA_THRESHOLD,&thres);
if (force!=-1)
ms_filter_call_method(f,MS_VOLUME_SET_EA_FORCE,&force);
}
if (lc->vtable.dtmf_received!=NULL){
/* replace by our default action*/

View file

@ -46,6 +46,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MS_VOLUME_SET_EA_SPEED MS_FILTER_METHOD(MS_VOLUME_ID,6,float)
#define MS_VOLUME_SET_EA_FORCE MS_FILTER_METHOD(MS_VOLUME_ID,7,float)
extern MSFilterDesc ms_volume_desc;
#endif

View file

@ -34,6 +34,7 @@ typedef struct Volume{
float static_gain;
float gain_k;
float thres;
float force;
MSFilter *peer;
bool_t ea_active;
}Volume;
@ -46,6 +47,7 @@ static void volume_init(MSFilter *f){
v->ea_active=FALSE;
v->gain_k=gain_k;
v->thres=noise_thres;
v->force=en_weight;
v->peer=NULL;
f->data=v;
}
@ -83,7 +85,7 @@ static void volume_echo_avoider_process(Volume *v){
if (v->ea_active){
if (peer_e>v->thres){
/*lower our output*/
gain=compute_gain(v->static_gain,peer_e,en_weight);
gain=compute_gain(v->static_gain,peer_e,v->force);
}else {
gain=v->static_gain;
v->ea_active=FALSE;
@ -93,7 +95,7 @@ static void volume_echo_avoider_process(Volume *v){
ms_filter_call_method(v->peer,MS_VOLUME_GET_EA_STATE,&peer_active);
if (peer_e>v->thres && ! peer_active){
/*lower our output*/
gain=compute_gain(v->static_gain,peer_e,en_weight);
gain=compute_gain(v->static_gain,peer_e,v->force);
v->ea_active=TRUE;
}else gain=v->static_gain;
}
@ -148,6 +150,13 @@ static int volume_set_ea_speed(MSFilter *f, void*arg){
return 0;
}
static int volume_set_ea_force(MSFilter *f, void*arg){
Volume *v=(Volume*)f->data;
float val=*(float*)arg;
v->force=val;
return 0;
}
static inline int16_t saturate(float val){
return (val>32767) ? 32767 : ( (val<-32767) ? -32767 : val);
}
@ -188,6 +197,7 @@ static MSFilterMethod methods[]={
{ MS_VOLUME_SET_PEER , volume_set_peer },
{ MS_VOLUME_SET_EA_THRESHOLD , volume_set_ea_threshold },
{ MS_VOLUME_SET_EA_SPEED , volume_set_ea_speed },
{ MS_VOLUME_SET_EA_FORCE , volume_set_ea_force },
{ 0 , NULL }
};