Maestro Audio Framework v 1.7
NXP Semiconductors
Loading...
Searching...
No Matches
pipeline.c File Reference

The implementation for the Af Streamer pipeline. More...

#include <string.h>
#include "audio_cfg.h"
#include "streamer_api.h"
#include "streamer.h"
#include "pipeline.h"
#include "streamer_element.h"

Functions

static StreamElement * find_element_sibling_list (StreamElement *list_head, StreamElementType type, int8_t key)
 find_element_sibling_list
 
static int pipeline_path_blocked (StreamElement *element)
 Pipeline Path Blocked?
 
int32_t create_pipeline (PipelineHandle *handle, unsigned int index, osa_msgq_handle_t *app_mq)
 create_pipeline
 
int32_t destroy_pipeline (PipelineHandle handle)
 destroy_pipeline
 
PipelineState get_state_pipeline (PipelineHandle handle)
 get_state_pipeline
 
int32_t set_state_pipeline (PipelineHandle handle, PipelineState state)
 set_state_pipeline
 
int32_t seek_pipeline (PipelineHandle handle, uint32_t time_msec)
 seek_pipeline
 
int32_t seek_relative (PipelineHandle handle, int32_t time_msec)
 seek_relative
 
int32_t query_info_pipeline (PipelineHandle handle, StreamInfoType info_type, StreamData *data)
 query_info_pipeline:
 
int32_t add_element_pipeline (PipelineHandle pipeline_handle, ElementHandle element_handle, int8_t level)
 add_element_pipeline
 
int32_t remove_element_pipeline (PipelineHandle pipeline_handle, ElementHandle element_handle)
 remove_element_pipeline
 
int32_t get_element_pipeline (PipelineHandle pipeline_handle, StreamElementType type, int8_t key, ElementHandle *handle)
 get_element_pipeline
 
int32_t send_msg_pipeline (Pipeline *pipeline, StreamMessage *msg)
 send_msg_pipeline
 
int32_t process_pipeline (PipelineHandle handle)
 Process Pipeline.
 
int32_t set_repeat_pipeline (PipelineHandle handle, bool repeat)
 Set pipeline repeat mode.
 
bool get_repeat_pipeline (PipelineHandle handle)
 Get pipeline repeat mode.
 
void clear_pipeline_trackinfo (PipelineHandle handle)
 Clears the pipeline track info cache.
 
int32_t is_element_in_pipeline (PipelineElements pipe_elems, ElementIndex id)
 

Function Documentation

◆ find_element_sibling_list()

static StreamElement * find_element_sibling_list ( StreamElement * list_head,
StreamElementType type,
int8_t key )
static

Finds an element within a specified level of the pipeline. This functions iterates through the siblings at a specified level pointed to by 'list_head' and tries to find the element matching the values provided for Type and Key.

Parameters
list_headPointer to element at head of a pipeline level.
typeType of element
keyUnique Key value to identify the element
Returns
StreamElement* Pointer to element

◆ pipeline_path_blocked()

static int pipeline_path_blocked ( StreamElement * element)
static

Check to see if the pipeline path is blocked starting with the element passed in.

Parameters
elementPointer to an element in the pipeline marking the start of the current data flow path.
Returns
Pipeline Path is Blocked?
Return values
0Path is NOT BLOCKED
1Path is blocked

◆ create_pipeline()

int32_t create_pipeline ( PipelineHandle * handle,
unsigned int index,
osa_msgq_handle_t * app_mq )

Create a pipeline object within the streamer task

Parameters
[in]handlePointer to pipeline
[in]indexIndex of pipeline within streamer task
[in]app_mqApplication message queue
Returns
Error Status
Return values
STREAM_OKSuccess
STREAM_ERR_INVALID_ARGSInvalid pipeline handle
STREAM_ERR_NO_MEMUnable to allocate memory

◆ destroy_pipeline()

int32_t destroy_pipeline ( PipelineHandle handle)

Sets the pipeline state to NULL and destroys the pipeline with all the elements added.

Parameters
[in]handlePointer to pipeline
Returns
Error Status
Return values
STREAM_OKSuccess
STREAM_ERR_INVALID_ARGSInvalid Pipeline object

◆ get_state_pipeline()

PipelineState get_state_pipeline ( PipelineHandle handle)

Get the current state of the pipeline

Parameters
[in]handlePointer to pipeline
Returns
Current Pipeline State
Return values
STATE_NULLPipeline is in NULL state
STATE_READYPipeline is in Ready state
STATE_PAUSEDPipeline is in Paused state
STATE_PLAYINGPipeline is in Playing state

◆ set_state_pipeline()

int32_t set_state_pipeline ( PipelineHandle handle,
PipelineState state )

Sets a new state of the pipeline if not already in the same state. This takes care of any intermediate states like changing state from NULL to PLAYING.

The order of the states is NULL, READY, PAUSED and then PLAYING. Element can switch from any state to another, but in steps of one.

