Maestro Audio Framework v 1.5
NXP Semiconductors
file_src_freertos.c File Reference

this file implement file source element. More...

#include <string.h>
#include <stdio.h>
#include "audio_cfg.h"
#include "streamer_element.h"
#include "file_src_freertos.h"
#include "audio_sink.h"
#include "pipeline.h"
#include "streamer_element_properties.h"

Functions

int32_t filesrc_src_pad_process (StreamPad *pad)
 Function is the loop function of the filesrc source pad which runs in the task thread. It reads the chunk_size of data from the file and pushes it to peer element sink pad. When EOF file is reached, the task goes to PAUSE state. More...
 
static int32_t filesrc_change_state (StreamElement *element, PipelineState state)
 Function handles the state change of the element in a pipeline. More...
 
static uint8_t filesrc_handle_src_event (StreamPad *pad, StreamEvent *event)
 Function handles the events of the element source pad. More...
 
static uint8_t filesrc_handle_src_query (StreamPad *pad, StreamQuery *query)
 Function Description: This function is the empty impl of the src pad query handler. More...
 
static uint8_t filesrc_src_activate_push (StreamPad *pad, uint8_t active)
 Function activates or deactivates the filesrc source pad in PUSH mode. More...
 
static uint8_t filesrc_src_activate_pull (StreamPad *pad, uint8_t active)
 Function activates or deactivates the filesrc source pad in PULL mode. More...
 
static uint8_t filesrc_src_activate (StreamPad *pad, uint8_t active)
 Function is the queue src pad activatation handler. Activation is handled by the peer sink pad, this should just handle the deactivation. More...
 
static FlowReturn filesrc_pull (StreamPad *pad, StreamBuffer *buffer, uint32_t size, uint32_t offset)
 Function is the pull function of the filesrc source pad in SCHEDULING_PULL mode. It reads the size of data from the offset to buffer. More...
 
static int32_t filesrc_get_property (StreamElement *element_ptr, uint16_t prop, uint64_t *val_ptr)
 This function get file source element properties. More...
 
static int32_t filesrc_set_property (StreamElement *element_ptr, uint16_t prop, uintptr_t val)
 This function set file source element properties. More...
 
int32_t filesrc_init (StreamElement *element)
 this function initializes the file source element and source pad. All the pad's handlers are intialized. More...
 
int32_t filesrc_set_location (ElementHandle element, char *path)
 Set a destination file to be read by file source element. More...
 
int32_t filesrc_get_location (ElementHandle element, char **pp_path)
 This function gets the location of the file. More...
 
int32_t filesrc_set_push_chunk_size (ElementHandle element, uint32_t chunk_size)
 Set the chunk size in which the file source sends the data in push mode. More...
 
int32_t filesrc_get_push_chunk_size (ElementHandle element, uint64_t *chunk_size)
 Get the chunk size in which the file source sends the data in push mode. More...
 
static FlowReturn filesrc_read (ElementFileSrc *filesrc, uint32_t offset, uint32_t length, StreamBuffer *buf)
 Function reads the data from the file specified by the element. NOTE: Function may or may not be able to read the required length of data. Returns FLOW_EOS when EOF file is encountered. or FLOW_UNEXPECTED when read fails. More...
 
int32_t file_query (int32_t fd, StreamInfoType info, StreamData *data)
 file_query More...
 

Function Documentation

◆ filesrc_src_pad_process()

int32_t filesrc_src_pad_process ( StreamPad *  pad)

filesrc_src_pad_process:

Parameters
padElement pad

◆ filesrc_change_state()

static int32_t filesrc_change_state ( StreamElement *  element,
PipelineState  state 
)
static
Parameters
elementPointer to element
statechanged state.

◆ filesrc_handle_src_event()

static uint8_t filesrc_handle_src_event ( StreamPad *  pad,
StreamEvent event 
)
static
Parameters
padElement pad
eventtype of event

◆ filesrc_handle_src_query()

