Make sure the received DTMF duration is initialsed at the beginning, and if the realtime calllback is set or altered during operation of the detector.

This commit is contained in:
Steve Underwood 2011-12-09 00:19:01 +08:00
parent 7bbecb7eed
commit 1868e14520
1 changed files with 3 additions and 0 deletions

View File

@ -346,6 +346,7 @@ SPAN_DECLARE(void) dtmf_rx_set_realtime_callback(dtmf_rx_state_t *s,
{ {
s->realtime_callback = callback; s->realtime_callback = callback;
s->realtime_callback_data = user_data; s->realtime_callback_data = user_data;
s->duration = 0;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@ -395,6 +396,7 @@ SPAN_DECLARE(dtmf_rx_state_t *) dtmf_rx_init(dtmf_rx_state_t *s,
if ((s = (dtmf_rx_state_t *) malloc(sizeof (*s))) == NULL) if ((s = (dtmf_rx_state_t *) malloc(sizeof (*s))) == NULL)
return NULL; return NULL;
} }
memset(s, 0, sizeof(*s));
span_log_init(&s->logging, SPAN_LOG_NONE, NULL); span_log_init(&s->logging, SPAN_LOG_NONE, NULL);
span_log_set_protocol(&s->logging, "DTMF"); span_log_set_protocol(&s->logging, "DTMF");
s->digits_callback = callback; s->digits_callback = callback;
@ -547,6 +549,7 @@ SPAN_DECLARE(dtmf_tx_state_t *) dtmf_tx_init(dtmf_tx_state_t *s)
if ((s = (dtmf_tx_state_t *) malloc(sizeof (*s))) == NULL) if ((s = (dtmf_tx_state_t *) malloc(sizeof (*s))) == NULL)
return NULL; return NULL;
} }
memset(s, 0, sizeof(*s));
if (!dtmf_tx_inited) if (!dtmf_tx_inited)
dtmf_tx_initialise(); dtmf_tx_initialise();
tone_gen_init(&(s->tones), &dtmf_digit_tones[0]); tone_gen_init(&(s->tones), &dtmf_digit_tones[0]);