diff mbox

[FFmpeg-devel] hlsenc: flush segments to guarantuee atomic single file hls

Message ID 04FE9BEC-B607-4139-B4BD-BABD2392907A@googlemail.com
State New
Headers show

Commit Message

Daniel Oberhoff Sept. 2, 2019, 9:18 a.m. UTC
Hi all,

This makes sure segments published in the playlist of a single file hls recording are actually visible in the filesystem before the playlist entry. Otherwise there is a tiny race condition where a read to a piblished segment may fail.

from c309a535a865be70682885aa3b3bffcede41d85c Mon Sep 17 00:00:00 2001
From: Daniel Oberhoff <daniel@danieloberhoff.de>
Date: Wed, 16 Jan 2019 15:58:52 +0100
Subject: [PATCH] flush segments to guarantuee atomic single file hls

 libavformat/hlsenc.c | 1 +
 1 file changed, 1 insertion(+)

diff mbox


diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index d7a4cd2cc4..b0e0ce2300 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -461,6 +461,7 @@  static int flush_dynbuf(VariantStream *vs, int *range_length)
     *range_length = avio_close_dyn_buf(ctx->pb, &buffer);
     ctx->pb = NULL;
     avio_write(vs->out, buffer, *range_length);
+    avio_flush(vs->out);

     // re-open buffer