[asterisk-commits] trunk - r7864 /trunk/apps/app_playback.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Jan 7 18:08:50 CST 2006


Author: markster
Date: Sat Jan  7 18:08:49 2006
New Revision: 7864

URL: http://svn.digium.com/view/asterisk?rev=7864&view=rev
Log:
Merge playback cleanups (bug #6163)

Modified:
    trunk/apps/app_playback.c

Modified: trunk/apps/app_playback.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_playback.c?rev=7864&r1=7863&r2=7864&view=diff
==============================================================================
--- trunk/apps/app_playback.c (original)
+++ trunk/apps/app_playback.c Sat Jan  7 18:08:49 2006
@@ -72,13 +72,13 @@
 
 static int playback_exec(struct ast_channel *chan, void *data)
 {
-	int res = 0, mres = 0;
+	int res = 0;
 	struct localuser *u;
-	char *tmp = NULL;
+	char *tmp;
 	int option_skip=0;
 	int option_noanswer = 0;
-	char *front = NULL, *back = NULL;
 	int priority_jump = 0;
+
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(filenames);
 		AST_APP_ARG(options);
@@ -89,15 +89,13 @@
 		return -1;
 	}
 
-	LOCAL_USER_ADD(u);
-
 	tmp = ast_strdupa(data);
 	if (!tmp) {
 		ast_log(LOG_ERROR, "Out of memory!\n");
-		LOCAL_USER_REMOVE(u);
 		return -1;	
 	}
 
+	LOCAL_USER_ADD(u);
 	AST_STANDARD_APP_ARGS(args, tmp);
 
 	if (args.options) {
@@ -119,13 +117,11 @@
 			res = ast_answer(chan);
 	}
 	if (!res) {
+		int mres = 0;
+		char *front;
+
 		ast_stopstream(chan);
-		front = tmp;
-		while (!res && front) {
-			if ((back = strchr(front, '&'))) {
-				*back = '\0';
-				back++;
-			}
+		while (!res && (front = strsep(&tmp, "&"))) {
 			res = ast_streamfile(chan, front, chan->language);
 			if (!res) { 
 				res = ast_waitstream(chan, "");	
@@ -137,12 +133,8 @@
 				res = 0;
 				mres = 1;
 			}
-			front = back;
 		}
-		if (mres)
-			pbx_builtin_setvar_helper(chan, "PLAYBACKSTATUS", "FAILED");
-		else
-			pbx_builtin_setvar_helper(chan, "PLAYBACKSTATUS", "SUCCESS");
+		pbx_builtin_setvar_helper(chan, "PLAYBACKSTATUS", mres ? "FAILED" : "SUCCESS");
 	}
 	LOCAL_USER_REMOVE(u);
 	return res;



More information about the asterisk-commits mailing list