[asterisk-commits] file: trunk r53089 - in /trunk: ./
res/res_musiconhold.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Feb 1 14:12:27 MST 2007
Author: file
Date: Thu Feb 1 15:12:26 2007
New Revision: 53089
URL: http://svn.digium.com/view/asterisk?view=rev&rev=53089
Log:
Merged revisions 53088 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r53088 | file | 2007-02-01 15:11:28 -0600 (Thu, 01 Feb 2007) | 10 lines
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)
........
................
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=53089&r1=53088&r2=53089
==============================================================================
--- trunk/res/res_musiconhold.c (original)
+++ trunk/res/res_musiconhold.c Thu Feb 1 15:12:26 2007
@@ -216,28 +216,29 @@
struct moh_files_state *state = chan->music_state;
int tries;
+ /* Discontinue a stream if it is running already */
+ if (chan->stream) {
+ ast_closestream(chan->stream);
+ chan->stream = NULL;
+ }
+
+ /* If a specific file has been saved, use it */
if (state->save_pos) {
state->pos = state->save_pos;
state->save_pos = 0;
- }
-
- state->samples = 0;
- if (chan->stream) {
- ast_closestream(chan->stream);
- chan->stream = NULL;
+ } 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;
+ 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;
- }
-
- 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->samples = 0;
}
if (!ast_openstream_full(chan, state->class->filearray[state->pos], chan->language, 1)) {
More information about the asterisk-commits
mailing list