From patchwork Sun Dec 1 11:39:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Gonzalo_Garramu=C3=B1o?= X-Patchwork-Id: 16507 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 A6B4944798F for ; Sun, 1 Dec 2019 13:48:32 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8644D68AEA8; Sun, 1 Dec 2019 13:48:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E6F9868AE70 for ; Sun, 1 Dec 2019 13:48:25 +0200 (EET) Received: by mail-qt1-f193.google.com with SMTP id i17so38127523qtq.1 for ; Sun, 01 Dec 2019 03:48:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SUIYoWqw83Q8ZHk0Gj8rpGwluwAzemp5awz7+KOqAmw=; b=UKtVuLldqGzc1L8D/WNN8lBGVhoFarMAOSioprXi+JTfUb9o0eHevamqPuIi6iFKHT z8sbEQWlIe95ZIEoxmicMLWbIFIJjHDYFAfEq0LjsRxbgUQMKVWS3s7eAO2zllcWEK50 2ePhJGnES/xNO1v27RniayZOSD8yadnHLyNQuaF2T1l6uD1zhVtYpxfadGpjkfpsmObH 32SLlBMddrIOoYdqutRVlSdMcQSSAm13VGOgHKAZh70EIhdZqEaVlZQWN45mrGBttilU eOq32vs7i6qiEdI6IVdqjslEG/5Fvhu++0OB/G6m44aRBW1AsNKH93wdGIKl4x77j3Dq wzNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SUIYoWqw83Q8ZHk0Gj8rpGwluwAzemp5awz7+KOqAmw=; b=ipKE3zvp7Do8w9ZTrvOANmlnzLbilPQ0wW51TsqP3mbJoyA0jZCZy91lOFpJQelDNH fPsj0Tvj3HlWV2V7xS7+N3agyKPADGfsD0VHBcdA8c9wckNVMd9UF87KwIkzUCWcPtc1 dnxJkVdc4nxxaA74/Y2u8N6cNx+cTiuDqgGOO+VdW9FFfasgUgmjMffYV+u8sPUd3AMn Fj2/xcuRhgpT9sWnJ5gMg+iRIyu2p4vjEExvMbnB/G6/+2Xzyv5rNCZ+FsSVtbbO8qYf MUJ6G91W2H/1rBcr0JY2SvWhSPf5pGgq8CfUkumBLaK1wnRYFP1I9jli8VLcq4GnKt/T daEw== X-Gm-Message-State: APjAAAXCeYCwxjOsQsHslbSAjg06TH9xBYWBIUq7j4LpIU1wdggvpHwq o8A/rEsdqyvrhT+mAupUsEeQ0rielQw= X-Google-Smtp-Source: APXvYqwJwzvmcCWHChWRnZ6QqKQ+eGxE24Z2Em0wzU/KQySF/OteDMDUwiG1gCs3ArI55T7BeyAesw== X-Received: by 2002:ac8:1112:: with SMTP id c18mr48230663qtj.379.1575200408289; Sun, 01 Dec 2019 03:40:08 -0800 (PST) Received: from localhost.localdomain ([181.167.72.151]) by smtp.gmail.com with ESMTPSA id c184sm13167090qke.118.2019.12.01.03.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Dec 2019 03:40:07 -0800 (PST) From: ggarra13@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 1 Dec 2019 08:39:52 -0300 Message-Id: <20191201113952.2909-1-ggarra13@gmail.com> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/utils.c: allows av_read_frame to return after a timeout period. 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: =?UTF-8?q?Gonzalo=20Garramu=C3=B1o?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Gonzalo Garramuño Moved the check inside and at the end of the if (pktl) as per Michael Niedermayer's suggestion. This patch is based on one from Blake Senftner ( bsenftner at earthlink.net ). The hanging in av_read_frame can be reproduced with an rtmp stream that is aborted midway and ffplay (for example) playing that stream. --- libavformat/utils.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavformat/utils.c b/libavformat/utils.c index 8196442dd1..653918d5a5 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1836,6 +1836,11 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) &s->internal->packet_buffer_end, pkt); goto return_packet; } + + if (ff_check_interrupt(&s->interrupt_callback)) { + av_log(s, AV_LOG_DEBUG, "interrupted\n"); + return AVERROR_EXIT; + } } ret = read_frame_internal(s, pkt);