From patchwork Mon May 27 15:22:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 49297 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:542:0:b0:460:55fa:d5ed with SMTP id 63csp3337427vqf; Mon, 27 May 2024 08:22:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU3BPFTA4L4SQEjbc1XwYRFgfNgpVV22TfLIe+7Ati0qG8Ng+5g4TiP/wiZSlCI1OiDQmEpaeHJ2Aqj2ELkXVPcFyNTmzs1TBpqAA== X-Google-Smtp-Source: AGHT+IHZCgnP8NWTxmQBwdRLgR2asL+rm3ghPB05ADhhdR/lFw4CQyOmSQkkYHSlgIyNv94X6pAp X-Received: by 2002:a50:aa94:0:b0:579:b6d:b8ba with SMTP id 4fb4d7f45d1cf-5790b6db91fmr4718870a12.22.1716823347408; Mon, 27 May 2024 08:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716823347; cv=none; d=google.com; s=arc-20160816; b=sQGIhW1bo645B2gz+BLaF8TbMoU25qZSmRHKntj+EoODUH3AE6czNyVYdDrybDixla /az2mu9S/gV9uHHyDxJ26nzNjxiWG9mDah4Y3bDuMxB/WFqbbgclK3LNdl9k4e/B1eTd +TRGTvTQ2mNC+vRshbdOeKdFHL84lfTIA3Zo490tRXDaWjdu4PjXRAm2ZAI0syDvzxBm oKCZ3UvMKK5v+D/oAu6CCl5PpHTWxKCsF/8g2V/usMwD8H9ByswcH4h87kBVzyK47Vx/ uH/Uw55GcsOKTIR9Qq4u70C9/DG1IH4aBbe9aybZ9OTqNOw5+0B1rVAr5Au0raCnqO9X iElQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=5oRoHZgF6+1aHG9r0t4YFrca1WYzLbEyNH61udOuWBM=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=wYTgDE+6RH9uSd3L3W1oLYYN+IBDc4fuuna+/jABEg/o5zTezuKDH2Wa93TA8U+PUO ZHTF0mUF6wgZRSESzqIPcoid60R4xMuZIGxWDi9+n9UQbl7Zk0Vp1EL02ypZGKd6DxT5 zi25nYsa3jJVC9M2tZkMgStFSybSMXYUZRsUSGIfpk3rQi1vDxHXYdlmioy8lQ6GVaeA sl1Ru2M17auJ3tJGUSISP1WujqbYdiLrtOluHCMvl7JkI3NBrLvWH0ZyAkBwkF9bxkSc ZZ7qkP+1ikxaiVfvk2UFKb5WStGbUFE29cT8O3cH/tZxPL1RmgnbpsMl6Oe8cWOcwrjP 7Klg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-5786242d5besi3432817a12.76.2024.05.27.08.22.26; Mon, 27 May 2024 08:22:27 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AFBB468D4E4; Mon, 27 May 2024 18:22:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BFB3D68D403 for ; Mon, 27 May 2024 18:22:14 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id EDD61C0069 for ; Mon, 27 May 2024 18:22:13 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 27 May 2024 18:22:13 +0300 Message-ID: <20240527152213.259504-1-remi@remlab.net> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] Revert "avformat/file: seek back to initial position for fd protocol" X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: AjLWAhQGjHxT The generally expected behaviour is for software to append from the current position, not to keep resetting. See also how shell works: # (foo && bar) > file ...would normally concatenate the output of both commands to file. If foo seeks like lavf, bar would instead overwrite the output of foo (possibly not completely). This reverts commit 5c3d2177e7be7dde69a83b1b394f57976c164c84. --- libavformat/file.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/libavformat/file.c b/libavformat/file.c index 0ed4cff266..3fc1e741f2 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -99,7 +99,6 @@ typedef struct FileContext { #if HAVE_DIRENT_H DIR *dir; #endif - int64_t initial_pos; } FileContext; static const AVOption file_options[] = { @@ -220,12 +219,7 @@ static int fd_dup(URLContext *h, int oldfd) static int file_close(URLContext *h) { FileContext *c = h->priv_data; - int ret; - - if (c->initial_pos >= 0 && !h->is_streamed) - lseek(c->fd, c->initial_pos, SEEK_SET); - - ret = close(c->fd); + int ret = close(c->fd); return (ret == -1) ? AVERROR(errno) : 0; } @@ -293,7 +287,6 @@ static int file_open(URLContext *h, const char *filename, int flags) av_strstart(filename, "file:", &filename); - c->initial_pos = -1; if (flags & AVIO_FLAG_WRITE && flags & AVIO_FLAG_READ) { access = O_CREAT | O_RDWR; if (c->trunc) @@ -505,11 +498,6 @@ static int fd_open(URLContext *h, const char *filename, int flags) if (c->fd == -1) return AVERROR(errno); - if (h->is_streamed) - c->initial_pos = -1; - else - c->initial_pos = lseek(c->fd, 0, SEEK_CUR); - return 0; }