summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/app_queue.c21
-rw-r--r--channels/chan_iax2.c13
-rw-r--r--channels/sip/dialplan_functions.c2
-rw-r--r--main/jitterbuf.c2
-rw-r--r--res/res_calendar.c10
-rw-r--r--res/res_rtp_asterisk.c12
6 files changed, 31 insertions, 29 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 9397e64c2..1b84da1ea 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -3724,7 +3724,8 @@ static int valid_exit(struct queue_ent *qe, char digit)
static int say_position(struct queue_ent *qe, int ringing)
{
- int res = 0, avgholdmins, avgholdsecs, announceposition = 0;
+ int res = 0, announceposition = 0;
+ long avgholdmins, avgholdsecs;
int say_thanks = 1;
time_t now;
@@ -3798,23 +3799,23 @@ static int say_position(struct queue_ent *qe, int ringing)
}
}
/* Round hold time to nearest minute */
- avgholdmins = abs(((qe->parent->holdtime + 30) - (now - qe->start)) / 60);
+ avgholdmins = labs(((qe->parent->holdtime + 30) - (now - qe->start)) / 60);
/* If they have specified a rounding then round the seconds as well */
if (qe->parent->roundingseconds) {
- avgholdsecs = (abs(((qe->parent->holdtime + 30) - (now - qe->start))) - 60 * avgholdmins) / qe->parent->roundingseconds;
+ avgholdsecs = (labs(((qe->parent->holdtime + 30) - (now - qe->start))) - 60 * avgholdmins) / qe->parent->roundingseconds;
avgholdsecs *= qe->parent->roundingseconds;
} else {
avgholdsecs = 0;
}
- ast_verb(3, "Hold time for %s is %d minute(s) %d seconds\n", qe->parent->name, avgholdmins, avgholdsecs);
+ ast_verb(3, "Hold time for %s is %ld minute(s) %ld seconds\n", qe->parent->name, avgholdmins, avgholdsecs);
/* If the hold time is >1 min, if it's enabled, and if it's not
supposed to be only once and we have already said it, say it */
- if ((avgholdmins+avgholdsecs) > 0 && qe->parent->announceholdtime &&
- ((qe->parent->announceholdtime == ANNOUNCEHOLDTIME_ONCE && !qe->last_pos) ||
- !(qe->parent->announceholdtime == ANNOUNCEHOLDTIME_ONCE))) {
+ if ((avgholdmins+avgholdsecs) > 0 && qe->parent->announceholdtime &&
+ ((qe->parent->announceholdtime == ANNOUNCEHOLDTIME_ONCE && !qe->last_pos) ||
+ !(qe->parent->announceholdtime == ANNOUNCEHOLDTIME_ONCE))) {
res = play_file(qe->chan, qe->parent->sound_holdtime);
if (res) {
goto playout;
@@ -6618,11 +6619,11 @@ static int try_calling(struct queue_ent *qe, struct ast_flags opts, char **opt_a
}
if (!res2 && qe->parent->reportholdtime) {
if (!play_file(peer, qe->parent->sound_reporthold)) {
- int holdtime, holdtimesecs;
+ long holdtime, holdtimesecs;
time(&now);
- holdtime = abs((now - qe->start) / 60);
- holdtimesecs = abs((now - qe->start) % 60);
+ holdtime = labs((now - qe->start) / 60);
+ holdtimesecs = labs((now - qe->start) % 60);
if (holdtime > 0) {
ast_say_number(peer, holdtime, AST_DIGIT_ANY, ast_channel_language(peer), NULL);
if (play_file(peer, qe->parent->sound_minutes) < 0) {
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 702a76327..ff45b83fc 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -5986,7 +5986,7 @@ static unsigned int calc_txpeerstamp(struct iax2_trunk_peer *tpeer, int sampms,
ms = ast_tvdiff_ms(*now, tpeer->txtrunktime);
/* Predict from last value */
pred = tpeer->lastsent + sampms;
- if (abs(ms - pred) < MAX_TIMESTAMP_SKEW)
+ if (labs(ms - pred) < MAX_TIMESTAMP_SKEW)
ms = pred;
/* We never send the same timestamp twice, so fudge a little if we must */
@@ -6059,7 +6059,8 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str
ms = 0;
if (voice) {
/* On a voice frame, use predicted values if appropriate */
- if (p->notsilenttx && abs(ms - p->nextpred) <= MAX_TIMESTAMP_SKEW) {
+ adjust = (ms - p->nextpred);
+ if (p->notsilenttx && abs(adjust) <= MAX_TIMESTAMP_SKEW) {
/* Adjust our txcore, keeping voice and non-voice synchronized */
/* AN EXPLANATION:
When we send voice, we usually send "calculated" timestamps worked out
@@ -6078,7 +6079,6 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str
changing at all. But if a consistent different starts to develop it
will be eliminated over the course of 10 frames (200-300msecs)
*/
- adjust = (ms - p->nextpred);
if (adjust < 0)
p->offset = ast_tvsub(p->offset, ast_samp2tv(abs(adjust), 10000));
else if (adjust > 0)
@@ -6100,9 +6100,9 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str
* silent periods are multiples of
* frame size too) */
- if (iaxdebug && abs(ms - p->nextpred) > MAX_TIMESTAMP_SKEW )
+ if (iaxdebug && abs(adjust) > MAX_TIMESTAMP_SKEW )
ast_debug(1, "predicted timestamp skew (%d) > max (%d), using real ts instead.\n",
- abs(ms - p->nextpred), MAX_TIMESTAMP_SKEW);
+ abs(adjust), MAX_TIMESTAMP_SKEW);
if (f->samples >= rate) /* check to make sure we don't core dump */
{
@@ -6128,11 +6128,12 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str
} else {
/* On a dataframe, use last value + 3 (to accomodate jitter buffer shrinking) if appropriate unless
it's a genuine frame */
+ adjust = (ms - p->lastsent);
if (genuine) {
/* genuine (IAX LAGRQ etc) must keep their clock-based stamps */
if (ms <= p->lastsent)
ms = p->lastsent + 3;
- } else if (abs(ms - p->lastsent) <= MAX_TIMESTAMP_SKEW) {
+ } else if (abs(adjust) <= MAX_TIMESTAMP_SKEW) {
/* non-genuine frames (!?) (DTMF, CONTROL) should be pulled into the predicted stream stamps */
ms = p->lastsent + 3;
}
diff --git a/channels/sip/dialplan_functions.c b/channels/sip/dialplan_functions.c
index 03441aa72..1793ee61a 100644
--- a/channels/sip/dialplan_functions.c
+++ b/channels/sip/dialplan_functions.c
@@ -386,7 +386,7 @@ AST_TEST_DEFINE(test_sip_rtpqos_1)
for (j = 1.0; j < 10.0; j += 0.3) {
*lookup[i].d8 = j;
ast_str_substitute_variables(&buffer, 0, chan, ast_str_buffer(varstr));
- if (sscanf(ast_str_buffer(buffer), "%lf", &cmpdbl) != 1 || fabs(j - cmpdbl > .05)) {
+ if (sscanf(ast_str_buffer(buffer), "%lf", &cmpdbl) != 1 || abs(j - cmpdbl > .05)) {
res = AST_TEST_FAIL;
ast_test_status_update(test, "%s != %f != %s\n", ast_str_buffer(varstr), j, ast_str_buffer(buffer));
break;
diff --git a/main/jitterbuf.c b/main/jitterbuf.c
index 4add56892..1bfe508da 100644
--- a/main/jitterbuf.c
+++ b/main/jitterbuf.c
@@ -139,7 +139,7 @@ static int check_resync(jitterbuf *jb, long ts, long now, long ms, const enum jb
/* check for drastic change in delay */
if (jb->info.conf.resync_threshold != -1) {
- if (abs(*delay - jb->info.last_delay) > threshold) {
+ if (labs(*delay - jb->info.last_delay) > threshold) {
jb->info.cnt_delay_discont++;
/* resync the jitterbuffer on 3 consecutive discontinuities,
* or immediately if a control frame */
diff --git a/res/res_calendar.c b/res/res_calendar.c
index 980e14125..5b911ca5b 100644
--- a/res/res_calendar.c
+++ b/res/res_calendar.c
@@ -1106,8 +1106,8 @@ static struct ast_custom_function calendar_busy_function = {
static int add_event_to_list(struct eventlist *events, struct ast_calendar_event *event, time_t start, time_t end)
{
struct evententry *entry, *iter;
- int event_startdiff = abs(start - event->start);
- int event_enddiff = abs(end - event->end);
+ long event_startdiff = labs(start - event->start);
+ long event_enddiff = labs(end - event->end);
int i = 0;
if (!(entry = ast_calloc(1, sizeof(*entry)))) {
@@ -1120,16 +1120,16 @@ static int add_event_to_list(struct eventlist *events, struct ast_calendar_event
if (start == end) {
AST_LIST_TRAVERSE_SAFE_BEGIN(events, iter, list) {
- int startdiff = abs(iter->event->start - start);
+ long startdiff = labs(iter->event->start - start);
- ast_debug(10, "Comparing %s with startdiff %d to %s with startdiff %d\n", event->summary, event_startdiff, iter->event->summary, startdiff);
+ ast_debug(10, "Comparing %s with startdiff %ld to %s with startdiff %ld\n", event->summary, event_startdiff, iter->event->summary, startdiff);
++i;
if (startdiff > event_startdiff) {
AST_LIST_INSERT_BEFORE_CURRENT(entry, list);
return i;
}
if (startdiff == event_startdiff) {
- int enddiff = abs(iter->event->end - end);
+ long enddiff = labs(iter->event->end - end);
if (enddiff > event_enddiff) {
AST_LIST_INSERT_BEFORE_CURRENT(entry, list);
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index c3f258c9e..4ab7626cd 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -3147,10 +3147,10 @@ static int ast_rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame
if (ast_tvzero(frame->delivery)) {
/* If this isn't an absolute delivery time, Check if it is close to our prediction,
and if so, go with our prediction */
- if (abs(rtp->lastts - pred) < MAX_TIMESTAMP_SKEW) {
+ if (abs((int)rtp->lastts - pred) < MAX_TIMESTAMP_SKEW) {
rtp->lastts = pred;
} else {
- ast_debug(3, "Difference is %d, ms is %u\n", abs(rtp->lastts - pred), ms);
+ ast_debug(3, "Difference is %d, ms is %u\n", abs((int)rtp->lastts - pred), ms);
mark = 1;
}
}
@@ -3161,11 +3161,11 @@ static int ast_rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame
rtp->lastts = rtp->lastts + ms * 90;
/* If it's close to our prediction, go for it */
if (ast_tvzero(frame->delivery)) {
- if (abs(rtp->lastts - pred) < 7200) {
+ if (abs((int)rtp->lastts - pred) < 7200) {
rtp->lastts = pred;
rtp->lastovidtimestamp += frame->samples;
} else {
- ast_debug(3, "Difference is %d, ms is %u (%u), pred/ts/samples %u/%d/%d\n", abs(rtp->lastts - pred), ms, ms * 90, rtp->lastts, pred, frame->samples);
+ ast_debug(3, "Difference is %d, ms is %u (%u), pred/ts/samples %u/%d/%d\n", abs((int)rtp->lastts - pred), ms, ms * 90, rtp->lastts, pred, frame->samples);
rtp->lastovidtimestamp = rtp->lastts;
}
}
@@ -3175,11 +3175,11 @@ static int ast_rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame
rtp->lastts = rtp->lastts + ms;
/* If it's close to our prediction, go for it */
if (ast_tvzero(frame->delivery)) {
- if (abs(rtp->lastts - pred) < 7200) {
+ if (abs((int)rtp->lastts - pred) < 7200) {
rtp->lastts = pred;
rtp->lastotexttimestamp += frame->samples;
} else {
- ast_debug(3, "Difference is %d, ms is %u, pred/ts/samples %u/%d/%d\n", abs(rtp->lastts - pred), ms, rtp->lastts, pred, frame->samples);
+ ast_debug(3, "Difference is %d, ms is %u, pred/ts/samples %u/%d/%d\n", abs((int)rtp->lastts - pred), ms, rtp->lastts, pred, frame->samples);
rtp->lastotexttimestamp = rtp->lastts;
}
}