summaryrefslogtreecommitdiff
path: root/pbx.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2004-12-29 12:49:35 +0000
committerMark Spencer <markster@digium.com>2004-12-29 12:49:35 +0000
commited185670730366ee4d9a15a1d2c70d0887a0c110 (patch)
tree42643c8cd46af420e2487ff77a7fa9077ebad28a /pbx.c
parent8bf932bf275daf3c77921c5440ce337bfbab4de9 (diff)
Allow Answer(delay) to create delay after answering (bug #3160)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4586 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx.c')
-rwxr-xr-xpbx.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/pbx.c b/pbx.c
index 67348fa27..0acfb9760 100755
--- a/pbx.c
+++ b/pbx.c
@@ -210,8 +210,10 @@ static struct pbx_builtin {
{ "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_congestion(struct ast_channel *chan, void *data)
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)