diff options
author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2022-05-30 17:27:17 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2022-06-04 02:21:05 +0300 |
commit | 7ef83e02284715db95e3f4cd61744290baff2840 (patch) | |
tree | 2954b0a38a8e7004eab84297ebc5f98145ea36fa /src | |
parent | b4bb5ce629294e5a0b186c6824ffe231bd86c3c7 (diff) |
py: Merge read_event() and get_ready_requests()
We always call CameraManager.read_event() and
CameraManager.get_ready_requests(), so to simplify the use merge the
read_event() into the get_ready_requests().
This has the side effect that get_ready_requests() will now block if
there is no event ready. If we ever need to call get_ready_requests() in
a polling manner we will need a new function which behaves differently.
However, afaics the only sensible way to manage the event loop is to use
select/poll on the eventfd and then call get_ready_requests() once,
which is the use case what the current merged function supports.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/py/cam/cam.py | 2 | ||||
-rw-r--r-- | src/py/libcamera/py_main.cpp | 7 |
2 files changed, 2 insertions, 7 deletions
diff --git a/src/py/cam/cam.py b/src/py/cam/cam.py index bf8529d9..2ae89fa8 100755 --- a/src/py/cam/cam.py +++ b/src/py/cam/cam.py @@ -243,8 +243,6 @@ class CaptureState: # Called from renderer when there is a libcamera event def event_handler(self): try: - self.cm.read_event() - reqs = self.cm.get_ready_requests() for req in reqs: diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp index fcf009f0..505cc3dc 100644 --- a/src/py/libcamera/py_main.cpp +++ b/src/py/libcamera/py_main.cpp @@ -213,15 +213,12 @@ PYBIND11_MODULE(_libcamera, m) return gEventfd; }) - .def("read_event", [](CameraManager &) { + .def("get_ready_requests", [](CameraManager &) { uint8_t buf[8]; - int ret = read(gEventfd, buf, 8); - if (ret != 8) + if (read(gEventfd, buf, 8) != 8) throw std::system_error(errno, std::generic_category()); - }) - .def("get_ready_requests", [](CameraManager &) { std::vector<Request *> v; { |