From patchwork Tue Dec 4 11:44:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Semashev X-Patchwork-Id: 11270 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 0D18044D491 for ; Tue, 4 Dec 2018 13:44:34 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AE9EB68A580; Tue, 4 Dec 2018 13:44:25 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F081468A3B2 for ; Tue, 4 Dec 2018 13:44:18 +0200 (EET) Received: by mail-lf1-f67.google.com with SMTP id e26so11721238lfc.2 for ; Tue, 04 Dec 2018 03:44:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qhenZfzT3lRzzGfUONGe6vxAO3OisOjzVLIdNp3ECWk=; b=dkKhrUI7OSAEH2njXhpZBXav4T2WVm06aDiO/2JknjPKdqHzLS0OwdUslsBQOOYljV n6toX60CIUg2m4qPLStCmr+lpf7Gv65LUNGRC/bLEg+y+mSsNkqge5lFGn3ozpU1dlAQ T1PtyUa6/4cgb197HyzNqKfKvt5szovLzqMv3gEwDnuOurD/BTWBzwVn4eFm2KR4P5Kc GCGFjcY7yeECEpmMnHQgPVR5pDFz0e2uvWdFbvRI8Ux6ZaT20qNVm2QGpGcKtwy5xfui dLbwRrYzsvhjyFP6FlatF6DViuOnWE62HasTS9lQsB40vir02rnWxS8Js1kPGlflheOl nkEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qhenZfzT3lRzzGfUONGe6vxAO3OisOjzVLIdNp3ECWk=; b=MB3OCTs7vhc/M2Ss/vLzogXotPFQdN40MFS5Iw0jlm9FQtwNK8yrxHj2c2Be/Y2yKq 2ftS4ITm1W1KNMHpd8L1z+9juka9z89bNKsUjbKTBTnbLDMAfo7eK5B8E6hhXrlllprc WznDh5cXmAWn/kQ78h/Rlvi+Z2mOWsdXifrrzIzyLphCPCJ1aEYbi2jcbpBrPTe1YD9D V0WbmKAuGITou+hza/m0SBWy/nSVUIoPkk29kYY3UVCFcTWxZLuF111TCNHPwkvPwGcN ES9e2GOSOo6VxElM3qPk+0qCFtJtSC/UsDv0l/DiilPSbEbZEr1RANeWLMHLHatNYArV bQZg== X-Gm-Message-State: AA+aEWZETbZw9wXwuabBnFwt4LlRsKLkgLNt41ELY7JdgdKylDqp0Y8u NzQaiT889oY0Ow3V7wZ1tUQuBhr44SU= X-Google-Smtp-Source: AFSGD/XHRhBr1g5fD6UaA20xOeq3L/B6Mdh6SiYkbQcddqXF9eGp50iuQWg13BgyCV3hcIxF6o4m/w== X-Received: by 2002:a19:d857:: with SMTP id p84mr11215551lfg.44.1543923866484; Tue, 04 Dec 2018 03:44:26 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-31-10.ip.moscow.rt.ru. [37.110.31.10]) by smtp.gmail.com with ESMTPSA id f8sm2953009lfb.2.2018.12.04.03.44.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 03:44:25 -0800 (PST) From: Andrey Semashev To: ffmpeg-devel@ffmpeg.org Date: Tue, 4 Dec 2018 14:44:07 +0300 Message-Id: <20181204114406.25933-2-andrey.semashev@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181204114406.25933-1-andrey.semashev@gmail.com> References: <20181204114406.25933-1-andrey.semashev@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/2] lavf/file: Add support for file syncing. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andrey Semashev Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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