PadBufferAllocFunction
Description:
[
CCode ( has_target =
false ) ]
public delegate FlowReturn PadBufferAllocFunction (
Pad pad,
uint64 offset,
uint size,
Caps caps,
out Buffer buf)
Ask the sinkpad pad to allocate a buffer with offset, size and caps.
The result will be stored in buf.
The purpose of this function is to allocate a buffer that is optimal to be processed by pad. The function is mostly overridden by
elements that can provide a hardware buffer in order to avoid additional memcpy operations.
The function can return a buffer that has caps different from the requested caps, in which case the upstream element requests a
format change to this new caps. If a format change was requested, the returned buffer will be one to hold the data of said new caps, so its size
might be different from the requested size.
When this function returns anything else than OK, the buffer allocation
failed and buf does not contain valid data. If the function returns
OK and the buf is NULL, a
Buffer will be created with caps, offset and size
.
By default this function returns a new buffer of size and with caps containing purely malloced data. The buffer
should be freed with unref after usage.
Parameters:
| pad |
a sink Pad
|
| offset |
the desired offset of the buffer |
| size |
the desired size of the buffer |
| caps |
the desired caps of the buffer |
| buf |
pointer to hold the allocated buffer. |
Returns:
OK if buf contains a valid buffer, any other return
value means buf does not hold a valid buffer. |