dect
/
asterisk
Archived
13
0
Fork 0

optimize frame handling in agent_read()

ensure that the call is marked acknowledged when it goes to AST_STATE_UP even if AST_CONTROL_ANSWER is not received (if ackcall is disabled)


git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5413 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
kpfleming 2005-04-05 21:30:24 +00:00
parent 3b18a3930d
commit 0aecb9fb67
1 changed files with 43 additions and 36 deletions

View File

@ -379,7 +379,7 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
} else } else
f = &null_frame; f = &null_frame;
if (!f) { if (!f) {
/* If there's a channel, hang it up (if it's on a callback) make it NULL */ /* If there's a channel, hang it up (if it's on a callback) make it NULL */
if (p->chan) { if (p->chan) {
p->chan->_bridge = NULL; p->chan->_bridge = NULL;
/* Note that we don't hangup if it's not a callback because Asterisk will do it /* Note that we don't hangup if it's not a callback because Asterisk will do it
@ -401,41 +401,48 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
p->chan = NULL; p->chan = NULL;
p->acknowledged = 0; p->acknowledged = 0;
} }
} } else {
if (p->chan && f && (f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_ANSWER)) { /* if acknowledgement is not required, and the channel is up, we may have missed
/* TC */ an AST_CONTROL_ANSWER (if there was one), so mark the call acknowledged anyway */
ast_log(LOG_DEBUG, "Got answer on %s\n", p->chan->name); if (!p->ackcall && !p->acknowledged && p->chan->_state == AST_STATE_UP)
if (p->ackcall) { p->acknowledged = 1;
if (option_verbose > 2) switch (f->frametype) {
ast_verbose(VERBOSE_PREFIX_3 "%s answered, waiting for '#' to acknowledge\n", p->chan->name); case AST_FRAME_CONTROL:
/* Don't pass answer along */ if (f->subclass == AST_CONTROL_ANSWER) {
ast_frfree(f); if (p->ackcall) {
f = &null_frame; if (option_verbose > 2)
} else { ast_verbose(VERBOSE_PREFIX_3 "%s answered, waiting for '#' to acknowledge\n", p->chan->name);
p->acknowledged = 1; /* Don't pass answer along */
ast_frfree(f); ast_frfree(f);
f = &answer_frame; f = &null_frame;
} } else {
} p->acknowledged = 1;
if (f && (f->frametype == AST_FRAME_DTMF) && (f->subclass == '#')) { }
if (!p->acknowledged) { }
if (option_verbose > 2) break;
ast_verbose(VERBOSE_PREFIX_3 "%s acknowledged\n", p->chan->name); case AST_FRAME_DTMF:
p->acknowledged = 1; if (!p->acknowledged && (f->subclass == '#')) {
ast_frfree(f); if (option_verbose > 2)
f = &answer_frame; ast_verbose(VERBOSE_PREFIX_3 "%s acknowledged\n", p->chan->name);
} p->acknowledged = 1;
} ast_frfree(f);
if (f && (f->frametype == AST_FRAME_DTMF) && (f->subclass == '*')) { f = &answer_frame;
/* * terminates call */ } else if (f->subclass == '*') {
ast_frfree(f); /* terminates call */
f = NULL; ast_frfree(f);
} f = NULL;
if (f && (f->frametype == AST_FRAME_VOICE) && !p->acknowledged) { }
/* Don't pass along agent audio until call is acknowledged */ break;
ast_frfree(f); case AST_FRAME_VOICE:
f = &null_frame; /* don't pass voice until the call is acknowledged */
} if (!p->acknowledged) {
ast_frfree(f);
f = &null_frame;
}
break;
}
}
CLEANUP(ast,p); CLEANUP(ast,p);
if (p->chan && !p->chan->_bridge) { if (p->chan && !p->chan->_bridge) {
if (strcasecmp(p->chan->type, "Local")) { if (strcasecmp(p->chan->type, "Local")) {