diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-01-05 23:52:34 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-01-05 23:52:34 +0000 |
commit | c8282b54f403090d2172513e1cd7747b2d81e1c9 (patch) | |
tree | 7583877a0981d4c06fa8cb433594135b57a58c1d | |
parent | 87aa4936dd9d504887da33f6fd31a28698deeaa0 (diff) |
Merged revisions 7825 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r7825 | kpfleming | 2006-01-05 17:49:50 -0600 (Thu, 05 Jan 2006) | 3 lines
eliminate rounding errors that caused call time limits to be inaccurate (issue #5913)
round 'time left' reported during call limit warnings up to sound more accurate
........
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7826 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channel.c | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -3201,7 +3201,8 @@ static void bridge_playfile(struct ast_channel *chan, struct ast_channel *peer, } static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct ast_channel *c1, - struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc, int toms) + struct ast_bridge_config *config, struct ast_frame **fo, + struct ast_channel **rc, struct timeval bridge_end) { /* Copy voice back and forth between the two channels. */ struct ast_channel *cs[3]; @@ -3213,6 +3214,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct int watch_c0_dtmf; int watch_c1_dtmf; void *pvt0, *pvt1; + int to; cs[0] = c0; cs[1] = c1; @@ -3231,12 +3233,13 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct res = AST_BRIDGE_RETRY; break; } - who = ast_waitfor_n(cs, 2, &toms); + to = ast_tvdiff_ms(bridge_end, ast_tvnow()); + if (to <= 0) { + res = AST_BRIDGE_RETRY; + break; + } + who = ast_waitfor_n(cs, 2, &to); if (!who) { - if (!toms) { - res = AST_BRIDGE_RETRY; - break; - } ast_log(LOG_DEBUG, "Nobody there, continuing...\n"); if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE || c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) { if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE) @@ -3405,10 +3408,13 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha if (!to) { if (time_left_ms >= 5000) { + /* force the time left to round up if appropriate */ if (caller_warning && config->warning_sound && config->play_warning) - bridge_playfile(c0, c1, config->warning_sound, time_left_ms / 1000); + bridge_playfile(c0, c1, config->warning_sound, + (time_left_ms + 500) / 1000); if (callee_warning && config->warning_sound && config->play_warning) - bridge_playfile(c1, c0, config->warning_sound, time_left_ms / 1000); + bridge_playfile(c1, c0, config->warning_sound, + (time_left_ms + 500) / 1000); } if (config->warning_freq) { nexteventts = ast_tvadd(nexteventts, ast_samp2tv(config->warning_freq, 1000)); @@ -3509,7 +3515,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha o0nativeformats = c0->nativeformats; o1nativeformats = c1->nativeformats; } - res = ast_generic_bridge(c0, c1, config, fo, rc, to); + res = ast_generic_bridge(c0, c1, config, fo, rc, nexteventts); if (res != AST_BRIDGE_RETRY) break; } |