move common conditions to the outside block.
authorLuigi Rizzo <rizzo@icir.org>
Sun, 16 Apr 2006 16:04:24 +0000 (16:04 +0000)
committerLuigi Rizzo <rizzo@icir.org>
Sun, 16 Apr 2006 16:04:24 +0000 (16:04 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@20540 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channel.c

index 8dbf884..9d0efd5 100644 (file)
--- a/channel.c
+++ b/channel.c
@@ -3465,10 +3465,10 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
                        if (time_left_ms < to)
                                to = time_left_ms;
 
-                       if (time_left_ms <= 0) {
-                               if (caller_warning && config->end_sound)
+                       if (time_left_ms <= 0 && config->end_sound) {
+                               if (caller_warning)
                                        bridge_playfile(c0, c1, config->end_sound, 0);
-                               if (callee_warning && config->end_sound)
+                               if (callee_warning)
                                        bridge_playfile(c1, c0, config->end_sound, 0);
                                *fo = NULL;
                                if (who)
@@ -3478,14 +3478,12 @@ 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 + 500) / 1000);
-                                       if (callee_warning && config->warning_sound && config->play_warning)
-                                               bridge_playfile(c1, c0, config->warning_sound,
-                                                               (time_left_ms + 500) / 1000);
+                               if (time_left_ms >= 5000 && config->warning_sound && config->play_warning) {
+                                       int t = (time_left_ms + 500) / 1000; /* round to nearest second */
+                                       if (caller_warning)
+                                               bridge_playfile(c0, c1, config->warning_sound, t);
+                                       if (callee_warning)
+                                               bridge_playfile(c1, c0, config->warning_sound, t);
                                }
                                if (config->warning_freq) {
                                        nexteventts = ast_tvadd(nexteventts, ast_samp2tv(config->warning_freq, 1000));