screen_release_buffer()

Updated: April 19, 2023

Return a buffer to the producer

Synopsis:

#include <screen/screen.h>
int screen_release_buffer(screen_buffer_t buf)

Arguments:

buf
The buffer that needs to be released.

Library:

libscreen

Description:

Function Type: Immediate Execution

This function is typically used by consumers to indicate that they are no longer using a buffer. This function returns the buffer to the producer and it becomes available the next time the producer posts a frame. If the producer is blocked waiting for a render buffer, it will unblock after the last of the consumers, that have acquired this buffer, have released the buffer.

Note that acquiring a buffer doesn't implicitly release the previously acquired buffer. Each consumer is responsible for calling screen_release_buffer() each time it's finished with a buffer. The consumer can call screen_release_buffer() immediately after using the buffer one time, or it can release the buffer only when it has acquired a new buffer to replace the old one. Consumers of single-buffered streams must call screen_release_buffer() immediately after using the latest frame.

This function returns an error when it's called with a buffer that wasn't previously acquired, or with a buffer that has already been released.

Returns:

0 if successful, or -1 if an error occurred (errno is set; refer to errno.h for more details).