diff options
-rw-r--r-- | apps/app_dial.c | 4 | ||||
-rw-r--r-- | apps/app_dictate.c | 4 | ||||
-rw-r--r-- | apps/app_waitforsilence.c | 4 | ||||
-rw-r--r-- | include/asterisk/channel.h | 2 | ||||
-rw-r--r-- | main/channel.c | 14 | ||||
-rw-r--r-- | main/pbx.c | 2 |
6 files changed, 23 insertions, 7 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c index 50404d204..36d073afb 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -1353,6 +1353,10 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags res = -1; /* reset default */ } + if (ast_test_flag64(&opts, OPT_DTMF_EXIT)) { + __ast_answer(chan, 0, 0); + } + if (continue_exec) *continue_exec = 0; diff --git a/apps/app_dictate.c b/apps/app_dictate.c index 86ccad875..abac0c8ed 100644 --- a/apps/app_dictate.c +++ b/apps/app_dictate.c @@ -116,7 +116,9 @@ static int dictate_exec(struct ast_channel *chan, void *data) return -1; } - ast_answer(chan); + if (chan->_state != AST_STATE_UP) { + ast_answer(chan); + } ast_safe_sleep(chan, 200); for (res = 0; !res;) { if (ast_strlen_zero(filename)) { diff --git a/apps/app_waitforsilence.c b/apps/app_waitforsilence.c index 38d98fa5d..dd00506d5 100644 --- a/apps/app_waitforsilence.c +++ b/apps/app_waitforsilence.c @@ -153,7 +153,9 @@ static int waitforsilence_exec(struct ast_channel *chan, void *data) int iterations = 1, i; time_t waitstart; - res = ast_answer(chan); /* Answer the channel */ + if (chan->_state != AST_STATE_UP) { + res = ast_answer(chan); /* Answer the channel */ + } if (!data || ( (sscanf(data, "%d,%d,%d", &silencereqd, &iterations, &timeout) != 3) && (sscanf(data, "%d|%d", &silencereqd, &iterations) != 2) && diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 1068a2f33..55604694c 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -985,7 +985,7 @@ void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset); * \retval non-zero on failure */ int ast_answer(struct ast_channel *chan); -int __ast_answer(struct ast_channel *chan, unsigned int delay); +int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer); /*! \brief Make a call * \param chan which channel to make the call on diff --git a/main/channel.c b/main/channel.c index d0c5ff05f..e03ed2109 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1688,7 +1688,7 @@ int ast_hangup(struct ast_channel *chan) } #define ANSWER_WAIT_MS 500 -int __ast_answer(struct ast_channel *chan, unsigned int delay) +int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer) { int res = 0; @@ -1716,7 +1716,9 @@ int __ast_answer(struct ast_channel *chan, unsigned int delay) res = chan->tech->answer(chan); } ast_setstate(chan, AST_STATE_UP); - ast_cdr_answer(chan->cdr); + if (cdr_answer) { + ast_cdr_answer(chan->cdr); + } ast_channel_unlock(chan); if (delay) { ast_safe_sleep(chan, delay); @@ -1752,6 +1754,12 @@ int __ast_answer(struct ast_channel *chan, unsigned int delay) } break; case AST_STATE_UP: + /* Calling ast_cdr_answer when it it has previously been called + * is essentially a no-op, so it is safe. + */ + if (cdr_answer) { + ast_cdr_answer(chan->cdr); + } break; default: break; @@ -1765,7 +1773,7 @@ int __ast_answer(struct ast_channel *chan, unsigned int delay) int ast_answer(struct ast_channel *chan) { - return __ast_answer(chan, 0); + return __ast_answer(chan, 0, 1); } void ast_deactivate_generator(struct ast_channel *chan) diff --git a/main/pbx.c b/main/pbx.c index 2828a6bf1..103d27815 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -7576,7 +7576,7 @@ static int pbx_builtin_answer(struct ast_channel *chan, void *data) delay = 0; } - return __ast_answer(chan, delay); + return __ast_answer(chan, delay, 1); } AST_APP_OPTIONS(resetcdr_opts, { |