2979
- 收藏
- 点赞
- 分享
- 举报
请问有在3536上边试过立体声输出的吗
本帖最后由 qn1541039029 于 2018-12-20 17:51 编辑
我的程序是基于海思的sample_audio.c改的,
如下:
[code]/******************************************************************************
* function : file -> Adec -> Ao
******************************************************************************/
HI_S32 SAMPLE_AUDIO_AdecAo(HI_VOID)
{
HI_S32 s32Ret;
AUDIO_DEV AoDev = SAMPLE_AUDIO_AO_DEV;
AO_CHN AoChn = 0;
ADEC_CHN AdChn = 0;
FILE *pfd = NULL;
AIO_ATTR_S stAioAttr;
stAioAttr.enSamplerate = AUDIO_SAMPLE_RATE_32000;
stAioAttr.enBitwidth = AUDIO_BIT_WIDTH_16;
stAioAttr.enWorkmode = AIO_MODE_I2S_MASTER;
stAioAttr.enSoundmode = AUDIO_SOUND_MODE_STEREO;//这里设为立体声
stAioAttr.u32EXFlag = 1;
stAioAttr.u32FrmNum = 30;
stAioAttr.u32PtNumPerFrm = SAMPLE_AUDIO_PTNUMPERFRM;
stAioAttr.u32ChnCnt = 2;//这里设为2
stAioAttr.u32ClkChnCnt = 2;
stAioAttr.u32ClkSel = 0;
gs_pstAiReSmpAttr = NULL;
gs_pstAoReSmpAttr = NULL;
s32Ret = SAMPLE_COMM_AUDIO_CfgAcodec(&stAioAttr);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_DBG(s32Ret);
return HI_FAILURE;
}
s32Ret = SAMPLE_COMM_AUDIO_StartAdec(AdChn, gs_enPayloadType);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_DBG(s32Ret);
return HI_FAILURE;
}
s32Ret = SAMPLE_COMM_AUDIO_StartAo(AoDev, stAioAttr.u32ChnCnt, &stAioAttr, AUDIO_SAMPLE_RATE_BUTT, HI_FALSE, NULL, 0);
具体函数见后
if (s32Ret != HI_SUCCESS)
{
SAMPLE_DBG(s32Ret);
return HI_FAILURE;
}
s32Ret = SAMPLE_COMM_AUDIO_AoBindAdec(AoDev, AoChn, AdChn);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_DBG(s32Ret);
return HI_FAILURE;
}
pfd = SAMPLE_AUDIO_OpenAdecFile(AdChn, gs_enPayloadType);
if (!pfd)
{
SAMPLE_DBG(HI_FAILURE);
return HI_FAILURE;
}
s32Ret = SAMPLE_COMM_AUDIO_CreatTrdFileAdec(AdChn, pfd); 具体函数见后
if (s32Ret != HI_SUCCESS)
{
SAMPLE_DBG(s32Ret);
return HI_FAILURE;
}
。。。
后边销毁的略了
。。。
[/code]
然后是StartAO这个函数
HI_S32 SAMPLE_COMM_AUDIO_StartAo(AUDIO_DEV AoDevId, HI_S32 s32AoChnCnt,
AIO_ATTR_S* pstAioAttr, AUDIO_SAMPLE_RATE_E enInSampleRate, HI_BOOL bResampleEn, HI_VOID* pstAoVqeAttr, HI_U32 u32AoVqeType)
{
HI_S32 i;
HI_S32 s32Ret;
if (SAMPLE_AUDIO_HDMI_AO_DEV == AoDevId)
{
#ifdef HI_ACODEC_TYPE_HDMI
pstAioAttr->u32ClkSel = 0;
SAMPLE_COMM_AUDIO_StartHdmi(pstAioAttr);
#endif
}
if (pstAioAttr->u32ClkChnCnt == 0)
{
pstAioAttr->u32ClkChnCnt = pstAioAttr->u32ChnCnt;
}
s32Ret = HI_MPI_AO_SetPubAttr(AoDevId, pstAioAttr); // 设 备 属 性
if (HI_SUCCESS != s32Ret)
{
printf("%s: HI_MPI_AO_SetPubAttr(%d) failed with %#x!\n", __FUNCTION__, \
AoDevId, s32Ret);
return HI_FAILURE;
}
s32Ret = HI_MPI_AO_Enable(AoDevId);
if (HI_SUCCESS != s32Ret)
{
printf("%s: HI_MPI_AO_Enable(%d) failed with %#x!\n", __FUNCTION__, AoDevId, s32Ret);
return HI_FAILURE;
}
s32AoChnCnt = 1;//我这里特定设成1了。因为立体声只需要处理一半通道。
for (i = 0; i < s32AoChnCnt; i++)
{
s32Ret = HI_MPI_AO_EnableChn(AoDevId, i);
if (HI_SUCCESS != s32Ret)
{
printf("%s: HI_MPI_AO_EnableChn(%d) failed with %#x!\n", __FUNCTION__, i, s32Ret);
return HI_FAILURE;
}
}
}
最后是
/******************************************************************************
* function : Create the thread to get stream from file and send to adec
******************************************************************************/
HI_S32 SAMPLE_COMM_AUDIO_CreatTrdFileAdec(ADEC_CHN AdChn, FILE *pAdcFd)
{
SAMPLE_ADEC_S *pstAdec = NULL;
if (NULL == pAdcFd)
{
return HI_FAILURE;
}
pstAdec = &gs_stSampleAdec[AdChn];
pstAdec->AdChn = AdChn;
pstAdec->pfd = pAdcFd;
pstAdec->bStart = HI_TRUE;
pthread_create(&pstAdec->stAdPid, 0, SAMPLE_COMM_AUDIO_AdecProc 具体函数见后, pstAdec);
return HI_SUCCESS;
}
以及:
/******************************************************************************
* function : get stream from file, and send it to Adec
******************************************************************************/
void *SAMPLE_COMM_AUDIO_AdecProc(void *parg)
{
HI_S32 s32Ret;
AUDIO_STREAM_S stAudioStream;
HI_U32 u32Len = 1024;
HI_U32 u32ReadLen;
HI_S32 s32AdecChn;
HI_U8 *pu8AudioStream = NULL;
SAMPLE_ADEC_S *pstAdecCtl = (SAMPLE_ADEC_S *)parg;
FILE *pfd = pstAdecCtl->pfd;
s32AdecChn = pstAdecCtl->AdChn;
pu8AudioStream = (HI_U8*)malloc(sizeof(HI_U8)*MAX_AUDIO_STREAM_LEN);
if (NULL == pu8AudioStream)
{
printf("%s: malloc failed!\n", __FUNCTION__);
return NULL;
}
while (HI_TRUE == pstAdecCtl->bStart)
{
/* read from file */
stAudioStream.pStream = pu8AudioStream;
u32ReadLen = fread(stAudioStream.pStream, 1, u32Len, pfd);
if (u32ReadLen <= 0)
{
fseek(pfd, 0, SEEK_SET);/*read file again*/
continue;
}
/* here only demo adec streaming sending mode, but pack sending mode is commended */
stAudioStream.u32Len = u32ReadLen;
s32Ret = HI_MPI_ADEC_SendStream(s32AdecChn, &stAudioStream, HI_TRUE);
if(HI_SUCCESS != s32Ret)
{
printf("%s: HI_MPI_ADEC_SendStream(%d) failed with %#x!\n",\
__FUNCTION__, s32AdecChn, s32Ret);
break;
}
}
free(pu8AudioStream);
pu8AudioStream = NULL;
fclose(pfd);
pstAdecCtl->bStart = HI_FALSE;
return NULL;
}
但是运行的时候报错:
[code]
# ./sample_audio
/************************************/
please choose the case which you want to run:
0: start AI to AO loop
1: send audio frame to AENC channel from AI, save them
2: read audio stream from file, decode and send AO
3: start AI(AIC31) to AO(Hdmi) loop
q: quit whole audio sample
sample command:2 选择读取文件进行播放
open stream file:"audio_chn0.pcm" for adec ok
bind adec:0 to ao(0,0) ok
please press twice ENTER to exit this sample
[Func]:AoCheckFrameInfo [Line]:1862 [Info]:Soundmode(0), stAioAttr.enSoundmode(1)!
[Func]:HI_MPI_AO_SendFrame [Line]:2142 [Info]:Ao dev: 0, ao chn:0, frame info error.
[Func]:AoCheckFrameInfo [Line]:1862 [Info]:Soundmode(0), stAioAttr.enSoundmode(1)!
[Func]:HI_MPI_AO_SendFrame [Line]:2142 [Info]:Ao dev: 0, ao chn:0, frame info error.
后边一直重复打印这个错误。。。
[/code]
这个错误海思文档里没有,网上也找不到特别好的解释,大家有碰到的没,帮忙一下吧,谢谢。
根据他提示:
AoCheckFrameInfo [Line]:1862 [Info]:Soundmode(0), stAioAttr.enSoundmode(1)!
应该是AO的sound mode是单声道的,但是我设置的AIO属性是立体声的。
所以发送流的时候发现不匹配。。。
.
我的程序是基于海思的sample_audio.c改的,
如下:
[code]/******************************************************************************
* function : file -> Adec -> Ao
******************************************************************************/
HI_S32 SAMPLE_AUDIO_AdecAo(HI_VOID)
{
HI_S32 s32Ret;
AUDIO_DEV AoDev = SAMPLE_AUDIO_AO_DEV;
AO_CHN AoChn = 0;
ADEC_CHN AdChn = 0;
FILE *pfd = NULL;
AIO_ATTR_S stAioAttr;
stAioAttr.enSamplerate = AUDIO_SAMPLE_RATE_32000;
stAioAttr.enBitwidth = AUDIO_BIT_WIDTH_16;
stAioAttr.enWorkmode = AIO_MODE_I2S_MASTER;
stAioAttr.enSoundmode = AUDIO_SOUND_MODE_STEREO;//这里设为立体声
stAioAttr.u32EXFlag = 1;
stAioAttr.u32FrmNum = 30;
stAioAttr.u32PtNumPerFrm = SAMPLE_AUDIO_PTNUMPERFRM;
stAioAttr.u32ChnCnt = 2;//这里设为2
stAioAttr.u32ClkChnCnt = 2;
stAioAttr.u32ClkSel = 0;
gs_pstAiReSmpAttr = NULL;
gs_pstAoReSmpAttr = NULL;
s32Ret = SAMPLE_COMM_AUDIO_CfgAcodec(&stAioAttr);
if (HI_SUCCESS != s32Ret)
{
SAMPLE_DBG(s32Ret);
return HI_FAILURE;
}
s32Ret = SAMPLE_COMM_AUDIO_StartAdec(AdChn, gs_enPayloadType);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_DBG(s32Ret);
return HI_FAILURE;
}
s32Ret = SAMPLE_COMM_AUDIO_StartAo(AoDev, stAioAttr.u32ChnCnt, &stAioAttr, AUDIO_SAMPLE_RATE_BUTT, HI_FALSE, NULL, 0);
具体函数见后
if (s32Ret != HI_SUCCESS)
{
SAMPLE_DBG(s32Ret);
return HI_FAILURE;
}
s32Ret = SAMPLE_COMM_AUDIO_AoBindAdec(AoDev, AoChn, AdChn);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_DBG(s32Ret);
return HI_FAILURE;
}
pfd = SAMPLE_AUDIO_OpenAdecFile(AdChn, gs_enPayloadType);
if (!pfd)
{
SAMPLE_DBG(HI_FAILURE);
return HI_FAILURE;
}
s32Ret = SAMPLE_COMM_AUDIO_CreatTrdFileAdec(AdChn, pfd); 具体函数见后
if (s32Ret != HI_SUCCESS)
{
SAMPLE_DBG(s32Ret);
return HI_FAILURE;
}
。。。
后边销毁的略了
。。。
[/code]
然后是StartAO这个函数
HI_S32 SAMPLE_COMM_AUDIO_StartAo(AUDIO_DEV AoDevId, HI_S32 s32AoChnCnt,
AIO_ATTR_S* pstAioAttr, AUDIO_SAMPLE_RATE_E enInSampleRate, HI_BOOL bResampleEn, HI_VOID* pstAoVqeAttr, HI_U32 u32AoVqeType)
{
HI_S32 i;
HI_S32 s32Ret;
if (SAMPLE_AUDIO_HDMI_AO_DEV == AoDevId)
{
#ifdef HI_ACODEC_TYPE_HDMI
pstAioAttr->u32ClkSel = 0;
SAMPLE_COMM_AUDIO_StartHdmi(pstAioAttr);
#endif
}
if (pstAioAttr->u32ClkChnCnt == 0)
{
pstAioAttr->u32ClkChnCnt = pstAioAttr->u32ChnCnt;
}
s32Ret = HI_MPI_AO_SetPubAttr(AoDevId, pstAioAttr); // 设 备 属 性
if (HI_SUCCESS != s32Ret)
{
printf("%s: HI_MPI_AO_SetPubAttr(%d) failed with %#x!\n", __FUNCTION__, \
AoDevId, s32Ret);
return HI_FAILURE;
}
s32Ret = HI_MPI_AO_Enable(AoDevId);
if (HI_SUCCESS != s32Ret)
{
printf("%s: HI_MPI_AO_Enable(%d) failed with %#x!\n", __FUNCTION__, AoDevId, s32Ret);
return HI_FAILURE;
}
s32AoChnCnt = 1;//我这里特定设成1了。因为立体声只需要处理一半通道。
for (i = 0; i < s32AoChnCnt; i++)
{
s32Ret = HI_MPI_AO_EnableChn(AoDevId, i);
if (HI_SUCCESS != s32Ret)
{
printf("%s: HI_MPI_AO_EnableChn(%d) failed with %#x!\n", __FUNCTION__, i, s32Ret);
return HI_FAILURE;
}
}
}
最后是
/******************************************************************************
* function : Create the thread to get stream from file and send to adec
******************************************************************************/
HI_S32 SAMPLE_COMM_AUDIO_CreatTrdFileAdec(ADEC_CHN AdChn, FILE *pAdcFd)
{
SAMPLE_ADEC_S *pstAdec = NULL;
if (NULL == pAdcFd)
{
return HI_FAILURE;
}
pstAdec = &gs_stSampleAdec[AdChn];
pstAdec->AdChn = AdChn;
pstAdec->pfd = pAdcFd;
pstAdec->bStart = HI_TRUE;
pthread_create(&pstAdec->stAdPid, 0, SAMPLE_COMM_AUDIO_AdecProc 具体函数见后, pstAdec);
return HI_SUCCESS;
}
以及:
/******************************************************************************
* function : get stream from file, and send it to Adec
******************************************************************************/
void *SAMPLE_COMM_AUDIO_AdecProc(void *parg)
{
HI_S32 s32Ret;
AUDIO_STREAM_S stAudioStream;
HI_U32 u32Len = 1024;
HI_U32 u32ReadLen;
HI_S32 s32AdecChn;
HI_U8 *pu8AudioStream = NULL;
SAMPLE_ADEC_S *pstAdecCtl = (SAMPLE_ADEC_S *)parg;
FILE *pfd = pstAdecCtl->pfd;
s32AdecChn = pstAdecCtl->AdChn;
pu8AudioStream = (HI_U8*)malloc(sizeof(HI_U8)*MAX_AUDIO_STREAM_LEN);
if (NULL == pu8AudioStream)
{
printf("%s: malloc failed!\n", __FUNCTION__);
return NULL;
}
while (HI_TRUE == pstAdecCtl->bStart)
{
/* read from file */
stAudioStream.pStream = pu8AudioStream;
u32ReadLen = fread(stAudioStream.pStream, 1, u32Len, pfd);
if (u32ReadLen <= 0)
{
fseek(pfd, 0, SEEK_SET);/*read file again*/
continue;
}
/* here only demo adec streaming sending mode, but pack sending mode is commended */
stAudioStream.u32Len = u32ReadLen;
s32Ret = HI_MPI_ADEC_SendStream(s32AdecChn, &stAudioStream, HI_TRUE);
if(HI_SUCCESS != s32Ret)
{
printf("%s: HI_MPI_ADEC_SendStream(%d) failed with %#x!\n",\
__FUNCTION__, s32AdecChn, s32Ret);
break;
}
}
free(pu8AudioStream);
pu8AudioStream = NULL;
fclose(pfd);
pstAdecCtl->bStart = HI_FALSE;
return NULL;
}
但是运行的时候报错:
[code]
# ./sample_audio
/************************************/
please choose the case which you want to run:
0: start AI to AO loop
1: send audio frame to AENC channel from AI, save them
2: read audio stream from file, decode and send AO
3: start AI(AIC31) to AO(Hdmi) loop
q: quit whole audio sample
sample command:2 选择读取文件进行播放
open stream file:"audio_chn0.pcm" for adec ok
bind adec:0 to ao(0,0) ok
please press twice ENTER to exit this sample
[Func]:AoCheckFrameInfo [Line]:1862 [Info]:Soundmode(0), stAioAttr.enSoundmode(1)!
[Func]:HI_MPI_AO_SendFrame [Line]:2142 [Info]:Ao dev: 0, ao chn:0, frame info error.
[Func]:AoCheckFrameInfo [Line]:1862 [Info]:Soundmode(0), stAioAttr.enSoundmode(1)!
[Func]:HI_MPI_AO_SendFrame [Line]:2142 [Info]:Ao dev: 0, ao chn:0, frame info error.
后边一直重复打印这个错误。。。
[/code]
这个错误海思文档里没有,网上也找不到特别好的解释,大家有碰到的没,帮忙一下吧,谢谢。
根据他提示:
AoCheckFrameInfo [Line]:1862 [Info]:Soundmode(0), stAioAttr.enSoundmode(1)!
应该是AO的sound mode是单声道的,但是我设置的AIO属性是立体声的。
所以发送流的时候发现不匹配。。。
.
我来回答
回答4个
时间排序
认可量排序
认可0
认可0
认可0
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2017-04-25 18:11:15
-
2023-07-19 16:46:20
-
2016-03-28 16:20:59
-
2015-12-09 12:10:53
-
2019-01-28 09:32:19
-
2017-05-10 18:52:28
-
2020-04-26 10:33:59
-
2015-03-31 11:31:52
-
2016-05-17 16:22:50
-
2018-08-24 11:29:46
-
2016-06-12 09:36:19
-
2020-07-01 17:18:17
-
2018-07-06 11:19:20
-
2019-03-25 10:41:32
-
2020-06-04 19:00:23
-
32014-09-25 16:18:31
-
2020-11-05 11:50:24
-
2018-10-26 15:00:15
-
2017-03-13 08:57:46
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
-
10求HI3519DV500_SDK_V2.0.1.1
-
5有偿求HI3516DV500 + OV5647驱动
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认