From patchwork Tue Jan 11 20:46:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 33260 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp4050090iog; Tue, 11 Jan 2022 12:51:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhTI8vMhktH2bTFJX/Kypg4we3mTtnKCDOYJb2ETrm0SR9AihC8uAWVzHakYh/4HiEWpoK X-Received: by 2002:a17:906:830b:: with SMTP id j11mr5121294ejx.347.1641934315732; Tue, 11 Jan 2022 12:51:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641934315; cv=none; d=google.com; s=arc-20160816; b=GZCkbRD5JSjF+h1348GskiazTgfcDvdSle7aw6hlKFnUFAI8d+DUbKCqP2xAdRAcaQ bswyMSWQtLeP8tqFwps0B9YCT7Yrn3o6MbwTRM7Gqf7Fbm12JUP5YQBcKxgM1YOUvXjP SWLTOZb6TYhH0Ei6zU6QxJ9g1Gb0ipUjxnnToBV64rOWz6aVG/sNW2tdK1XgehcthLim QtrI4yM88ZUoUTqzqUpbrG3N16tWoI79rMsp4Dy49V1DnwxxMCMDZbY/m4B44lhtEdzG 920ALOc6TH0mcaussjP6i4LVG+ggNY7l+KJt9RryDh1Uf/aYWYfKb9JnNq+L1fLh3P/j aI6A== 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=tyRKv+nswD2Ki4xgJAUZYz3DAmTpUwaI7TGe8myJiyY=; b=OOKRuV4DEeaYMRh5RoULRjrKFa1rpgi/yDwY1dVM67XTf3vMqzjOv5S7zTIJHwlTw1 iFgyHB3LETJXwHZSlw2BnrfRMnNj+fAM0X0zmf+J7U1DBNc2l660kRcuNcPZg5oH1R70 5XMS7xP/fk+IsV2nBepLFdW4p7UY/xcpc22pDjT8Xv/9yeqwGFirEoFz9lAMHlTX3eAq 3r925BlrxllIQIU+hOcJYPCt3LIM6bkLGMVMmel8oh31BRx82fb78omonKz8lZtOreeX PqVZS381f1iBoyh5fKfP2WVXuifmLCkoqG9nVfxcGMdjJkRBnkxG19bVJTvSqf8s+KxS x7Jg== 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 sc18si5897530ejc.114.2022.01.11.12.51.54; Tue, 11 Jan 2022 12:51:55 -0800 (PST) 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 7596568AFF3; Tue, 11 Jan 2022 22:47:58 +0200 (EET) 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 64D9968ACA5 for ; Tue, 11 Jan 2022 22:47:38 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D63E124017C for ; Tue, 11 Jan 2022 21:47:37 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id RxzUZlFnjXBU for ; Tue, 11 Jan 2022 21:47:37 +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 521C9240691 for ; Tue, 11 Jan 2022 21:47:26 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 529553A073E; Tue, 11 Jan 2022 21:47:25 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Jan 2022 21:46:01 +0100 Message-Id: <20220111204610.14262-26-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 26/35] lavf/udp: 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 9LqxWQ674k66 --- libavformat/udp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index 83c042d079..4c8f104d9d 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -500,7 +500,7 @@ static void *circular_buffer_task_rx( void *_URLContext) continue; AV_WL32(s->tmp, len); - if(av_fifo_space(s->fifo) < len + 4) { + if (av_fifo_can_write(s->fifo) < len + 4) { /* No Space left */ if (s->overrun_nonfatal) { av_log(h, AV_LOG_WARNING, "Circular buffer overrun. " @@ -514,7 +514,7 @@ static void *circular_buffer_task_rx( void *_URLContext) goto end; } } - av_fifo_generic_write(s->fifo, s->tmp, len+4, NULL); + av_fifo_write(s->fifo, s->tmp, len + 4); pthread_cond_signal(&s->cond); } @@ -548,22 +548,22 @@ static void *circular_buffer_task_tx( void *_URLContext) uint8_t tmp[4]; int64_t timestamp; - len = av_fifo_size(s->fifo); + len = av_fifo_can_read(s->fifo); while (len<4) { if (s->close_req) goto end; pthread_cond_wait(&s->cond, &s->mutex); - len = av_fifo_size(s->fifo); + len = av_fifo_can_read(s->fifo); } - av_fifo_generic_read(s->fifo, tmp, 4, NULL); + av_fifo_read(s->fifo, tmp, 4); len = AV_RL32(tmp); av_assert0(len >= 0); av_assert0(len <= sizeof(s->tmp)); - av_fifo_generic_read(s->fifo, s->tmp, len, NULL); + av_fifo_read(s->fifo, s->tmp, len); pthread_mutex_unlock(&s->mutex); @@ -906,7 +906,7 @@ static int udp_open(URLContext *h, const char *uri, int flags) if ((!is_output && s->circular_buffer_size) || (is_output && s->bitrate && s->circular_buffer_size)) { /* start the task going */ - s->fifo = av_fifo_alloc(s->circular_buffer_size); + s->fifo = av_fifo_alloc2(s->circular_buffer_size, 1, 0); if (!s->fifo) { ret = AVERROR(ENOMEM); goto fail; @@ -970,19 +970,19 @@ static int udp_read(URLContext *h, uint8_t *buf, int size) if (s->fifo) { pthread_mutex_lock(&s->mutex); do { - avail = av_fifo_size(s->fifo); + avail = av_fifo_can_read(s->fifo); if (avail) { // >=size) { uint8_t tmp[4]; - av_fifo_generic_read(s->fifo, tmp, 4, NULL); + av_fifo_read(s->fifo, tmp, 4); avail = AV_RL32(tmp); if(avail > size){ av_log(h, AV_LOG_WARNING, "Part of datagram lost due to insufficient buffer size\n"); avail = size; } - av_fifo_generic_read(s->fifo, buf, avail, NULL); - av_fifo_drain(s->fifo, AV_RL32(tmp) - avail); + av_fifo_read(s->fifo, buf, avail); + av_fifo_drain2(s->fifo, AV_RL32(tmp) - avail); pthread_mutex_unlock(&s->mutex); return avail; } else if(s->circular_buffer_error){ @@ -1043,14 +1043,14 @@ static int udp_write(URLContext *h, const uint8_t *buf, int size) return err; } - if(av_fifo_space(s->fifo) < size + 4) { + if (av_fifo_can_write(s->fifo) < size + 4) { /* What about a partial packet tx ? */ pthread_mutex_unlock(&s->mutex); return AVERROR(ENOMEM); } AV_WL32(tmp, size); - av_fifo_generic_write(s->fifo, tmp, 4, NULL); /* size of packet */ - av_fifo_generic_write(s->fifo, (uint8_t *)buf, size, NULL); /* the data */ + av_fifo_write(s->fifo, tmp, 4); /* size of packet */ + av_fifo_write(s->fifo, (uint8_t *)buf, size); /* the data */ pthread_cond_signal(&s->cond); pthread_mutex_unlock(&s->mutex); return size;