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

This file implement audio source. More...

#include <string.h>
#include "audio_cfg.h"
#include "streamer_element.h"
#include "audio_src.h"
#include "pipeline.h"
#include "streamer_element_properties.h"

Functions

static int32_t audiosrc_src_process (StreamPad *pad)
 Function is the loop function of the audiosrc source pad which runs in the task thread. It reads the chunk_size of data and pushes it to peer element sink pad.
 
static FlowReturn audiosrc_src_pull_handler (StreamPad *pad, StreamBuffer *buffer, uint32_t size, uint32_t offset)
 Function is the pull function of the audiosrc source pad in SCHEDULING_PULL mode. It reads the size of data from the offset to buffer.
 
static int32_t audiosrc_change_state (StreamElement *element, PipelineState state)
 Function handles the state change of the element in a pipeline.
 
static uint8_t audiosrc_handle_src_event (StreamPad *pad, StreamEvent *event)
 Function handles the events of the element source pad.
 
static uint8_t audiosrc_handle_src_query (StreamPad *pad, StreamQuery *query)
 This function is the empty impl of the src pad query handler.
 
static uint8_t audiosrc_src_activate_push (StreamPad *pad, uint8_t active)
 Activates or deactivates the audiosrc source pad in PUSH mode.
 
static uint8_t audiosrc_src_activate_pull (StreamPad *pad, uint8_t active)
 Activates or deactivates the audiosrc source pad in PUSH mode.
 
static uint8_t audiosrc_src_activate (StreamPad *pad, uint8_t active)
 Queue src pad activation handler. Activation is handled by the peer sink pad, this should just handle the deactivation.
 
static int32_t audiosrc_get_property (StreamElement *element_ptr, uint16_t prop, uint64_t *val_ptr)
 This function get audio source element properties.
 
static int32_t audiosrc_set_property (StreamElement *element_ptr, uint16_t prop, uint32_t val)
 This function set audio source element properties.
 
static int32_t audiosrc_set_device_name (ElementHandle element, const char *device_name, const char *output_device_name)
 This function sets the device name.
 
static int32_t audiosrc_set_device_type (ElementHandle element, uint32_t device_type)
 This function sets the device driver type.
 
static int32_t audiosrc_set_push_chunk_size (ElementHandle element, uint32_t chunk_size)
 This function sets the chunk size in which the audio source sends the data when src pad is activated in push mode.
 
static int32_t audiosrc_get_push_chunk_size (ElementHandle element, uint64_t *chunk_size)
 This function gets the chunk size.
 
static int32_t audiosrc_set_sampling_rate (ElementHandle element, uint32_t sample_rate)
 This function sets the device name.
 
static int32_t audiosrc_set_continuous_read (ElementHandle element, bool continuous_read)
 This function sets the continuous read property.
 
static int32_t audiosrc_set_dummy_tx_enable (ElementHandle element, bool dummy_tx)
 This function sets the dummy rx enable property.
 
static int32_t audiosrc_set_num_channels (ElementHandle element, uint32_t num_channels)
 This function sets the number of channels in which the audio source sends the data when src pad is activated in push mode.
 
int32_t audiosrc_init (StreamElement *element)
 This function initializes audio source element and its source pads.
 
static int32_t audiosrc_set_bits_per_sample (ElementHandle element, uint32_t bits_per_sample)
 This function sets the number of channels in which the audio source sends the data when src pad is activated in push mode.
 
static int32_t audiosrc_set_frame_ms (ElementHandle element, uint32_t frame_ms)
 This function sets the number of frame millisecond in which the audio source sends the data when src pad is activated in push mode.
 
