| Maestro Audio Framework v 1.0 NXP Semiconductors

Typedefs | Functions
streamer_pcm.h File Reference

Streamer PCM API header. More...

## Typedefs
typedef void * | 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_t * | streamer_pcm_open (uint32_t num_buffers)
| Open the PCM interface for writing and configuring. More...
pcm_rtos_t * | streamer_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, uint8_t *next_buffer, 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)
| 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...

## Detailed Description

Public APIs for configuring the input/output PCM interfaces

## 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_buffers | Number 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_buffers | Number 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

  pcm | Pointer 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

  pcm | Pointer 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

  pcm | Pointer 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

  pcm | Pointer 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

  pcm | Pointer to PCM interface handle
  data | Pointer to data buffer with PCM data
  size | Size 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,
|  | uint8_t * | next_buffer,
|  | 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

  pcm | Pointer to PCM interface handle
  data | Pointer to data buffer with PCM data
  next_buffer | Pointer to next data buffer with PCM data
  size | Size 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
| ) |  |

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

  pcm | Pointer to PCM interface handle
  sample_rate | Sample rate in Hz of the PCM data
  bit_width | Size of each PCM data sample, in bits
  num_channels | Number of channels of audio data for each PCM frame
  transfer | Flag for setting params of input/output pcm interface

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

  pcm | Pointer to PCM interface handle
  sample_rate | Pointer to pcm handle sample rate
  bit_width | Pointer to pcm handle bit width
  num_channels | Pointer 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

  pcm | Pointer to PCM interface handle
  mute | Boolean indicated true/false requested codec mute state

Returns
  0 on success, non-zero on failure