aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-11-27 17:31:56 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-11-27 17:31:56 +0000
commitb9db5d68389e7ad84fcb2643388fa71367101929 (patch)
treee06f3bae58769c81d93daa860f30542f206e5466 /res/res_musiconhold.c
parent0fe2754e186569dc597766bbefd767930d741297 (diff)
Merged revisions 48049 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ................ r48049 | tilghman | 2006-11-27 11:20:37 -0600 (Mon, 27 Nov 2006) | 10 lines Merged revisions 48045 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r48045 | tilghman | 2006-11-27 11:15:54 -0600 (Mon, 27 Nov 2006) | 2 lines Random MOH wasn't really random (bug 8381) ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48050 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r--res/res_musiconhold.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 90bc47a62..2085cc4f9 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -205,7 +205,7 @@ static void moh_files_release(struct ast_channel *chan, void *data)
if (state->origwfmt && ast_set_write_format(chan, state->origwfmt)) {
ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", chan->name, state->origwfmt);
}
- state->save_pos = state->pos + 1;
+ state->save_pos = state->pos;
}
}
@@ -216,32 +216,29 @@ static int ast_moh_files_next(struct ast_channel *chan)
int tries;
if (state->save_pos) {
- state->pos = state->save_pos - 1;
+ state->pos = state->save_pos;
state->save_pos = 0;
- } else {
- /* Try 20 times to find something good */
- for (tries=0;tries < 20;tries++) {
- state->samples = 0;
- if (chan->stream) {
- ast_closestream(chan->stream);
- chan->stream = NULL;
- state->pos++;
- }
+ }
- if (ast_test_flag(state->class, MOH_RANDOMIZE))
- state->pos = ast_random();
+ state->samples = 0;
+ if (chan->stream) {
+ ast_closestream(chan->stream);
+ chan->stream = NULL;
+ state->pos++;
+ state->pos %= state->class->total_files;
+ }
- state->pos %= state->class->total_files;
+ if (ast_test_flag(state->class, MOH_RANDOMIZE)) {
+ /* Try 20 times to find something good */
+ 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->pos = state->pos % state->class->total_files;
-
if (!ast_openstream_full(chan, state->class->filearray[state->pos], chan->language, 1)) {
ast_log(LOG_WARNING, "Unable to open file '%s': %s\n", state->class->filearray[state->pos], strerror(errno));
state->pos++;