mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 23:08:32 +00:00
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: https://origsvn.digium.com/svn/asterisk/branches/1.2@7825 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
24
channel.c
24
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user