aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-01 21:13:32 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-01 21:13:32 +0000
commitc899481fc0e99ce08d774156ea56eb79d9f8515b (patch)
tree51e24894f16704e6146304b064a31b0e4db46444 /main
parentfdf092858f3346a6e6c880b9d9c0b38eef4802a7 (diff)
Merging Revision 127113 from trunk
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@127156 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/channel.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/main/channel.c b/main/channel.c
index f8406feb0..2c6dba1d0 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -1679,15 +1679,31 @@ int __ast_answer(struct ast_channel *chan, unsigned int delay)
switch (chan->_state) {
case AST_STATE_RINGING:
case AST_STATE_RING:
- if (chan->tech->answer)
- res = chan->tech->answer(chan);
- ast_setstate(chan, AST_STATE_UP);
- ast_cdr_answer(chan->cdr);
- ast_channel_unlock(chan);
- if (delay)
+ if (delay) {
+ int needanswer = (chan->tech->answer != NULL);
+
+ ast_setstate(chan, AST_STATE_UP);
+ ast_cdr_answer(chan->cdr);
+ ast_channel_unlock(chan);
ast_safe_sleep(chan, delay);
+ /* don't tell the channel it has been answered until *after* the delay,
+ so that the media path will be in place and usable when it wants to
+ send media
+ */
+ if (needanswer) {
+ ast_channel_lock(chan);
+ res = chan->tech->answer(chan);
+ ast_channel_unlock(chan);
+ }
+ } else {
+ if (chan->tech->answer) {
+ res = chan->tech->answer(chan);
+ }
+ ast_setstate(chan, AST_STATE_UP);
+ ast_cdr_answer(chan->cdr);
+ ast_channel_unlock(chan);
+ }
return res;
- break;
case AST_STATE_UP:
ast_cdr_answer(chan->cdr);
break;