From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 6C7E145147 for ; Thu, 9 Feb 2023 15:57:35 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9678268BE34; Thu, 9 Feb 2023 17:57:32 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B761C68BA18 for ; Thu, 9 Feb 2023 17:57:26 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 6F0D12404EE for ; Thu, 9 Feb 2023 16:57:26 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id dqd8PHCfCcnX for ; Thu, 9 Feb 2023 16:57:25 +0100 (CET) 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 CA8452404EC for ; Thu, 9 Feb 2023 16:57:25 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 86E713A0101 for ; Thu, 9 Feb 2023 16:57:25 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 9 Feb 2023 16:57:22 +0100 Message-Id: <20230209155722.28285-1-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] fftools/ffmpeg_mux: distinguish between sync queue and muxer EOF 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- How about something like this? --- fftools/ffmpeg_mux.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index dffc1410c8..cf58051949 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -159,14 +159,18 @@ fail: return ret; } -static int sync_queue_process(Muxer *mux, OutputStream *ost, AVPacket *pkt) +static int sync_queue_process(Muxer *mux, OutputStream *ost, AVPacket *pkt, int *stream_eof) { OutputFile *of = &mux->of; if (ost->sq_idx_mux >= 0) { int ret = sq_send(mux->sq_mux, ost->sq_idx_mux, SQPKT(pkt)); - if (ret < 0) + if (ret < 0) { + if (ret == AVERROR_EOF) + *stream_eof = 1; + return ret; + } while (1) { ret = sq_receive(mux->sq_mux, -1, SQPKT(mux->sq_pkt)); @@ -208,7 +212,7 @@ static void *muxer_thread(void *arg) while (1) { OutputStream *ost; - int stream_idx; + int stream_idx, stream_eof = 0; ret = tq_receive(mux->tq, &stream_idx, pkt); if (stream_idx < 0) { @@ -218,9 +222,9 @@ static void *muxer_thread(void *arg) } ost = of->streams[stream_idx]; - ret = sync_queue_process(mux, ost, ret < 0 ? NULL : pkt); + ret = sync_queue_process(mux, ost, ret < 0 ? NULL : pkt, &stream_eof); av_packet_unref(pkt); - if (ret == AVERROR_EOF) + if (ret == AVERROR_EOF && stream_eof) tq_receive_finish(mux->tq, stream_idx); else if (ret < 0) { av_log(mux, AV_LOG_ERROR, "Error muxing a packet\n"); -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".