summaryrefslogtreecommitdiff
path: root/libavformat/smoothstreamingenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-08-28 12:34:29 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-08-28 12:34:33 +0200
commit72196a4b8d4bf3fcd273d30334b993dc8b909b22 (patch)
treed3fec7ed9b428b06c6ca3bcbb498250d1749e9fe /libavformat/smoothstreamingenc.c
parent7efa9b1794d27372f714c0aae3111acceae7f33a (diff)
parent310cc4bf82824f09bdd0b9147ed725cdbeaf9bdd (diff)
Merge commit '310cc4bf82824f09bdd0b9147ed725cdbeaf9bdd'
* commit '310cc4bf82824f09bdd0b9147ed725cdbeaf9bdd': smoothstreamingenc: Write to a temp file while updating the manifest Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/smoothstreamingenc.c')
-rw-r--r--libavformat/smoothstreamingenc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index 7163c90c4d..fe6e27f94b 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -210,14 +210,15 @@ static int write_manifest(AVFormatContext *s, int final)
{
SmoothStreamingContext *c = s->priv_data;
AVIOContext *out;
- char filename[1024];
+ char filename[1024], temp_filename[1024];
int ret, i, video_chunks = 0, audio_chunks = 0, video_streams = 0, audio_streams = 0;
int64_t duration = 0;
snprintf(filename, sizeof(filename), "%s/Manifest", s->filename);
- ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL);
+ snprintf(temp_filename, sizeof(temp_filename), "%s/Manifest.tmp", s->filename);
+ ret = avio_open2(&out, temp_filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL);
if (ret < 0) {
- av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", filename);
+ av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", temp_filename);
return ret;
}
avio_printf(out, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
@@ -278,6 +279,7 @@ static int write_manifest(AVFormatContext *s, int final)
avio_printf(out, "</SmoothStreamingMedia>\n");
avio_flush(out);
avio_close(out);
+ rename(temp_filename, filename);
return 0;
}