USBD_Audio_DrvStreamStop
Description
Stop record or playback stream.
Files
usbd_audio_drv_<codec-name>.h / usbd_audio_drv_<codec-name>.c
Prototype
static CPU_BOOLEAN USBD_Audio_DrvStreamStop (USBD_AUDIO_DRV *p_audio_drv, CPU_INT08U terminal_id_link);
Arguments
p_audio_drv
Pointer to audio driver structure.
terminal_id_link
AudioStreaming terminal link.
Returned Value
DEF_OK
, if NO error(s) occurred.
DEF_FAIL
, otherwise.
Callers
Audio Class.
Implementation guidelines
This listing shows an example usage of this function handling record and playback streams.
static CPU_BOOLEAN USBD_Audio_DrvStreamStop (USBD_AUDIO_DRV *p_audio_drv, CPU_INT08U terminal_id_link) { if (terminal_id_link == Mic_OT_USB_IN_ID) { (1) /* $$$$ Abort ongoing DMA transfer(s). */ (2) /* $$$$ Disable record operations on audio chip. */ (3) } else if (terminal_id_link == Speaker_IT_USB_OUT_ID) { /* $$$$ Abort ongoing DMA transfer(s). */ (2) /* $$$$ Disable playback operations on audio chip. */ (3) } return (DEF_OK); }
(1) If the function handles different streams, the terminal ID allows to differentiate them.
(2) Abort ongoing DMA transfer(s). The buffer associated to the DMA transfer may be freed with USBD_Audio_RecordBufFree()
or USBD_Audio_PlaybackBufFree
into the ISR responsible for DMA data transfer completion.
(3) You may have to disable the record or playback operations on the audio chip. It could be disabling some clocks, disabling some modules, etc. It may require sending a series of I2C commands for registers access,