summaryrefslogtreecommitdiff
path: root/apps/app_playback.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2005-03-10 07:47:02 +0000
committerMark Spencer <markster@digium.com>2005-03-10 07:47:02 +0000
commitd18b2f29bf219ab8a9778cfb5e1325d39d75d37e (patch)
treeb6269cd3f158d10211e565d5de62286d3d84dbb7 /apps/app_playback.c
parent3334ab2653bb10d6186687f1d3d8bf83339168e5 (diff)
Allow playback for multiple files (bug #3749)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5157 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_playback.c')
-rwxr-xr-xapps/app_playback.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/apps/app_playback.c b/apps/app_playback.c
index d61ba0e61..7730c93b4 100755
--- a/apps/app_playback.c
+++ b/apps/app_playback.c
@@ -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@linux-support.net>
+ * Mark Spencer <markster@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 @@ static int playback_exec(struct ast_channel *chan, void *data)
{
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 @@ static int playback_exec(struct ast_channel *chan, void *data)
}
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;