aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-19 19:14:56 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-19 19:14:56 +0000
commitd4cfaf20d5910622eae56b32664e2bc877f823b5 (patch)
treeafb856e6ad35c36bddabfcca30f8779d29d53e13 /res
parent3e232ac30fddb815497a68e90079b126884462cf (diff)
Merged revisions 110036 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r110036 | file | 2008-03-19 16:13:39 -0300 (Wed, 19 Mar 2008) | 12 lines Merged revisions 110035 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r110035 | file | 2008-03-19 16:11:33 -0300 (Wed, 19 Mar 2008) | 4 lines Add sanity checking for position resuming. We *have* to make sure that the position does not exceed the total number of files present, and we have to make sure that the position's filename is the same as previous. These values can change if a music class is reloaded and give unpredictable behavior. (closes issue #11663) Reported by: junky ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@110037 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r--res/res_musiconhold.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 70f846976..1b44b3dfd 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -122,6 +122,7 @@ struct moh_files_state {
int sample_queue;
int pos;
int save_pos;
+ char *save_pos_filename;
};
#define MOH_QUIET (1 << 0)
@@ -248,8 +249,8 @@ static int ast_moh_files_next(struct ast_channel *chan)
return -1;
}
- /* If a specific file has been saved, use it */
- if (state->save_pos >= 0) {
+ /* If a specific file has been saved confirm it still exists and that it is still valid */
+ if (state->save_pos >= 0 && state->save_pos < state->class->total_files && state->class->filearray[state->save_pos] == state->save_pos_filename) {
state->pos = state->save_pos;
state->save_pos = -1;
} else if (ast_test_flag(state->class, MOH_RANDOMIZE)) {
@@ -259,11 +260,13 @@ static int ast_moh_files_next(struct ast_channel *chan)
if (ast_fileexists(state->class->filearray[state->pos], NULL, NULL) > 0)
break;
}
+ state->save_pos = -1;
state->samples = 0;
} else {
/* This is easy, just increment our position and make sure we don't exceed the total file count */
state->pos++;
state->pos %= state->class->total_files;
+ state->save_pos = -1;
state->samples = 0;
}
@@ -274,6 +277,9 @@ static int ast_moh_files_next(struct ast_channel *chan)
return -1;
}
+ /* Record the pointer to the filename for position resuming later */
+ state->save_pos_filename = state->class->filearray[state->pos];
+
ast_debug(1, "%s Opened file %d '%s'\n", chan->name, state->pos, state->class->filearray[state->pos]);
if (state->samples)