From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 660E145B3E for ; Mon, 18 Sep 2023 06:38:00 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8A4E068C824; Mon, 18 Sep 2023 09:37:57 +0300 (EEST) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8FCDE68C655 for ; Mon, 18 Sep 2023 09:37:50 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695019075; x=1726555075; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=/Idm+D5aXbA3LDskfnBkieCVUO3H8FYE1AX2VK7X5xs=; b=G4T2ueOq2W4SwCVT1tAYGrhZwua397LycY1JVoRCCgPhDrogKkb2qwg9 x2CYp0hP7bAY/KrxCnQEOVFkN6828pFweLuF6i85rOAMpSXJ1INqMTCcl KGWSwh9+LF0hxHx01TI4SmWfZ8OCUSJxNleGxG7l0NU6GzGqia/ORol56 kV8DD2twJ1cGs8L4YQMzSroQvqZXxKHdec7z4NezL5U8wTFB7DHlDbj3v 5wypCx5RfS3P8lubKDbphwrSoycBBLXWA1rhNYltvMJt7c/a6skBoLmgQ Wsy+N4fIQqguIo8lodh1eWA+UsVbitd+xhKJUwyHm5iTCnaSxgmrLBNUl w==; X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="443654829" X-IronPort-AV: E=Sophos;i="6.02,155,1688454000"; d="scan'208";a="443654829" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2023 23:37:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="739011073" X-IronPort-AV: E=Sophos;i="6.02,155,1688454000"; d="scan'208";a="739011073" Received: from xhh-tgl64.sh.intel.com ([10.238.6.115]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2023 23:37:46 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 18 Sep 2023 14:37:28 +0800 Message-Id: <20230918063728.198377-1-haihao.xiang@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavd/sdl2: postpone sdl2 window creation 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: Haihao Xiang Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Haihao Xiang Since 2d924b3, sdl2_write_header() and sdl2_write_packet() are called in two different threads. However SDL2 requires window creation and rendering should be done in the same thread, otherwise it shows nothing when specifying SDL2 output device. $ ffmpeg -f lavfi -i yuvtestsrc -pix_fmt yuv420p -f sdl2 "sdl2" Signed-off-by: Haihao Xiang --- libavdevice/sdl2.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libavdevice/sdl2.c b/libavdevice/sdl2.c index 342a253dc0..c9f7f03c28 100644 --- a/libavdevice/sdl2.c +++ b/libavdevice/sdl2.c @@ -158,6 +158,11 @@ static int sdl2_write_trailer(AVFormatContext *s) } static int sdl2_write_header(AVFormatContext *s) +{ + return 0; +} + +static int sdl2_init(AVFormatContext *s) { SDLContext *sdl = s->priv_data; AVStream *st = s->streams[0]; @@ -165,6 +170,9 @@ static int sdl2_write_header(AVFormatContext *s) int i, ret = 0; int flags = 0; + if (sdl->inited) + return 0; + if (!sdl->window_title) sdl->window_title = av_strdup(s->url); @@ -249,6 +257,11 @@ static int sdl2_write_packet(AVFormatContext *s, AVPacket *pkt) int linesize[4]; SDL_Event event; + + ret = sdl2_init(s); + if (ret) + return ret; + if (SDL_PollEvent(&event)){ switch (event.type) { case SDL_KEYDOWN: -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".