From bc5891547b88f302758887609a8d32fc2ea1c006 Mon Sep 17 00:00:00 2001 From: aymeric Date: Mon, 16 Mar 2009 20:31:01 +0000 Subject: [PATCH] fix for linux compilation git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@348 3f6dc0c8-ddfe-455d-9043-3cd528dc4637 --- linphone/mediastreamer2/src/msconf.c | 75 ++++++++++++++++------------ 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/linphone/mediastreamer2/src/msconf.c b/linphone/mediastreamer2/src/msconf.c index ab6af6425..792f4690c 100644 --- a/linphone/mediastreamer2/src/msconf.c +++ b/linphone/mediastreamer2/src/msconf.c @@ -17,6 +17,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include "mediastreamer-config.h" +#endif + #include "mediastreamer2/msfilter.h" #include @@ -254,35 +258,40 @@ static bool_t should_process(MSFilter *f, ConfState *s){ #ifndef DISABLE_SPEEX static double powerspectrum_stat_beyond8K(struct Channel *chan) { - spx_int32_t ps_size = 0; - spx_int32_t *ps = NULL; - double mystat = 0; - float fftmul = 1.0 / (32768.0); - - speex_preprocess_ctl(chan->speex_pp, SPEEX_PREPROCESS_GET_PSD_SIZE, &ps_size); - ps = (spx_int32_t*)ortp_malloc(sizeof(spx_int32_t)*ps_size); - speex_preprocess_ctl(chan->speex_pp, SPEEX_PREPROCESS_GET_PSD, ps); - - - mystat = 0; - for (int i=ps_size/2;i < ps_size; i++) { - double yp; - yp = sqrtf(sqrtf(static_cast(ps[i]))) - 1.0f; - yp = yp * fftmul; - yp = MIN(yp * 3000.0, 1.0); - mystat = yp + mystat; - } - - ortp_free(ps); - - /* value between 0 and 100? */ - mystat = mystat*100*2/ps_size; - if (mystat<0) - mystat=0; - if (mystat>100) - mystat=100; - - return mystat; + spx_int32_t ps_size = 0; + spx_int32_t *ps = NULL; + double mystat = 0; + float fftmul = 1.0 / (32768.0); + int i; + + speex_preprocess_ctl(chan->speex_pp, SPEEX_PREPROCESS_GET_PSD_SIZE, &ps_size); + ps = (spx_int32_t*)ortp_malloc(sizeof(spx_int32_t)*ps_size); + speex_preprocess_ctl(chan->speex_pp, SPEEX_PREPROCESS_GET_PSD, ps); + + + mystat = 0; + for (i=ps_size/2;i < ps_size; i++) { + double yp; +#if defined(__cplusplus) + yp = sqrtf(sqrtf(static_cast(ps[i]))) - 1.0f; +#else + yp = sqrtf(sqrtf((float)(ps[i]))) - 1.0f; +#endif + yp = yp * fftmul; + yp = MIN(yp * 3000.0, 1.0); + mystat = yp + mystat; + } + + ortp_free(ps); + + /* value between 0 and 100? */ + mystat = mystat*100*2/ps_size; + if (mystat<0) + mystat=0; + if (mystat>100) + mystat=100; + + return mystat; } #endif @@ -395,10 +404,10 @@ static void conf_sum(MSFilter *f, ConfState *s){ if (s->enable_halfduplex>0) { double mystat = powerspectrum_stat_beyond8K(chan); - //ms_message("is_speaking (chan=%i) -> on/stat=%.3lf", i, mystat); - if (mystat>10) - { - ms_message("is_speaking (chan=%i) -> on/stat=%.3lf", i, mystat); + //ms_message("is_speaking (chan=%i) -> on/stat=%.3lf", i, mystat); + if (mystat>10) + { + ms_message("is_speaking (chan=%i) -> on/stat=%.3lf", i, mystat); s->channels[0].is_speaking=20; /* keep RTP muted for the next few ms */ } else