pub struct StreamManual {
io: StreamIo,
arena: Arena<EntryDmaBufProtected>,
}
Expand description
A stream using the manual buffer management API, where owned buffers are handed to the user, to be enqueued and dequeued explicitly, rather than only borrowed.
Fields§
§io: StreamIo
§arena: Arena<EntryDmaBufProtected>
Bufers in the arena are always locked for writing.
Implementations§
source§impl StreamManual
impl StreamManual
sourcepub fn new(dev: &Device, buf_type: Type, buf_count: u32) -> Result<Self>
pub fn new(dev: &Device, buf_type: Type, buf_count: u32) -> Result<Self>
Returns an advanced, buffer-owning stream for frame capturing.
Currently allows only one buffer to be in flight.
§Arguments
dev
- Device ref to get its file descriptorbuf_type
- Type of the buffersbuf_count
- the number of buffers to allocate. Too many buffers will hog memory, too few will give less processing time for each buffer (although that doesn’t matter with this API). A safe number is 4.
§Example
use v4l::buffer::Type;
use v4l::device::Device;
use v4l::io::dmabuf::StreamManual;
let dev = Device::new(0);
if let Ok(dev) = dev {
let stream = StreamManual::new(&dev, Type::VideoCapture, 4);
}
sourcepub fn start(&mut self) -> Result<DmaBufProtected>
pub fn start(&mut self) -> Result<DmaBufProtected>
Returns an uninitialized buffer for immediate queueing in cycle_buffer and starts the stream.
sourcepub fn finish(
self,
buf: DmaBufProtected,
) -> Result<(), (Error, DmaBufProtected, Self)>
pub fn finish( self, buf: DmaBufProtected, ) -> Result<(), (Error, DmaBufProtected, Self)>
Stops the stream and deallocates buffers.
sourcepub fn cycle_buffer(
&mut self,
buf: DmaBufProtected,
) -> Result<(DmaBufProtected, Metadata)>
pub fn cycle_buffer( &mut self, buf: DmaBufProtected, ) -> Result<(DmaBufProtected, Metadata)>
Returns a buffer and removes a new buffer once it’s ready.
This will lock the buffer passed in for writing, so the buffer must be unlocked in a timely fashion. Watch out for deadlocks!
FIXME: if this fails, the buffer is swallowed and streaming can’t continue due to no free buffers.
fn enqueue(&mut self, index: usize) -> Result<()>
fn dequeue(&mut self) -> Result<(usize, Metadata)>
Auto Trait Implementations§
impl Freeze for StreamManual
impl !RefUnwindSafe for StreamManual
impl !Send for StreamManual
impl !Sync for StreamManual
impl Unpin for StreamManual
impl !UnwindSafe for StreamManual
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more