aboutsummaryrefslogtreecommitdiffstats
path: root/channel.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-05 23:49:50 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-05 23:49:50 +0000
commitff061431f1fa13962b3e63707e7a89332827d730 (patch)
tree7bbc101964a85e8d4d1b2a38f8fd6310710daa26 /channel.c
parente1820a3f10f990efbdfaa68a997c20785dac6f4b (diff)
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/branches/1.2@7825 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rw-r--r--channel.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/channel.c b/channel.c
index dd1ca044c..34f8d09ca 100644
--- a/channel.c
+++ b/channel.c
@@ -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;
}