?? xms_confdemo_event.cpp
字號(hào):
#include "stdafx.h"
#include "XMS_ConfDemo.h"
#include "XMS_ConfDemoDlg.h"
#include "DJAcsDataDef.h"
#include "DJAcsAPIDef.h"
#include "XMS_ConfDemo_Sub.H"
#include "XMS_ConfDemo_Event.H"
#include "XMS_ConfDemo_String.H"
extern int cfg_iPartWork;
extern int cfg_iPartWorkModuleID;
// ----------------------------------------------------------------------------------------------------
TYPE_XMS_DSP_DEVICE_RES_CONFDEMO AllDeviceRes[MAX_DSP_MODULE_NUMBER_OF_XMS];
int g_iTotalModule = 0;
DJ_S8 MapTable_Module[MAX_DSP_MODULE_NUMBER_OF_XMS];
int g_iTotalPcm = 0;
int g_iTotalPcmOpened = 0;
TYPE_CHANNEL_MAP_TABLE MapTable_Pcm[MAX_PCM_NUM_IN_THIS_DEMO];
int g_iTotalTrunk = 0;
int g_iTotalTrunkOpened = 0;
TYPE_CHANNEL_MAP_TABLE MapTable_Trunk[MAX_TRUNK_NUM_IN_THIS_DEMO];
int g_iTotalVoice = 0;
int g_iTotalVoiceOpened = 0;
int g_iTotalVoiceFree = 0;
TYPE_CHANNEL_MAP_TABLE MapTable_Voice[MAX_TRUNK_NUM_IN_THIS_DEMO];
int g_iTotalConf = 0;
int g_iTotalConfOpened = 0;
int g_iTotalConfFree = 0;
TYPE_CHANNEL_MAP_TABLE MapTable_Conf[MAX_TRUNK_NUM_IN_THIS_DEMO];
// ----------------------------------------------------------------------------------------------------
void DispEventInfo ( Acs_Evt_t *pAcsEvt )
{
char TmpStr[256];
char TmpS[128];
Acs_Dev_List_Head_t * pAcsDevList = NULL;
Acs_UniFailure_Data * pAcsUniFailure = NULL;
sprintf ( TmpStr, "EVT(%4d) : ", pAcsEvt->m_s32EvtSize );
strcat ( TmpStr, GetString_EventType ( pAcsEvt->m_s32EventType ) );
switch ( pAcsEvt->m_s32EventType )
{
case XMS_EVT_OPEN_STREAM:
break;
case XMS_EVT_QUERY_DEVICE:
pAcsDevList = (Acs_Dev_List_Head_t *) FetchEventData(pAcsEvt);
sprintf ( TmpS, " (%s,%2d,%3d)",
GetString_DeviceMain(pAcsDevList->m_s32DeviceMain),
pAcsDevList->m_s32ModuleID,
pAcsDevList->m_s32DeviceNum );
strcat ( TmpStr, TmpS );
break;
case XMS_EVT_OPEN_DEVICE:
break;
case XMS_EVT_UNIFAILURE:
pAcsUniFailure = (Acs_UniFailure_Data *) FetchEventData(pAcsEvt);
sprintf ( TmpS, ": %s(0x%X) dev=(%s, %d, %d), %d ?=? %d+%d",
GetString_ErrorCode(pAcsUniFailure->m_s32AcsEvtErrCode), pAcsUniFailure->m_s32AcsEvtErrCode,
GetString_DeviceMain(pAcsEvt->m_DeviceID.m_s16DeviceMain), pAcsEvt->m_DeviceID.m_s8ModuleID, pAcsEvt->m_DeviceID.m_s16ChannelID,
pAcsEvt->m_s32EvtSize, sizeof(Acs_Evt_t), sizeof(Acs_UniFailure_Data)
);
strcat ( TmpStr, TmpS );
break;
default:
break;
}
AddMsg ( TmpStr );
}
// --------------------------------------------------------------------------
void InitAllDeviceRes (void)
{
// 將AllDeviceRes所有清為0,包括:lFlag, 各個(gè)數(shù)量,以及各個(gè)指針清為NULL
memset ( AllDeviceRes, 0, sizeof(AllDeviceRes) );
g_iTotalModule = 0;
g_iTotalPcm = 0;
g_iTotalPcmOpened = 0;
g_iTotalTrunk = 0;
g_iTotalTrunkOpened = 0;
g_iTotalVoice = 0;
g_iTotalVoiceOpened = 0;
g_iTotalVoiceFree = 0;
g_iTotalConf = 0;
g_iTotalConfOpened = 0;
g_iTotalConfFree = 0;
}
void FreeOneDeviceRes ( int ID )
{
if ( AllDeviceRes[ID].pVoice != NULL )
delete [] AllDeviceRes[ID].pVoice;
if ( AllDeviceRes[ID].pPcm != NULL )
delete [] AllDeviceRes[ID].pPcm;
if ( AllDeviceRes[ID].pTrunk != NULL )
delete [] AllDeviceRes[ID].pTrunk;
if ( AllDeviceRes[ID].pConf != NULL )
delete [] AllDeviceRes[ID].pConf;
memset ( &AllDeviceRes[ID], 0, sizeof (TYPE_XMS_DSP_DEVICE_RES_CONFDEMO) );
}
void FreeAllDeviceRes (void)
{
int i;
for ( i = 0; i < MAX_DSP_MODULE_NUMBER_OF_XMS; i ++ )
{
FreeOneDeviceRes ( i );
}
InitAllDeviceRes ();
}
// --------------------------------------------------------------------------
void RefreshMapTable ( void )
{
int i, j;
int TrkCount, VocCount, PcmCount, ModuleCount, ConfCount;
int iModSeqID;
// 將AllDeviceRes中的每個(gè)接口通道、語(yǔ)音通道、PCM通道、Conf通道所對(duì)應(yīng)的(順序號(hào))記錄下來(lái)
ModuleCount = TrkCount = VocCount = PcmCount = ConfCount = 0;
for ( i = 0; i < MAX_DSP_MODULE_NUMBER_OF_XMS; i ++ )
{
if ( AllDeviceRes[i].lFlag == 1 )
{
// DSP 模塊
AllDeviceRes[i].iSeqID = ModuleCount;
MapTable_Module[ModuleCount] = i;
ModuleCount ++;
// 語(yǔ)音通道
for ( j = 0; j < AllDeviceRes[i].lVocNum; j ++ )
{
AllDeviceRes[i].pVoice[j].iSeqID = VocCount;
MapTable_Voice[VocCount].m_s8ModuleID = AllDeviceRes[i].pVoice[j].deviceID.m_s8ModuleID;
MapTable_Voice[VocCount].m_s16ChannelID = AllDeviceRes[i].pVoice[j].deviceID.m_s16ChannelID;
VocCount ++;
}
// Conf通道
for ( j = 0; j < AllDeviceRes[i].lConfNum; j ++ )
{
AllDeviceRes[i].pConf[j].iSeqID = ConfCount;
MapTable_Conf[ConfCount].m_s8ModuleID = AllDeviceRes[i].pConf[j].deviceID.m_s8ModuleID;
MapTable_Conf[ConfCount].m_s16ChannelID = AllDeviceRes[i].pConf[j].deviceID.m_s16ChannelID;
ConfCount ++;
}
// PCM通道
for ( j = 0; j < AllDeviceRes[i].lPcmNum; j ++ )
{
AllDeviceRes[i].pPcm[j].iSeqID = PcmCount;
MapTable_Pcm[PcmCount].m_s8ModuleID = AllDeviceRes[i].pPcm[j].deviceID.m_s8ModuleID;
MapTable_Pcm[PcmCount].m_s16ChannelID = AllDeviceRes[i].pPcm[j].deviceID.m_s16ChannelID;
PcmCount ++;
}
// 接口通道
iModSeqID = 0;
for ( j = 0; j < AllDeviceRes[i].lTrunkNum; j ++ )
AllDeviceRes[i].pTrunk[j].iSeqID = TrkCount;
MapTable_Trunk[TrkCount].m_s8ModuleID = AllDeviceRes[i].pTrunk[j].deviceID.m_s8ModuleID;
MapTable_Trunk[TrkCount].m_s16ChannelID = AllDeviceRes[i].pTrunk[j].deviceID.m_s16ChannelID;
TrkCount ++;
if ( AllDeviceRes[i].pTrunk[j].deviceID.m_s16DeviceSub != XMS_DEVSUB_UNUSABLE )
{
// 可用的通道
AllDeviceRes[i].pTrunk[j].iModSeqID = iModSeqID;
iModSeqID ++;
}
}
}
}
g_iTotalModule = ModuleCount;
g_iTotalTrunk = TrkCount;
g_iTotalVoice = VocCount;
g_iTotalPcm = PcmCount;
g_iTotalConf = ConfCount;
}
// --------------------------------------------------------------------------
void AddDeviceRes_Trunk ( DJ_S8 s8DspModID, Acs_Dev_List_Head_t *pAcsDevList )
{
DJ_S32 s32Num;
int i;
char TmpStr[256];
s32Num = pAcsDevList->m_s32DeviceNum;
if ( (AllDeviceRes[s8DspModID].lTrunkNum == 0) && (s32Num > 0) ) // 新增加的資源
{
//
AllDeviceRes[s8DspModID].pTrunk = new TRUNK_STRUCT[s32Num];
if( !AllDeviceRes[s8DspModID].pTrunk )
{
AllDeviceRes[s8DspModID].lTrunkNum = 0;
AllDeviceRes[s8DspModID].lTrunkOpened = 0;
// alloc fail, maybe disp this error in your log
sprintf ( TmpStr, "new TRUNK_STRUCT[%d] fail in AddDeviceRes_Trunk()" );
AddMsg ( TmpStr );
}
else
{
AllDeviceRes[s8DspModID].lTrunkNum = s32Num;
AllDeviceRes[s8DspModID].lTrunkOpened = 0;
memset ( AllDeviceRes[s8DspModID].pTrunk, 0, sizeof(TRUNK_STRUCT)*s32Num );
DeviceID_t *pDev;
pDev = (DeviceID_t *)((BYTE *)pAcsDevList + sizeof(Acs_Dev_List_Head_t));
for ( i = 0; i < s32Num; i ++ )
{
AllDeviceRes[s8DspModID].pTrunk[i].deviceID = pDev[i];
AllDeviceRes[s8DspModID].pTrunk[i].State = TRK_WAITOPEN;
}
}
}
else if ( (AllDeviceRes[s8DspModID].lTrunkNum > 0) && (s32Num == 0) ) // 刪除該資源
{
// 如果有設(shè)備沒有關(guān)閉,則等同于關(guān)閉事件
for ( i = 0; i < AllDeviceRes[s8DspModID].lTrunkNum; i ++ )
{
if ( AllDeviceRes[s8DspModID].pTrunk[i].State != TRK_WAITOPEN )
CloseDeviceOK ( &AllDeviceRes[s8DspModID].pTrunk[i].deviceID );
}
AllDeviceRes[s8DspModID].lTrunkNum = 0;
AllDeviceRes[s8DspModID].lTrunkOpened = 0;
delete [] AllDeviceRes[s8DspModID].pTrunk;
AllDeviceRes[s8DspModID].pTrunk = NULL;
}
}
void AddDeviceRes_Voice ( DJ_S8 s8DspModID, Acs_Dev_List_Head_t *pAcsDevList )
{
DJ_S32 s32Num;
int i;
char TmpStr[256];
s32Num = pAcsDevList->m_s32DeviceNum;
if ( (AllDeviceRes[s8DspModID].lVocNum == 0) && (s32Num > 0) ) // 新增加的資源
{
AllDeviceRes[s8DspModID].pVoice = new VOICE_STRUCT[s32Num];
if( !AllDeviceRes[s8DspModID].pVoice )
{
AllDeviceRes[s8DspModID].lVocNum = 0;
AllDeviceRes[s8DspModID].lVocOpened = 0;
AllDeviceRes[s8DspModID].lVocFreeNum = 0;
// alloc fail, maybe disp this error in your log
sprintf ( TmpStr, "new VOICE_STRUCT[%d] fail in AddDeviceRes_Voice()" );
AddMsg ( TmpStr );
}
else
{
AllDeviceRes[s8DspModID].lVocNum = s32Num;
AllDeviceRes[s8DspModID].lVocOpened = 0;
AllDeviceRes[s8DspModID].lVocFreeNum = 0;
memset ( AllDeviceRes[s8DspModID].pVoice, 0, sizeof(VOICE_STRUCT)*s32Num );
DeviceID_t *pDev;
pDev = (DeviceID_t *)((BYTE *)pAcsDevList + sizeof(Acs_Dev_List_Head_t));
for ( i = 0; i < s32Num; i ++ )
{
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -