aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-21 19:49:44 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-21 19:49:44 +0000
commit6e6b06f15f096df88f847e1c7446b571b156eb6d (patch)
tree43658856ffa988cdfed5e3419ffa21b87ee880bb /apps
parent9d2f9edaa4a2432fcfe577ce634a605903f5a3d5 (diff)
When volgain is used don't leave a temporary file behind.
(Closes Issue 8514, Reported and patched by ulogic, code reviewed by Jason Parker) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@70808 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_voicemail.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 803e9ee6c..3e5979e5c 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -1964,19 +1964,21 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
/* 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);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "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;
+ create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
+ snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
+ tmpfd = mkstemp(newtmp);
if (option_debug > 2)
- ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
+ ast_log(LOG_DEBUG, "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;
+ if (option_debug > 2)
+ ast_log(LOG_DEBUG, "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);
@@ -1986,9 +1988,11 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
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
}