]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6535 mod_rayo: close recognizer when input component is complete
authorChris Rienzo <chris.rienzo@grasshopper.com>
Fri, 13 Jun 2014 16:34:19 +0000 (12:34 -0400)
committerChris Rienzo <chris.rienzo@grasshopper.com>
Fri, 13 Jun 2014 16:34:19 +0000 (12:34 -0400)
src/mod/event_handlers/mod_rayo/rayo_input_component.c

index cfada79370ec6c54d3a29f92a73fb898d68d6527..76bffff055684d0ee56c2198cb64079cc3fb5f5b 100644 (file)
@@ -720,6 +720,22 @@ static char *create_input_component_id(switch_core_session_t *session, iks *inpu
        return switch_core_session_sprintf(session, "%s-input-%s", switch_core_session_get_uuid(session), mode);
 }
 
+/**
+ * Release any resources consumed by this input component
+ */
+static void input_component_cleanup(struct rayo_actor *component)
+{
+       switch_mutex_lock(component->mutex);
+       if (INPUT_COMPONENT(component)->speech_mode) {
+               switch_core_session_t *session = switch_core_session_locate(component->parent->id);
+               if (session) {
+                       switch_ivr_stop_detect_speech(session);
+                       switch_core_session_rwunlock(session);
+               }
+       }
+       switch_mutex_unlock(component->mutex);
+}
+
 /**
  * Start execution of input component
  */
@@ -745,7 +761,7 @@ static iks *start_call_input_component(struct rayo_actor *call, struct rayo_mess
 
        switch_core_new_memory_pool(&pool);
        input_component = switch_core_alloc(pool, sizeof(*input_component));
-       input_component = INPUT_COMPONENT(rayo_component_init(RAYO_COMPONENT(input_component), pool, RAT_CALL_COMPONENT, "input", component_id, call, iks_find_attrib(iq, "from")));
+       input_component = INPUT_COMPONENT(rayo_component_init_cleanup(RAYO_COMPONENT(input_component), pool, RAT_CALL_COMPONENT, "input", component_id, call, iks_find_attrib(iq, "from"), input_component_cleanup));
        if (!input_component) {
                switch_core_destroy_memory_pool(&pool);
                return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Failed to create input entity");