From 65e03e0f228a13bc1c2fda5d0af72ae8e3404c8f Mon Sep 17 00:00:00 2001 From: Frank Livingston Date: Fri, 2 Sep 2016 18:05:08 -0500 Subject: [PATCH] Fix dec output circ buffer PCM init, add read AF mute. --- .../pasdk/common/paf_decOpCircBuf.c | 83 +++++++++++++------ 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/processor_audio_sdk_1_00_00_00/pasdk/common/paf_decOpCircBuf.c b/processor_audio_sdk_1_00_00_00/pasdk/common/paf_decOpCircBuf.c index dfa8f809..565bea45 100644 --- a/processor_audio_sdk_1_00_00_00/pasdk/common/paf_decOpCircBuf.c +++ b/processor_audio_sdk_1_00_00_00/pasdk/common/paf_decOpCircBuf.c @@ -43,10 +43,17 @@ All rights reserved. #include "pafsp.h" #include "paf_decOpCircBuf.h" +// Generate mute AF on circular buffer read +static Void cbReadAfMute( + PAF_AudioFrame *pAfRd, // audio frame into which to read + Int16 strFrameLen // stream frame length (output transaction size) +); + #define MAX_NUM_AF_PCM ( 4 ) -#define MAX_NUM_AF_DDP ( 2 ) +#define CB_INIT_RD_LAG_PCM ( 2 ) // 0...3 -#define CB_INIT_RD_LAG ( 4 ) +#define MAX_NUM_AF_DDP ( 2 ) +#define CB_INIT_RD_LAG_DDP ( 4 ) // 0...5 // Initialize circular buffer Int cbInit( @@ -73,7 +80,7 @@ Int cbInit( if (sourceSelect == PAF_SOURCE_PCM) { pCb->maxNumAfCb = MAX_NUM_AF_PCM; - pCb->afWrtIdx = CB_INIT_RD_LAG; + pCb->afWrtIdx = CB_INIT_RD_LAG_PCM; pCb->afRdIdx = 0; pCb->pcmRdIdx = 0; // 2*256 in behind @@ -96,9 +103,9 @@ Int cbInit( else if (sourceSelect == PAF_SOURCE_DDP) { pCb->maxNumAfCb = MAX_NUM_AF_DDP; - pCb->afRdIdx = 0; - pCb->pcmRdIdx = decOpFrameLen - CB_INIT_RD_LAG*strFrameLen; pCb->afWrtIdx = 1; + pCb->afRdIdx = 0; + pCb->pcmRdIdx = decOpFrameLen - CB_INIT_RD_LAG_DDP*strFrameLen; // 4*256 behind // initialize audio frames for (n=0; nmaxNumAfCb; n++) @@ -321,28 +328,7 @@ Int cbReadAf( // No active writer, not draining circular buffer. // Skip UNDerflow check, mute output. // - pAfRd->sampleDecode = PAF_SOURCE_PCM; - PAF_PROCESS_ZERO(pAfRd->sampleProcess); - pAfRd->sampleRate = PAF_SAMPLERATE_48000HZ; - pAfRd->sampleCount = pCb->strFrameLen; - pAfRd->channelConfigurationRequest.full = 0; - pAfRd->channelConfigurationRequest.part.sat = PAF_CC_SAT_SURROUND4; - pAfRd->channelConfigurationRequest.part.sub = PAF_CC_SUB_ONE; - pAfRd->channelConfigurationStream.full = 0; - pAfRd->channelConfigurationStream.part.sat = PAF_CC_SAT_SURROUND4; - pAfRd->channelConfigurationStream.part.sub = PAF_CC_SUB_ONE; - - // compute stream mask - streamMask = pAfRd->fxns->channelMask(pAfRd, pAfRd->channelConfigurationStream); - // Clear PCM data - for (i = 0; i < PAF_DECOP_CB_MAX_NUM_PCM_CH; i++) - { - if ((streamMask >> i) & 0x1) - { - memset(pAfRd->data.sample[i], pCb->strFrameLen, 0); - } - pAfRd->data.samsiz[i] = 0; - } + cbReadAfMute(pAfRd, pCb->strFrameLen); return PAF_DECOP_CB_SOK; } @@ -352,8 +338,18 @@ Int cbReadAf( // check underflow if (pCb->numAfCb <= 0) { + // + // Increment underflow count. + // Mute output on underflow. + // pCb->errUndCnt++; + cbReadAfMute(pAfRd, pCb->strFrameLen); //SW_BREAKPOINT; // FL: debug + + // Write back circular buffer configuration. + Cache_wb(pCb, sizeof(PAF_DecodeOpCircBuf), Cache_Type_ALLD, 0); + Cache_wait(); + return PAF_DECOP_CB_READ_UNDERFLOW; } } @@ -650,3 +646,36 @@ Int cbLog( return 0; } + +// Generate mute AF on circular buffer read +static Void cbReadAfMute( + PAF_AudioFrame *pAfRd, // audio frame into which to read + Int16 strFrameLen // stream frame length (output transaction size) +) +{ + PAF_ChannelMask_HD streamMask; + Int8 i; + + pAfRd->sampleDecode = PAF_SOURCE_PCM; + PAF_PROCESS_ZERO(pAfRd->sampleProcess); + pAfRd->sampleRate = PAF_SAMPLERATE_48000HZ; + pAfRd->sampleCount = strFrameLen; + pAfRd->channelConfigurationRequest.full = 0; + pAfRd->channelConfigurationRequest.part.sat = PAF_CC_SAT_SURROUND4; + pAfRd->channelConfigurationRequest.part.sub = PAF_CC_SUB_ONE; + pAfRd->channelConfigurationStream.full = 0; + pAfRd->channelConfigurationStream.part.sat = PAF_CC_SAT_SURROUND4; + pAfRd->channelConfigurationStream.part.sub = PAF_CC_SUB_ONE; + + // compute stream mask + streamMask = pAfRd->fxns->channelMask(pAfRd, pAfRd->channelConfigurationStream); + // Clear PCM data + for (i = 0; i < PAF_DECOP_CB_MAX_NUM_PCM_CH; i++) + { + if ((streamMask >> i) & 0x1) + { + memset(pAfRd->data.sample[i], strFrameLen, 0); + } + pAfRd->data.samsiz[i] = 0; + } +} \ No newline at end of file -- 2.39.2