static err_t CODEC_MSG_TEST_AUDIO_handle(codec_t* codec)
{
/*-------------------------------------
Mic------>SPK
--------------------------------------*/
int32_t ret_enc = 0;
int32_t ret_dec = 0;
int16_t loop_back_pcm[640];
sa_adc_t pcm_mic_buf[640];
uint8_t loop_back_encode_buf[60];
uint32_t loop_back_audio_pcm32[640];
if(play_samples_in_buf(codec) >= 320)
{
return ERR_INVALID_STATE;
}
codec_read_mic_data(codec, pcm_mic_buf, 640);
for(int i = 0; i < 640; i++)
{
loop_back_pcm[i] = pcm_mic_buf[i] & 0x0000ffff;
}
for(int i = 0; i < 640; i++)
{
loop_back_audio_pcm32[i] = ((uint32_t)(loop_back_pcm[i]) << 16) |\
(((uint32_t)loop_back_pcm[i]) & 0xffff);
}
codec_push_buf(codec, loop_back_audio_pcm32, 640 * 4);
#if WAV_RECORD_EN
wav_write(pcm_mic_buf, 320);
#endif
return ERR_SUCCESS;
}
|