aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r--res/res_musiconhold.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 1f86b88e3..fcae10f0e 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -294,10 +294,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;
}
@@ -1081,6 +1088,19 @@ static int init_files_class(struct mohclass *class)
return 0;
}
+static void moh_rescan_files(void) {
+ struct ao2_iterator i;
+ struct mohclass *c;
+
+ i = ao2_iterator_init(mohclasses, 0);
+
+ while ((c = ao2_iterator_next(&i))) {
+ moh_scan_files(c);
+ ao2_ref(c, -1);
+ }
+
+ ao2_iterator_destroy(&i);
+}
static int moh_diff(struct mohclass *old, struct mohclass *new)
{
@@ -1584,6 +1604,9 @@ static int load_moh_classes(int reload)
ao2_t_callback(mohclasses, OBJ_NODATA, moh_class_mark, NULL, "Mark deleted classes");
ao2_t_callback(mohclasses, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, moh_classes_delete_marked, NULL, "Purge marked classes");
}
+ if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
+ moh_rescan_files();
+ }
return 0;
}