From: Brett Bryant Date: Thu, 9 Sep 2010 17:20:17 +0000 (+0000) Subject: Fixes an issue with MOH where it doesn't recover cleanly when it can't play a file... X-Git-Tag: 1.4.37-rc1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=314ac1bea677d1e41ddb662a37fb064fd9d2b7cd;p=thirdparty%2Fasterisk.git Fixes an issue with MOH where it doesn't recover cleanly when it can't play a file and would just stop, instead of continuing to find the next playable file in the MOH class. (closes issue #17807) Reported by: kshumard Review: https://reviewboard.asterisk.org/r/910/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@285638 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 271779461e..f67fa5a1cc 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -250,10 +250,17 @@ static int ast_moh_files_next(struct ast_channel *chan) state->samples = 0; } - if (!ast_openstream_full(chan, state->class->filearray[state->pos], chan->language, 1)) { + for (tries = 0; tries < state->class->total_files; ++tries) { + if (ast_openstream_full(chan, state->class->filearray[state->pos], chan->language, 1)) { + break; + } + ast_log(LOG_WARNING, "Unable to open file '%s': %s\n", state->class->filearray[state->pos], strerror(errno)); state->pos++; state->pos %= state->class->total_files; + } + + if (tries == state->class->total_files) { return -1; }