| Updated: October 28, 2024 |
Wait for the next buffer to become available from a producer
#include <screen/screen.h>
int screen_acquire_buffer(screen_buffer_t *pbuf,
screen_stream_t stream,
int *pcount,
int **pdirty_rects,
int *pflags,
int flags)
Function Type: Immediate Execution
This function is typically used by consumers to get the next frame posted by the producer. The consumer uses a stream that shares buffers with an external stream handle by calling screen_consume_stream_buffers(). Producers and consumers that reside in the same process can use the API, or simply pass the buffers between each other.
Acquiring a buffer doesn't release previously acquired buffers unless you specify SCREEN_ACQUIRE_AND_RELEASE_OTHERS in the flags parameter. In this case, all other buffers are released whenever a new buffer is returned. Typically, after calling screen_acquire_buffer(), the consumer releases the previously acquired buffer by calling screen_release_buffer(). Note that if the stream is single-buffered, the consumer calls screen_release_buffer() after finishing with the buffer.
This function returns the next available buffer. However, if the stream is in SCREEN_STREAM_MODE_MAILBOX mode, this function returns all queued front buffers to the render queue, except for the last buffer. If no buffer is available, this function blocks unless you specify SCREEN_ACQUIRE_DONT_BLOCK in the flags parameter.
If you provide a non-NULL pointer in pcount and pdirty_rects, this function returns the number of regions in the location pointed to by pcount and pdirty_rects will point to an array of integers that represents the dirty regions. This array is allocated dynamically and must be freed when it's no longer needed.
If you provide NULL in pcount and pdirty_rects, this function doesn't make the dirty regions (if any) available to the consumer.
0 if successful, or -1 if an error occurred (errno is set; refer to errno.h for more details).