From 11ca1a2b2ebe0ab1c19fd766077a6ade0b724adf Mon Sep 17 00:00:00 2001
From: Travis Cross <tc@traviscross.com>
Date: Mon, 3 Mar 2014 23:21:58 +0000
Subject: [PATCH] Fix handling of send_silence_when_idle==0 in switch_ivr_sleep

When the channel variable send_silence_when_idle was set to zero,
switch_ivr_sleep was calling SWITCH_IVR_VERIFY_SILENCE_DIVISOR on it
anyway, causing it to be set to 400.  The only way to get the behavior
of not sending silence when idle was to unset the variable completely.

This corrects the behavior such that setting the value to zero has the
same effect as leaving it unset.
---
 src/switch_ivr.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/switch_ivr.c b/src/switch_ivr.c
index b18a67ace8..87ea8af4b5 100644
--- a/src/switch_ivr.c
+++ b/src/switch_ivr.c
@@ -166,9 +166,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session,
 		switch_goto_status(SWITCH_STATUS_SUCCESS, end);
 	}
 
-	var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE);
-	if (var) {
-		sval = atoi(var);
+	if ((var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE))
+		&& (sval = atoi(var))) {
 		SWITCH_IVR_VERIFY_SILENCE_DIVISOR(sval);
 	}