From patchwork Tue Sep 3 01:02:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 14874 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id E217844A4A6 for ; Tue, 3 Sep 2019 04:10:20 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C9294687FF5; Tue, 3 Sep 2019 04:10:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 04FF7687FC2 for ; Tue, 3 Sep 2019 04:10:14 +0300 (EEST) Received: by mail-ot1-f66.google.com with SMTP id 21so7640239otj.11 for ; Mon, 02 Sep 2019 18:10:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm1-net.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x4QKvK7irnUGohPOJRFgiSKhVbxNOCBPpWAn+tFNiQI=; b=lT/CWvOj9SK6MZfBHgCZudSxvmFAz6pV+wnLKUiU4sGdQvS8H89Wj2Y0b0dONTqu7K +wTa1hCH7xdexK+tuMHCtgz0HAwLRWjY2pUhUG8walTBB6n43Qy9ezYSfp7ArfI9P/A6 bNMlAJuZzp3XRQWFZQY8v9sKLdn+dVxZXefmuarUEfavY/RLmpzElEIKsRe8vKOOEUlb LVCMIGBFRRVLdsUuZzzzf+Sf3XLxv4yMcXkkL2744oWP8h2zOOtd2a9mxCrLhx5+FtT7 QthoID9CW75n8FsFxH814gPYDy2iyai9j5tLFJ35aRsG6akD9JGyBf1M/C7PKpLF7P0X FshQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=x4QKvK7irnUGohPOJRFgiSKhVbxNOCBPpWAn+tFNiQI=; b=oSZAztfML0Q4zvjt0MTO2vkO7H34v4inyL7jHkF6WqnWNcB11QBdLy7hr2zzyX3xxJ 8DeZ0kgh9BiKEwjoRYViOPs0yusXiDLsTwYFUEihdaMwtcIJKNLkgarqLXtXwaGQTP1d XJEcDHd/QMFtuTxInacPXhEu28B3MpIG+dr5d7ESUEl657PepUQlbQrfkVI3elqP0iel UIHoYqtushuGxfl6o0YihwVEJKN25koD+Zt4KRKKy+HKs6BXuUGMJctF2jUsgxAgnEqf /gf+a8N72QlJyfto4SlEqPSnT7dPWxnuFB37O9Qm1uqNSsXy50mbnG7f573jrzlL2LrS +TQg== X-Gm-Message-State: APjAAAWmyL+gO3CzNsJDufSTQSqmSVK06RT3rMeic3zwt7FCNL5bA1f8 gr4ouVpFVsPPelGy46skHmlrWBCJYTs= X-Google-Smtp-Source: APXvYqzaif1Jbx3gHhSGGV0fPoBhRY/cK9uW5FopWtFF7evSIS012GKk+Jw6XspHfWAOHbsQQoY2Tg== X-Received: by 2002:a9d:6189:: with SMTP id g9mr1069323otk.348.1567472570966; Mon, 02 Sep 2019 18:02:50 -0700 (PDT) Received: from tmm1-imac.lan (ip184-189-221-177.sb.sd.cox.net. [184.189.221.177]) by smtp.gmail.com with ESMTPSA id a21sm4299633oie.9.2019.09.02.18.02.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Sep 2019 18:02:50 -0700 (PDT) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Sep 2019 18:02:06 -0700 Message-Id: <20190903010230.96236-2-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190903010230.96236-1-ffmpeg@tmm1.net> References: <20190903010230.96236-1-ffmpeg@tmm1.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/25] avcodec/v4l2_context: ensure v4l2_dequeue does not hang in poll() when no buffers are pending X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: lorusak@gmail.com, Aman Gupta , jorge.ramirez.ortiz@gmail.com, Aman Gupta Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta Signed-off-by: Aman Gupta --- libavcodec/v4l2_context.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index 6924760840..070988b4c3 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -264,8 +264,8 @@ static V4L2Buffer* v4l2_dequeue_v4l2buf(V4L2Context *ctx, int timeout) }; int i, ret; - /* if we are draining and there are no more capture buffers queued in the driver we are done */ - if (!V4L2_TYPE_IS_OUTPUT(ctx->type) && ctx_to_m2mctx(ctx)->draining) { + /* if there are no more capture buffers queued in the driver, skip polling */ + if (!V4L2_TYPE_IS_OUTPUT(ctx->type)) { for (i = 0; i < ctx->num_buffers; i++) { /* capture buffer initialization happens during decode hence * detection happens at runtime @@ -276,7 +276,9 @@ static V4L2Buffer* v4l2_dequeue_v4l2buf(V4L2Context *ctx, int timeout) if (ctx->buffers[i].status == V4L2BUF_IN_DRIVER) goto start; } - ctx->done = 1; + /* if we were waiting to drain, all done! */ + if (ctx_to_m2mctx(ctx)->draining) + ctx->done = 1; return NULL; }