[asterisk-commits] tilghman: trunk r48050 - in /trunk: ./
res/res_musiconhold.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Nov 27 10:31:56 MST 2006
Author: tilghman
Date: Mon Nov 27 11:31:56 2006
New Revision: 48050
URL: http://svn.digium.com/view/asterisk?view=rev&rev=48050
Log:
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)
........
................
Modified:
trunk/ (props changed)
trunk/res/res_musiconhold.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Modified: trunk/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_musiconhold.c?view=diff&rev=48050&r1=48049&r2=48050
==============================================================================
--- trunk/res/res_musiconhold.c (original)
+++ trunk/res/res_musiconhold.c Mon Nov 27 11:31:56 2006
@@ -205,7 +205,7 @@
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 @@
int tries;
if (state->save_pos) {
- state->pos = state->save_pos - 1;
+ state->pos = state->save_pos;
state->save_pos = 0;
- } else {
+ }
+
+ state->samples = 0;
+ 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 */
- 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->pos %= state->class->total_files;
+ 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++;
More information about the asterisk-commits
mailing list