Exemplo n.º 1
0
bool HimppAiDev::enableObject()
{
    HI_S32 s32Ret;
    AIO_ATTR_S  aio_attr;

    aio_attr.enSamplerate = (AUDIO_SAMPLE_RATE_E)_sample_rate;
    aio_attr.enBitwidth = AUDIO_BIT_WIDTH_16;
    aio_attr.enWorkmode = AIO_MODE_I2S_MASTER;
    aio_attr.enSoundmode = AUDIO_SOUND_MODE_MONO;
    aio_attr.u32EXFlag = 1;
    aio_attr.u32FrmNum = 30;
    aio_attr.u32PtNumPerFrm = AUDIO_PTNUMPERFRM;
    aio_attr.u32ChnCnt = 2;
    aio_attr.u32ClkSel = 1;
    s32Ret = HI_MPI_AI_SetPubAttr(_devid, &aio_attr);
    if (s32Ret) {
        fprintf(stderr, "failed to set AI dev%d attr\n", _devid);
        return false;
    }

    s32Ret = HI_MPI_AI_Enable(_devid);
    if (s32Ret) {
        fprintf(stderr, "failed to enable AI dev%d\n", _devid);
        return false;
    }

    return true;
}
/******************************************************************************
* function : Start Ai
******************************************************************************/
HI_S32 SAMPLE_COMM_AUDIO_StartAi(AUDIO_DEV AiDevId, HI_S32 s32AiChnCnt,
        AIO_ATTR_S *pstAioAttr, HI_BOOL bAnrEn, AUDIO_RESAMPLE_ATTR_S *pstAiReSmpAttr)
{
    HI_S32 i, s32Ret;
    
    s32Ret = HI_MPI_AI_SetPubAttr(AiDevId, pstAioAttr);
    if (s32Ret)
    {
        printf("%s: HI_MPI_AI_SetPubAttr(%d) failed with %#x\n", __FUNCTION__, AiDevId, s32Ret);
        return HI_FAILURE;
    }
    if (HI_MPI_AI_Enable(AiDevId))
    {
        printf("%s: HI_MPI_AI_Enable(%d) failed with %#x\n", __FUNCTION__, AiDevId, s32Ret);
        return HI_FAILURE;
    }                
    for (i=0; i<s32AiChnCnt; i++)
    {
        if (HI_MPI_AI_EnableChn(AiDevId, i))
        {
            printf("%s: HI_MPI_AI_EnableChn(%d,%d) failed with %#x\n", __FUNCTION__,\
                    AiDevId, i, s32Ret);
            return HI_FAILURE;
        }

        if (HI_TRUE == bAnrEn)
        {
            if (HI_MPI_AI_EnableAnr(AiDevId, i))
            {
                printf("%s: HI_MPI_AI_EnableAnr(%d,%d) failed with %#x\n", __FUNCTION__,\
                    AiDevId, i, s32Ret);
                return HI_FAILURE;
            }
        }

        if (NULL != pstAiReSmpAttr)
        {
            if (HI_MPI_AI_EnableReSmp(AiDevId, i, pstAiReSmpAttr))
            {
                printf("%s: HI_MPI_AI_EnableReSmp(%d,%d) failed with %#x\n",\
                        __FUNCTION__, AiDevId, i, s32Ret);
                return HI_FAILURE;
            }
        }
    }
    
    return HI_SUCCESS;
}
Exemplo n.º 3
0
static int ai_start(AUDIO_DEV AiDevId, HI_S32 s32AiChnCnt, AIO_ATTR_S *pstAioAttr)
{
    HI_S32 i = 0;
    HI_S32 s32Ret = HI_FAILURE;

    s32Ret = HI_MPI_AI_SetPubAttr(AiDevId, pstAioAttr);
    CHECK(s32Ret == HI_SUCCESS, HI_FAILURE, "Error with %#x.\n", s32Ret);

    s32Ret = HI_MPI_AI_Enable(AiDevId);
    CHECK(s32Ret == HI_SUCCESS, HI_FAILURE, "Error with %#x.\n", s32Ret);

    for (i = 0; i < s32AiChnCnt; i++)
    {
        s32Ret = HI_MPI_AI_EnableChn(AiDevId, i);
        CHECK(s32Ret == HI_SUCCESS, HI_FAILURE, "Error with %#x.\n", s32Ret);
    }

    return HI_SUCCESS;
}
Exemplo n.º 4
0
/******************************************************************************
* function : Start Ai
******************************************************************************/
HI_S32 unidoli_start_ai(AUDIO_DEV AiDevId, HI_S32 s32AiChnCnt, AIO_ATTR_S* pstAioAttr, HI_VOID* pstAiVqeAttr, HI_U32 u32AiVqeType)
{
    HI_S32 i;
    HI_S32 s32Ret;

    s32Ret = HI_MPI_AI_SetPubAttr(AiDevId, pstAioAttr);
    if (s32Ret)
    {
        printf("%s: HI_MPI_AI_SetPubAttr(%d) failed with %#x\n", __FUNCTION__, AiDevId, s32Ret);
        return s32Ret;
    }

    s32Ret = HI_MPI_AI_Enable(AiDevId);
    if (s32Ret)
    {
        printf("%s: HI_MPI_AI_Enable(%d) failed with %#x\n", __FUNCTION__, AiDevId, s32Ret);
        return s32Ret;
    }

    for (i = 0; i < s32AiChnCnt; i++)
    {
        s32Ret = HI_MPI_AI_EnableChn(AiDevId, i/(pstAioAttr->enSoundmode + 1));
        if (s32Ret)
        {
            printf("%s: HI_MPI_AI_EnableChn(%d,%d) failed with %#x\n", __FUNCTION__, AiDevId, i, s32Ret);
            return s32Ret;
        }

        if (NULL != pstAiVqeAttr)
        {
            HI_BOOL bAiVqe = HI_TRUE;
            switch (u32AiVqeType)
            {
                case 0:
                    s32Ret = HI_SUCCESS;
                    bAiVqe = HI_FALSE;
                    break;
                case 1:
                    s32Ret = HI_MPI_AI_SetTalkVqeAttr(AiDevId, i, SAMPLE_AUDIO_AO_DEV, i, (AI_TALKVQE_CONFIG_S *)pstAiVqeAttr);
                    break;
                default:
                    s32Ret = HI_FAILURE;
                    break;
            }
            if (s32Ret)
            {
                printf("%s: SetAiVqe%d(%d,%d) failed with %#x\n", __FUNCTION__, u32AiVqeType, AiDevId, i, s32Ret);
                return s32Ret;
            }
            if (bAiVqe)
            {
            s32Ret = HI_MPI_AI_EnableVqe(AiDevId, i);
            if (s32Ret)
            {
                printf("%s: HI_MPI_AI_EnableVqe(%d,%d) failed with %#x\n", __FUNCTION__, AiDevId, i, s32Ret);
                return s32Ret;
            }
        }
    }
    }
    
    return HI_SUCCESS;
}