From 4a02e80d5ea655e146ac3ff6e656a09b270267c8 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 10 Feb 2007 23:16:34 +0000 Subject: [PATCH] fix dtmf bug git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4194 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/languages/mod_spidermonkey/mod_spidermonkey.c | 6 +++--- src/switch_ivr.c | 2 +- src/switch_rtp.c | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index 2dbd0beb5f..6080808236 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -1282,7 +1282,7 @@ static JSBool session_get_digits(JSContext *cx, JSObject *obj, uintN argc, jsval { struct js_session *jss = JS_GetPrivate(cx, obj); char *terminators = NULL; - char *buf; + char buf[128] = ""; int digits; int32 timeout = 5000; switch_channel_t *channel; @@ -1307,8 +1307,8 @@ static JSBool session_get_digits(JSContext *cx, JSObject *obj, uintN argc, jsval JS_ValueToInt32(cx, argv[2], &timeout); } - buf = switch_core_session_alloc(jss->session, digits); - switch_ivr_collect_digits_count(jss->session, buf, digits, digits, terminators, &term, timeout); + + switch_ivr_collect_digits_count(jss->session, buf, sizeof(buf), digits, terminators, &term, timeout); *rval = STRING_TO_JSVAL ( JS_NewStringCopyZ(cx, buf) ); return JS_TRUE; } diff --git a/src/switch_ivr.c b/src/switch_ivr.c index e014819cd5..b3d745b3d3 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -314,7 +314,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess if (switch_channel_has_dtmf(channel)) { char dtmf[128]; - switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf)); + switch_channel_dequeue_dtmf(channel, dtmf, maxdigits); for(i =0 ; i < (uint32_t) strlen(dtmf); i++) { if (!switch_strlen_zero(terminators) && strchr(terminators, dtmf[i]) && terminator != NULL) { diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 3a8cfa31cc..fcfd8a16ae 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -838,6 +838,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ rtp_session->dtmf_data.last_digit = 0; rtp_session->dtmf_data.dc = 0; } + if (duration && end) { if (key != rtp_session->dtmf_data.last_digit) { char digit_str[] = {key, 0}; @@ -917,6 +918,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_queue_dtmf(switch_rtp_t *rtp_session, } p++; } + status = switch_buffer_write(rtp_session->dtmf_data.dtmf_buffer, dtmf, wr) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_MEMERR; switch_mutex_unlock(rtp_session->dtmf_data.dtmf_mutex);