aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-08 22:48:47 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-08 22:48:47 +0000
commitd0b2229ebdf2a6569b092d4adf4ad7a984b2ef15 (patch)
tree9486a727b8e1260f7df7e56c9f2dbfa10936f2a4 /res
parent908810e23f7815eccab97be7023a1aed15f89464 (diff)
merge up to branch 1.2 and re-enable automerge
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2-netsec@53671 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r--res/res_musiconhold.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 04e4a39ee..7649d6f5b 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -203,28 +203,29 @@ static int ast_moh_files_next(struct ast_channel *chan)
struct moh_files_state *state = chan->music_state;
int tries;
- if (state->save_pos) {
- state->pos = state->save_pos;
- state->save_pos = 0;
- }
-
- state->samples = 0;
+ /* Discontinue a stream if it is running already */
if (chan->stream) {
ast_closestream(chan->stream);
chan->stream = NULL;
- state->pos++;
- state->pos %= state->class->total_files;
}
- if (ast_test_flag(state->class, MOH_RANDOMIZE)) {
- /* Try 20 times to find something good */
+ /* If a specific file has been saved, use it */
+ if (state->save_pos) {
+ state->pos = state->save_pos;
+ state->save_pos = 0;
+ } else if (ast_test_flag(state->class, MOH_RANDOMIZE)) {
+ /* Get a random file and ensure we can open it */
for (tries = 0; tries < 20; tries++) {
state->pos = rand() % state->class->total_files;
-
- /* check to see if this file's format can be opened */
if (ast_fileexists(state->class->filearray[state->pos], NULL, NULL) > 0)
break;
}
+ 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->samples = 0;
}
if (!ast_openstream_full(chan, state->class->filearray[state->pos], chan->language, 1)) {