Loading...

使用海思mpp,如何播放pcm数据?

youlong144
youlong144  发布于 2021-08-27 15:35:38 72

目前已经有pcm数据,能直接送AO播放数据吗?但是尝试过失败了,会挂机。
sigNO.11;P-0;GP-277;T-RTCCB;PC-0x149bdc<>FNC-HI_MPI_AO_SendFrame;FN-./demo;RelativeAddr:1900—1

以下是我写的送AO的接口:

int MppSendPcmData2Ao(const void data, size_t len, sz_u64 pts, sz_u32 seq)
{
HI_S32 s32Ret;
AUDIO_FRAME_S stAoFrame;
VB_BLK VbBlk;
unsigned int u32PhyAddr;
unsigned char pVirAddr;
AUDIO_DEV Ao_dev = 0;
AO_CHN Ao_chn = 0;
static int num = 1;

if (num > 0)
{
    COMM_AUDIO_AoUnbindAdec(Ao_dev, Ao_chn, 0);
    --num;
}

if (len <= 0) 
{
    printf("recv len: %d\n", len);
    return HI_NULL;
}

VB_POOL_CONFIG_S stVbPoolCfg;
VB_POOL vbpool;
memset(&stVbPoolCfg, 0, sizeof(VB_POOL_CONFIG_S));
stVbPoolCfg.u64BlkSize  = 1024 * 64;
stVbPoolCfg.u32BlkCnt   = 1;
stVbPoolCfg.enRemapMode = VB_REMAP_MODE_NONE;
vbpool = HI_MPI_VB_CreatePool(&stVbPoolCfg);
if (VB_INVALID_POOLID == vbpool)
{
    ZLOG_ERROR("HI_MPI_VB_CreatePool failed!\n");
    return HI_FAILURE;
}


stAoFrame.u32Len = len;
stAoFrame.enBitwidth = AUDIO_BIT_WIDTH_16;
stAoFrame.enSoundmode = AUDIO_SOUND_MODE_STEREO;
stAoFrame.u32Seq = seq;
stAoFrame.u64PhyAddr[1] = 0;
stAoFrame.u32PoolId[1] = 0;
stAoFrame.u64TimeStamp = pts;

VbBlk = HI_MPI_VB_GetBlock(vbpool, len, NULL);
if (VB_INVALID_HANDLE == VbBlk)
{
    printf("HI_MPI_VB_GetBlock err! size:%d\n",len);
    return HI_FAILURE;
}

u32PhyAddr = HI_MPI_VB_Handle2PhysAddr(VbBlk);
if (0 == u32PhyAddr)
{
    printf("Func:%s, Info:HI_MPI_VB_Handle2PhysAddr fail\n", __FUNCTION__);
    HI_MPI_VB_ReleaseBlock(VbBlk);
    return HI_FAILURE;
}

stAoFrame.u32PoolId[0]= HI_MPI_VB_Handle2PoolId(VbBlk);
pVirAddr = (unsigned char *)HI_MPI_SYS_Mmap(u32PhyAddr,len);
if (NULL == pVirAddr)
{
    printf("Func:%s, Info:HI_MPI_SYS_Mmap fail\n", __FUNCTION__);
    HI_MPI_VB_ReleaseBlock(VbBlk);
    return HI_FAILURE;
}

memcpy(pVirAddr,data,len);
stAoFrame.u64PhyAddr[0]= u32PhyAddr;
stAoFrame.u64VirAddr[0] = pVirAddr;

s32Ret = HI_MPI_AO_SendFrame(Ao_dev, Ao_chn, &stAoFrame, 0);

if (HI_SUCCESS != s32Ret )
{
    printf("%s: HI_MPI_AENC_SendFrame(0, 0), failed with %#x!\n", __FUNCTION__, s32Ret);
    return HI_FAILURE;
}

HI_MPI_SYS_Munmap(pVirAddr,len);
HI_MPI_VB_ReleaseBlock(VbBlk);
HI_MPI_VB_DestroyPool(vbpool);

return HI_SUCCESS;

}

哪位朋友能帮忙指导下?

我来回答
回答可得5积分
1个回答
发布于 2021-09-02 14:16:33

感觉海思论坛的问题都没人理,这是啥情况?

1
+ 添加网盘链接/附件
或将文件直接拖到这里
悬赏:
EBC
文件格式必须为doc,docx,xls,xlsx,pdf,ppt,pptx,txt,zip,rar,tar,7z,gz
网盘
* 网盘链接:
* 提取码:
悬赏:
EBC
易百纳技术社区
确定要删除此文章、专栏、评论吗?
确定
取消
易百纳技术社区