This commit adds support for IO synchronization API to the file backend. --- libavformat/file.c | 11 +++++++++++ libavformat/os_support.h | 2 ++ 2 files changed, 13 insertions(+)
diff --git a/libavformat/file.c b/libavformat/file.c index 1d321c4205..58fd55b928 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -254,6 +254,16 @@ 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; + if (fsync(c->fd) < 0) + return AVERROR(errno); + } + return 0; +} + static int file_close(URLContext *h) { FileContext *c = h->priv_data; @@ -353,6 +363,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..1864763cb1 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(fd) _commit((fd)) #endif #if CONFIG_NETWORK -- 2.19.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel