Allocator#
Superclasses: Object, InitiallyUnowned, Object
Memory is usually created by allocators with a alloc()
method call. When None is used as the allocator, the default allocator will
be used.
New allocators can be registered with register().
Allocators are identified by name and can be retrieved with
find(). set_default() can be used to change the
default allocator.
New memory can be created with new_wrapped() that wraps the memory
allocated elsewhere.
Methods#
- class Allocator
- alloc(size: int, params: AllocationParams | None = None) Memory | None#
Use
allocatorto allocate a new memory block with memory that is at leastsizebig.The optional
paramscan specify the prefix and padding for the memory. IfNoneis passed, no flags, no extra prefix/padding and a default alignment is used.The prefix/padding will be filled with 0 if flags contains
GST_MEMORY_FLAG_ZERO_PREFIXEDandGST_MEMORY_FLAG_ZERO_PADDEDrespectively.When
allocatorisNone, the default allocator will be used.The alignment in
paramsis given as a bitmask so thatalign+ 1 equals the amount of bytes to align to. For example, to align to 8 bytes, use an alignment of 7.- Parameters:
size – size of the visible memory area
params – optional parameters
- do_alloc(self, size: int, params: AllocationParams | None = None) Memory | None#
- Parameters:
size
params
- classmethod find() Allocator | None#
Find a previously registered allocator with
name. WhennameisNone, the default allocator will be returned.
- free(memory: Memory) None#
Free
memorythat was previously allocated withalloc().- Parameters:
memory – the memory to free
Virtual Methods#
- class Allocator
- do_alloc(size: int, params: AllocationParams | None = None) Memory | None#
Use
allocatorto allocate a new memory block with memory that is at leastsizebig.The optional
paramscan specify the prefix and padding for the memory. IfNoneis passed, no flags, no extra prefix/padding and a default alignment is used.The prefix/padding will be filled with 0 if flags contains
GST_MEMORY_FLAG_ZERO_PREFIXEDandGST_MEMORY_FLAG_ZERO_PADDEDrespectively.When
allocatorisNone, the default allocator will be used.The alignment in
paramsis given as a bitmask so thatalign+ 1 equals the amount of bytes to align to. For example, to align to 8 bytes, use an alignment of 7.- Parameters:
size – size of the visible memory area
params – optional parameters
Fields#
- class Allocator
- mem_copy#
The implementation of the GstMemoryCopyFunction
- mem_is_span#
The implementation of the GstMemoryIsSpanFunction
- mem_map#
The implementation of the GstMemoryMapFunction
- mem_map_full#
- The implementation of the GstMemoryMapFullFunction.
Will be used instead of
mem_mapif present. (Since: 1.6)
The implementation of the GstMemoryShareFunction
- mem_type#
- mem_unmap#
The implementation of the GstMemoryUnmapFunction
- mem_unmap_full#
- The implementation of the GstMemoryUnmapFullFunction.
Will be used instead of
mem_unmapif present. (Since: 1.6)
- object#
- priv#