From patchwork Mon Jul 19 07:15:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 28969 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp4143153ios; Mon, 19 Jul 2021 00:16:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycyijTuohbZTpLMxjIIG1UPM14fP7SguUwnWcuEbZ9PEIvsbRUMPg8QmeNuZZZ8WQapOCR X-Received: by 2002:a50:c88b:: with SMTP id d11mr33719829edh.318.1626678966822; Mon, 19 Jul 2021 00:16:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626678966; cv=none; d=google.com; s=arc-20160816; b=wXEzjdZllQXc05EarIDRuZkni5lQhEVGZ2mndMlpYigJ5PmJzdeQwFl/gTQbzNUCth O1wpODsE/6XzSu0Eur4zEceDWX1sCxBJitVyXYK65BE2VSdLd4LnZs2jJyTKTxoEYdan a5aVJgleUrjgnsx+Cx1Y/kYz7WgtHb05YBA4r7Iho6mErAj7GLRVifGRfzim7zrdn7lI Y3EA8EZ6KrZhBgo1DMLhfTUzCzxzYiCZcpxzPrPqEhh2rgljIHuZ2YLteAqrqZVvHtjK i8W6nqVc92OuwPUMbiMtw2e5tXOXFn+EiBywop88M0Tg5aVGl/OgqO+2oUcqVAzCRvET 9t/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:mime-version:message-id:date :to:from:delivered-to; bh=L5zQkQLDpaZTO7OJbmkfRBX2C3H/lV4lvcNo9ap1iDY=; b=Mn5q9oRqsrKnoHChOq/cGBsSFTpq4YughB1kP8547mYtjjt5UMi7sDqivjspjwuov4 1YAkohrJRA0sJvv9wtOeSsF6I+sczY+RzkbxTtEZ5/XxqkVlc4XxU/OsSHfmdnz67sOq hWYQgTub7PKDbXOqPlR+Wyu65UhHCrTlLhFNDHInhxAtpz4Gn1EttiyjU3kLzuBrRLTp BfN9nCtvdy3TklLfMJ2G6EhflfHZ8G7DyyLEDCFaeXd1wjXYzkxyDjyOLC65W3RqZEno RqcVBZFzdwjLmVYuJP7JA2D0UoUpgzTdg/v4zWjYuDI66E9ARBTO4QvogbqzXyBBtQ42 jMGA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kuaishou.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s23si13563289ejj.684.2021.07.19.00.16.06; Mon, 19 Jul 2021 00:16:06 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kuaishou.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7873668AD0C; Mon, 19 Jul 2021 10:16:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgsg2.qq.com (smtpbgsg2.qq.com [54.254.200.128]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 78A6368AC87 for ; Mon, 19 Jul 2021 10:15:55 +0300 (EEST) X-QQ-mid: bizesmtp49t1626678946tl7cre62 Received: from localhost (unknown [103.107.216.231]) by esmtp6.qq.com (ESMTP) with id ; Mon, 19 Jul 2021 15:15:44 +0800 (CST) X-QQ-SSF: 01100000001000Z0Z000000A0020000 X-QQ-FEAT: ui4ED9uslZCWqUTapOMcpYEf2T/1e+ooXQwrx/obu+JHnK3WOVJrMNyKnxq27 9KwbjSd0UDmBs6tRJGzi2hTpUJ0lDEl5++zQ6jW5ap120E46/bgeUKRdOQ8rnhImrEETQsm GxYDO+frCa8Cy8f/nle5Tb7hCMiZVApiR92VRCY9MvGDlI8nnn9rdQQ0TA/4XN8FQbs+vxR LmC8eBDAz8lbbidZzFVrsErnxZfMxTFVOxQU0eiLRrUkledMa1JCyu7zKJDthCtt1SX3A/0 2wmrKD7Vnk1sDBZ9uGFqv8zB1Z9o3jUbtSt/hOf6dVlI9+xd/g3EVsDQsXz3tgx8D456r50 yM2tPlw X-QQ-GoodBg: 0 X-QQ-CSender: lq@chinaffmpeg.org From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Jul 2021 15:15:41 +0800 Message-Id: <20210719071541.80003-1-liuqi05@kuaishou.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign2 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avdevice/avfoundation: continue to try get packet if not in observed_quit mode 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 Cc: Steven Liu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: h2v6SwCES8E5 move unlock_frames before return in observed_quit mode. before patch: ./ffmpeg -f avfoundation -i ":0" -y out.wav say something to microphone ffplay out.wav will hear some noise, because not get enough samples from devices after patch: ./ffmpeg -f avfoundation -i ":0" -y out.wav say something to microphone ffplay out.wav will ok. Signed-off-by: Steven Liu --- libavdevice/avfoundation.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m index bad3760159..ddde640c80 100644 --- a/libavdevice/avfoundation.m +++ b/libavdevice/avfoundation.m @@ -1170,11 +1170,9 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt) ctx->current_audio_frame = nil; } else { pkt->data = NULL; - unlock_frames(ctx); if (ctx->observed_quit) { + unlock_frames(ctx); return AVERROR_EOF; - } else { - return AVERROR(EAGAIN); } }