]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 174218 via svnmerge from
authorJoshua Colp <jcolp@digium.com>
Mon, 9 Feb 2009 14:49:24 +0000 (14:49 +0000)
committerJoshua Colp <jcolp@digium.com>
Mon, 9 Feb 2009 14:49:24 +0000 (14:49 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r174218 | file | 2009-02-09 10:48:21 -0400 (Mon, 09 Feb 2009) | 4 lines

  Don't overwrite our pointer to the music class when music on hold stops. We will use this if it starts again to see if we can resume the music where it left off.
  (closes issue #14407)
  Reported by: mostyn
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@174219 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_musiconhold.c

index c53bf29c1f055249d190ad27fd76a4da8b577bd3..0bf69e6c52090dd4c0a1e9f0ce8236c70dbd35f2 100644 (file)
@@ -214,7 +214,7 @@ static void moh_files_release(struct ast_channel *chan, void *data)
 
        state->save_pos = state->pos;
 
-       state->class = mohclass_unref(state->class);
+       mohclass_unref(state->class);
 }
 
 static int ast_moh_files_next(struct ast_channel *chan) 
@@ -315,8 +315,6 @@ static void *moh_files_alloc(struct ast_channel *chan, void *params)
 
        if (!chan->music_state && (state = ast_calloc(1, sizeof(*state)))) {
                chan->music_state = state;
-               state->class = mohclass_ref(class);
-               state->save_pos = -1;
        } else {
                state = chan->music_state;
        }
@@ -326,17 +324,13 @@ static void *moh_files_alloc(struct ast_channel *chan, void *params)
        }
 
        if (state->class != class) {
-               /* (re-)initialize */
-               if (state->class) {
-                       state->class = mohclass_unref(state->class);
-               }
                memset(state, 0, sizeof(*state));
-               state->class = mohclass_ref(class);
-               if (ast_test_flag(state->class, MOH_RANDOMIZE) && class->total_files) {
+               if (ast_test_flag(class, MOH_RANDOMIZE) && class->total_files) {
                        state->pos = ast_random() % class->total_files;
                }
        }
 
+       state->class = mohclass_ref(class);
        state->origwfmt = chan->writeformat;
 
        ast_verb(3, "Started music on hold, class '%s', on %s\n", class->name, chan->name);