Fifos

Thread save fifo buffers for A/V data. More...


Typedefs

typedef struct bg_fifo_s bg_fifo_t
 Opaque fifo handle.

Enumerations

enum  bg_fifo_state_t {
  BG_FIFO_PLAYING,
  BG_FIFO_STOPPED,
  BG_FIFO_PAUSED
}
 Operation states a fifo can have. More...

Functions

bg_fifo_tbg_fifo_create (int num_frames, void *(*create_func)(void *), void *data)
 Create a fifo.
void bg_fifo_destroy (bg_fifo_t *f, void(*destroy_func)(void *, void *), void *data)
 Destroy a fifo.
void * bg_fifo_lock_read (bg_fifo_t *f, bg_fifo_state_t *state)
 Lock a fifo for reading.
void * bg_fifo_try_lock_read (bg_fifo_t *f, bg_fifo_state_t *state)
 Lock a fifo for reading (nonblocking).
void bg_fifo_unlock_read (bg_fifo_t *f)
 Unlock a fifo for reading.
void * bg_fifo_lock_write (bg_fifo_t *f, bg_fifo_state_t *state)
 Lock a fifo for writing.
void * bg_fifo_try_lock_write (bg_fifo_t *f, bg_fifo_state_t *state)
 Lock a fifo for writing (nonblocking).
void bg_fifo_unlock_write (bg_fifo_t *f, int eof)
 Unlock a fifo for writing.
void bg_fifo_set_state (bg_fifo_t *f, bg_fifo_state_t state)
 Set the state of a fifo.
void bg_fifo_clear (bg_fifo_t *f)
 Clear a fifo.


Detailed Description

Thread save fifo buffers for A/V data.

Fifos are used in multithreaded realtime applications to transfer A/V frames from the source to the destination. They have a fixed number of frames.

They also allow save suspension and termination of threads through the state values returned by the bg_fifo_lock_* functions.


Typedef Documentation

typedef struct bg_fifo_s bg_fifo_t

Opaque fifo handle.

You don't want to know what's inside


Enumeration Type Documentation

Operation states a fifo can have.

Enumerator:
BG_FIFO_PLAYING  Normal operation.
BG_FIFO_STOPPED  Playback is stopped, threads should be terminated.
BG_FIFO_PAUSED  Playback is paused, threads should wait until playback is resumed.


Function Documentation

bg_fifo_t* bg_fifo_create ( int  num_frames,
void *(*)(void *)  create_func,
void *  data 
)

Create a fifo.

Parameters:
num_frames Number of frames
create_func Function to be called for each created frame
data Argument for create_func
Returns:
A newly allocated fifo

void bg_fifo_destroy ( bg_fifo_t f,
void(*)(void *, void *)  destroy_func,
void *  data 
)

Destroy a fifo.

Parameters:
f A fifo
destroy_func Function to be called for each frame to destroy it
data Argument for destroy_func

void* bg_fifo_lock_read ( bg_fifo_t f,
bg_fifo_state_t state 
)

Lock a fifo for reading.

Parameters:
f A fifo
state If non NULL, returns the state of the fifo
Returns:
A frame or NULL
This function blocks until a new frame is available

void* bg_fifo_try_lock_read ( bg_fifo_t f,
bg_fifo_state_t state 
)

Lock a fifo for reading (nonblocking).

Parameters:
f A fifo
state If non NULL, returns the state of the fifo
Returns:
A frame or NULL

void bg_fifo_unlock_read ( bg_fifo_t f  ) 

Unlock a fifo for reading.

Parameters:
f A fifo

void* bg_fifo_lock_write ( bg_fifo_t f,
bg_fifo_state_t state 
)

Lock a fifo for writing.

Parameters:
f A fifo
state If non NULL, returns the state of the fifo
Returns:
A frame or NULL
This function blocks until a new frame is available

void* bg_fifo_try_lock_write ( bg_fifo_t f,
bg_fifo_state_t state 
)

Lock a fifo for writing (nonblocking).

Parameters:
f A fifo
state If non NULL, returns the state of the fifo
Returns:
A frame or NULL

void bg_fifo_unlock_write ( bg_fifo_t f,
int  eof 
)

Unlock a fifo for writing.

Parameters:
f A fifo
eof Set to 1 if EOF (also means, the last frame is invalid)

void bg_fifo_set_state ( bg_fifo_t f,
bg_fifo_state_t  state 
)

Set the state of a fifo.

Parameters:
f A fifo
state The new state

void bg_fifo_clear ( bg_fifo_t f  ) 

Clear a fifo.

Parameters:
f A fifo
This flushes the fifo but keeps all buffers. It should only be called, if there are no other threads accessing the fifo


Generated on Sat Aug 22 00:44:56 2009 for gmerlin by  doxygen 1.5.9