[Home]

Summary:ASTERISK-01304: Perform proper rounding in calc_txstamp
Reporter:rburkholder (rburkholder)Labels:
Date Opened:2004-03-27 17:13:24.000-0600Date Closed:2004-09-25 02:52:20
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Two lines modified in following snippet:

static unsigned int calc_txstamp(struct ast_rtp *rtp, struct timeval
*delivery)
{
       struct timeval now;
       unsigned int ms;
       if (!rtp->txcore.tv_sec && !rtp->txcore.tv_usec) {
               gettimeofday(&rtp->txcore, NULL);
               rtp->txcore.tv_usec -= rtp->txcore.tv_usec % 20000;
       }
       if (delivery && (delivery->tv_sec || delivery->tv_usec)) {
               /* Use previous txcore */
=>                ms = (delivery->tv_sec - rtp->txcore.tv_sec) * 1000;
               ms += ((delivery->tv_usec - rtp->txcore.tv_usec) + 500) /
1000;
               rtp->txcore.tv_sec = delivery->tv_sec;
               rtp->txcore.tv_usec = delivery->tv_usec;
       } else {
               gettimeofday(&now, NULL);
               ms = (now.tv_sec - rtp->txcore.tv_sec) * 1000;
=>                ms += ((now.tv_usec - rtp->txcore.tv_usec) + 500 ) / 1000;
               /* Use what we just got for next time */
               rtp->txcore.tv_sec = now.tv_sec;
               rtp->txcore.tv_usec = now.tv_usec;
       }
       return ms;
}
Comments:By: Ricardo Villa (ricvil) 2004-03-28 22:59:06.000-0600

I tried the fix but I still se jumps of 152 and 168 samples in the TimeStamp.  Did it fix it for you 100%?

By: Mark Spencer (markster) 2004-03-31 14:45:28.000-0600

This has been fixed in a more sophisticated way.