| Copyright | Will Thompson and Iñaki García Etxebarria |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
GI.Gst.Structs.Memory
Description
GstMemory is a lightweight refcounted object that wraps a region of memory.
They are typically used to manage the data of a Buffer.
A GstMemory object has an allocated region of memory of maxsize. The maximum size does not change during the lifetime of the memory object. The memory also has an offset and size property that specifies the valid range of memory in the allocated region.
Memory is usually created by allocators with a allocatorAlloc
method call. When Nothing is used as the allocator, the default allocator will
be used.
New allocators can be registered with allocatorRegister.
Allocators are identified by name and can be retrieved with
allocatorFind. allocatorSetDefault can be used to change the
default allocator.
New memory can be created with memoryNewWrapped that wraps the memory
allocated elsewhere.
Refcounting of the memory block is performed with gst_memory_ref() and
gst_memory_unref().
The size of the memory can be retrieved and changed with
memoryGetSizes and memoryResize respectively.
Getting access to the data of the memory is performed with memoryMap.
The call will return a pointer to offset bytes into the region of memory.
After the memory access is completed, memoryUnmap should be called.
Memory can be copied with memoryCopy, which will return a writable
copy. memoryShare will create a new memory block that shares the
memory with an existing memory block at a custom offset and with a custom
size.
Memory can be efficiently merged when memoryIsSpan returns True.
Synopsis
- newtype Memory = Memory (ManagedPtr Memory)
- newZeroMemory :: MonadIO m => m Memory
- memoryCopy :: (HasCallStack, MonadIO m) => Memory -> Int64 -> Int64 -> m (Maybe Memory)
- memoryGetSizes :: (HasCallStack, MonadIO m) => Memory -> m (Word64, Word64, Word64)
- memoryIsSpan :: (HasCallStack, MonadIO m) => Memory -> Memory -> m (Bool, Word64)
- memoryIsType :: (HasCallStack, MonadIO m) => Memory -> Text -> m Bool
- memoryMakeMapped :: (HasCallStack, MonadIO m) => Memory -> [MapFlags] -> m (Maybe Memory, MapInfo)
- memoryMap :: (HasCallStack, MonadIO m) => Memory -> [MapFlags] -> m (Bool, MapInfo)
- memoryNewWrapped :: (HasCallStack, MonadIO m) => [MemoryFlags] -> ByteString -> Word64 -> Word64 -> Maybe DestroyNotify -> m (Maybe Memory)
- memoryResize :: (HasCallStack, MonadIO m) => Memory -> Int64 -> Word64 -> m ()
- memoryShare :: (HasCallStack, MonadIO m) => Memory -> Int64 -> Int64 -> m Memory
- memoryUnmap :: (HasCallStack, MonadIO m) => Memory -> MapInfo -> m ()
- getMemoryAlign :: MonadIO m => Memory -> m Word64
- setMemoryAlign :: MonadIO m => Memory -> Word64 -> m ()
- clearMemoryAllocator :: MonadIO m => Memory -> m ()
- getMemoryAllocator :: MonadIO m => Memory -> m (Maybe Allocator)
- setMemoryAllocator :: MonadIO m => Memory -> Ptr Allocator -> m ()
- getMemoryMaxsize :: MonadIO m => Memory -> m Word64
- setMemoryMaxsize :: MonadIO m => Memory -> Word64 -> m ()
- getMemoryMiniObject :: MonadIO m => Memory -> m MiniObject
- getMemoryOffset :: MonadIO m => Memory -> m Word64
- setMemoryOffset :: MonadIO m => Memory -> Word64 -> m ()
- clearMemoryParent :: MonadIO m => Memory -> m ()
- getMemoryParent :: MonadIO m => Memory -> m (Maybe Memory)
- setMemoryParent :: MonadIO m => Memory -> Ptr Memory -> m ()
- getMemorySize :: MonadIO m => Memory -> m Word64
- setMemorySize :: MonadIO m => Memory -> Word64 -> m ()
Exported types
Memory-managed wrapper type.
Instances
| Eq Memory Source # | |
| GBoxed Memory Source # | |
Defined in GI.Gst.Structs.Memory | |
| ManagedPtrNewtype Memory Source # | |
Defined in GI.Gst.Structs.Memory Methods toManagedPtr :: Memory -> ManagedPtr Memory | |
| TypedObject Memory Source # | |
Defined in GI.Gst.Structs.Memory | |
| HasParentTypes Memory Source # | |
Defined in GI.Gst.Structs.Memory | |
| tag ~ 'AttrSet => Constructible Memory tag Source # | |
| IsGValue (Maybe Memory) Source # | Convert |
Defined in GI.Gst.Structs.Memory Methods gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Memory -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Memory) | |
| type ParentTypes Memory Source # | |
Defined in GI.Gst.Structs.Memory | |
Methods
Click to display all available methods, including inherited ones
copy
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Memory |
|
| -> Int64 |
|
| -> Int64 |
|
| -> m (Maybe Memory) | Returns: a new copy of |
Return a copy of size bytes from mem starting from offset. This copy is
guaranteed to be writable. size can be set to -1 to return a copy
from offset to the end of the memory region.
getSizes
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Memory |
|
| -> m (Word64, Word64, Word64) | Returns: the current size of |
Get the current size, offset and maxsize of mem.
isSpan
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Memory |
|
| -> Memory |
|
| -> m (Bool, Word64) | Returns: |
Check if mem1 and mem2 share the memory with a common parent memory object
and that the memory is contiguous.
If this is the case, the memory of mem1 and mem2 can be merged
efficiently by performing memoryShare on the parent object from
the returned offset.
isType
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Memory |
|
| -> Text |
|
| -> m Bool | Returns: |
Check if mem if allocated with an allocator for memType.
Since: 1.2
makeMapped
map
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Memory |
|
| -> [MapFlags] |
|
| -> m (Bool, MapInfo) | Returns: |
Fill info with the pointer and sizes of the memory in mem that can be
accessed according to flags.
This function can return False for various reasons:
- the memory backed by
memis not accessible with the givenflags. - the memory was already mapped with a different mapping.
info and its contents remain valid for as long as mem is valid and
until memoryUnmap is called.
For each memoryMap call, a corresponding memoryUnmap call
should be done.
newWrapped
Arguments
| :: (HasCallStack, MonadIO m) | |
| => [MemoryFlags] |
|
| -> ByteString |
|
| -> Word64 |
|
| -> Word64 |
|
| -> Maybe DestroyNotify |
|
| -> m (Maybe Memory) | Returns: a new |
Allocate a new memory block that wraps the given data.
The prefix/padding must be filled with 0 if flags contains
GST_MEMORY_FLAG_ZERO_PREFIXED and GST_MEMORY_FLAG_ZERO_PADDED respectively.
resize
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Memory |
|
| -> Int64 |
|
| -> Word64 |
|
| -> m () |
Resize the memory region. mem should be writable and offset + size should be
less than the maxsize of mem.
GST_MEMORY_FLAG_ZERO_PREFIXED and GST_MEMORY_FLAG_ZERO_PADDED will be
cleared when offset or padding is increased respectively.
share
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Memory |
|
| -> Int64 |
|
| -> Int64 |
|
| -> m Memory | Returns: a new |
Return a shared copy of size bytes from mem starting from offset. No
memory copy is performed and the memory region is simply shared. The result
is guaranteed to be non-writable. size can be set to -1 to return a shared
copy from offset to the end of the memory region.
unmap
Release the memory obtained with memoryMap
Properties
align
the alignment of the memory
getMemoryAlign :: MonadIO m => Memory -> m Word64 Source #
Get the value of the “align” field.
When overloading is enabled, this is equivalent to
get memory #align
setMemoryAlign :: MonadIO m => Memory -> Word64 -> m () Source #
Set the value of the “align” field.
When overloading is enabled, this is equivalent to
setmemory [ #align:=value ]
allocator
pointer to the Allocator
clearMemoryAllocator :: MonadIO m => Memory -> m () Source #
Set the value of the “allocator” field to Nothing.
When overloading is enabled, this is equivalent to
clear #allocator
getMemoryAllocator :: MonadIO m => Memory -> m (Maybe Allocator) Source #
Get the value of the “allocator” field.
When overloading is enabled, this is equivalent to
get memory #allocator
setMemoryAllocator :: MonadIO m => Memory -> Ptr Allocator -> m () Source #
Set the value of the “allocator” field.
When overloading is enabled, this is equivalent to
setmemory [ #allocator:=value ]
maxsize
the maximum size allocated
getMemoryMaxsize :: MonadIO m => Memory -> m Word64 Source #
Get the value of the “maxsize” field.
When overloading is enabled, this is equivalent to
get memory #maxsize
setMemoryMaxsize :: MonadIO m => Memory -> Word64 -> m () Source #
Set the value of the “maxsize” field.
When overloading is enabled, this is equivalent to
setmemory [ #maxsize:=value ]
miniObject
parent structure
getMemoryMiniObject :: MonadIO m => Memory -> m MiniObject Source #
Get the value of the “mini_object” field.
When overloading is enabled, this is equivalent to
get memory #miniObject
offset
the offset where valid data starts
getMemoryOffset :: MonadIO m => Memory -> m Word64 Source #
Get the value of the “offset” field.
When overloading is enabled, this is equivalent to
get memory #offset
setMemoryOffset :: MonadIO m => Memory -> Word64 -> m () Source #
Set the value of the “offset” field.
When overloading is enabled, this is equivalent to
setmemory [ #offset:=value ]
parent
parent memory block
clearMemoryParent :: MonadIO m => Memory -> m () Source #
Set the value of the “parent” field to Nothing.
When overloading is enabled, this is equivalent to
clear #parent
getMemoryParent :: MonadIO m => Memory -> m (Maybe Memory) Source #
Get the value of the “parent” field.
When overloading is enabled, this is equivalent to
get memory #parent
setMemoryParent :: MonadIO m => Memory -> Ptr Memory -> m () Source #
Set the value of the “parent” field.
When overloading is enabled, this is equivalent to
setmemory [ #parent:=value ]
size
the size of valid data
getMemorySize :: MonadIO m => Memory -> m Word64 Source #
Get the value of the “size” field.
When overloading is enabled, this is equivalent to
get memory #size
setMemorySize :: MonadIO m => Memory -> Word64 -> m () Source #
Set the value of the “size” field.
When overloading is enabled, this is equivalent to
setmemory [ #size:=value ]