From 168624aa5f28b021a5c6e9cd0286c5006edcb407 Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Wed, 23 Nov 2011 16:10:07 +0000 Subject: [PATCH] Resume playing existing hold music for cached realtime MOH As a result of the fix for ASTERISK-18039, realtime caching MOH no longer properly resumes playing back a file between different holds in the same call. This is because scanning for new files causes the existing file array to be emptied and we were just comparing that the saved pointer to the filename matched the pointer to the filename in a particular position in the array. An easy fix is to save the filename instead of a pointer to it and then do a strcmp instead of comparing the addresses. (closes issue ASTERISK-18912) Review: https://reviewboard.asterisk.org/r/1596/ ........ Merged revisions 346030 from http://svn.asterisk.org/svn/asterisk/branches/1.8 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@346031 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_musiconhold.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index a857b9ab7f..d5f9e2c6fa 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -163,7 +163,7 @@ struct moh_files_state { int pos; int save_pos; int save_total; - char *save_pos_filename; + char save_pos_filename[PATH_MAX]; }; #define MOH_QUIET (1 << 0) @@ -298,10 +298,10 @@ static int ast_moh_files_next(struct ast_channel *chan) return -1; } - if (state->pos == 0 && state->save_pos_filename == NULL) { + if (state->pos == 0 && ast_strlen_zero(state->save_pos_filename)) { /* First time so lets play the file. */ state->save_pos = -1; - } else if (state->save_pos >= 0 && state->save_pos < state->class->total_files && state->class->filearray[state->save_pos] == state->save_pos_filename) { + } else if (state->save_pos >= 0 && state->save_pos < state->class->total_files && !strcmp(state->class->filearray[state->save_pos], state->save_pos_filename)) { /* If a specific file has been saved confirm it still exists and that it is still valid */ state->pos = state->save_pos; state->save_pos = -1; @@ -338,7 +338,7 @@ static int ast_moh_files_next(struct ast_channel *chan) } /* Record the pointer to the filename for position resuming later */ - state->save_pos_filename = state->class->filearray[state->pos]; + ast_copy_string(state->save_pos_filename, state->class->filearray[state->pos], sizeof(state->save_pos_filename)); ast_debug(1, "%s Opened file %d '%s'\n", chan->name, state->pos, state->class->filearray[state->pos]);