Add notification of interrupted file

Add file information to data element of T event so
the file information is sent to the client when it is
interrupted. Previously only notification of pending
files that were dropped was sent

(closes issue #16147)
Reported by: thedavidfactor
Tested by: thedavidfactor

Review: https://reviewboard.asterisk.org/r/449/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@240969 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
David Ruggles
2010-01-18 17:41:44 +00:00
parent 5a1c9f1283
commit 174cd3c65c

View File

@@ -205,7 +205,7 @@ static int gen_nextfile(struct gen_state *state)
gen_closestream(state); gen_closestream(state);
while (!state->stream) { while (!state->stream) {
state->current = AST_LIST_REMOVE_HEAD(&u->playlist, list); state->current = AST_LIST_FIRST(&u->playlist);
if (state->current) { if (state->current) {
file_to_stream = state->current->filename; file_to_stream = state->current->filename;
} else { } else {
@@ -215,6 +215,9 @@ static int gen_nextfile(struct gen_state *state)
if (!(state->stream = ast_openstream_full(u->chan, file_to_stream, u->chan->language, 1))) { if (!(state->stream = ast_openstream_full(u->chan, file_to_stream, u->chan->language, 1))) {
ast_chan_log(LOG_WARNING, u->chan, "File '%s' could not be opened: %s\n", file_to_stream, strerror(errno)); ast_chan_log(LOG_WARNING, u->chan, "File '%s' could not be opened: %s\n", file_to_stream, strerror(errno));
AST_LIST_LOCK(&u->playlist);
AST_LIST_REMOVE_HEAD(&u->playlist, list);
AST_LIST_UNLOCK(&u->playlist);
if (!u->playing_silence) { if (!u->playing_silence) {
continue; continue;
} else { } else {
@@ -241,6 +244,11 @@ static struct ast_frame *gen_readframe(struct gen_state *state)
if (!(state->stream && (f = ast_readframe(state->stream)))) { if (!(state->stream && (f = ast_readframe(state->stream)))) {
if (state->current) { if (state->current) {
/* remove finished file from playlist */
AST_LIST_LOCK(&u->playlist);
AST_LIST_REMOVE_HEAD(&u->playlist, list);
AST_LIST_UNLOCK(&u->playlist);
/* add finished file to finishlist */
AST_LIST_LOCK(&u->finishlist); AST_LIST_LOCK(&u->finishlist);
AST_LIST_INSERT_TAIL(&u->finishlist, state->current, list); AST_LIST_INSERT_TAIL(&u->finishlist, state->current, list);
AST_LIST_UNLOCK(&u->finishlist); AST_LIST_UNLOCK(&u->finishlist);
@@ -642,8 +650,12 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
if (f->frametype == AST_FRAME_DTMF) { if (f->frametype == AST_FRAME_DTMF) {
send_eivr_event(eivr_events, f->subclass.integer, NULL, chan); send_eivr_event(eivr_events, f->subclass.integer, NULL, chan);
if (u->option_autoclear) { if (u->option_autoclear) {
if (!u->abort_current_sound && !u->playing_silence) if (!u->abort_current_sound && !u->playing_silence) {
send_eivr_event(eivr_events, 'T', NULL, chan); /* send interrupted file as T data */
entry = AST_LIST_REMOVE_HEAD(&u->playlist, list);
send_eivr_event(eivr_events, 'T', entry->filename, chan);
ast_free(entry);
}
AST_LIST_LOCK(&u->playlist); AST_LIST_LOCK(&u->playlist);
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'D', entry->filename, chan); send_eivr_event(eivr_events, 'D', entry->filename, chan);
@@ -673,8 +685,8 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
if (!fgets(input, sizeof(input), eivr_commands)) if (!fgets(input, sizeof(input), eivr_commands))
continue; continue;
ast_strip(input);
ast_verb(4, "got command '%s'\n", ast_strip(input)); ast_verb(4, "got command '%s'\n", input);
if (strlen(input) < 4) { if (strlen(input) < 4) {
continue; continue;
@@ -715,20 +727,26 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]); ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]);
send_eivr_event(eivr_events, 'Z', &input[2], chan); send_eivr_event(eivr_events, 'Z', &input[2], chan);
} else { } else {
if (!u->abort_current_sound && !u->playing_silence)
send_eivr_event(eivr_events, 'T', NULL, chan);
AST_LIST_LOCK(&u->playlist); AST_LIST_LOCK(&u->playlist);
if (!u->abort_current_sound && !u->playing_silence) {
/* send interrupted file as T data */
entry = AST_LIST_REMOVE_HEAD(&u->playlist, list);
send_eivr_event(eivr_events, 'T', entry->filename, chan);
ast_free(entry);
}
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) { while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'D', entry->filename, chan); send_eivr_event(eivr_events, 'D', entry->filename, chan);
ast_free(entry); ast_free(entry);
} }
} if (!u->playing_silence) {
if (!u->playing_silence) u->abort_current_sound = 1;
u->abort_current_sound = 1; }
entry = make_entry(&input[2]); entry = make_entry(&input[2]);
if (entry) if (entry) {
AST_LIST_INSERT_TAIL(&u->playlist, entry, list); AST_LIST_INSERT_TAIL(&u->playlist, entry, list);
AST_LIST_UNLOCK(&u->playlist); }
AST_LIST_UNLOCK(&u->playlist);
}
} else if (input[0] == EIVR_CMD_APND) { } else if (input[0] == EIVR_CMD_APND) {
if (chan->_state != AST_STATE_UP || ast_check_hangup(chan)) { if (chan->_state != AST_STATE_UP || ast_check_hangup(chan)) {
ast_chan_log(LOG_WARNING, chan, "Queue 'A'ppend called on unanswered channel\n"); ast_chan_log(LOG_WARNING, chan, "Queue 'A'ppend called on unanswered channel\n");