这个是我早期的处理MusicTaskWaitBuffer 。
#define MusicTaskWaitBuffer (MusicTaskAudioFillBuffer0_10 | MusicTaskAudioFillBuffer1_9)
[C] 纯文本查看 复制代码 /* 当前使用的是缓冲0,填充缓冲1,并通过64点FFT实行频谱显示 */
case MusicTaskAudioFillBuffer1_9:
VedioSynCount--;
if(hWinMusic != WM_HWIN_NULL)
{
DSP_FFT64(ptMP3->pI2SBuffer0);
}
MP3_FillAudio((uint16_t *)ptMP3->pI2SBuffer1,
(uint16_t *)ptMP3->pI2STempBuff,
mp3FrameInfo.outputSamps);
GetMP3DecoderData(fout, ptMP3->pI2STempBuff, &mp3FrameInfo, mp3Decoder, ptMP3);
break;
/* 当前使用的是缓冲1,填充缓冲0,并通过64点FFT实行频谱显示 */
case MusicTaskAudioFillBuffer0_10:
VedioSynCount--;
if(hWinMusic != WM_HWIN_NULL)
{
DSP_FFT64(ptMP3->pI2SBuffer1);
}
MP3_FillAudio((uint16_t *)ptMP3->pI2SBuffer0,
(uint16_t *)ptMP3->pI2STempBuff,
mp3FrameInfo.outputSamps);
GetMP3DecoderData(fout, ptMP3->pI2STempBuff, &mp3FrameInfo, mp3Decoder, ptMP3);
break;
/*
早期设计的时候,为了防止视频播放任务一直占用文件系统,导致音频的DMA的
双缓冲都发消息过来,现在的版本进入这个消息的概率极小了。
*/
case MusicTaskWaitBuffer:
#if 0 /* 这种方式有时候会多计算一次 */
printf_MP3dbg("count = %d, ddd = %x\r\n", count, xResult);
xResult = 0;
while(os_sem_wait (&SemaphoreVedio, 0) == OS_R_OK)
{
xResult++;
GetMP3DecoderData(fout, ptMP3->pI2STempBuff, &mp3FrameInfo, mp3Decoder, ptMP3);
}
printf_MP3dbg("count = %d, ddd = %x\r\n", count, xResult);
count = 0;
#else
printf_MP3dbg("count = %d, ddd = %x\r\n", VedioSynCount, xResult);
uiTempCount = VedioSynCount;
VedioSynCount = 0;
for(i = 0; i < uiTempCount; i++)
{
GetMP3DecoderData(fout, ptMP3->pI2STempBuff, &mp3FrameInfo, mp3Decoder, ptMP3);
}
/* 防止同步的过程中,count被改变,再进行一次 */
for(i = 0; i < VedioSynCount; i++)
{
GetMP3DecoderData(fout, ptMP3->pI2STempBuff, &mp3FrameInfo, mp3Decoder, ptMP3);
}
printf_MP3dbg("count = %d, ddd = %x\r\n", VedioSynCount, xResult);
VedioSynCount = 0;
#endif
break;
|