[asterisk-commits] diruggles: trunk r240969 - /trunk/apps/app_externalivr.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jan 18 11:41:51 CST 2010
Author: diruggles
Date: Mon Jan 18 11:41:44 2010
New Revision: 240969
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=240969
Log:
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/
Modified:
trunk/apps/app_externalivr.c
Modified: trunk/apps/app_externalivr.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_externalivr.c?view=diff&rev=240969&r1=240968&r2=240969
==============================================================================
--- trunk/apps/app_externalivr.c (original)
+++ trunk/apps/app_externalivr.c Mon Jan 18 11:41:44 2010
@@ -205,7 +205,7 @@
gen_closestream(state);
while (!state->stream) {
- state->current = AST_LIST_REMOVE_HEAD(&u->playlist, list);
+ state->current = AST_LIST_FIRST(&u->playlist);
if (state->current) {
file_to_stream = state->current->filename;
} else {
@@ -215,6 +215,9 @@
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_LIST_LOCK(&u->playlist);
+ AST_LIST_REMOVE_HEAD(&u->playlist, list);
+ AST_LIST_UNLOCK(&u->playlist);
if (!u->playing_silence) {
continue;
} else {
@@ -241,6 +244,11 @@
if (!(state->stream && (f = ast_readframe(state->stream)))) {
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_INSERT_TAIL(&u->finishlist, state->current, list);
AST_LIST_UNLOCK(&u->finishlist);
@@ -642,8 +650,12 @@
if (f->frametype == AST_FRAME_DTMF) {
send_eivr_event(eivr_events, f->subclass.integer, NULL, chan);
if (u->option_autoclear) {
- if (!u->abort_current_sound && !u->playing_silence)
- send_eivr_event(eivr_events, 'T', NULL, chan);
+ 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);
+ }
AST_LIST_LOCK(&u->playlist);
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'D', entry->filename, chan);
@@ -673,8 +685,8 @@
if (!fgets(input, sizeof(input), eivr_commands))
continue;
-
- ast_verb(4, "got command '%s'\n", ast_strip(input));
+ ast_strip(input);
+ ast_verb(4, "got command '%s'\n", input);
if (strlen(input) < 4) {
continue;
@@ -715,20 +727,26 @@
ast_chan_log(LOG_WARNING, chan, "Unknown file requested '%s'\n", &input[2]);
send_eivr_event(eivr_events, 'Z', &input[2], chan);
} else {
- if (!u->abort_current_sound && !u->playing_silence)
- send_eivr_event(eivr_events, 'T', NULL, chan);
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))) {
send_eivr_event(eivr_events, 'D', entry->filename, chan);
ast_free(entry);
}
- }
- if (!u->playing_silence)
- u->abort_current_sound = 1;
- entry = make_entry(&input[2]);
- if (entry)
- AST_LIST_INSERT_TAIL(&u->playlist, entry, list);
- AST_LIST_UNLOCK(&u->playlist);
+ if (!u->playing_silence) {
+ u->abort_current_sound = 1;
+ }
+ entry = make_entry(&input[2]);
+ if (entry) {
+ AST_LIST_INSERT_TAIL(&u->playlist, entry, list);
+ }
+ AST_LIST_UNLOCK(&u->playlist);
+ }
} else if (input[0] == EIVR_CMD_APND) {
if (chan->_state != AST_STATE_UP || ast_check_hangup(chan)) {
ast_chan_log(LOG_WARNING, chan, "Queue 'A'ppend called on unanswered channel\n");
More information about the asterisk-commits
mailing list