If somebody enters a digit during ast_stream_and_wait, the return value is the digit...
authorJason Parker <jparker@digium.com>
Tue, 15 Apr 2008 20:27:04 +0000 (20:27 +0000)
committerJason Parker <jparker@digium.com>
Tue, 15 Apr 2008 20:27:04 +0000 (20:27 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114149 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_directory.c

index 03f8dbb..981e1f1 100644 (file)
@@ -858,14 +858,23 @@ static int directory_exec(struct ast_channel *chan, void *data)
                if (!ast_strlen_zero(dirintro) && !res) {
                        res = ast_stream_and_wait(chan, dirintro, AST_DIGIT_ANY);
                } else if (!res) {
                if (!ast_strlen_zero(dirintro) && !res) {
                        res = ast_stream_and_wait(chan, dirintro, AST_DIGIT_ANY);
                } else if (!res) {
-                       res = ast_stream_and_wait(chan, "dir-welcome", AST_DIGIT_ANY) ||
-                               ast_stream_and_wait(chan, "dir-pls-enter", AST_DIGIT_ANY) ||
-                               ast_stream_and_wait(chan, digits, AST_DIGIT_ANY) ||
-                               ast_stream_and_wait(chan, 
+                       /* Stop playing sounds as soon as we have a digit. */
+                       res = ast_stream_and_wait(chan, "dir-welcome", AST_DIGIT_ANY);
+                       if (!res) {
+                               res = ast_stream_and_wait(chan, "dir-pls-enter", AST_DIGIT_ANY);
+                       }
+                       if (!res) {
+                               res = ast_stream_and_wait(chan, digits, AST_DIGIT_ANY);
+                       }
+                       if (!res) {
+                               res = ast_stream_and_wait(chan, 
                                        which == FIRST ? "dir-first" :
                                        which == LAST ? "dir-last" :
                                        which == FIRST ? "dir-first" :
                                        which == LAST ? "dir-last" :
-                                       "dir-firstlast", AST_DIGIT_ANY) ||
+                                       "dir-firstlast", AST_DIGIT_ANY);
+                       }
+                       if (!res) {
                                ast_stream_and_wait(chan, "dir-usingkeypad", AST_DIGIT_ANY);
                                ast_stream_and_wait(chan, "dir-usingkeypad", AST_DIGIT_ANY);
+                       }
                }
                ast_stopstream(chan);
                if (!res)
                }
                ast_stopstream(chan);
                if (!res)