fplayer
C99 Falcon Sequence (fseq) file player for Light-O-Rama hardware (like xLights)
Loading...
Searching...
No Matches
pump.c File Reference

Frame data loading implementation. More...

#include "pump.h"
#include <assert.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tinyfseq.h"
#include "fseq/comblock.h"
#include "fseq/fd.h"
#include "std2/errcode.h"
#include "std2/fc.h"
Include dependency graph for pump.c:

Data Structures

struct  frame_pump_s
 Frame pump state controller for loading/tracking frame data. More...
 

Functions

int FP_init (struct FC *fc, const struct tf_header_t *seq, struct frame_pump_s **pump)
 Initializes a frame pump with the provided file controller. The pump will read frames from the file controller and store them in an internal buffer for playback. The pump will also preload the next frame set asynchronously in a separate thread to ensure smooth playback. The caller is responsible for freeing the pump with FP_free.
 
static int FP_readSeq (struct FC *fc, const struct tf_header_t *seq, const uint32_t frame, struct fd_list_s *list)
 Reads the next frame set from the file controller and stores it in the provided frame data node pointer. This function is used when the sequence is not compressed and read sequentially from the file controller.
 
static int FP_read (struct frame_pump_s *pump, struct fd_list_s *list)
 Reads the next frame set from the file controller and stores it in the provided frame data node pointer. The pump should have its pos union updated with read request position information before calling this function.
 
static void * FP_thread (void *pargs)
 
int FP_checkPreload (struct frame_pump_s *pump, const uint32_t frame)
 Checks if the pump's internal buffer is low, and if so, preloads the next frame set from the file controller asynchronously in a separate thread. The preloaded data is stored within the pump, allowing it to be read once the pre-existing primary buffer is empty.
 
int FP_nextFrame (struct frame_pump_s *pump, uint8_t **fd)
 Copies the next frame of data from the pump to the provided frame data buffer. If the pump's internal buffer is empty, the pump will attempt to read more frames from the file controller provided during initialization.
 
int FP_framesRemaining (struct frame_pump_s *pump)
 Returns the number of frames remaining in the pump's internal buffer.
 
void FP_free (struct frame_pump_s *pump)
 Frees the resources associated with the provided frame pump.
 

Detailed Description

Frame data loading implementation.

Function Documentation

◆ FP_checkPreload()

int FP_checkPreload ( struct frame_pump_s * pump,
uint32_t frame )

Checks if the pump's internal buffer is low, and if so, preloads the next frame set from the file controller asynchronously in a separate thread. The preloaded data is stored within the pump, allowing it to be read once the pre-existing primary buffer is empty.

Parameters
pumppump to check
framecurrent frame index for aligning read position
Returns
0 on success, a negative error code on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FP_framesRemaining()

int FP_framesRemaining ( struct frame_pump_s * pump)

Returns the number of frames remaining in the pump's internal buffer.

Parameters
pumppump to check
Returns
number of frames remaining in the pump's internal buffer
Here is the caller graph for this function:

◆ FP_free()

void FP_free ( struct frame_pump_s * pump)

Frees the resources associated with the provided frame pump.

Parameters
pumppump to free
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FP_init()

int FP_init ( struct FC * fc,
const struct tf_header_t * seq,
struct frame_pump_s ** pump )

Initializes a frame pump with the provided file controller. The pump will read frames from the file controller and store them in an internal buffer for playback. The pump will also preload the next frame set asynchronously in a separate thread to ensure smooth playback. The caller is responsible for freeing the pump with FP_free.

Parameters
fcfile controller to read frames from
seqsequence file for file layout information
pumppointer to store the initialized frame pump in
Returns
0 on success, a negative error code on failure
Here is the caller graph for this function:

◆ FP_nextFrame()

int FP_nextFrame ( struct frame_pump_s * pump,
uint8_t ** fd )

Copies the next frame of data from the pump to the provided frame data buffer. If the pump's internal buffer is empty, the pump will attempt to read more frames from the file controller provided during initialization.

Parameters
pumppump to copy from
fdframe data pointer to return the next frame in
Returns
0 on success, a negative error code on failure, or 1 if the pump has reached the end of the sequence
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FP_read()

static int FP_read ( struct frame_pump_s * pump,
struct fd_list_s * list )
static

Reads the next frame set from the file controller and stores it in the provided frame data node pointer. The pump should have its pos union updated with read request position information before calling this function.

Parameters
pumpframe pump to read from
listframe data list pointer to store the next frame set in
Returns
0 on success, a negative error code on failure, or FP_ESEQEND if the pump has reached the end of the sequence
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FP_readSeq()

static int FP_readSeq ( struct FC * fc,
const struct tf_header_t * seq,
const uint32_t frame,
struct fd_list_s * list )
static

Reads the next frame set from the file controller and stores it in the provided frame data node pointer. This function is used when the sequence is not compressed and read sequentially from the file controller.

Parameters
fcfile controller to read from
seqsequence header for playback configuration
frameframe index to read
listframe data list pointer to store the next frame set in
Returns
0 on success, a negative error code on failure, or FP_ESEQEND if the pump has reached the end of the sequence
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FP_thread()

static void * FP_thread ( void * pargs)
static
Here is the call graph for this function:
Here is the caller graph for this function: