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
allocator
to allocate a new memory block with memory that is at leastsize
big.The optional
params
can specify the prefix and padding for the memory. IfNone
is 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_PREFIXED
andGST_MEMORY_FLAG_ZERO_PADDED
respectively.When
allocator
isNone
, the default allocator will be used.The alignment in
params
is 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
- find(name: str | None = None) Allocator | None
Find a previously registered allocator with
name
. Whenname
isNone
, the default allocator will be returned.- Parameters:
name – the name of the allocator
- free(memory: Memory) None
Free
memory
that 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
allocator
to allocate a new memory block with memory that is at leastsize
big.The optional
params
can specify the prefix and padding for the memory. IfNone
is 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_PREFIXED
andGST_MEMORY_FLAG_ZERO_PADDED
respectively.When
allocator
isNone
, the default allocator will be used.The alignment in
params
is 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_map
if 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_unmap
if present. (Since: 1.6)
- object
- priv