]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Properly indicate failure to open an audio stream in res_agi
authorMichael L. Young <elgueromexicano@gmail.com>
Thu, 18 Jul 2013 12:52:33 +0000 (12:52 +0000)
committerMichael L. Young <elgueromexicano@gmail.com>
Thu, 18 Jul 2013 12:52:33 +0000 (12:52 +0000)
If there is an error streaming an audio file, the current return status makes it
difficult for an AGI script to determine that there was an error with the audio
file.

This patches changes the result to return -1 and the function returns
RESULT_FAILURE instead of RESULT_SUCCESS.  From looking at other parts of
res_agi, this would appear to be the proper way to handle an error.

(closes issue ASTERISK-21903)
Reported by: Ariel Wainer
Tested by: Ariel Wainer
Patches:
asterisk-21903-return-stream-res_1.8.diff
by Michael L. Young (license 5026)

Review: https://reviewboard.asterisk.org/r/2625/
........

Merged revisions 394640 from http://svn.asterisk.org/svn/asterisk/branches/1.8

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@394641 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_agi.c

index 5fc6f05cb285d9bb863d8ae683b4ef1ddd270ba7..fe6fbc07cea4675b47b761bbfe1c8fec255bac1a 100644 (file)
@@ -2007,8 +2007,8 @@ static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, const
        }
 
        if (!(fs = ast_openstream(chan, argv[2], ast_channel_language(chan)))) {
-               ast_agi_send(agi->fd, chan, "200 result=%d endpos=%ld\n", 0, sample_offset);
-               return RESULT_SUCCESS;
+               ast_agi_send(agi->fd, chan, "200 result=-1 endpos=%ld\n", sample_offset);
+               return RESULT_FAILURE;
        }
 
        if ((vfs = ast_openvstream(chan, argv[2], ast_channel_language(chan)))) {
@@ -2065,9 +2065,9 @@ static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, const
        }
 
        if (!(fs = ast_openstream(chan, argv[2], ast_channel_language(chan)))) {
-               ast_agi_send(agi->fd, chan, "200 result=%d endpos=%ld\n", 0, sample_offset);
+               ast_agi_send(agi->fd, chan, "200 result=-1 endpos=%ld\n", sample_offset);
                ast_log(LOG_WARNING, "Unable to open %s\n", argv[2]);
-               return RESULT_SUCCESS;
+               return RESULT_FAILURE;
        }
 
        if ((vfs = ast_openvstream(chan, argv[2], ast_channel_language(chan))))