From patchwork Thu Jan 4 04:14:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 7114 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.79.195 with SMTP id r64csp16696547jad; Wed, 3 Jan 2018 20:14:32 -0800 (PST) X-Google-Smtp-Source: ACJfBov58EqHDHoRWBJ0ACIeKpYPor2CzEZ4xw5TEU2/p6X3fv93S2kV/7yYYi1fiMm6A++bjxTx X-Received: by 10.223.150.61 with SMTP id b58mr3151028wra.185.1515039272416; Wed, 03 Jan 2018 20:14:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515039272; cv=none; d=google.com; s=arc-20160816; b=BTpngu0V2u4b1hxvl41Z0aWOimP1JsBQGQj997t5SSPgIH7aZLZ4WVFothFfdnTqka +js8beVf4CzQ20QGZrrJ3wQDAFbTP61o6q7/2J8mc1AUNX2MA8INYhPxhtWFVqBbhye7 iCNaMg4U2Vh/C/J6FAvlFqyz+MSQ18rYvJMA0jF022ZExLD3Bz+OtuFBmMJerv/3lZdo MyQ7SvgflCjZzb4gyD0uI7YdMe9YenM21EtMsoQofO2l5pBXNTMYVTVDlrA/fB36c3Mh 5TwualjcTUt86kyi6foZnLTJfzQcSeNXndQmiVX0P2y8IyfgemaHynDDE831b0wBm4SR WC3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=1HfFWNDEvL2h2jcj9XmOziclq8+rEgWiLWg6TH32zio=; b=Ev+NiNTRgrRMAi8DyVLIOU7961/h4eKDsTZOB8hRV9zXRYKPCi12RaqjWdu9gvWaci 28wGy3ryfyIliBKJZAnvaA/NVsf0c0NRiRJY8PjQx5b2rt3G+c7fOk2qmMNn1ImhKTkT PFr8A/DW2bkmMo2IFGVpSRsQfMnPTyZ80mKVGBTUK6boboC005sa4ISTuf0aqu5HoYgD xIM15o3tHam1SvJZ7SGN4UGsKgkz1YYPMdjloETqfLhxHg9BzXFEdu5VPto8T6q2MhkS E31Y26zZ7F4Lml+83cTCMF/0PL9E9buwKHP65AAhc2yVNkQQHshLdxVYZ1EhvNus7BM8 55ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=aVUCRmkR; 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=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p9si1832876wrd.324.2018.01.03.20.14.31; Wed, 03 Jan 2018 20:14:32 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=aVUCRmkR; 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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F2797689885; Thu, 4 Jan 2018 06:14:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 488576883CC for ; Thu, 4 Jan 2018 06:14:07 +0200 (EET) Received: by mail-qk0-f194.google.com with SMTP id o126so541947qke.12 for ; Wed, 03 Jan 2018 20:14:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=klo1P43mno4fZ7qzoQqMKKwCoz3PdwDwRS+GjhB3N/w=; b=aVUCRmkRv1tbku2vgVuu/5mBdpmA+cMHrdflcGPq25VJ7Azl7y5mMYMhgFP7fJhdDQ NwrxUoirZhyqvKZoy8BqcRZspEfaDCy+OhNTbwFkk+VpJ3UVKrPVk9/BTwcbmdyQVswc hUibGy0wCioXAxy7DJgbrrUkYb0SZ7gG16KiyZx2i+sJoaSTWa+4hL5f2Lz14zhfGwoF 9z0Ug1bQXZlQe5Nk8vpm68H4vZVHuUP1HLyHwwQZKGpBBwpgxIFMtmcw7L1brR1DnsqU kmqnNO4Y2jT97Q54d7xmUWCtpXE2MmySYTrYDeR3m1LdFuXmUwo/NvSgb4KLy2C5DJaN RiJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=klo1P43mno4fZ7qzoQqMKKwCoz3PdwDwRS+GjhB3N/w=; b=jJV9n4JNnbR7OZp9/029i3ai52hBCOnBHHGAYg+xcRHe+9acvwFLMVz3z+6Ghw6hcv HzRq9FMgq44wQvIbUg/LRnJ2RIYNGS6MSbz/MnK3xEX1lJkwe5qhhfc0VBEydgMnJW7z 0mTj+qMK+USDIfa4qsZ/U+h7li399w+6SUQqObdOsHwmpvc/f0xgCw0j1y5qJ0hS8V8l H08kykBWN78vnDT6wL3vsY2yJ/d96ElTWV636E7H1arEFXwC/3/WsAHo3hpxVCq84+Hz rFlgUcl8ydTdR7o7Gn89I/P4S+fJEPhL9F0VPfCskBgZKydegCSTIhQA40NJV4PaTSwA bQfg== X-Gm-Message-State: AKGB3mK9lKvNd++c1Lb6QqIn5M6XL5aC7axuad8I5blEXMSO6YiZ/bQZ 6LTsTczBzVp2QXCo8A7lD4So7g== X-Received: by 10.55.182.194 with SMTP id g185mr4233954qkf.287.1515039262601; Wed, 03 Jan 2018 20:14:22 -0800 (PST) Received: from localhost.localdomain ([181.229.225.176]) by smtp.gmail.com with ESMTPSA id q73sm166245qke.41.2018.01.03.20.14.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Jan 2018 20:14:22 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Jan 2018 01:14:07 -0300 Message-Id: <20180104041408.6268-1-jamrial@gmail.com> X-Mailer: git-send-email 2.15.0 Subject: [FFmpeg-devel] [PATCH 1/2] ffmpeg: use thread wrappers for the thread message functionality 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: James Almer --- fftools/ffmpeg.c | 19 ++++++++----------- fftools/ffmpeg.h | 7 ++----- fftools/ffmpeg_opt.c | 2 +- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 6aff3366c5..528849a2c6 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -61,6 +61,7 @@ #include "libavutil/timestamp.h" #include "libavutil/bprint.h" #include "libavutil/time.h" +#include "libavutil/thread.h" #include "libavutil/threadmessage.h" #include "libavcodec/mathops.h" #include "libavformat/os_support.h" @@ -98,10 +99,6 @@ #include #endif -#if HAVE_PTHREADS -#include -#endif - #include #include "ffmpeg.h" @@ -161,7 +158,7 @@ static struct termios oldtty; static int restore_tty; #endif -#if HAVE_PTHREADS +#if HAVE_THREADS static void free_input_threads(void); #endif @@ -578,7 +575,7 @@ static void ffmpeg_cleanup(int ret) av_freep(&output_streams[i]); } -#if HAVE_PTHREADS +#if HAVE_THREADS free_input_threads(); #endif for (i = 0; i < nb_input_files; i++) { @@ -3996,7 +3993,7 @@ static int check_keyboard_interaction(int64_t cur_time) return 0; } -#if HAVE_PTHREADS +#if HAVE_THREADS static void *input_thread(void *arg) { InputFile *f = arg; @@ -4106,7 +4103,7 @@ static int get_input_packet(InputFile *f, AVPacket *pkt) } } -#if HAVE_PTHREADS +#if HAVE_THREADS if (nb_input_files > 1) return get_input_packet_mt(f, pkt); #endif @@ -4615,7 +4612,7 @@ static int transcode(void) timer_start = av_gettime_relative(); -#if HAVE_PTHREADS +#if HAVE_THREADS if ((ret = init_input_threads()) < 0) goto fail; #endif @@ -4646,7 +4643,7 @@ static int transcode(void) /* dump report by using the output first video and audio streams */ print_report(0, timer_start, cur_time); } -#if HAVE_PTHREADS +#if HAVE_THREADS free_input_threads(); #endif @@ -4712,7 +4709,7 @@ static int transcode(void) ret = 0; fail: -#if HAVE_PTHREADS +#if HAVE_THREADS free_input_threads(); #endif diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 4e73d59082..8195f73e8b 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -25,10 +25,6 @@ #include #include -#if HAVE_PTHREADS -#include -#endif - #include "cmdutils.h" #include "libavformat/avformat.h" @@ -45,6 +41,7 @@ #include "libavutil/hwcontext.h" #include "libavutil/pixfmt.h" #include "libavutil/rational.h" +#include "libavutil/thread.h" #include "libavutil/threadmessage.h" #include "libswresample/swresample.h" @@ -415,7 +412,7 @@ typedef struct InputFile { int rate_emu; int accurate_seek; -#if HAVE_PTHREADS +#if HAVE_THREADS AVThreadMessageQueue *in_thread_queue; pthread_t thread; /* thread reading from this file */ int non_blocking; /* reading packets from the thread should not block */ diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index a6e36ac822..754c297b93 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1161,7 +1161,7 @@ static int open_input_file(OptionsContext *o, const char *filename) f->loop = o->loop; f->duration = 0; f->time_base = (AVRational){ 1, 1 }; -#if HAVE_PTHREADS +#if HAVE_THREADS f->thread_queue_size = o->thread_queue_size > 0 ? o->thread_queue_size : 8; #endif