aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-01 21:11:28 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-01 21:11:28 +0000
commita8756f8bd1818358dc960e1a260d246536ca8f45 (patch)
tree739a13463a1181291475a3fba1e1e7b4a11728b5 /res/res_musiconhold.c
parent30601889e5de5f2529bf2f5382e233fcb8e4c879 (diff)
Merged revisions 53084 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r53084 | file | 2007-02-01 15:03:10 -0600 (Thu, 01 Feb 2007) | 2 lines Return previous behavior of having MOH pick up where it was left off. (issue #8672 reported by sinistermidget) ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@53088 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_musiconhold.c')
-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 6d9c667ae..57c56e568 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -218,28 +218,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)) {