⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 voiceloopback.c

📁 DSP与VXWORKS平台的通信
💻 C
字号:
/**************************************************************************
Copyright 2002-2007 TGL Ltd. All rights reserved

VoiceLoopBack.c   -- the source file for VoiceLoopBack

DESCRIPTION


modification history
--------------------
2007-10-24, Lixiaoke, v1.0 initial version
--------------------

**************************************************************************/
#include <taskLib.h>
#include "c5416DataBuff.h"
#include "VoiceLoopBack.h"

static  const char    VOICE_LOOP_BACK_TASK_NAME[ ] = "LoopTask";
static  int           giTaskVoiceBackHandle        = -1;
static unsigned short gpusVoiceLoopBuf[ 7 ] = { };

int voiceLoopInit( void )
{
    if( giTaskVoiceBackHandle == -1 )
    {
        if( ( giTaskVoiceBackHandle = taskSpawn( ( char * )VOICE_LOOP_BACK_TASK_NAME, 120, 0, 10240, ( FUNCPTR )taskVoiceLoopBack,
                                            0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) ) == ERROR )
        {
            printf( "[ voiceLoopInit ] : create task \"%s\" error!\n", VOICE_LOOP_BACK_TASK_NAME );
            voiceLoopDInit();
            return( 0 );    		
        }
    }
    return( 1 );
}

int voiceLoopDInit( void )
{
    if( giTaskVoiceBackHandle != -1 )
    {
        if( taskDelete( giTaskVoiceBackHandle ) == ERROR )
        {
            printf("[ voiceLoopDInit ] : delete giTaskVoiceBackHandle error!\n" );
        }
        giTaskVoiceBackHandle = -1;
    }
    return ( 1 );
}

int taskVoiceLoopBack( void )
{
    while( giTaskVoiceBackHandle != -1 )
    {
        if( c5416ReadDataFromRecvBuf( ( unsigned short * ) gpusVoiceLoopBuf, sizeof( gpusVoiceLoopBuf ) ) == 0 )
        {
            printf( "[ taskVoiceLoopBack ] : c5416ReadDataFromRecvBuf error!\n" );
            voiceLoopDInit();
            return( 0 );
        }
        printf( "\nLoop : %d_%d_%d_%d_%d_%d_%d\n", gpusVoiceLoopBuf[ 0 ], gpusVoiceLoopBuf[ 1 ], gpusVoiceLoopBuf[ 2 ], gpusVoiceLoopBuf[ 3 ], gpusVoiceLoopBuf[ 4 ], gpusVoiceLoopBuf[ 5 ], gpusVoiceLoopBuf[ 6 ] );
        if( c5416SendDataToSendBuf( ( unsigned short * ) gpusVoiceLoopBuf, sizeof( gpusVoiceLoopBuf ) ) == 0 )
        {
            printf( "[ taskVoiceLoopBack ] : c5416SendDataToSendBuf error!\n" );
            voiceLoopDInit();
            return( 0 );
        }
    }
    return( 1 );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -