Class Allocator

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
Allocator.Allocator$Impl

@Generated("org.javagi.JavaGI") public abstract class Allocator extends GstObject

Memory is usually created by allocators with a gst_allocator_alloc() method call. When null is used as the allocator, the default allocator will be used.

New allocators can be registered with gst_allocator_register(). Allocators are identified by name and can be retrieved with gst_allocator_find(). gst_allocator_set_default() can be used to change the default allocator.

New memory can be created with gst_memory_new_wrapped() that wraps the memory allocated elsewhere.

  • Constructor Details

    • Allocator

      public Allocator(MemorySegment address)
      Create a Allocator instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Allocator

      public Allocator()
      Create a new Allocator.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Allocator class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected Allocator asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GstObject
      Returns:
      the instance as if it were its parent type
    • find

      public static @Nullable Allocator find(@Nullable String name)
      Find a previously registered allocator with name. When name is null, the default allocator will be returned.
      Parameters:
      name - the name of the allocator
      Returns:
      a GstAllocator or null when the allocator with name was not registered.
    • register

      public static void register(String name, Allocator allocator)
      Registers the memory allocator with name.
      Parameters:
      name - the name of the allocator
      allocator - GstAllocator
    • alloc

      public @Nullable Memory alloc(long size, @Nullable AllocationParams params)

      Use this Allocator to allocate a new memory block with memory that is at least size big.

      The optional params can specify the prefix and padding for the memory. If null 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 and GST_MEMORY_FLAG_ZERO_PADDED respectively.

      When this Allocator is null, the default allocator will be used.

      The alignment in params is given as a bitmask so that align + 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
      Returns:
      a new GstMemory.
    • free

      public void free(Memory memory)
      Free memory that was previously allocated with gst_allocator_alloc().
      Parameters:
      memory - the memory to free
    • setDefault

      public void setDefault()
      Set the default allocator.