static uint8_t filesrc_handle_src_query ( StreamPad *  pad,
StreamQuery query 
)
static
Parameters
padpad handle
queryquery
Returns
uint8_t

◆ filesrc_src_activate_push()

static uint8_t filesrc_src_activate_push ( StreamPad *  pad,
uint8_t  active 
)
static
Parameters
padElement pad
activetrue if pad is to be activated else false to deactivate

◆ filesrc_src_activate_pull()

static uint8_t filesrc_src_activate_pull ( StreamPad *  pad,
uint8_t  active 
)
static
Parameters
padElement pad
activetrue if pad is to be activated else false to deactivate

◆ filesrc_src_activate()

static uint8_t filesrc_src_activate ( StreamPad *  pad,
uint8_t  active 
)
static
Parameters
padQueue element src pad
activeTo activate or deactivate pad.

◆ filesrc_pull()

static FlowReturn filesrc_pull ( StreamPad *  pad,
StreamBuffer buffer,
uint32_t  size,
uint32_t  offset 
)
static
Parameters
padElement pad
bufferPointer of the buffer to read data
sizeNumber of bytes to read
offsetOffset to the file

◆ filesrc_get_property()

static int32_t filesrc_get_property ( StreamElement *  element_ptr,
uint16_t  prop,
uint64_t *  val_ptr 
)
static
Parameters
element_ptrelement pointer
propproperties
val_ptrparameters
Returns
StreamErrorType

◆ filesrc_set_property()

static int32_t filesrc_set_property ( StreamElement *  element_ptr,
uint16_t  prop,
uintptr_t  val 
)
static
Parameters
element_ptrelement pointer
propproperties
valparameters
Returns
StreamErrorType

◆ filesrc_init()

int32_t filesrc_init ( StreamElement *  element)
Parameters
elementpointer to element
Returns
StreamReturnType
Return values
STREAM_OKif successful
STREAM_ERR_INVALID_ARGSmeans invalid arguments

◆ filesrc_set_location()

int32_t filesrc_set_location ( ElementHandle  element,
char *  path 
)
Parameters
elementelement handle
pathpointer to a file path
Returns
StreamReturnType
Return values
STREAM_OKif successful
STREAM_ERR_INVALID_ARGSmeans invalid arguments

◆ filesrc_get_location()

int32_t filesrc_get_location ( ElementHandle  element,
char **  pp_path 
)
Parameters
elementelement handle
pp_pathlocation path
Returns
StreamReturnType
Return values
STREAM_OKif successful
STREAM_ERR_INVALID_ARGSmeans invalid arguments

◆ filesrc_set_push_chunk_size()

int32_t filesrc_set_push_chunk_size ( ElementHandle  element,
uint32_t  chunk_size 
)
Parameters
elementelement handle
chunk_sizechunk size
Returns
StreamReturnType
Return values
STREAM_OKif successful
STREAM_ERR_INVALID_ARGSmeans invalid arguments

◆ filesrc_get_push_chunk_size()

int32_t filesrc_get_push_chunk_size ( ElementHandle  element,
uint64_t *  chunk_size 
)
Parameters
elementelement handle
chunk_sizechunk size
Returns
StreamReturnType
Return values
STREAM_OKif successful
STREAM_ERR_INVALID_ARGSmeans invalid arguments

◆ filesrc_read()

static FlowReturn filesrc_read ( ElementFileSrc *  filesrc,
uint32_t  offset,
uint32_t  length,
StreamBuffer buf 
)
static
Parameters
filesrcPointer to filesrc element
offsetOffset of the file to read data from
lengthNumber of bytes to read
bufPointer to buffer to read data

◆ file_query()

int32_t file_query ( int32_t  fd,
StreamInfoType  info,
StreamData data 
)

Attempt to query information from a file

Parameters
fdFile handle
infoType of query
dataData pointer to result data
Returns
Status of query
Return values
STREAM_OKQuery was successful
STREAM_ERR_INFO_ABSENTFile does not supported specified query