]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't overwrite our pointer to the music class when music on hold stops. We will...
authorJoshua Colp <jcolp@digium.com>
Mon, 9 Feb 2009 14:48:21 +0000 (14:48 +0000)
committerJoshua Colp <jcolp@digium.com>
Mon, 9 Feb 2009 14:48:21 +0000 (14:48 +0000)
(closes issue #14407)
Reported by: mostyn

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

res/res_musiconhold.c

index a67999d653ea7cb2643b6a9fae0854a15ece4047..9a970f7f28537014097d0ba8447924a0f2c6e872 100644 (file)
@@ -202,7 +202,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);
 }
 
 
@@ -307,8 +307,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;
        }
@@ -318,17 +316,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;
 
        if (option_verbose > 2) {