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/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@346030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Terry Wilson
2011-11-23 16:09:09 +00:00
parent 0cb3847615
commit ac656bc6fe

View File

@@ -162,7 +162,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)
@@ -296,10 +296,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;
@@ -336,7 +336,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]);