]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
In-queue MOH stops after a periodic announcement
authorKinsey Moore <kmoore@digium.com>
Mon, 8 Aug 2011 20:52:45 +0000 (20:52 +0000)
committerKinsey Moore <kmoore@digium.com>
Mon, 8 Aug 2011 20:52:45 +0000 (20:52 +0000)
If the seek value is past the end of file when resuming G.722 MOH, MOH will
cease to function for the duration of the MOH session through all starts and
stops until saved state is cleared.  Adjusting the code to guarantee a single
valid read (which is already assumed) fixes the bug.

(closes issue ASTERISK-18077)
Review: https://reviewboard.asterisk.org/r/1328/
Tested-by: Jonathan Rose <jrose@digium.com>
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@331038 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_musiconhold.c

index 7d253db4bf15b360bd542b8125447b239f687726..a8011cec8c6aabfce35c4cc95fa516eb7b790b99 100644 (file)
@@ -338,7 +338,16 @@ static int ast_moh_files_next(struct ast_channel *chan)
        ast_debug(1, "%s Opened file %d '%s'\n", chan->name, state->pos, state->class->filearray[state->pos]);
 
        if (state->samples) {
+               size_t loc;
+               /* seek *SHOULD* be good since it's from a known location */
                ast_seekstream(chan->stream, state->samples, SEEK_SET);
+               /* if the seek failed then recover because if there is not a valid read,
+                * moh_files_generate will return -1 and MOH will stop */
+               loc = ast_tellstream(chan->stream);
+               if (state->samples > loc && loc) {
+                       /* seek one sample from the end for one guaranteed valid read */
+                       ast_seekstream(chan->stream, 1, SEEK_END);
+               }
        }
 
        return 0;