FreeCalypso > hg > themwi-system-sw
diff mgw/dtmf_ctrl.c @ 150:529906fddcfa
mgw DTMF timing fix in the corner case of no speech
arriving between the end of one DTMF and the start of next
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 11 Oct 2022 14:10:29 -0800 |
parents | f062c32a5116 |
children | a6eb2de277f6 |
line wrap: on
line diff
--- a/mgw/dtmf_ctrl.c Tue Oct 11 13:48:39 2022 -0800 +++ b/mgw/dtmf_ctrl.c Tue Oct 11 14:10:29 2022 -0800 @@ -62,7 +62,7 @@ { struct endpoint *ep; struct dtmf_desc *desc; - struct timeval tv_diff; + struct timeval tv_last, tv_diff; unsigned delta_frames; ep = find_ep_by_id(conn, req->ep_id); @@ -90,11 +90,15 @@ return; } /* figure out starting timestamp */ - if (!ep->dtmf_aftermath) + if (ep->dtmf_aftermath) + tv_last = ep->dtmf_last_time; + else { ep->dtmf_last_ts = ep->g2p_last_ts; + tv_last = ep->g2p_local_time; + } ep->dtmf_m_bit = 0; - if (timercmp(&cur_event_time, &ep->g2p_local_time, >)) { - timersub(&cur_event_time, &ep->g2p_local_time, &tv_diff); + if (timercmp(&cur_event_time, &tv_last, >)) { + timersub(&cur_event_time, &tv_last, &tv_diff); delta_frames = tv_diff.tv_sec * 50 + tv_diff.tv_usec / 20000; if (delta_frames) { ep->dtmf_last_ts += delta_frames * SAMPLES_PER_FRAME;