[Asterisk-cvs] asterisk/apps app_playback.c,1.15,1.16
markster at lists.digium.com
markster at lists.digium.com
Thu Mar 10 01:50:39 CST 2005
Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv4148/apps
Modified Files:
app_playback.c
Log Message:
Allow playback for multiple files (bug #3749)
Index: app_playback.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_playback.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- app_playback.c 26 Oct 2004 02:25:50 -0000 1.15
+++ app_playback.c 10 Mar 2005 07:47:02 -0000 1.16
@@ -3,9 +3,9 @@
*
* Trivial application to playback a sound file
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2005, Mark Spencer
*
- * Mark Spencer <markster at linux-support.net>
+ * Mark Spencer <markster at digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -22,14 +22,14 @@
#include <string.h>
#include <stdlib.h>
-static char *tdesc = "Trivial Playback Application";
+static char *tdesc = "Sound File Playback Application";
static char *app = "Playback";
static char *synopsis = "Play a file";
static char *descrip =
-" Playback(filename[|option]): Plays back a given filename (do not put\n"
+" Playback(filename[&filename2...][|option]): Plays back given filenames (do not put\n"
"extension). Options may also be included following a pipe symbol. The 'skip'\n"
"option causes the playback of the message to be skipped if the channel\n"
"is not in the 'up' state (i.e. it hasn't been answered yet. If 'skip' is \n"
@@ -47,17 +47,17 @@
{
int res = 0;
struct localuser *u;
- char tmp[256];
- char *options;
+ char *tmp = NULL;
+ char *options = NULL;
int option_skip=0;
int option_noanswer = 0;
- char *stringp;
- if (!data || ast_strlen_zero((char *)data)) {
+ char *stringp = NULL;
+ char *front = NULL, *back = NULL;
+ if (!data || ast_strlen_zero((char *)data) || !(tmp = ast_strdupa(data))) {
ast_log(LOG_WARNING, "Playback requires an argument (filename)\n");
return -1;
}
- strncpy(tmp, (char *)data, sizeof(tmp)-1);
- stringp=tmp;
+ stringp = tmp;
strsep(&stringp, "|");
options = strsep(&stringp, "|");
if (options && !strcasecmp(options, "skip"))
@@ -76,16 +76,24 @@
}
if (!res) {
ast_stopstream(chan);
- res = ast_streamfile(chan, tmp, chan->language);
- if (!res)
- res = ast_waitstream(chan, "");
- else {
- ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char *)data);
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
- chan->priority+=100;
- res = 0;
+ front = tmp;
+ while (!res && front) {
+ if ((back = strchr(front, '&'))) {
+ *back = '\0';
+ back++;
+ }
+ res = ast_streamfile(chan, front, chan->language);
+ if (!res) {
+ res = ast_waitstream(chan, "");
+ ast_stopstream(chan);
+ } else {
+ ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char *)data);
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
+ chan->priority+=100;
+ res = 0;
+ }
+ front = back;
}
- ast_stopstream(chan);
}
LOCAL_USER_REMOVE(u);
return res;
More information about the svn-commits
mailing list