static FlowReturn audiosrc_read (ElementAudioSrc *audiosrc, 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.
 

Variables

static AudioSrcStreamErrorType(* AudioSrcOpenDevice [LAST_AUDIOSRC_DEVICE_DRIVER_TYPE])(ElementAudioSrc *audiosrc)
 
static AudioSrcStreamErrorType(* AudioSrcCloseDevice [LAST_AUDIOSRC_DEVICE_DRIVER_TYPE])(ElementAudioSrc *audiosrc)
 
static AudioSrcStreamErrorType(* AudioSrcStartDevice [LAST_AUDIOSRC_DEVICE_DRIVER_TYPE])(ElementAudioSrc *audiosrc)
 
static AudioSrcStreamErrorType(* AudioSrcStopDevice [LAST_AUDIOSRC_DEVICE_DRIVER_TYPE])(ElementAudioSrc *audiosrc)
 
static AudioSrcStreamErrorType(* AudioSrcReadDevice [LAST_AUDIOSRC_DEVICE_DRIVER_TYPE])(ElementAudioSrc *audiosrc, uint32_t len, StreamBuffer *buf)
 

Function Documentation

◆ audiosrc_src_process()

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

◆ audiosrc_src_pull_handler()

static FlowReturn audiosrc_src_pull_handler ( StreamPad * pad,
StreamBuffer * buffer,
uint32_t size,
uint32_t offset )
static
Parameters
padPad pointer
bufferBuffer pointer
sizeData size
offsetOffset to be read
Returns
FlowReturn

◆ audiosrc_change_state()

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

◆ audiosrc_handle_src_event()

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

◆ audiosrc_handle_src_query()

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

◆ audiosrc_src_activate_push()

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

◆ audiosrc_src_activate_pull()

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

◆ audiosrc_src_activate()

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

◆ audiosrc_get_property()

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

◆ audiosrc_set_property()

static int32_t audiosrc_set_property ( StreamElement * element_ptr,
uint16_t prop,
uint32_t val )
static
Parameters
element_ptrelement pointer
propproperties
valparameters
Returns
AudioSinkStreamErrorType

◆ audiosrc_set_device_name()

static int32_t audiosrc_set_device_name ( ElementHandle element,
const char * device_name,
const char * output_device_name )
static

audiosrc_set_device_name:

Parameters
elementelement handle
device_namedevice name for ipod, line in and mic.
output_device_namethe output device name is the corresponding device that is in this streamer sink. This info is used to config and open the pcmmgr device.
Returns
StreamReturnType

◆ audiosrc_set_device_type()

static int32_t audiosrc_set_device_type ( ElementHandle element,
uint32_t device_type )
static
Parameters
elementelement handle
device_typedevice type
Returns
StreamReturnType

◆ audiosrc_set_push_chunk_size()

static int32_t audiosrc_set_push_chunk_size ( ElementHandle element,
uint32_t chunk_size )
static
Parameters
elementelement handle
chunk_sizechunk size
Returns
StreamReturnType

◆ audiosrc_get_push_chunk_size()

static int32_t audiosrc_get_push_chunk_size ( ElementHandle element,
uint64_t * chunk_size )
static
Parameters
elementelement handle
chunk_sizechunk size
Returns
StreamReturnType

◆ audiosrc_set_sampling_rate()

static int32_t audiosrc_set_sampling_rate ( ElementHandle element,
uint32_t sample_rate )
static
Parameters
elementelement handle
sample_ratesample rate to be set
Returns
StreamReturnType

◆ audiosrc_set_continuous_read()

static int32_t audiosrc_set_continuous_read ( ElementHandle element,
bool continuous_read )
static
Parameters
elementelement handle
continuous_readdetermines whether the device is in continuous read state or not.
Returns
StreamReturnType

◆ audiosrc_set_dummy_tx_enable()

static int32_t audiosrc_set_dummy_tx_enable ( ElementHandle element,
bool dummy_tx )
static
Parameters
elementelement handle
dummy_txenable sai tx to have clocks on rx correctly
Returns
StreamReturnType

◆ audiosrc_set_num_channels()

static int32_t audiosrc_set_num_channels ( ElementHandle element,
uint32_t num_channels )
static
Parameters
elementelement handle
num_channelsnumber of channels
Returns
StreamReturnType

◆ audiosrc_init()

int32_t audiosrc_init ( StreamElement * element)
Parameters
elementaudio source element
Returns
AudioSourceStreamErrorType
Return values
AUDIOSRC_SUCCESSsuccess
AUDIOSRC_ERROR_INVALID_ARGSinvalid argument

◆ audiosrc_set_bits_per_sample()

static int32_t audiosrc_set_bits_per_sample ( ElementHandle element,
uint32_t bits_per_sample )
static
Parameters
elementelement handle
bits_per_samplebits per sample
Returns
StreamReturnType

◆ audiosrc_set_frame_ms()

static int32_t audiosrc_set_frame_ms ( ElementHandle element,
uint32_t frame_ms )
static
Parameters
elementelement handle
frame_msframe_ms
Returns
StreamReturnType

◆ audiosrc_read()

static FlowReturn audiosrc_read ( ElementAudioSrc * audiosrc,
uint32_t offset,
uint32_t length,
StreamBuffer * buf )
static
Parameters
audiosrcPointer to audiosrc element
offsetOffset of the file to read data from (not used here)
lengthNumber of bytes to read
bufPointer to buffer to read data

Returns FLOW_OK or FLOW_ERROR when read fails.

Variable Documentation

◆ AudioSrcOpenDevice

AudioSrcStreamErrorType(* AudioSrcOpenDevice[LAST_AUDIOSRC_DEVICE_DRIVER_TYPE])(ElementAudioSrc *audiosrc) ( ElementAudioSrc * audiosrc)
static
Initial value:
= {
}

AudioSrcOpenDevice:

◆ AudioSrcCloseDevice

AudioSrcStreamErrorType(* AudioSrcCloseDevice[LAST_AUDIOSRC_DEVICE_DRIVER_TYPE])(ElementAudioSrc *audiosrc) ( ElementAudioSrc * audiosrc)
static
Initial value:
= {
}

AudioSrcCloseDevice:

◆ AudioSrcStartDevice

AudioSrcStreamErrorType(* AudioSrcStartDevice[LAST_AUDIOSRC_DEVICE_DRIVER_TYPE])(ElementAudioSrc *audiosrc) ( ElementAudioSrc * audiosrc)
static
Initial value:
= {
}

AudioSrcStartDevice:

◆ AudioSrcStopDevice

AudioSrcStreamErrorType(* AudioSrcStopDevice[LAST_AUDIOSRC_DEVICE_DRIVER_TYPE])(ElementAudioSrc *audiosrc) ( ElementAudioSrc * audiosrc)
static
Initial value:
= {
}

AudioSrcStopDevice:

◆ AudioSrcReadDevice

AudioSrcStreamErrorType(* AudioSrcReadDevice[LAST_AUDIOSRC_DEVICE_DRIVER_TYPE])(ElementAudioSrc *audiosrc, uint32_t len, StreamBuffer *buf) ( ElementAudioSrc * audiosrc,
uint32_t len,
StreamBuffer * buf )
static
Initial value:
= {
}

AudioSrcReadDevice: