[asterisk-commits] russell: branch russell/issue_12658 r163161 - /team/russell/issue_12658/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Dec 11 11:44:41 CST 2008
Author: russell
Date: Thu Dec 11 11:44:40 2008
New Revision: 163161
URL: http://svn.digium.com/view/asterisk?view=rev&rev=163161
Log:
The code that determines whether it is an acceptable time to pull DTMF out of the
channel readq did not account for a case when DTMF must be deferred. We enforce
a minimum amount of time between digits, so check for that, too.
Modified:
team/russell/issue_12658/main/channel.c
Modified: team/russell/issue_12658/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/issue_12658/main/channel.c?view=diff&rev=163161&r1=163160&r2=163161
==============================================================================
--- team/russell/issue_12658/main/channel.c (original)
+++ team/russell/issue_12658/main/channel.c Thu Dec 11 11:44:40 2008
@@ -2002,6 +2002,27 @@
ast_queue_frame(chan, fr);
}
+/*!
+ * \brief Determine whether or not we should ignore DTMF in the readq
+ */
+static inline int should_skip_dtmf(struct ast_channel *chan)
+{
+ if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_EMULATE_DTMF)) {
+ /* We're in the middle of emulating a digit, or DTMF has been
+ * explicitly deferred. Skip this digit, then. */
+ return 1;
+ }
+
+ if (!ast_tvzero(chan->dtmf_tv) &&
+ ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) {
+ /* We're not in the middle of a digit, but it hasn't been long enough
+ * since the last digit, so we'll have to skip DTMF for now. */
+ return 1;
+ }
+
+ return 0;
+}
+
static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
{
struct ast_frame *f = NULL; /* the return value */
@@ -2107,26 +2128,16 @@
/* Check for pending read queue */
if (!AST_LIST_EMPTY(&chan->readq)) {
+ int skip_dtmf = should_skip_dtmf(chan);
+
AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->readq, f, frame_list) {
/* We have to be picky about which frame we pull off of the readq because
* there are cases where we want to leave DTMF frames on the queue until
* some later time. */
- if (f->frametype != AST_FRAME_DTMF_BEGIN && f->frametype != AST_FRAME_DTMF_END) {
- /* It's not a DTMF frame, so we know we're good. */
- AST_LIST_REMOVE_CURRENT(&chan->readq, frame_list);
- break;
- }
-
- /* It's a DTMF frame. Let's see if now is the time. */
-
- if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_EMULATE_DTMF)) {
- /* We're in the middle of emulating a digit, or DTMF has been
- * explicitly deferred. Skip this digit, then. */
+ if ( (f->frametype == AST_FRAME_DTMF_BEGIN || f->frametype == AST_FRAME_DTMF_END) && skip_dtmf) {
continue;
}
-
- /* It was a DTMF FRAME, but now is an acceptable time to process it. */
AST_LIST_REMOVE_CURRENT(&chan->readq, frame_list);
break;
More information about the asterisk-commits
mailing list