make the automatic post-answer delay happen only when the answer is 'automatic' ...
authorKevin P. Fleming <kpfleming@digium.com>
Fri, 12 Jan 2007 15:01:46 +0000 (15:01 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Fri, 12 Jan 2007 15:01:46 +0000 (15:01 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@50571 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/channel.h
main/channel.c
main/pbx.c

index 0d07b5d..60b68fe 100644 (file)
@@ -758,13 +758,14 @@ int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset);
  */
 void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset);
 
-/*! \brief Answer a ringing call 
+/*! \brief Answer a channel
  * \param chan channel to answer
  * This function answers a channel and handles all necessary call
  * setup functions.
- * \return Returns 0 on success, -1 on failure
+ * \return Returns 0 on success, non-zero on failure
  */
 int ast_answer(struct ast_channel *chan);
+int __ast_answer(struct ast_channel *chan, unsigned int delay);
 
 /*! \brief Make a call 
  * \param chan which channel to make the call on
index 42bca18..dcdecdf 100644 (file)
@@ -1612,7 +1612,7 @@ int ast_hangup(struct ast_channel *chan)
        return res;
 }
 
-int ast_answer(struct ast_channel *chan)
+int __ast_answer(struct ast_channel *chan, unsigned int delay)
 {
        int res = 0;
 
@@ -1637,7 +1637,8 @@ int ast_answer(struct ast_channel *chan)
                        res = chan->tech->answer(chan);
                ast_setstate(chan, AST_STATE_UP);
                ast_cdr_answer(chan->cdr);
-               ast_safe_sleep(chan, 500);
+               if (delay)
+                       ast_safe_sleep(chan, delay);
                break;
        case AST_STATE_UP:
                ast_cdr_answer(chan->cdr);
@@ -1651,6 +1652,11 @@ int ast_answer(struct ast_channel *chan)
        return res;
 }
 
+int ast_answer(struct ast_channel *chan)
+{
+       return __ast_answer(chan, 500);
+}
+
 void ast_deactivate_generator(struct ast_channel *chan)
 {
        ast_channel_lock(chan);
index 10c9911..1f656ad 100644 (file)
@@ -5326,21 +5326,11 @@ static int pbx_builtin_congestion(struct ast_channel *chan, void *data)
 static int pbx_builtin_answer(struct ast_channel *chan, void *data)
 {
        int delay = 0;
-       int res;
 
-       if (chan->_state == AST_STATE_UP)
-               delay = 0;
-       else if (!ast_strlen_zero(data))
+       if ((chan->_state != AST_STATE_UP) && !ast_strlen_zero(data))
                delay = atoi(data);
 
-       res = ast_answer(chan);
-       if (res)
-               return res;
-
-       if (delay)
-               res = ast_safe_sleep(chan, delay);
-
-       return res;
+       return __ast_answer(chan, delay);
 }
 
 AST_APP_OPTIONS(resetcdr_opts, {