From 6088b7e39ad9d32c9194ba3a9a5b97bef88833ad Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Sat, 1 Aug 2009 05:29:50 +0000 Subject: [PATCH] core: fire_asr_events should be true/false (FSCORE-406) git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14447 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_ivr_async.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index b79fbaf106..969fbfd175 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -2073,19 +2073,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t * switch_status_t status; switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE; struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY); - switch_codec_implementation_t read_impl = {0}; - switch_core_session_get_read_impl(session, &read_impl); - + switch_codec_implementation_t read_impl = {0}; + switch_core_session_get_read_impl(session, &read_impl); + const char *p; + if (!ah) { if (!(ah = switch_core_session_alloc(session, sizeof(*ah)))) { return SWITCH_STATUS_MEMERR; } } - if ((switch_channel_get_variable(channel, "fire_asr_events"))) { - switch_set_flag(ah, SWITCH_ASR_FLAG_FIRE_EVENTS); - } - if (sth) { if (switch_core_asr_load_grammar(sth->ah, grammar, name) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error loading Grammar\n"); @@ -2093,6 +2090,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t * return SWITCH_STATUS_FALSE; } + if ((p = switch_channel_get_variable(channel, "fire_asr_events")) && switch_true(p)) { + switch_set_flag(sth->ah, SWITCH_ASR_FLAG_FIRE_EVENTS); + } + return SWITCH_STATUS_SUCCESS; } @@ -2118,6 +2119,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t * sth->session = session; sth->ah = ah; + if ((p = switch_channel_get_variable(channel, "fire_asr_events")) && switch_true(p)) { + switch_set_flag(ah, SWITCH_ASR_FLAG_FIRE_EVENTS); + } + if ((status = switch_core_media_bug_add(session, speech_callback, sth, 0, SMBF_READ_STREAM, &sth->bug)) != SWITCH_STATUS_SUCCESS) { switch_core_asr_close(ah, &flags); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);