USBD_Audio_DrvStreamRecordRx

USBD_Audio_DrvStreamRecordRx

Description

Get a ready record buffer from codec.

Files

usbd_audio_drv_<codec-name>.h / usbd_audio_drv_<codec-name>.c

Prototype

static void USBD_Audio_DrvStreamRecordRx (USBD_AUDIO_DRV *p_audio_drv, CPU_INT08U terminal_id_link, void *p_buf, CPU_INT16U *p_buf_len, USBD_ERR *p_err)

 

Arguments

p_audio_drv

Pointer to audio driver structure.

terminal_id_link

Terminal ID associated to this stream.

p_buf

Pointer to record buffer.

p_buf_len

Pointer to buffer length in bytes.

p_err

Pointer to variable that will receive the return error code from this function.

USBD_ERR_NONE 

USBD_ERR_RX

Returned Value

None.

...Pointer to a ready record buffer, if NO error(s) occurred.

Null pointer, otherwise. 

Callers

Audio Class.

Implementation guidelines

This listing shows an example usage of this function.

Listing - USBD_Audio_DrvStreamRecordRx() Example Usage
static void *USBD_Audio_DrvStreamRecordRx (USBD_AUDIO_DRV *p_audio_drv, CPU_INT08U terminal_id_link, void *p_buf, CPU_INT16U *p_buf_len, USBD_ERR *p_err) { /* $$$$ Retrieve a ready record buffer. */ (1) }

(1) When an audio transfer is completed, the codec driver should signal the record task that a buffer is ready by sending calling the function USBD_Audio_RecordRxCmpl. This function will post a request to the record task. Upon reception of this request, the record task will call the function USBD_Audio_DrvStreamRecordRx() through a function pointer to get a ready buffer. If the audio peripheral uses DMA, the buffer is already ready and there is nothing special to do in this function. If the audio peripheral uses a FIFO mode, you may have to copy the received audio samples to the buffer referenced by the pointer p_buf.

(2) In case of error, you may return the error code USBD_ERR_RX.