From fa39abb50b77d9d175cb8a5337ec546c3df7eb24 Mon Sep 17 00:00:00 2001
From: Russell Bryant <russell@russellbryant.com>
Date: Wed, 2 Jan 2008 23:22:25 +0000
Subject: [PATCH] Add support for generating a ringing sound on an incoming
 call.  This is a bit of a hack.  It just asks the core to generate the same
 tone that it would when you hear ringback when making an outbound call.  But
 hey, it works, and you get the localized ring tone for the appropriate
 language set on the channel.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@96079 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_console.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/channels/chan_console.c b/channels/chan_console.c
index 3e9efcb39a..1bdd836eae 100644
--- a/channels/chan_console.c
+++ b/channels/chan_console.c
@@ -42,7 +42,6 @@
  * - transfer CLI command
  * - boost CLI command and .conf option
  * - console_video support
- * - Add ringing sound on incoming calls
  */
 
 /*** MODULEINFO
@@ -466,19 +465,20 @@ static int console_call(struct ast_channel *c, char *dest, int timeout)
 	console_pvt_lock(pvt);
 
 	if (pvt->autoanswer) {
-		ast_verb(1, V_BEGIN "Auto-answered" V_END);
 		pvt->hookstate = 1;
+		console_pvt_unlock(pvt);
+		ast_verb(1, V_BEGIN "Auto-answered" V_END);
 		f.frametype = AST_FRAME_CONTROL;
 		f.subclass = AST_CONTROL_ANSWER;
 	} else {
+		console_pvt_unlock(pvt);
 		ast_verb(1, V_BEGIN "Type 'console answer' to answer, or use the 'autoanswer' option "
 				"for future calls" V_END);
 		f.frametype = AST_FRAME_CONTROL;
 		f.subclass = AST_CONTROL_RINGING;
+		ast_indicate(c, AST_CONTROL_RINGING);
 	}
 
-	console_pvt_unlock(pvt);
-
 	ast_queue_frame(c, &f);
 
 	return start_stream(pvt);
@@ -502,12 +502,12 @@ static int console_indicate(struct ast_channel *chan, int cond, const void *data
 	case AST_CONTROL_BUSY:
 	case AST_CONTROL_CONGESTION:
 	case AST_CONTROL_RINGING:
+	case -1:
 		res = -1;  /* Ask for inband indications */
 		break;
 	case AST_CONTROL_PROGRESS:
 	case AST_CONTROL_PROCEEDING:
 	case AST_CONTROL_VIDUPDATE:
-	case -1:
 		break;
 	case AST_CONTROL_HOLD:
 		ast_verb(1, V_BEGIN "Console Has Been Placed on Hold" V_END);
@@ -835,6 +835,9 @@ static char *cli_console_answer(struct ast_cli_entry *e, int cmd, struct ast_cli
 	}
 
 	pvt->hookstate = 1;
+
+	ast_indicate(pvt->owner, -1);
+
 	ast_queue_frame(pvt->owner, &f);
 
 	return CLI_SUCCESS;
-- 
GitLab