找了好久,才发现菠萝派有RTT的声音播放代码,但俺进行测试确卡住了,测试代码:
f1c100s_audio_init();
f1c100s_audio_config(1, 16, 44100);
f1c100s_audio_open(1024);
f1c100s_audio_vol_set(63);
int fd = -1;
int s = 0;
uint8_t *buffer = NULL;
buffer = rt_malloc(1024);
fd = open(argv[1], O_WRONLY);
rt_kprintf("wav play %s\n", argv[1]);
while (1)
{
int length;
/* 从文件系统读取 wav 文件的音频数据 */
length = read(fd, buffer, 1024);
if (length <= 0)
break;
s += length;
audio_pcm_play(buffer, length);
lseek(fd, s, SEEK_SET);
rt_thread_mdelay(6);
}
运行发现卡在了 函数 audio_pcm_play 内部的 while 里:
void audio_pcm_play(unsigned char * dat,int len)
{
int time_out = 100;
unsigned short *buf = (unsigned short *)dat;
// while((!f1c100s_ndma_is_all_complete(AUDIO_DMA_CH))&&(--time_out))
// {
// rt_thread_delay(1);
// }
while(!f1c100s_ndma_is_all_complete(AUDIO_DMA_CH));
memcpy(audio_buf[is_n],buf,len);
f1c100s_ndma_clear_all_complete(AUDIO_DMA_CH);
f1c100s_ndma_disable(AUDIO_DMA_CH);
f1c100s_ndma_config_for_audio(AUDIO_DMA_CH,(unsigned int)audio_buf[is_n],len);
f1c100s_ndma_enable(AUDIO_DMA_CH);
is_n=!is_n;
}
请问这是咋回事呀,后面怎么处理呢?
离线