Index: main/dsp.c =================================================================== --- main/dsp.c (revision 371649) +++ main/dsp.c (working copy) @@ -725,41 +725,21 @@ } } - if (hit == s->td.dtmf.lasthit) { - if (s->td.dtmf.current_hit) { - /* We are in the middle of a digit already */ - if (hit) { - if (hit != s->td.dtmf.current_hit) { - /* Look for a start of a new digit. - This is because hits_to_begin may be smaller than misses_to_end - and we may find the beginning of new digit before we consider last one ended. */ - s->td.dtmf.current_hit = 0; - } else { - /* Current hit was same as last, so increment digit duration (of last digit) */ - s->digitlen[s->current_digits - 1] += DTMF_GSIZE; - } - } else { - /* No Digit */ - s->td.dtmf.misses++; - if (s->td.dtmf.misses == s->td.dtmf.misses_to_end) { - /* There were enough misses to consider digit ended */ - s->td.dtmf.current_hit = 0; - } - } - } else if (hit) { - /* Detecting new digit */ - s->td.dtmf.hits++; - if (s->td.dtmf.hits == s->td.dtmf.hits_to_begin) { - store_digit(s, hit); - s->td.dtmf.current_hit = hit; - } + if ((hit != s->td.dtmf.current_hit) && (s->td.dtmf.lasthit != s->td.dtmf.current_hit)) { + ast_debug(1, "DTMF hit=%d\n", hit); + hit = (hit && hit == s->td.dtmf.lasthit) ? hit : 0; + if (hit) { + store_digit(s, hit); } + s->td.dtmf.current_hit = hit; } else { - s->td.dtmf.hits = 1; - s->td.dtmf.misses = 1; - s->td.dtmf.lasthit = hit; + if (hit) { + /* Current hit was same as last, so increment digit duration (of last digit) */ + s->digitlen[s->current_digits - 1] += DTMF_GSIZE; + } } - + s->td.dtmf.lasthit = hit; + /* If we had a hit in this block, include it into mute fragment */ if (squelch && hit) { if (mute.end < sample - DTMF_GSIZE) {