On 12/3/18 3:46 PM, Nicolas George wrote:
Andrey Semashev (2018-12-03):
This commit adds support for IO synchronization API to the file backend.
---
  libavformat/file.c       | 10 ++++++++++
  libavformat/os_support.h |  2 ++
  2 files changed, 12 insertions(+)

diff --git a/libavformat/file.c b/libavformat/file.c
index 1d321c4205..9765fd76c7 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -254,6 +254,15 @@ static int64_t file_seek(URLContext *h, int64_t pos, int 
whence)
      return ret < 0 ? AVERROR(errno) : ret;
  }
+static int file_sync(URLContext *h)
+{
+    if (h->flags & AVIO_FLAG_WRITE) {
+        FileContext *c = h->priv_data;

+        return fsync(c->fd);

In case of error, it needs to convert errno to an AVERROR code.

+    }
+    return 0;
+}
+
  static int file_close(URLContext *h)
  {
      FileContext *c = h->priv_data;
@@ -353,6 +362,7 @@ const URLProtocol ff_file_protocol = {
      .url_close           = file_close,
      .url_get_file_handle = file_get_handle,
      .url_check           = file_check,
+    .url_sync            = file_sync,
      .url_delete          = file_delete,
      .url_move            = file_move,
      .priv_data_size      = sizeof(FileContext),
diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 7a56dc9a7c..fcbdc884ba 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -93,6 +93,8 @@ static inline int is_dos_path(const char *path)
  #ifndef S_IWUSR
  #define S_IWUSR S_IWRITE
  #endif
+

+#define fsync _commit

Defining with the arguments would be more robust. A few occasions in the
same file do not do that, they should.

  #endif
#if CONFIG_NETWORK

Agreed to both comments.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to