pub trait FramePool:
Send
+ Sync
+ Debug {
// Required method
fn acquire(&self, size: usize) -> Option<PooledBuffer>;
// Provided method
fn release(&self, _buffer: Vec<u8>) { ... }
}Expand description
A trait for frame buffer pooling.
Implementing this trait allows custom memory management strategies for decoded video frames. This is useful for reducing allocation pressure during real-time video playback.
§Thread Safety
Implementations must be Send + Sync to allow sharing across threads.
§Example Implementation
ⓘ
use ff_common::{FramePool, PooledBuffer};
use std::sync::{Arc, Mutex};
struct SimplePool {
buffers: Mutex<Vec<Vec<u8>>>,
buffer_size: usize,
}
impl FramePool for SimplePool {
fn acquire(&self, size: usize) -> Option<PooledBuffer> {
// Implementation...
None
}
}Required Methods§
Sourcefn acquire(&self, size: usize) -> Option<PooledBuffer>
fn acquire(&self, size: usize) -> Option<PooledBuffer>
Acquires a buffer of at least the specified size from the pool.
§Arguments
size- The minimum required buffer size in bytes.
§Returns
Returns Some(PooledBuffer) if a buffer is available, or None if
the pool is exhausted. When None is returned, the decoder will
allocate a new buffer directly.
§Thread Safety
This method may be called from multiple threads concurrently.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".