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

Function rt_audio_register

components/drivers/audio/dev_audio.c:659–691  ·  view source on GitHub ↗

* @brief Register and initialize audio device * * @param[in] audio pointer to audio deive * * @param[in] name device name * * @param[in] flag device flags * * @param[in] data user data * * @return error code, RT_EOK is successful otherwise means failure */

Source from the content-addressed store, hash-verified

657 * @return error code, RT_EOK is successful otherwise means failure
658 */
659rt_err_t rt_audio_register(struct rt_audio_device *audio, const char *name, rt_uint32_t flag, void *data)
660{
661 rt_err_t result = RT_EOK;
662 struct rt_device *device;
663
664 RT_ASSERT(audio != RT_NULL);
665 device = &(audio->parent);
666
667 device->type = RT_Device_Class_Sound;
668 device->rx_indicate = RT_NULL;
669 device->tx_complete = RT_NULL;
670
671#ifdef RT_USING_DEVICE_OPS
672 device->ops = &audio_ops;
673#else
674 device->init = _audio_dev_init;
675 device->open = _audio_dev_open;
676 device->close = _audio_dev_close;
677 device->read = _audio_dev_read;
678 device->write = _audio_dev_write;
679 device->control = _audio_dev_control;
680#endif
681 device->user_data = data;
682
683 /* register a character device */
684 result = rt_device_register(device, name, flag | RT_DEVICE_FLAG_REMOVABLE);
685
686 /* initialize audio device */
687 if (result == RT_EOK)
688 result = rt_device_init(device);
689
690 return result;
691}
692
693/**
694 * @brief Set audio sample rate

Callers 15

rt_hw_mic_initFunction · 0.85
rt_hw_sound_initFunction · 0.85
rt_hw_sound_initFunction · 0.85
rt_hw_sound_initFunction · 0.85
rt_hw_mic_initFunction · 0.85
rt_hw_sound_initFunction · 0.85
rt_hw_mic_initFunction · 0.85
rt_hw_sound_initFunction · 0.85
rt_hw_mic_initFunction · 0.85
rt_hw_sound_initFunction · 0.85
rt_hw_sound_initFunction · 0.85
rt_hw_mic_initFunction · 0.85

Calls 2

rt_device_registerFunction · 0.85
rt_device_initFunction · 0.85

Tested by

no test coverage detected