Maestro Audio Framework v 1.5
NXP Semiconductors
streamer_pcm.h File Reference

Streamer PCM API header. Public APIs for configuring the input/output PCM interfaces. More...

Typedefs

typedef struct _pcm_rtos_t pcm_rtos_t
 Opaque type for PCM interface Application should extend this for PCM interface implementation.
 

Functions

void streamer_pcm_init (void)
 Initialize the PCM interface. More...
 
pcm_rtos_tstreamer_pcm_open (uint32_t num_buffers)
 Open the PCM interface for writing and configuring. More...
 
pcm_rtos_tstreamer_pcm_rx_open (uint32_t num_buffers)
 Open the receive PCM interface for reading and configuring. More...
 
void streamer_pcm_close (pcm_rtos_t *pcm)
 Close the PCM interface. More...
 
void streamer_pcm_rx_close (pcm_rtos_t *pcm)
 Close the receive PCM interface. More...
 
void streamer_pcm_start (pcm_rtos_t *pcm)
 Start playback on the PCM interface. More...
 
void streamer_pcm_rx_start (pcm_rtos_t *pcm)
 Start recording with the PCM interface. More...
 
int streamer_pcm_write (pcm_rtos_t *pcm, uint8_t *data, uint32_t size)
 Write audio data to the PCM interface. More...
 
int streamer_pcm_read (pcm_rtos_t *pcm, uint8_t *data, uint32_t size)
 Read audio data from the input PCM interface. More...
 
int streamer_pcm_setparams (pcm_rtos_t *pcm, uint32_t sample_rate, uint32_t bit_width, uint8_t num_channels, bool transfer, bool dummy_tx, int volume)
 Set PCM interface parameters. More...
 
void streamer_pcm_getparams (pcm_rtos_t *pcm, uint32_t *sample_rate, uint32_t *bit_width, uint8_t *num_channels)
 Get PCM interface parameters. More...
 
int streamer_pcm_mute (pcm_rtos_t *pcm, bool mute)
 Set PCM interface mute status. More...
 
int streamer_pcm_set_volume (pcm_rtos_t *pcm, int volume)
 Set PCM interface output volume. More...
 

Function Documentation

◆ streamer_pcm_init()

void streamer_pcm_init ( void  )

This function initializes the PCM interface for audio data output to a speaker or input from a microphone on a specific target hardware platform. This function should be executed directly by the application or other middleware library, and should be called before any other PCM interface functions. This function is responsible for initializing and configuring audio output peripherals, DMA and codecs so that they are ready to utilitize the PCM interface library.

◆ streamer_pcm_open()

pcm_rtos_t * streamer_pcm_open ( uint32_t  num_buffers)

This function returns a handle to the PCM interface that can be used for configuration and writing the data.

This function is called from the streamer when it is placed into a playing state, before audio output starts.

Parameters
num_buffersNumber of buffers to be used
Returns
Pointer to handle for PCM interface

◆ streamer_pcm_rx_open()

pcm_rtos_t * streamer_pcm_rx_open ( uint32_t  num_buffers)

This function returns a handle to the PCM interface that can be used for configuration and reading the data.

This function is called from the streamer when it is placed into a playing state, before audio input starts.

Parameters
num_buffersNumber of buffers to be used
Returns
Pointer to handle for PCM interface

◆ streamer_pcm_close()

void streamer_pcm_close ( pcm_rtos_t pcm)

This function closes the handle to the PCM interface

This function is called from the streamer when it is placed into a stopped state.

Parameters
pcmPointer to PCM interface handle

◆ streamer_pcm_rx_close()

void streamer_pcm_rx_close ( pcm_rtos_t pcm)

This function closes the handle to the PCM interface

This function is called from the streamer when it is placed into a stopped state.

Parameters
pcmPointer to PCM interface handle

◆ streamer_pcm_start()

void streamer_pcm_start ( pcm_rtos_t pcm)

This function places the PCM interface into a started state

This function is called from the streamer when it is placed into a playing state at the start of audio playback.

Parameters
pcmPointer to PCM interface handle

◆ streamer_pcm_rx_start()

void streamer_pcm_rx_start ( pcm_rtos_t pcm)

This function places the recording PCM interface into a started state

This function is called from the streamer when it is placed into a playing state at the start of audio recording.

Parameters
pcmPointer to PCM interface handle

◆ streamer_pcm_write()

int streamer_pcm_write ( pcm_rtos_t pcm,
uint8_t *  data,
uint32_t  size 
)

This function writes raw PCM data to the PCM output interface

This function is called from the streamer to output decoded audio data.

Parameters
pcmPointer to PCM interface handle
dataPointer to data buffer with PCM data
sizeSize in bytes of the data buffer
Returns
0 on success, non-zero on failure

◆ streamer_pcm_read()

int streamer_pcm_read ( pcm_rtos_t pcm,
uint8_t *  data,
uint32_t  size 
)

This function reads raw PCM data from the PCM input interface

This function is called from the streamer to input raw audio data.

Parameters
pcmPointer to PCM interface handle
dataPointer to next data buffer with PCM data
sizeSize in bytes of the data buffer
Returns
0 on success, non-zero on failure

◆ streamer_pcm_setparams()

int streamer_pcm_setparams ( pcm_rtos_t pcm,
uint32_t  sample_rate,
uint32_t  bit_width,
uint8_t  num_channels,
bool  transfer,
bool  dummy_tx,
int  volume 
)

This function is called from the streamer after the start of audio data decode, once the parameters of the data format are known. The PCM interface should be configured to match these parameters. The pcm handle should reflect the values configured.

If the PCM interface cannot support these parameters, the pcm handle should be set to the nearest values the interface can support and success should be returned. These will be queried by the streamer with streamer_pcm_getparams, and the streamer will resample or reconfigure the audio format to fit the desired output.

Parameters
pcmPointer to PCM interface handle
sample_rateSample rate in Hz of the PCM data
bit_widthSize of each PCM data sample, in bits
num_channelsNumber of channels of audio data for each PCM frame
transferFlag for setting params of input/output pcm interface
dummy_txDummy tx setting for clock enablement
volumeOutput volume
Returns
0 on success, non-zero on failure

◆ streamer_pcm_getparams()

void streamer_pcm_getparams ( pcm_rtos_t pcm,
uint32_t *  sample_rate,
uint32_t *  bit_width,
uint8_t *  num_channels 
)

This function is called by the streamer after streamer_pcm_setparams, and should reflect what parameters can be supported by the PCM interface. If these do not match what was requested in streamer_pcm_setparams, the streamer will attempt to configure SRC or other behavior to adjust the data format. If the streamer cannot support this, it will return a failure status to the application via the message task.

Parameters
pcmPointer to PCM interface handle
sample_ratePointer to pcm handle sample rate
bit_widthPointer to pcm handle bit width
num_channelsPointer to pcm handle number of channels

◆ streamer_pcm_mute()

int streamer_pcm_mute ( pcm_rtos_t pcm,
bool  mute 
)

This function is called by the streamer while entering the stopped state to mute the PCM output codec. This function is optional to implement as not all codecs will support this functionality.

Parameters
pcmPointer to PCM interface handle
muteBoolean indicated true/false requested codec mute state
Returns
0 on success, non-zero on failure

◆ streamer_pcm_set_volume()

int streamer_pcm_set_volume ( pcm_rtos_t pcm,
int  volume 
)

This function is called by the application interface to adjust the output volume for the PCM interface.

Parameters
pcmPointer to PCM interface handle
volumeVolume on a scale from 0-100
Returns
0 on success, non-zero on failure