[Asterisk-cvs] asterisk pbx.c,1.190,1.191

markster at lists.digium.com markster at lists.digium.com
Wed Dec 29 07:54:46 CST 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv18853

Modified Files:
	pbx.c 
Log Message:
Allow Answer(delay) to create delay after answering (bug #3160)


Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.190
retrieving revision 1.191
diff -u -d -r1.190 -r1.191
--- pbx.c	28 Dec 2004 22:52:40 -0000	1.190
+++ pbx.c	29 Dec 2004 12:49:35 -0000	1.191
@@ -210,8 +210,10 @@
 
 	{ "Answer", pbx_builtin_answer, 
 	"Answer a channel if ringing", 
-	"  Answer(): If the channel is ringing, answer it, otherwise do nothing. \n"
-	"Returns 0 unless it tries to answer the channel and fails.\n"   
+	"  Answer([delay]): If the channel is ringing, answer it, otherwise do nothing. \n"
+	"If delay is specified, asterisk will pause execution for the specified amount\n"
+	"of milliseconds if an answer is required, in order to give audio a chance to\n"
+	"become ready. Returns 0 unless it tries to answer the channel and fails.\n"   
 	},
 
 	{ "BackGround", pbx_builtin_background,
@@ -4705,7 +4707,16 @@
 
 static int pbx_builtin_answer(struct ast_channel *chan, void *data)
 {
-	return ast_answer(chan);
+	int delay = atoi(data);
+	int res;
+	if (chan->_state == AST_STATE_UP)
+		delay = 0;
+	res = ast_answer(chan);
+	if (res)
+		return res;
+	if (delay)
+		res = ast_safe_sleep(chan, delay);
+	return res;
 }
 
 static int pbx_builtin_setlanguage(struct ast_channel *chan, void *data)




More information about the svn-commits mailing list