mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2025-02-13 08:45:02 +00:00
hlsenc: write playlist into a temp file and replace the original atomically
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
ff48ae94f9
commit
3fe26bb608
@ -134,9 +134,11 @@ static int hls_window(AVFormatContext *s, int last)
|
|||||||
int target_duration = 0;
|
int target_duration = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
AVIOContext *out = NULL;
|
AVIOContext *out = NULL;
|
||||||
|
char temp_filename[1024];
|
||||||
int64_t sequence = FFMAX(hls->start_sequence, hls->sequence - hls->size);
|
int64_t sequence = FFMAX(hls->start_sequence, hls->sequence - hls->size);
|
||||||
|
|
||||||
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)
|
&s->interrupt_callback, NULL)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
@ -168,6 +170,8 @@ static int hls_window(AVFormatContext *s, int last)
|
|||||||
|
|
||||||
fail:
|
fail:
|
||||||
avio_closep(&out);
|
avio_closep(&out);
|
||||||
|
if (ret >= 0)
|
||||||
|
ff_rename(temp_filename, s->filename);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user