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: https://origsvn.digium.com/svn/asterisk/trunk@5413 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2005-04-05 21:30:24 +00:00
parent d41e65cd0d
commit 2650a7f2ae

View File

@@ -401,10 +401,14 @@ 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)
p->acknowledged = 1;
switch (f->frametype) {
case AST_FRAME_CONTROL:
if (f->subclass == AST_CONTROL_ANSWER) {
if (p->ackcall) { if (p->ackcall) {
if (option_verbose > 2) if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "%s answered, waiting for '#' to acknowledge\n", p->chan->name); ast_verbose(VERBOSE_PREFIX_3 "%s answered, waiting for '#' to acknowledge\n", p->chan->name);
@@ -413,29 +417,32 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
f = &null_frame; f = &null_frame;
} else { } else {
p->acknowledged = 1; p->acknowledged = 1;
ast_frfree(f);
f = &answer_frame;
} }
} }
if (f && (f->frametype == AST_FRAME_DTMF) && (f->subclass == '#')) { break;
if (!p->acknowledged) { case AST_FRAME_DTMF:
if (!p->acknowledged && (f->subclass == '#')) {
if (option_verbose > 2) if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "%s acknowledged\n", p->chan->name); ast_verbose(VERBOSE_PREFIX_3 "%s acknowledged\n", p->chan->name);
p->acknowledged = 1; p->acknowledged = 1;
ast_frfree(f); ast_frfree(f);
f = &answer_frame; f = &answer_frame;
} } else if (f->subclass == '*') {
} /* terminates call */
if (f && (f->frametype == AST_FRAME_DTMF) && (f->subclass == '*')) {
/* * terminates call */
ast_frfree(f); ast_frfree(f);
f = NULL; f = NULL;
} }
if (f && (f->frametype == AST_FRAME_VOICE) && !p->acknowledged) { break;
/* Don't pass along agent audio until call is acknowledged */ case AST_FRAME_VOICE:
/* don't pass voice until the call is acknowledged */
if (!p->acknowledged) {
ast_frfree(f); ast_frfree(f);
f = &null_frame; 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")) {