From: <bc...@us...> - 2007-12-03 16:27:35
|
Revision: 1296 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1296&view=rev Author: bcholew Date: 2007-12-03 08:27:40 -0800 (Mon, 03 Dec 2007) Log Message: ----------- Initialize session variable - avoiding possible garbage in calc_timestamp(). Reduce assumptions made in add_ms(), and don't permit tv_usec to exceed 999999. Modified Paths: -------------- trunk/lib/libiax2/src/iax.c Modified: trunk/lib/libiax2/src/iax.c =================================================================== --- trunk/lib/libiax2/src/iax.c 2007-12-03 15:55:43 UTC (rev 1295) +++ trunk/lib/libiax2/src/iax.c 2007-12-03 16:27:40 UTC (rev 1296) @@ -481,6 +481,10 @@ s->sendto = iax_sendto; s->pingid = -1; +#ifdef USE_VOICE_TS_PREDICTION + s->nextpred = 0; +#endif + s->jb = jb_new(); if ( !s->jb ) { @@ -539,13 +543,14 @@ static void add_ms(struct timeval *tv, int ms) { tv->tv_usec += ms * 1000; - if(tv->tv_usec > 1000000) { - tv->tv_usec -= 1000000; - tv->tv_sec++; + if (tv->tv_usec > 999999) { + tv->tv_sec += tv->tv_usec / 1000000; + tv->tv_usec %= 1000000; } - if(tv->tv_usec < 0) { - tv->tv_usec += 1000000; - tv->tv_sec--; + + if (tv->tv_usec < 0) { + tv->tv_sec += (tv->tv_usec / 1000000 - 1); + tv->tv_usec = (tv->tv_usec % 1000000) + 1000000; } } #endif @@ -646,7 +651,7 @@ #ifdef USE_VOICE_TS_PREDICTION /* set next predicted ts based on 8khz samples */ if(voice) - session->nextpred = session->nextpred + f->samples / 8; + session->nextpred += f->samples / 8; #endif return ms; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |