1

I'm writing a python library called linuxpy which supports V4L2. One of the features is being able to open de V4L2 device in non blocking mode (O_NONBLOCK) to be cooperative with python async/await.

I tried with several real cameras and everything seems to work properly. But when I test v4l2loopback device it blocks waiting for the first frame if I open the v4l2loopback device with O_NONBLOCK.

Does anyone know if v4l2loopback supports O_NONBLOCK?

2
  • I believe the developer(s) have considered non-blocking mode: are you capturing from the device or writing to it? Commented Oct 22, 2024 at 5:46
  • I tried capturing only Commented Oct 22, 2024 at 5:54

1 Answer 1

0

This is a bug in v4l2loopback where poll would (always) block if the first call to poll occurred while the device was in a 'readable' state.

In v4l2loopback's implementation of poll, it did not call poll_wait if the device was in a readable state. This has a side effect if the device was readable the first time poll was called: subsequent calls to poll_wait on the table become no-ops; and thus poll will block. See: https://github.com/torvalds/linux/commit/726daf6 for a similar example.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.