From patchwork Thu Jun 16 19:55:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36284 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp1129436pzb; Thu, 16 Jun 2022 13:07:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uXXXzoBzUVS9ueAtVR8dCXNLIcvIQUX76JgzTfvZMqSWqabHVSyr/JI/rzsaVaBvwBBWPi X-Received: by 2002:a05:6402:28b6:b0:433:2b53:157a with SMTP id eg54-20020a05640228b600b004332b53157amr8783476edb.395.1655410078634; Thu, 16 Jun 2022 13:07:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655410078; cv=none; d=google.com; s=arc-20160816; b=wS/DYqXaglclsUd5xXcB+bQmT+CcICNIBEz8ZA8l5gAfaQoY3jw9f9xbevfJljGib6 jyzmVry7xsu+akB42x293Z3S4dASMSMY1pPX5jzuMfF33R85LGN1ZSfw8XzBxXLFPca4 q+BD2sHh86A+gRaThD7FuSLurXUqLimHCGqVYLoChOSCaXbGHHTFwD+VAAENxZ8F0ICP TVrpGTVEhoCyYFGFLTEbcgVstkiA+Mzj7k3F5QErippN02czHVV7Hq4DGT5z2Bw0h5IB onNd2fHW3lq797YWqI+OM/7ilqEJpLb7ZJA9shsXsmM9R53tQ7gcmFncuNc/v/zZlCyo /Shw== 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:references:in-reply-to:message-id :date:to:from:delivered-to; bh=SE6INjYHNkvb2vNUdx5Gka6/vSnk+3CFBwdgCkBqyfY=; b=CIF6moyaXLh0M9qjxaAvY0PpdaNLVK8I8Rzy/OkX9A5tB15KOJrgj66YUKBYtxgOsK Hr3ux+5q+sBJj6tzDA0RnYioKUCZoy1mZ/NYCCv17B9KCkj2a1uMRN+JoobgW/XNt38A 5mP5c9kw2poaSUyISQxGn2bjEdz/uYj687Hlj7y3n2vOaO0hV1ls7cJ2aehUUw7a7jad MxGJH0WPqKu7xaThA7lOwSX0KkBiLqMPtcwJq8g5uYwXgh0umIm1Dj8pvSRL8+NbAXjU UeahmzxLeMpmFE8RO2xhy6LMQlMr/dUYE4Y77N8itIPAi93Fyt3xNiHrugQUvP6XnSWp qD5w== 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 js22-20020a17090797d600b00718c84e45d4si3005258ejc.794.2022.06.16.13.07.58; Thu, 16 Jun 2022 13:07:58 -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 5122E68B8DE; Thu, 16 Jun 2022 23:04:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D684368B881 for ; Thu, 16 Jun 2022 23:03:48 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9B8C0240175 for ; Thu, 16 Jun 2022 22:03:48 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id CFrCwSGy87G5 for ; Thu, 16 Jun 2022 22:03:48 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 5DB5824068C for ; Thu, 16 Jun 2022 22:03:34 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 0BC973A21CE; Thu, 16 Jun 2022 22:03:31 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Jun 2022 21:55:29 +0200 Message-Id: <20220616195534.5278-30-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220616195534.5278-1-anton@khirnov.net> References: <20220616195534.5278-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 30/35] fftools/ffmpeg_mux: return errors from write_packet() 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: oN2Ia9kx7LU/ Do not call exit_program(), as that would conflict with moving this code into a separate thread. --- fftools/ffmpeg_mux.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 98d3adaeac..cf24ae7700 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -116,7 +116,7 @@ static int queue_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) return 0; } -static void write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) +static int write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) { MuxStream *ms = &of->mux->streams[ost->index]; AVFormatContext *s = of->mux->fc; @@ -161,10 +161,8 @@ static void write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) av_log(s, loglevel, "Non-monotonous DTS in output stream " "%d:%d; previous: %"PRId64", current: %"PRId64"; ", ost->file_index, ost->st->index, ms->last_mux_dts, pkt->dts); - if (exit_on_error) { - av_log(NULL, AV_LOG_FATAL, "aborting.\n"); - exit_program(1); - } + if (exit_on_error) + return AVERROR(EINVAL); av_log(s, loglevel, "changing to %"PRId64". This may result " "in incorrect timestamps in the output file.\n", max); @@ -197,7 +195,10 @@ static void write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) print_error("av_interleaved_write_frame()", ret); main_return_code = 1; close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED); + return ret; } + + return 0; } static int submit_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) @@ -221,14 +222,16 @@ static int submit_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) else if (ret < 0) return ret; - write_packet(of, output_streams[of->ost_index + ret], - of->mux->sq_pkt); + ret = write_packet(of, output_streams[of->ost_index + ret], + of->mux->sq_pkt); + if (ret < 0) + return ret; } } else { if (pkt) - write_packet(of, ost, pkt); - else - ost->finished |= MUXER_FINISHED; + return write_packet(of, ost, pkt); + + ost->finished |= MUXER_FINISHED; } return 0;