This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM8168 Audio Decoder Failed

Hi Everyone.

     I had met difficulties when we write audio decoder demo.

     My usecase is read AAC file -> audio decoder ->  write PCM file

    When I call Adec_process(), this Function return failed. 

    SomeBody Can Help me?

   My ALL code like this:

int main(void)
{
int ret=0;
FILE *in = NULL, *out = NULL;
ADEC_PROCESS_PARAMS_S decPrm;
ADEC_CREATE_PARAMS_S adecParams;
Void *decHandle = NULL;
Bool isSharedRegion = FALSE;
Int32 inBufSize, outBufSize;
UInt8 *inBuf = NULL;
UInt8 *outBuf = NULL;
int to_read, readBytes;
int offset;

memset(&decPrm, 0, sizeof(decPrm));
memset(&adecParams, 0, sizeof(adecParams));
System_init();

if(1){
//AAC
adecParams.decoderType = AUDIO_CODEC_TYPE_AAC_LC;
adecParams.desiredChannelMode = 2;
}else{
//G711
adecParams.decoderType = AUDIO_CODEC_TYPE_G711;
adecParams.desiredChannelMode = 1;
}

decHandle = Adec_create(&adecParams);
if (decHandle)
{
printf ("ADEC Create done...........\n");
}else{
printf ("ADEC Create failed...........\n");
return -1;
}

if (adecParams.decoderType == AUDIO_CODEC_TYPE_AAC_LC)
isSharedRegion = TRUE;
else
isSharedRegion = FALSE;

inBufSize = MAX_INPUT_BUFFER / 2;
if (inBufSize < adecParams.minInBufSize){
inBufSize = adecParams.minInBufSize;
printf("inBufSize < adecParams.minInBufSize inBufSize change to %d\n",inBufSize);
}

outBufSize = MAX_OUTPUT_BUFFER;
if (outBufSize < adecParams.minOutBufSize){
outBufSize = adecParams.minOutBufSize;
printf("outBufSize < adecParams.minOutBufSize outBufSize change to %d\n",outBufSize);
}

inBuf = App_allocBuf(inBufSize, isSharedRegion);
if(inBuf == NULL){
printf("App_allocBuf inBuf Failed!\n");
}
outBuf = App_allocBuf(outBufSize, isSharedRegion);
if(outBuf == NULL){
printf("App_allocBuf inBuf Failed!\n");
}

in = fopen("audio.aac", "rb");
if (!in)
{
printf ("File Open Error....\n");
}

out = fopen("aduio.pcm", "wb");
if (!out)
{
printf ("File Open Error....\n");
}

offset = 0;
to_read = inBufSize;
while(1){
readBytes = fread (inBuf + offset, 1, to_read, in);
printf("readBytes=%d\n",readBytes);
readBytes += offset;
if(readBytes){
decPrm.inBuf.dataBufSize = readBytes;
decPrm.inBuf.dataBuf = inBuf;
decPrm.outBuf.dataBufSize = outBufSize;
Adec_process(decHandle, &decPrm);//here return failed
if (decPrm.inBuf.dataBufSize <= 0)
{
printf ("======== Decode completed, inBuf.dataBufSize = %d ========\n",decPrm.inBuf.dataBufSize);
break;
}
if (out)
{
writeToFile(out, &decPrm);
}
offset = (readBytes-decPrm.inBuf.dataBufSize);
if(offset)
memmove(inBuf, inBuf+decPrm.inBuf.dataBufSize, offset);
to_read = decPrm.inBuf.dataBufSize;
}
}

System_deInit();

return ret;
}

The error message as follow:

.....................................

AUDIO: DEC -> Handle 247E60, Int Handle 247E68
AUDIO: DEC -> Rpe_create(AAC_DEC) done....
ADEC Create done...........
inBufSize < adecParams.minInBufSize inBufSize change to 3840
readBytes=3840
Audio_decode
AUDIO: DEC -> AUDIO: Rpe process call failed, status: 1
readBytes=3840
Audio_decode
AUDIO: DEC -> AUDIO: Rpe process call failed, status: 1
readBytes=3840
Audio_decode
AUDIO: DEC -> AUDIO: Rpe process call failed, status: 1
readBytes=3840
Audio_decode
AUDIO: DEC -> AUDIO: Rpe process call failed, status: 1
readBytes=3840
Audio_decode
AUDIO: DEC -> AUDIO: Rpe process call failed, status: 1

................................................

Looking forward to your help!

thank you very much!