Once a state change is requested, the pipeline elements are iterated from the sink elements to the source elements. This makes sure that when changing the state of an element, the downstream elements are in the correct state to process the eventual buffers. In the case of a downwards state change, e.g. PLAYING ->NULL, the sink elements will shut down first which makes the upstream elements shutdown as well since the _push() function returns a FLOW_WRONG_STATE error.

Parameters
handlePointer to pipeline
stateNew pipeline state
Returns
Error Status
Return values
STREAM_OKState retrieved successfully.
STREAM_ERR_INVALID_ARGSInvalid pipeline object

◆ seek_pipeline()

int32_t seek_pipeline ( PipelineHandle handle,
uint32_t time_msec )

Seeks the playback position to a specified absolute time in msec. This is valid only in playing and paused state. Pipeline returns to the last when seek is done.

Parameters
handlePipeline handle
time_msecSeek time specified in msec.
Returns
Error Status
Return values
STREAM_OKSeek successful
STREAM_ERR_INVALID_ARGSInvalid Pipeline object
STREAM_ERR_NOT_SEEKABLEPipeline does not support seeking

◆ seek_relative()

int32_t seek_relative ( PipelineHandle handle,
int32_t time_msec )

Seeks the playback position to a time specified relative to the current playback position. This is valid only in playing and paused state. Pipeline returns to the last when seek is done.

Parameters
handlePipeline handle
time_msecSeek time specified in msec.
Returns
Error Status
Return values
STREAM_OKSeek successful
STREAM_ERR_INVALID_ARGSInvalid Pipeline object
STREAM_ERR_INFO_ABSENTUnable to determine current position
STREAM_ERR_NOT_SEEKABLEPipeline does not support seeking

◆ query_info_pipeline()

int32_t query_info_pipeline ( PipelineHandle handle,
StreamInfoType info_type,
StreamData * data )

Function to return info of the current playing/paused stream.

Parameters
handlePipeline handle
info_typeInfo type queried
dataHolds return query value
Returns
Error Status
Return values
STREAM_OKQuery successful
STREAM_ERR_INFO_ABSENTQuery unsuccessful. Info not present
STREAM_ERR_INVALID_ARGSInvalid pipeline object

◆ add_element_pipeline()

int32_t add_element_pipeline ( PipelineHandle pipeline_handle,
ElementHandle element_handle,
int8_t level )

Function to add element in a already created pipeline. If not already added in the pipeline then it is added in the pipeline so that it can be linked with other elements in the pipeline.

Parameters
pipeline_handlePipeline handle
element_handleElement handle
levelLevel of the element
Returns
Error Status
Return values
STREAM_OKElement successfully added to pipeline
STREAM_ERR_INVALID_ARGSInvalid pipeline or element object

◆ remove_element_pipeline()

int32_t remove_element_pipeline ( PipelineHandle pipeline_handle,
ElementHandle element_handle )

Function to remove element in a already created pipeline. This element should not be linked with any other pipeline before calling this function.

Parameters
pipeline_handlePipeline handle
element_handleElement handle
Returns
Error Status
Return values
STREAM_OKElement removed from pipeline
STREAM_ERR_INVALID_ARGSInvalid pipeline or element object

◆ get_element_pipeline()

int32_t get_element_pipeline ( PipelineHandle pipeline_handle,
StreamElementType type,
int8_t key,
ElementHandle * handle )

Function to return tag of the current playing/paused stream.

Parameters
pipeline_handlePipeline handle
typeElement type
keyUnique key used in creating the element
handlePointer to the element handle
Returns
Error Status
Return values
STREAM_OKElement handle successfully retrieved
STREAM_ERR_INVALID_ARGSInvalid pipeline object or element not found

◆ send_msg_pipeline()

int32_t send_msg_pipeline ( Pipeline * pipeline,
StreamMessage * msg )

The function sends the message to the callback function associated with the pipeline.

Parameters
pipelinePipeline to send the message to
msgStreamMessage pointer
Returns
Error Status
Return values
STREAM_OKMessage successfully sent
STREAM_ERR_INVALID_ARGSInvalid pipeline or message object

◆ process_pipeline()

int32_t process_pipeline ( PipelineHandle handle)

Iterate through the elements of a pipeline calling process handlers for non-blocked elements

Parameters
[in]handlePointer to pipeline
Returns
Error Status
Return values
STREAM_OKSuccess
STREAM_ERR_INVALID_ARGSInvalid Pipeline specified

◆ set_repeat_pipeline()

int32_t set_repeat_pipeline ( PipelineHandle handle,
bool repeat )

Set the repeat mode of a pipeline, if repeat mode is true, pipeline will play current stream repeatly when received a MSG_EOS event.

Parameters
handlePointer to a pipeline object
repeatrepeat true or false
Returns
none

◆ get_repeat_pipeline()

bool get_repeat_pipeline ( PipelineHandle handle)
Parameters
handlePointer to a pipeline object
Returns
repeat repeat true or false

◆ clear_pipeline_trackinfo()

void clear_pipeline_trackinfo ( PipelineHandle handle)

Clears all track info from the pipeline cache

Parameters
handlePointer to a pipeline object
Returns
none