int Hi3511AoutGetStream(int nChannel, void *stream, int *size)
{
	HI_S32 s32ret;
	
	if (stream==NULL || size==NULL)
	{
		return -1;
	}
	if (nChannel<0 || nChannel>=MAX_AOUT_CHANNEL)
	{
		return -1;
	}	
	if (g_Hi3511_aout_open_flag == 0)
	{
		return -1;
	}
	
	s32ret = HI_MPI_AO_SendFrame(0, 0, (AUDIO_FRAME_S *)stream, HI_IO_BLOCK);
	if (HI_SUCCESS != s32ret)
	{   
		printf("ao send frame err:0x%x\n",s32ret);	//add by liujw 12-3-3
		return NULL;
	}
	//printf("HI_MPI_AO_SendFrame ao send frame ok! \n"); //add by liujw 12-3-3
	*size = 0;
	
	return 0;
}
int unidoli_aduio_send(AUDIO_DEV AoDev, AO_CHN AoChn, void *buf, uint32_t len, uint32_t ms_timeout)
{
    AUDIO_FRAME_S audio_frame_s;
    audio_frame_s.enBitwidth = AUDIO_BIT_WIDTH_16;
    audio_frame_s.enSoundmode = AUDIO_SOUND_MODE_MONO;
    audio_frame_s.pVirAddr[0] = buf;
    audio_frame_s.u32Len = len;
    return HI_MPI_AO_SendFrame(AoDev, AoChn, &audio_frame_s, 1000);
}
/******************************************************************************
* function : get frame from Ai, send it  to Aenc or Ao
******************************************************************************/
void *SAMPLE_COMM_AUDIO_AiProc(void *parg)
{
    HI_S32 s32Ret;
    HI_S32 AiFd;
    SAMPLE_AI_S *pstAiCtl = (SAMPLE_AI_S *)parg;
    AUDIO_FRAME_S stFrame; 
    AEC_FRAME_S stRefFrame;
    fd_set read_fds;
    struct timeval TimeoutVal;
    AI_CHN_PARAM_S stAiChnPara;
    

    s32Ret = HI_MPI_AI_GetChnParam(pstAiCtl->AiDev, pstAiCtl->AiChn, &stAiChnPara);
    if (HI_SUCCESS != s32Ret)
    {
        printf("%s: Get ai chn param failed\n", __FUNCTION__);
        return NULL;
    }
    
    stAiChnPara.u32UsrFrmDepth = 30;
    
    s32Ret = HI_MPI_AI_SetChnParam(pstAiCtl->AiDev, pstAiCtl->AiChn, &stAiChnPara);
    if (HI_SUCCESS != s32Ret)
    {
        printf("%s: set ai chn param failed\n", __FUNCTION__);
        return NULL;
    }
    
    FD_ZERO(&read_fds);
    AiFd = HI_MPI_AI_GetFd(pstAiCtl->AiDev, pstAiCtl->AiChn);
    FD_SET(AiFd,&read_fds);
    
    while (pstAiCtl->bStart)
    {     
        TimeoutVal.tv_sec = 1;
        TimeoutVal.tv_usec = 0;
        
        FD_ZERO(&read_fds);
        FD_SET(AiFd,&read_fds);
        
        s32Ret = select(AiFd+1, &read_fds, NULL, NULL, &TimeoutVal);
        if (s32Ret < 0) 
        {
            break;
        }
        else if (0 == s32Ret) 
        {
            printf("%s: get ai frame select time out\n", __FUNCTION__);
            continue;
        }        
        
        if (FD_ISSET(AiFd, &read_fds))
        {
            /* get frame from ai chn */
            s32Ret = HI_MPI_AI_GetFrame(pstAiCtl->AiDev, pstAiCtl->AiChn,
                &stFrame, &stRefFrame, HI_FALSE);
            if (HI_SUCCESS != s32Ret )
            {
                printf("%s: HI_MPI_AI_GetFrame(%d, %d), failed with %#x!\n",\
                       __FUNCTION__, pstAiCtl->AiDev, pstAiCtl->AiChn, s32Ret);
                //pstAiCtl->bStart = HI_FALSE;
                //return NULL;
                continue;
            }


            /* send frame to encoder */
            if (HI_TRUE == pstAiCtl->bSendAenc)
            {
                HI_MPI_AENC_SendFrame(pstAiCtl->AencChn, &stFrame, &stRefFrame);
            }
            
            /* send frame to ao */
            if (HI_TRUE == pstAiCtl->bSendAo)
            {
                HI_MPI_AO_SendFrame(pstAiCtl->AoDev, pstAiCtl->AoChn,
                    &stFrame, HI_TRUE);
            }

            /* finally you must release the stream */
            HI_MPI_AI_ReleaseFrame(pstAiCtl->AiDev, pstAiCtl->AiChn,
                &stFrame, &stRefFrame);
            usleep(10000);
        }
    }
    
    pstAiCtl->bStart = HI_FALSE;
    return NULL;
}