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

Function rt_audio_pipe_init

components/drivers/audio/dev_audio_pipe.c:266–298  ·  view source on GitHub ↗

* @brief Init audio pipe * * This function will initialize a pipe device and put it under control of * resource management. * * @param pipe the pipe device * * @param name the name of pipe device * * @param flag the attribute of the pipe device * * @param buf the buffer of pipe device * * @param size the size of pipe device buffer * * @return the operation status, RT_EOK on success

Source from the content-addressed store, hash-verified

264 * @return the operation status, RT_EOK on successful
265 */
266rt_err_t rt_audio_pipe_init(struct rt_audio_pipe *pipe,
267 const char *name,
268 rt_int32_t flag,
269 rt_uint8_t *buf,
270 rt_size_t size)
271{
272 RT_ASSERT(pipe);
273 RT_ASSERT(buf);
274
275 /* initialize suspended list */
276 rt_list_init(&pipe->suspended_read_list);
277 rt_list_init(&pipe->suspended_write_list);
278
279 /* initialize ring buffer */
280 rt_ringbuffer_init(&pipe->ringbuffer, buf, size);
281
282 pipe->flag = flag;
283
284 /* create pipe */
285 pipe->parent.type = RT_Device_Class_Pipe;
286#ifdef RT_USING_DEVICE_OPS
287 pipe->parent.ops = &audio_pipe_ops;
288#else
289 pipe->parent.init = RT_NULL;
290 pipe->parent.open = RT_NULL;
291 pipe->parent.close = RT_NULL;
292 pipe->parent.read = rt_audio_pipe_read;
293 pipe->parent.write = rt_audio_pipe_write;
294 pipe->parent.control = rt_audio_pipe_control;
295#endif
296
297 return rt_device_register(&(pipe->parent), name, RT_DEVICE_FLAG_RDWR);
298}
299
300/**
301 * @brief This function will detach a pipe device from resource management

Callers 2

_audio_dev_initFunction · 0.85
rt_audio_pipe_createFunction · 0.85

Calls 3

rt_list_initFunction · 0.85
rt_ringbuffer_initFunction · 0.85
rt_device_registerFunction · 0.85

Tested by

no test coverage detected