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

This file contains the audio sink element implementation. More...

#include <string.h>
#include "audio_cfg.h"
#include "streamer.h"
#include "decoder.h"
#include "audio_sink.h"
#include "pipeline.h"
#include "streamer_element_properties.h"

Functions

static uint8_t audiosink_sink_pad_activation_handler (StreamPad *pad, uint8_t active)
 This function activates the sink pad and allocates memory for the audio sink element.
 
static FlowReturn audiosink_sink_pad_chain_handler (StreamPad *pad, StreamBuffer *buffer)
 This pad function accumulates data from the decoder and pushes it onto the selected audio driver. The audio sink maintains a double buffer and starts sending data once both the buffers are full. It blocks if the previous data is not sent out by the driver for some reason.
 
static int32_t audiosink_sink_pad_process_handler (StreamPad *pad)
 Function is the loop function of the audio sink pad which runs in the task thread. It reads the chunk_size of data and pushes it to peer element sink pad.
 
static uint8_t audiosink_sink_pad_event_handler (StreamPad *pad, StreamEvent *event)
 This function is the calls the specified audio device driver implementation of the sink pad event handler.
 
static int32_t audiosink_change_state (StreamElement *element, PipelineState new_state)
 This function changes the audio sink state and calls the appropriate apis for that state and takes the actions and then returns. PipelineState Transition: NULL to READY: Initialize audio device (now, playback only) READY to PAUSE: Activate sink pads and their peer pads PAUSE to PLAY: Start Playing.
 
static uint8_t audiosink_sink_pad_query_handler (StreamPad *pad, StreamQuery *query)
 This pad function handles query from the pipeline. If not able to handle the query then it pushes the query to its peer.
 
static int32_t audiosink_get_property (StreamElement *element_ptr, uint16_t prop, uint32_t *val_ptr)
 This function gets audio sink element's properties.
 
static int32_t audiosink_set_property (StreamElement *element_ptr, uint16_t prop, uint32_t val)
 This function sets audio sink element's properties.
 
int32_t audiosink_init_element (StreamElement *element)
 This function initializes audio sink element and its sink pads.
 
AudioSinkStreamErrorType audiosink_set_device_driver_type (ElementHandle element, AudioSinkDeviceDriverType device_driver_type)
 This function sets the audio driver type as SSI or ALSA. Now, only a SSI interface is implemented.
 
AudioSinkStreamErrorType audiosink_set_device_name (ElementHandle element, AudioSinkDeviceName device_name)
 This function sets the audio device name. This API is provided just in case an enumeration is done by ALSA or OSS probably before opening the device.
 
AudioSinkStreamErrorType audiosink_set_device_string_name (ElementHandle element, char *device_string_name)
 This function sets the audio device string name.
 

Function Documentation

◆ audiosink_sink_pad_activation_handler()

static uint8_t audiosink_sink_pad_activation_handler ( StreamPad * pad,
uint8_t active )
static
Parameters
padpad handle
activeboolean o activate/disactivate pad
Returns
: pad error return

◆ audiosink_sink_pad_chain_handler()

static FlowReturn audiosink_sink_pad_chain_handler ( StreamPad * pad,
StreamBuffer * buffer )
static
Parameters
padpad instance
bufferinput buffer
Returns
: FlowReturn error types

◆ audiosink_sink_pad_process_handler()

static int32_t audiosink_sink_pad_process_handler ( StreamPad * pad)
static
Parameters
padElement pad

◆ audiosink_sink_pad_event_handler()

static uint8_t audiosink_sink_pad_event_handler ( StreamPad * pad,
StreamEvent * event )
static
Parameters
padpad instance
eventevent enumeration
Returns
: true or false

◆ audiosink_change_state()

static int32_t audiosink_change_state ( StreamElement * element,
PipelineState new_state )
static
Parameters
elementaudio sink element
new_stateaudio sink state to be changed
Returns
: int32_t

◆ audiosink_sink_pad_query_handler()

static uint8_t audiosink_sink_pad_query_handler ( StreamPad * pad,
StreamQuery * query )
static
Parameters
padpad instance
queryinput buffer
Returns
: true/false

◆ audiosink_get_property()

static int32_t audiosink_get_property ( StreamElement * element_ptr,
uint16_t prop,
uint32_t * val_ptr )
static
Parameters
element_ptraudio sink element instance
propaudio sink element property
val_ptrvalue pointer
Returns
AudioSinkStreamErrorType
Return values
AUDIO_SINK_SUCCESS
AUDIO_SINK_ERROR_INVALID_ARGS
AUDIO_SINK_ERROR_NO_RESOURCE

◆ audiosink_set_property()

static int32_t audiosink_set_property ( StreamElement * element_ptr,
uint16_t prop,
uint32_t val )
static
Parameters
element_ptraudio sink element instance
propaudio sink element property
valvalue pointer
Returns
AudioSinkStreamErrorType
Return values
AUDIO_SINK_SUCCESS
AUDIO_SINK_ERROR_INVALID_ARGS
AUDIO_SINK_ERROR_NO_RESOURCE

◆ audiosink_init_element()

int32_t audiosink_init_element ( StreamElement * element)
Parameters
elementaudio sink element
Returns
AudioSinkStreamErrorType
Return values
AUDIO_SINK_SUCCESSsuccess
AUDIO_SINK_ERROR_INVALID_ARGSinvalid argument

◆ audiosink_set_device_driver_type()

AudioSinkStreamErrorType audiosink_set_device_driver_type ( ElementHandle element,
AudioSinkDeviceDriverType device_driver_type )
Parameters
elementaudio sink element
device_driver_typeset audio device driver type relate with AudioSinkDeviceDriverType
Note
This function should be called only at STATE_NULL state
Returns
AudioSinkStreamErrorType
Return values
AUDIO_SINK_SUCCESSsuccess
AUDIO_SINK_ERROR_INVALID_ARGSinvalid argument
AUDIO_SINK_ERROR_BAD_STATEif element state is not STATE_NULL

◆ audiosink_set_device_name()

AudioSinkStreamErrorType audiosink_set_device_name ( ElementHandle element,
AudioSinkDeviceName device_name )
Parameters
elementaudio sink element
device_nameset audio device name
Returns
AudioSinkStreamErrorType
Return values
AUDIO_SINK_SUCCESSsuccess
AUDIO_SINK_ERROR_INVALID_ARGSinvalid arguments

◆ audiosink_set_device_string_name()

AudioSinkStreamErrorType audiosink_set_device_string_name ( ElementHandle element,
char * device_string_name )
Parameters
elementaudio sink element
device_string_nameset audio device string name
Returns
AudioSinkStreamErrorType
Return values
AUDIO_SINK_SUCCESS
AUDIO_SINK_ERROR_INVALID_ARGS