Loading...
Searching...
No Matches
fftools_thread_queue.c File Reference

Go to the source code of this file.

## Data Structures

struct | FifoElem
struct | ThreadQueue

## Typedefs

typedef struct FifoElem | FifoElem

## Enumerations

enum | { FINISHED_SEND = (1 << 0) , FINISHED_RECV = (1 << 1) }

## Functions

void | tq_free (ThreadQueue **ptq)
ThreadQueue * | tq_alloc (unsigned int nb_streams, size_t queue_size, ObjPool *obj_pool, void(*obj_move)(void *dst, void *src))
int | tq_send (ThreadQueue *tq, unsigned int stream_idx, void *data)
static int | receive_locked (ThreadQueue *tq, int *stream_idx, void *data)
int | tq_receive (ThreadQueue *tq, int *stream_idx, void *data)
void | tq_send_finish (ThreadQueue *tq, unsigned int stream_idx)
void | tq_receive_finish (ThreadQueue *tq, unsigned int stream_idx)

## Typedef Documentation

## FifoElem

typedef struct FifoElem FifoElem

## Enumeration Type Documentation

## anonymous enum

anonymous enum

Enumerator
FINISHED_SEND |
FINISHED_RECV |

Definition at line 46 of file fftools_thread_queue.c.

## Function Documentation

## receive_locked()

static int receive_locked | ( | ThreadQueue * | tq,
|  | int * | stream_idx,
|  | void * | data
| ) |  |

static

Definition at line 175 of file fftools_thread_queue.c.

## 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_streams | number of streams for which a distinct EOF state is maintained
  queue_size | number of items that can be stored in the queue without blocking
  obj_pool | object pool that will be used to allocate items stored in the queue; the pool becomes owned by the queue
  callback | that moves the contents between two data pointers

Definition at line 93 of file fftools_thread_queue.c.

## tq_free()

void tq_free | ( | ThreadQueue ** | ptq | ) |

Definition at line 69 of file fftools_thread_queue.c.

## tq_receive()

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

Read the next item from the queue.

Parameters

  stream_idx | the index of the stream that was processed or -1 will be written here
  data | the 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 205 of file fftools_thread_queue.c.

## 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 246 of file fftools_thread_queue.c.

## tq_send()

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

Send an item for the given stream to the queue.

Parameters

  data | the 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 134 of file fftools_thread_queue.c.

## 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 231 of file fftools_thread_queue.c.