summaryrefslogtreecommitdiff
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r--res/res_musiconhold.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index e4ea16479..6024e9da8 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -318,10 +318,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;
}