From 638684636c4539f6af62a1d706c219c08eb923c4 Mon Sep 17 00:00:00 2001 From: Mark Spencer <markster@digium.com> Date: Thu, 25 Mar 2004 07:17:33 +0000 Subject: [PATCH] Make sure calculation of time is always > 0... git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2557 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_iax2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 7050e7d727..2cd0ef80d1 100755 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -2578,7 +2578,7 @@ static unsigned int fix_peerts(struct iax2_peer *peer, int callno, unsigned int static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, struct timeval *delivery) { struct timeval tv; - unsigned int ms; + int ms; if (!p->offset.tv_sec && !p->offset.tv_usec) { gettimeofday(&p->offset, NULL); /* Round to nearest 20ms */ @@ -2592,6 +2592,8 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str } else { gettimeofday(&tv, NULL); ms = (tv.tv_sec - p->offset.tv_sec) * 1000 + (tv.tv_usec - p->offset.tv_usec) / 1000; + if (ms < 0) + ms = 0; } /* We never send the same timestamp twice, so fudge a little if we must */ if (ms <= p->lastsent) { @@ -2632,7 +2634,7 @@ static unsigned int calc_rxstamp(struct chan_iax2_pvt *p) { /* Returns where in "receive time" we are */ struct timeval tv; - unsigned int ms; + int ms; /* Setup rxcore if necessary */ if (!p->rxcore.tv_sec && !p->rxcore.tv_usec) gettimeofday(&p->rxcore, NULL); -- GitLab