Skip to content

Commit e0675fd

Browse files
committed
Adding change by @anatawa12 from
raymanfx#71 (comment)
1 parent 8c1e5f4 commit e0675fd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/io/mmap/arena.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,21 @@ impl<'a> Arena<'a> {
106106
// each plane has to be mapped separately
107107
let mut planes = Vec::new();
108108
for plane in &v4l2_planes {
109+
let length = if !self.buf_type.planar() {
110+
v4l2_buf.length as usize
111+
} else {
112+
plane.length as usize
113+
};
109114
let ptr = v4l2::mmap(
110115
ptr::null_mut(),
111-
plane.length as usize,
116+
length,
112117
libc::PROT_READ | libc::PROT_WRITE,
113118
libc::MAP_SHARED,
114119
self.handle.fd(),
115120
plane.m.mem_offset as libc::off_t,
116121
)?;
117-
118122
planes.push(slice::from_raw_parts_mut::<u8>(
119-
ptr as *mut u8, plane.length as usize
123+
ptr as *mut u8, length,
120124
));
121125
}
122126

0 commit comments

Comments
 (0)