{"id":15589,"url":"https://patchwork.libcamera.org/api/patches/15589/?format=json","web_url":"https://patchwork.libcamera.org/patch/15589/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220331130610.31806-2-ecurtin@redhat.com>","date":"2022-03-31T13:06:10","name":"[libcamera-devel,v5,2/2] cam: event_loop: Add timed events to event loop","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"94449b087775e1b18215770e0d9a3890e6d4aa62","submitter":{"id":101,"url":"https://patchwork.libcamera.org/api/people/101/?format=json","name":"Eric Curtin","email":"ecurtin@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15589/mbox/","series":[{"id":3017,"url":"https://patchwork.libcamera.org/api/series/3017/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3017","date":"2022-03-31T13:06:09","name":"[libcamera-devel,v5,1/2] cam: sdl_sink: Add SDL sink","version":5,"mbox":"https://patchwork.libcamera.org/series/3017/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15589/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15589/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id EF220C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 31 Mar 2022 13:06:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9F4F065638;\n\tThu, 31 Mar 2022 15:06:23 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3999A6559A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 31 Mar 2022 15:06:21 +0200 (CEST)","from mail-wm1-f71.google.com (mail-wm1-f71.google.com\n\t[209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n\tus-mta-107-7GxvI2_GONS6_U4b9IS73Q-1; Thu, 31 Mar 2022 09:06:19 -0400","by mail-wm1-f71.google.com with SMTP id\n\t2-20020a1c0202000000b0038c71e8c49cso1395830wmc.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 31 Mar 2022 06:06:18 -0700 (PDT)","from p1.Home ([2001:8a0:6724:4500:a69c:e66f:828e:b340])\n\tby smtp.gmail.com with ESMTPSA id\n\t7-20020a05600c028700b0038cc9bfe6a4sm6883538wmk.37.2022.03.31.06.06.16\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 31 Mar 2022 06:06:16 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1648731983;\n\tbh=zMLvytW4CG/cfsO6Ief/dhTrEb4NA6qGozArrJJWFbM=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=yGFg4MI/xabfROBUFI8xxf8DW4jRfxVQYJCQoEGsId7HYvpeJ9PRK3kMcSzQpbtWu\n\th+ymTakKmxcdYfqGYIWQWxR3YgZ/M9nT6mmoynU2jHJRnbNE7oFl4Zy7U5tKHcDAhs\n\teHXFseM4S0M6y9d5bOSTczupFCE3ZDAO4hoOXU7V93Uz4P/3jW5ZL1SVshUj2Y3+aU\n\tA3ahg9dd8HkYA3c2SjWnrXUcJlEjFB3eTT9t+dhsoTbmMQ1tbbQ2/A5k7bCqo9mtsj\n\tHiU6oKsuL06r35tVysNiCxC0uhaIa22tByc0pLLiSIV66Lihtad7fn43V7+j/6tBs6\n\txW4Ro8xzkknCw==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1648731980;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=95sP7rPZv50sCVWcj2ajITKn/riJ4Z8qvWBgJqLAoBY=;\n\tb=Vq3JAZOaKmMvQfB3fjZ2e0CWyfbdqFZ6xeoUP/YbJxhcA6/yIomyCowhIT0M/pHqGHcw54\n\t+DWGdpKoeCyKgRyK5rSx0/J4Gq2R0+9wfknyef790XEKEKKzA2UTvEAslS85LzfFW9jSwu\n\tUHKsudUDaFmMM27xJFpm6CUJdHnmYP8="],"Authentication-Results":["lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"Vq3JAZOa\"; \n\tdkim-atps=neutral","relay.mimecast.com;\n\tauth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ecurtin@redhat.com"],"X-MC-Unique":"7GxvI2_GONS6_U4b9IS73Q-1","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=95sP7rPZv50sCVWcj2ajITKn/riJ4Z8qvWBgJqLAoBY=;\n\tb=MqbW9mNlq8ciPkJ5S52Wp9rbkVQKPmhhSp3YFx89JxhYArTzWvonMLT6yWm68yYk2W\n\trnj2q6AnddxnRvy1Gvv03l4rS0362GK49eJQBsGFYMOcxRuMph+Slpp7VZIqr9eMqojG\n\txkrS5YA+2b5PUcYUWh/rze643veAVXGPIMnEHSQhPbnUk25xwTYTTQ5YBQxHVgmUdqCu\n\tz4W5lKR1saL46RDtlF1HHZbR828a2WtwCXK7ZbngjzKxm1jITPui7RoIXzEKmyG5rvby\n\tWwfljC6/YbFdS/JY7wSSrXH1Z6ZMVmcpVYm8xegT1P8DOl7prSRm9fMNGQY25NiH+XVX\n\tDFpw==","X-Gm-Message-State":"AOAM530vYtVV4ViKzShal2jWsVuXwBtaDAroMZDCdxyVEXXWnwNwflxc\n\tlDY/39qEEXGs2gIXqSCowBHU/1XQSDKzogqc3FbAuPaM+L3npbiKqP2cRhTXpH7PQKxRaabZGbX\n\t9gMCYsnK5ok9WNvdKUuWjMGcjwrAQPBZdb6siAiV3i3geV9mERNFjvVfI88pFOwdR0y5VNWKZhi\n\tEHg5rcDu7L","X-Received":["by 2002:adf:ee87:0:b0:203:de0b:b236 with SMTP id\n\tb7-20020adfee87000000b00203de0bb236mr4003112wro.337.1648731977269; \n\tThu, 31 Mar 2022 06:06:17 -0700 (PDT)","by 2002:adf:ee87:0:b0:203:de0b:b236 with SMTP id\n\tb7-20020adfee87000000b00203de0bb236mr4003090wro.337.1648731976969; \n\tThu, 31 Mar 2022 06:06:16 -0700 (PDT)"],"X-Google-Smtp-Source":"ABdhPJxnl6RQhKRhp2JWzdcdglIhwERUO8vK3XCOyBXvx+uznWBGrNftvKMPbnlyrrV4wAIsPfoSdA==","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 31 Mar 2022 14:06:10 +0100","Message-Id":"<20220331130610.31806-2-ecurtin@redhat.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220331130610.31806-1-ecurtin@redhat.com>","References":"<20220331130610.31806-1-ecurtin@redhat.com>","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain; charset=\"US-ASCII\"; x-default=true","Subject":"[libcamera-devel] [PATCH v5 2/2] cam: event_loop: Add timed events\n\tto event loop","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Eric Curtin via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Eric Curtin <ecurtin@redhat.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"If you add an event with EventLoop::Default, that event will be executed\nevery 10ms or at a rate of 100fps. Used to handle resize of windows and\nquit events in SDL.\n\nSigned-off-by: Eric Curtin <ecurtin@redhat.com>\n---\n src/cam/event_loop.cpp | 10 +++++++++-\n src/cam/event_loop.h   |  1 +\n src/cam/sdl_sink.cpp   |  2 +-\n 3 files changed, 11 insertions(+), 2 deletions(-)","diff":"diff --git a/src/cam/event_loop.cpp b/src/cam/event_loop.cpp\nindex e25784c0..7a5ed4da 100644\n--- a/src/cam/event_loop.cpp\n+++ b/src/cam/event_loop.cpp\n@@ -75,7 +75,15 @@ void EventLoop::addEvent(int fd, EventType type,\n \t\treturn;\n \t}\n \n-\tint ret = event_add(event->event_, nullptr);\n+\tstruct timeval *tp = nullptr;\n+\tstruct timeval tv;\n+\tif (events == EV_PERSIST) { /* EventType = Default */\n+\t\ttp = &tv;\n+\t\ttv.tv_sec = 0;\n+\t\ttv.tv_usec = 10000; /* every 10 ms */\n+\t}\n+\n+\tint ret = event_add(event->event_, tp);\n \tif (ret < 0) {\n \t\tstd::cerr << \"Failed to add event for fd \" << fd << std::endl;\n \t\treturn;\ndiff --git a/src/cam/event_loop.h b/src/cam/event_loop.h\nindex a4613eb2..8fd9bd20 100644\n--- a/src/cam/event_loop.h\n+++ b/src/cam/event_loop.h\n@@ -20,6 +20,7 @@ class EventLoop\n {\n public:\n \tenum EventType {\n+\t\tDefault = 0, /* the event can be triggered only by a timeout or by manual activation */\n \t\tRead = 1,\n \t\tWrite = 2,\n \t};\ndiff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp\nindex 28e59cbb..97a550b5 100644\n--- a/src/cam/sdl_sink.cpp\n+++ b/src/cam/sdl_sink.cpp\n@@ -117,7 +117,7 @@ int SDLSink::start()\n \t\treturn -EINVAL;\n \t}\n \n-\tEventLoop::instance()->addEvent(-1, EventLoop::Read, std::bind(&SDLSink::processSDLEvents, this));\n+\tEventLoop::instance()->addEvent(-1, EventLoop::Default, std::bind(&SDLSink::processSDLEvents, this));\n \n \treturn 0;\n }\n","prefixes":["libcamera-devel","v5","2/2"]}