]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Fix ivr_menu, no entry is considered invalid, keying digits during audio is not...
authorMike Murdock <mmurdock@coppercom.com>
Tue, 13 Feb 2007 17:15:42 +0000 (17:15 +0000)
committerMike Murdock <mmurdock@coppercom.com>
Tue, 13 Feb 2007 17:15:42 +0000 (17:15 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4234 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_ivr.c

index 4725abe854a254a01806e59e232e05504586a729..519dc6834ed6dc5d0878a6936e2c53d8a7a9bad7 100644 (file)
@@ -4158,7 +4158,9 @@ static switch_status_t play_or_say(switch_core_session_t *session, switch_ivr_me
        uint32_t len;
        char *ptr;
        switch_status_t status = SWITCH_STATUS_FALSE;
-    switch_input_args_t args= {0};
+       switch_input_args_t args= {0};
+
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "play_or_say sound=[%s]\n",sound);
 
        if (session != NULL && menu != NULL && !switch_strlen_zero(sound)) {
                memset(menu->buf, 0, menu->inlen);
@@ -4171,8 +4173,8 @@ static switch_status_t play_or_say(switch_core_session_t *session, switch_ivr_me
                        len = menu->inlen;
                        ptr = menu->ptr;
                }
-        args.buf = ptr;
-        args.buflen = len;
+               args.buf = ptr;
+               args.buflen = len;
 
                if (*sound == '/' || *sound == '\\') {
                        status = switch_ivr_play_file(session, NULL, sound, &args);
@@ -4180,6 +4182,9 @@ static switch_status_t play_or_say(switch_core_session_t *session, switch_ivr_me
                        if (menu->tts_engine && menu->tts_voice) {
                                status = switch_ivr_speak_text(session, menu->tts_engine, menu->tts_voice, 0, sound, &args);
                        }
+                       else {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No TTS engine to play sound\n");
+                       }
                }
 
                if (need) {
@@ -4191,6 +4196,7 @@ static switch_status_t play_or_say(switch_core_session_t *session, switch_ivr_me
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "digits '%s'\n",menu->buf);
                }
        }
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "play_or_say returning [%d]\n",status);
 
        return status;
 }
@@ -4262,6 +4268,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s
                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IVR action on menu '%s' matched '%s' param '%s'\n", menu->name, menu->buf,aptr);
                                        }
 
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "switch_ivr_menu_execute todo=[%d]\n", todo);
 
                                        switch(todo) {
                                        case SWITCH_IVR_ACTION_DIE:
@@ -4292,7 +4299,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s
                                                                *app_arg = '\0';
                                                                app_arg++;
                                                        }
-                                               
+
                                                        if (app_name && app_arg) {
                                                                if ((application_interface = switch_loadable_module_get_application_interface(app_name))) {
                                                                        if (application_interface->application_function) {
@@ -4331,23 +4338,30 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s
                                }
                        }
                }
-               if (*menu->buf && !match) {
-                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IVR menu '%s' caught invalid input '%s'\n", menu->name, menu->buf);
-
+               if (!match) {
+                       if (*menu->buf) {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IVR menu '%s' caught invalid input '%s'\n", menu->name, menu->buf);
+                               }
+                       else {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IVR menu '%s' no input detected\n", menu->name);
+                       }
                        if (menu->invalid_sound) {
                                play_or_say(session, menu, menu->invalid_sound, 0);
                        }
                        errs++;
-
                        if (status == SWITCH_STATUS_SUCCESS) {
                                status = switch_ivr_sleep(session, 1000);
                        }
+                       /* breaks are ok too */
+                       if (SWITCH_STATUS_IS_BREAK(status)) {
+                               status = SWITCH_STATUS_SUCCESS;
+                       }
                }
        }
 
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "exit-sound '%s'\n",menu->exit_sound);
        if (!switch_strlen_zero(menu->exit_sound)) {
-               status = switch_ivr_play_file(session, NULL, menu->exit_sound, NULL);
+               play_or_say(session, menu, menu->exit_sound, 0);
        }
 
        switch_safe_free(menu->buf);