MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _audio_dev_control

Function _audio_dev_control

components/drivers/audio/dev_audio.c:557–632  ·  view source on GitHub ↗

* @brief Control audio device * * @param[in] dev pointer to device * * @param[in] cmd audio cmd, it can be one of value in @ref group_audio_control * * @param[in] args command argument * * @return error code, RT_EOK is successful otherwise means failure */

Source from the content-addressed store, hash-verified

555 * @return error code, RT_EOK is successful otherwise means failure
556 */
557static rt_err_t _audio_dev_control(struct rt_device *dev, int cmd, void *args)
558{
559 rt_err_t result = RT_EOK;
560 struct rt_audio_device *audio;
561 RT_ASSERT(dev != RT_NULL);
562 audio = (struct rt_audio_device *) dev;
563
564 /* dev stat...*/
565 switch (cmd)
566 {
567 case AUDIO_CTL_GETCAPS:
568 {
569 struct rt_audio_caps *caps = (struct rt_audio_caps *) args;
570
571 LOG_D("AUDIO_CTL_GETCAPS: main_type = %d,sub_type = %d", caps->main_type, caps->sub_type);
572 if (audio->ops->getcaps != RT_NULL)
573 {
574 result = audio->ops->getcaps(audio, caps);
575 }
576
577 break;
578 }
579
580 case AUDIO_CTL_CONFIGURE:
581 {
582 struct rt_audio_caps *caps = (struct rt_audio_caps *) args;
583
584 LOG_D("AUDIO_CTL_CONFIGURE: main_type = %d,sub_type = %d", caps->main_type, caps->sub_type);
585 if (audio->ops->configure != RT_NULL)
586 {
587 result = audio->ops->configure(audio, caps);
588 }
589
590 break;
591 }
592
593 case AUDIO_CTL_START:
594 {
595 int stream = *(int *) args;
596
597 LOG_D("AUDIO_CTL_START: stream = %d", stream);
598 if (stream == AUDIO_STREAM_REPLAY)
599 {
600 result = _aduio_replay_start(audio);
601 }
602 else
603 {
604 result = _audio_record_start(audio);
605 }
606
607 break;
608 }
609
610 case AUDIO_CTL_STOP:
611 {
612 int stream = *(int *) args;
613
614 LOG_D("AUDIO_CTL_STOP: stream = %d", stream);

Callers

nothing calls this directly

Calls 4

_aduio_replay_startFunction · 0.85
_audio_record_startFunction · 0.85
_aduio_replay_stopFunction · 0.85
_audio_record_stopFunction · 0.85

Tested by

no test coverage detected