Limit v4l2_loopback_write calls to (streaming) writers #477
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously whenever someone called the
write
function on the loopback devicethe device was put in a state where no further openers could request access
to write frames to the device. While the intention of this is correct it
was missing to also make that opener doing the
write
operation an writer.When an opener releases its file descriptor this output capability is
usually restored due to the fact that there's only ever one writer and
that writer should have the
opener->type
set toWRITER
. With theunconditional update of the
dev->ready_to_output
field this invariant isbroken as a file descriptor starts with a
opener->type
ofUNKNOWN
. Thuswhen performing a
write
operation followed byclose
to the file descriptorthe logic to restore the output capabilities does not trigger and the
output capability is lost.
Thus instead of aiding sloppy user-land programming and guessing what
the caller desires this patch makes the
write
operation more strict inits preconditions by enforcing the file descriptor to belong to an
opener with type
WRITER
. Failure to adhere to this is indicated byan explicit
EINVAL
error return, aswrite
operations as a non-WRITER
should not be allowed.
Fixes: #470