Commit da97e4c6 authored by Hendrik Leppkes's avatar Hendrik Leppkes Committed by Michael Niedermayer

hlsenc: write playlist into a temp file and replace the original atomically

Reviewed-by: 's avatarLukasz Marek <lukasz.m.luki2@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 0d6ae067
......@@ -242,10 +242,12 @@ static int hls_window(AVFormatContext *s, int last)
int target_duration = 0;
int ret = 0;
AVIOContext *out = NULL;
char temp_filename[1024];
int64_t sequence = FFMAX(hls->start_sequence, hls->sequence - hls->nb_entries);
int version = hls->flags & HLS_SINGLE_FILE ? 4 : 3;
if ((ret = avio_open2(&out, s->filename, AVIO_FLAG_WRITE,
snprintf(temp_filename, sizeof(temp_filename), "%s.tmp", s->filename);
if ((ret = avio_open2(&out, temp_filename, AVIO_FLAG_WRITE,
&s->interrupt_callback, NULL)) < 0)
goto fail;
......@@ -280,6 +282,8 @@ static int hls_window(AVFormatContext *s, int last)
fail:
avio_closep(&out);
if (ret >= 0)
ff_rename(temp_filename, s->filename, s);
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment