mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-23 04:04:15 +08:00
[core] 使用rt_memcpy rt_memset代替memcpy memset
This commit is contained in:
@@ -52,14 +52,14 @@ static rt_err_t _audio_send_replay_frame(struct rt_audio_device *audio)
|
||||
rt_completion_done(&audio->replay->cmp);
|
||||
|
||||
/* send zero frames */
|
||||
memset(&buf_info->buffer[audio->replay->pos], 0, dst_size);
|
||||
rt_memset(&buf_info->buffer[audio->replay->pos], 0, dst_size);
|
||||
|
||||
audio->replay->pos += dst_size;
|
||||
audio->replay->pos %= buf_info->total_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&buf_info->buffer[audio->replay->pos], 0, dst_size);
|
||||
rt_memset(&buf_info->buffer[audio->replay->pos], 0, dst_size);
|
||||
|
||||
/* copy data from memory pool to hardware device fifo */
|
||||
while (index < dst_size)
|
||||
@@ -77,7 +77,7 @@ static rt_err_t _audio_send_replay_frame(struct rt_audio_device *audio)
|
||||
}
|
||||
|
||||
remain_bytes = MIN((dst_size - index), (src_size - audio->replay->read_index));
|
||||
memcpy(&buf_info->buffer[audio->replay->pos],
|
||||
rt_memcpy(&buf_info->buffer[audio->replay->pos],
|
||||
&data[audio->replay->read_index], remain_bytes);
|
||||
|
||||
index += remain_bytes;
|
||||
@@ -229,7 +229,7 @@ static rt_err_t _audio_dev_init(struct rt_device *dev)
|
||||
|
||||
if (replay == RT_NULL)
|
||||
return -RT_ENOMEM;
|
||||
memset(replay, 0, sizeof(struct rt_audio_replay));
|
||||
rt_memset(replay, 0, sizeof(struct rt_audio_replay));
|
||||
|
||||
/* init memory pool for replay */
|
||||
replay->mp = rt_mp_create("adu_mp", RT_AUDIO_REPLAY_MP_BLOCK_COUNT, RT_AUDIO_REPLAY_MP_BLOCK_SIZE);
|
||||
@@ -258,7 +258,7 @@ static rt_err_t _audio_dev_init(struct rt_device *dev)
|
||||
|
||||
if (record == RT_NULL)
|
||||
return -RT_ENOMEM;
|
||||
memset(record, 0, sizeof(struct rt_audio_record));
|
||||
rt_memset(record, 0, sizeof(struct rt_audio_record));
|
||||
|
||||
/* init pipe for record*/
|
||||
buffer = rt_malloc(RT_AUDIO_RECORD_PIPE_SIZE);
|
||||
@@ -393,12 +393,12 @@ static rt_size_t _audio_dev_write(struct rt_device *dev, rt_off_t pos, const voi
|
||||
if (audio->replay->write_index % block_size == 0)
|
||||
{
|
||||
audio->replay->write_data = rt_mp_alloc(audio->replay->mp, RT_WAITING_FOREVER);
|
||||
memset(audio->replay->write_data, 0, block_size);
|
||||
rt_memset(audio->replay->write_data, 0, block_size);
|
||||
}
|
||||
|
||||
/* copy data to replay memory pool */
|
||||
remain_bytes = MIN((block_size - audio->replay->write_index), (size - index));
|
||||
memcpy(&audio->replay->write_data[audio->replay->write_index], &ptr[index], remain_bytes);
|
||||
rt_memcpy(&audio->replay->write_data[audio->replay->write_index], &ptr[index], remain_bytes);
|
||||
|
||||
index += remain_bytes;
|
||||
audio->replay->write_index += remain_bytes;
|
||||
|
||||
Reference in New Issue
Block a user