Closed rytec-nl closed 3 years ago
I think we need some kind of safeguard here. If self.buf_meta[index].bytesused
is not set, I would like to retain the old behavior.
Indeed, would it make sense to make the meta.bytesused an Option
?
The Default::default()
impl for the Metadata
struct (https://github.com/raymanfx/libv4l-rs/blob/master/src/buffer.rs#L102) will zero that field. So it's fine to check for a value of 0
and then just fallback to the existing logic.
If I read the v4l2 documentation, if bytesused is set to 0, for an output stream, the value is set to the size of the plane. So would it then not mean that the current implementation would work?
Ah, good find. Yes, I think you're right. However, that behavior seems counter-intuitive to me. Would you mind adding a comment to that portion of the code referencing the v4l2 docs and hinting at this specific fallback behavior?
Fixes #30