FFmpeg
Functions
thread_queue.h File Reference
#include <string.h>
#include "objpool.h"

Go to the source code of this file.

Functions

ThreadQueuetq_alloc (unsigned int nb_streams, size_t queue_size, ObjPool *obj_pool, void(*obj_move)(void *dst, void *src))
 Allocate a queue for sending data between threads. More...
 
void tq_free (ThreadQueue **tq)
 
int tq_send (ThreadQueue *tq, unsigned int stream_idx, void *data)
 Send an item for the given stream to the queue. More...
 
void tq_send_finish (ThreadQueue *tq, unsigned int stream_idx)
 Mark the given stream finished from the sending side. More...
 
int tq_receive (ThreadQueue *tq, int *stream_idx, void *data)
 Read the next item from the queue. More...
 
void tq_receive_finish (ThreadQueue *tq, unsigned int stream_idx)
 Mark the given stream finished from the receiving side. More...
 

Function Documentation

◆ tq_alloc()

ThreadQueue* tq_alloc ( unsigned int  nb_streams,
size_t  queue_size,
ObjPool obj_pool,
void(*)(void *dst, void *src obj_move 
)

Allocate a queue for sending data between threads.

Parameters
nb_streamsnumber of streams for which a distinct EOF state is maintained
queue_sizenumber of items that can be stored in the queue without blocking
obj_poolobject pool that will be used to allocate items stored in the queue; the pool becomes owned by the queue
callbackthat moves the contents between two data pointers

Definition at line 79 of file thread_queue.c.

Referenced by thread_start().

◆ tq_free()

void tq_free ( ThreadQueue **  tq)

Definition at line 55 of file thread_queue.c.

Referenced by thread_start(), thread_stop(), and tq_alloc().

◆ tq_send()

int tq_send ( ThreadQueue tq,
unsigned int  stream_idx,
void *  data 
)

Send an item for the given stream to the queue.

Parameters
datathe item to send, its contents will be moved using the callback provided to tq_alloc(); on failure the item will be left untouched
Returns
  • 0 the item was successfully sent
  • AVERROR(ENOMEM) could not allocate an item for writing to the FIFO
  • AVERROR(EINVAL) the sending side has previously been marked as finished
  • AVERROR_EOF the receiving side has marked the given stream as finished

Definition at line 120 of file thread_queue.c.

Referenced by thread_submit_packet().

◆ tq_send_finish()

void tq_send_finish ( ThreadQueue tq,
unsigned int  stream_idx 
)

Mark the given stream finished from the sending side.

Definition at line 217 of file thread_queue.c.

Referenced by thread_stop(), and thread_submit_packet().

◆ tq_receive()

int tq_receive ( ThreadQueue tq,
int stream_idx,
void *  data 
)

Read the next item from the queue.

Parameters
stream_idxthe index of the stream that was processed or -1 will be written here
datathe data item will be written here on success using the callback provided to tq_alloc()
Returns
  • 0 a data item was successfully read; *stream_idx contains a non-negative stream index
  • AVERROR_EOF When *stream_idx is non-negative, this signals that the sending side has marked the given stream as finished. This will happen at most once for each stream. When *stream_idx is -1, all streams are done.

Definition at line 191 of file thread_queue.c.

Referenced by muxer_thread().

◆ tq_receive_finish()

void tq_receive_finish ( ThreadQueue tq,
unsigned int  stream_idx 
)

Mark the given stream finished from the receiving side.

Definition at line 232 of file thread_queue.c.

Referenced by muxer_thread().