mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-06 02:40:45 +08:00
[audio]新版本pipe导致audio编译错误,添加以前的pipe
This commit is contained in:
1 parent
afc2256d01
commit
f7a6078c5c
4 files changed
+372
-7
No files matched your search
@@ -29,6 +29,9 @@
|
||||
|
||||
#include <drivers/audio.h>
|
||||
|
||||
#include "audio_pipe.h"
|
||||
|
||||
|
||||
#define AUDIO_DEBUG 0
|
||||
#if AUDIO_DEBUG
|
||||
#define AUDIO_DBG(...) printf("[AUDIO]:"),printf(__VA_ARGS__)
|
||||
@@ -36,6 +39,8 @@
|
||||
#define AUDIO_DBG(...)
|
||||
#endif
|
||||
|
||||
static struct rt_audio_pipe audio_pipe;
|
||||
|
||||
static rt_err_t _audio_send_replay_frame(struct rt_audio_device *audio)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
@@ -178,8 +183,8 @@ static rt_err_t _audio_dev_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||
|
||||
return -RT_ENOMEM;
|
||||
}
|
||||
|
||||
rt_pipe_init(&record->pipe, "recpipe", RT_PIPE_FLAG_FORCE_WR | RT_PIPE_FLAG_BLOCK_RD, buf,
|
||||
|
||||
rt_audio_pipe_init(&audio_pipe, "recpipe", RT_PIPE_FLAG_FORCE_WR | RT_PIPE_FLAG_BLOCK_RD, buf,
|
||||
CFG_AUDIO_RECORD_PIPE_SIZE);
|
||||
}
|
||||
|
||||
@@ -190,7 +195,7 @@ static rt_err_t _audio_dev_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||
//open record pipe
|
||||
if (audio->record != RT_NULL)
|
||||
{
|
||||
rt_device_open(RT_DEVICE(&audio->record->pipe), RT_DEVICE_OFLAG_RDONLY);
|
||||
rt_device_open(RT_DEVICE(&audio_pipe), RT_DEVICE_OFLAG_RDONLY);
|
||||
}
|
||||
|
||||
dev->open_flag |= RT_DEVICE_OFLAG_RDONLY;
|
||||
@@ -236,7 +241,7 @@ static rt_err_t _audio_dev_close(struct rt_device *dev)
|
||||
|
||||
//close record pipe
|
||||
if (audio->record != RT_NULL)
|
||||
rt_device_close(RT_DEVICE(&audio->record->pipe));
|
||||
rt_device_close(RT_DEVICE(&audio_pipe));
|
||||
|
||||
dev->open_flag &= ~RT_DEVICE_OFLAG_RDONLY;
|
||||
}
|
||||
@@ -252,7 +257,7 @@ static rt_size_t _audio_dev_read(struct rt_device *dev, rt_off_t pos, void *buff
|
||||
if (!(dev->open_flag & RT_DEVICE_OFLAG_RDONLY) || (audio->record == RT_NULL))
|
||||
return 0;
|
||||
|
||||
return rt_device_read(RT_DEVICE(&audio->record->pipe), pos, buffer, size);
|
||||
return rt_device_read(RT_DEVICE(&audio_pipe), pos, buffer, size);
|
||||
}
|
||||
|
||||
static rt_size_t _audio_dev_write(struct rt_device *dev, rt_off_t pos, const void *buffer, rt_size_t size)
|
||||
@@ -528,7 +533,7 @@ void rt_audio_rx_done(struct rt_audio_device *audio, rt_uint8_t *pbuf, rt_size_t
|
||||
rt_err_t result = RT_EOK;
|
||||
|
||||
//save data to record pipe
|
||||
rt_device_write(RT_DEVICE(RT_DEVICE(&audio->record->pipe)), 0, pbuf, len);
|
||||
rt_device_write(RT_DEVICE(RT_DEVICE(&audio_pipe)), 0, pbuf, len);
|
||||
|
||||
/* invoke callback */
|
||||
if (audio->parent.rx_indicate != RT_NULL)
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,65 @@
|
||||
#ifndef __AUDIO_PIPE_H__
|
||||
#define __AUDIO_PIPE_H__
|
||||
|
||||
/**
|
||||
* Pipe Device
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#ifndef RT_PIPE_BUFSZ
|
||||
#define PIPE_BUFSZ 512
|
||||
#else
|
||||
#define PIPE_BUFSZ RT_PIPE_BUFSZ
|
||||
#endif
|
||||
|
||||
/* portal device */
|
||||
struct rt_audio_portal_device
|
||||
{
|
||||
struct rt_device parent;
|
||||
struct rt_device *write_dev;
|
||||
struct rt_device *read_dev;
|
||||
};
|
||||
|
||||
enum rt_audio_pipe_flag
|
||||
{
|
||||
/* both read and write won't block */
|
||||
RT_PIPE_FLAG_NONBLOCK_RDWR = 0x00,
|
||||
/* read would block */
|
||||
RT_PIPE_FLAG_BLOCK_RD = 0x01,
|
||||
/* write would block */
|
||||
RT_PIPE_FLAG_BLOCK_WR = 0x02,
|
||||
/* write to this pipe will discard some data when the pipe is full.
|
||||
* When this flag is set, RT_PIPE_FLAG_BLOCK_WR will be ignored since write
|
||||
* operation will always be success. */
|
||||
RT_PIPE_FLAG_FORCE_WR = 0x04,
|
||||
};
|
||||
|
||||
struct rt_audio_pipe
|
||||
{
|
||||
struct rt_device parent;
|
||||
|
||||
/* ring buffer in pipe device */
|
||||
struct rt_ringbuffer ringbuffer;
|
||||
|
||||
enum rt_audio_pipe_flag flag;
|
||||
|
||||
/* suspended list */
|
||||
rt_list_t suspended_read_list;
|
||||
rt_list_t suspended_write_list;
|
||||
|
||||
struct rt_audio_portal_device *write_portal;
|
||||
struct rt_audio_portal_device *read_portal;
|
||||
};
|
||||
|
||||
#define PIPE_CTRL_GET_SPACE 0x14 /**< get the remaining size of a pipe device */
|
||||
|
||||
rt_err_t rt_audio_pipe_init(struct rt_audio_pipe *pipe,
|
||||
const char *name,
|
||||
enum rt_audio_pipe_flag flag,
|
||||
rt_uint8_t *buf,
|
||||
rt_size_t size);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -198,7 +198,6 @@ struct rt_audio_replay
|
||||
struct rt_audio_record
|
||||
{
|
||||
rt_bool_t activated;
|
||||
struct rt_pipe_device pipe;
|
||||
};
|
||||
|
||||
struct rt_audio_device
|
||||
|
||||
Reference in new issue
Block a user