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 5A16342B48 for ; Tue, 11 Jan 2022 20:54:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6851568AEEC; Tue, 11 Jan 2022 22:54:53 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D36CD68A441 for ; Tue, 11 Jan 2022 22:54:47 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5EBA2240507 for ; Tue, 11 Jan 2022 21:54:47 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 1Tqcvph9RyLi for ; Tue, 11 Jan 2022 21:54:46 +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 C810024017E for ; Tue, 11 Jan 2022 21:54:46 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 74EBB3A0F66; Tue, 11 Jan 2022 21:47:25 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Jan 2022 21:46:09 +0100 Message-Id: <20220111204610.14262-34-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220111204610.14262-1-anton@khirnov.net> References: <20220111204610.14262-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 34/35] ffplay: switch to new FIFO API 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: --- fftools/ffplay.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index e7b20be76b..4bef9a6ecc 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -424,19 +424,18 @@ int64_t get_valid_channel_layout(int64_t channel_layout, int channels) static int packet_queue_put_private(PacketQueue *q, AVPacket *pkt) { MyAVPacketList pkt1; + int ret; if (q->abort_request) return -1; - if (av_fifo_space(q->pkt_list) < sizeof(pkt1)) { - if (av_fifo_grow(q->pkt_list, sizeof(pkt1)) < 0) - return -1; - } pkt1.pkt = pkt; pkt1.serial = q->serial; - av_fifo_generic_write(q->pkt_list, &pkt1, sizeof(pkt1), NULL); + ret = av_fifo_write(q->pkt_list, &pkt1, 1); + if (ret < 0) + return ret; q->nb_packets++; q->size += pkt1.pkt->size + sizeof(pkt1); q->duration += pkt1.pkt->duration; @@ -477,7 +476,7 @@ static int packet_queue_put_nullpacket(PacketQueue *q, AVPacket *pkt, int stream static int packet_queue_init(PacketQueue *q) { memset(q, 0, sizeof(PacketQueue)); - q->pkt_list = av_fifo_alloc(sizeof(MyAVPacketList)); + q->pkt_list = av_fifo_alloc2(1, sizeof(MyAVPacketList), AV_FIFO_FLAG_AUTO_GROW); if (!q->pkt_list) return AVERROR(ENOMEM); q->mutex = SDL_CreateMutex(); @@ -499,8 +498,8 @@ static void packet_queue_flush(PacketQueue *q) MyAVPacketList pkt1; SDL_LockMutex(q->mutex); - while (av_fifo_size(q->pkt_list) >= sizeof(pkt1)) { - av_fifo_generic_read(q->pkt_list, &pkt1, sizeof(pkt1), NULL); + while (av_fifo_can_read(q->pkt_list)) { + av_fifo_read(q->pkt_list, &pkt1, 1); av_packet_free(&pkt1.pkt); } q->nb_packets = 0; @@ -551,8 +550,8 @@ static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block, int *seria break; } - if (av_fifo_size(q->pkt_list) >= sizeof(pkt1)) { - av_fifo_generic_read(q->pkt_list, &pkt1, sizeof(pkt1), NULL); + if (av_fifo_can_read(q->pkt_list)) { + av_fifo_read(q->pkt_list, &pkt1, 1); q->nb_packets--; q->size -= pkt1.pkt->size + sizeof(pkt1); q->duration -= pkt1.pkt->duration; -- 2.33.0 _______________________________________________ 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".