Index: asterisk/apps/app_externalivr.c =================================================================== --- asterisk/apps/app_externalivr.c (revision 226308) +++ asterisk/apps/app_externalivr.c (working copy) @@ -115,6 +115,7 @@ struct ivr_localuser { struct ast_channel *chan; AST_LIST_HEAD(playlist, playlist_entry) playlist; + AST_LIST_HEAD(playinglist, playlist_entry) playinglist; AST_LIST_HEAD(finishlist, playlist_entry) finishlist; int abort_current_sound; int playing_silence; @@ -194,6 +195,7 @@ while (!state->stream) { state->current = AST_LIST_REMOVE_HEAD(&u->playlist, list); if (state->current) { + AST_LIST_INSERT_TAIL(&u->playinglist, state->current, list); file_to_stream = state->current->filename; } else { file_to_stream = "silence/10"; @@ -217,6 +219,7 @@ { struct ast_frame *f = NULL; struct ivr_localuser *u = state->u; + struct playlist_entry *entry; if (u->abort_current_sound || (u->playing_silence && AST_LIST_FIRST(&u->playlist))) { @@ -231,6 +234,11 @@ AST_LIST_LOCK(&u->finishlist); AST_LIST_INSERT_TAIL(&u->finishlist, state->current, list); AST_LIST_UNLOCK(&u->finishlist); + AST_LIST_LOCK(&u->playinglist); + while ((entry = AST_LIST_REMOVE_HEAD(&u->playinglist, list))) { + ast_free(entry); + } + AST_LIST_UNLOCK(&u->playinglist); state->current = NULL; } if (!gen_nextfile(state)) @@ -631,6 +639,12 @@ if (u->option_autoclear) { if (!u->abort_current_sound && !u->playing_silence) send_eivr_event(eivr_events, 'T', NULL, chan); + AST_LIST_LOCK(&u->playinglist); + while ((entry = AST_LIST_REMOVE_HEAD(&u->playinglist, list))) { + send_eivr_event(eivr_events, 'D', entry->filename, chan); + ast_free(entry); + } + AST_LIST_UNLOCK(&u->playinglist); AST_LIST_LOCK(&u->playlist); while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { send_eivr_event(eivr_events, 'D', entry->filename, chan);