[asterisk-commits] mmichelson: trunk r70809 - in /trunk: ./ apps/app_voicemail.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 21 14:54:41 CDT 2007


Author: mmichelson
Date: Thu Jun 21 14:54:40 2007
New Revision: 70809

URL: http://svn.digium.com/view/asterisk?view=rev&rev=70809
Log:
Merged revisions 70808 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r70808 | mmichelson | 2007-06-21 14:49:44 -0500 (Thu, 21 Jun 2007) | 4 lines

When volgain is used don't leave a temporary file behind.
(Closes Issue 8514, Reported and patched by ulogic, code reviewed by Jason Parker)


........

Modified:
    trunk/   (props changed)
    trunk/apps/app_voicemail.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=70809&r1=70808&r2=70809
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Thu Jun 21 14:54:40 2007
@@ -2095,17 +2095,19 @@
 		/* Eww. We want formats to tell us their own MIME type */
 		char *ctype = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-";
 		char tmpdir[256], newtmp[256];
-		int tmpfd;
+		int tmpfd = -1;
 	
-		create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
-		snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
-		tmpfd = mkstemp(newtmp);
-		ast_debug(3, "newtmp: %s\n", newtmp);
 		if (vmu->volgain < -.001 || vmu->volgain > .001) {
-			snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format);
-			ast_safe_system(tmpcmd);
-			attach = newtmp;
-			ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
+			create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
+			snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
+			tmpfd = mkstemp(newtmp);
+			ast_debug(3, "newtmp: %s\n", newtmp);
+			if (tmpfd > -1) {
+				snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format);
+				ast_safe_system(tmpcmd);
+				attach = newtmp;
+				ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
+			}
 		}
 		fprintf(p, "--%s" ENDL, bound);
 		fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum + 1, format);
@@ -2115,9 +2117,11 @@
 		snprintf(fname, sizeof(fname), "%s.%s", attach, format);
 		base_encode(fname, p);
 		fprintf(p, ENDL "--%s--" ENDL "." ENDL, bound);
-		if (tmpfd > -1)
+		if (tmpfd > -1) {
+			unlink(fname);
 			close(tmpfd);
-		unlink(newtmp);
+			unlink(newtmp);
+		}
 	}
 #undef ENDL
 }




More information about the asterisk-commits mailing list