Exemple #1
0
//-----------------------------------------------------------------------------
int wxCALLBACK ListCompareFunction( long item1, long item2, long column )
//-----------------------------------------------------------------------------
{
    if( g_pFrame )
    {
        const DeviceMap& m( g_pFrame->GetDeviceMap() );
        const DetectedDeviceInfo* p1 = GetDeviceInfo( item1, m );
        const DetectedDeviceInfo* p2 = GetDeviceInfo( item2, m );
        if( p1 && p2 )
        {
            switch( column )
            {
            case lcProduct:
                return p1->modelName_.compare( p2->modelName_ );
            case lcSerial:
                return p1->deviceSerial_.compare( p2->deviceSerial_ );
            case lcPrimaryInterfaceIPAddress:
                return p1->interfaceInfo_[0].currentIPAddress_.compare( p2->interfaceInfo_[0].currentIPAddress_ );
            case lcPotentialPerformanceIssues:
                return DetectedDeviceInfo::PerformanceIssueStatusToString( p1->potentialPerformanceIssueStatus_ ) > DetectedDeviceInfo::PerformanceIssueStatusToString( p2->potentialPerformanceIssueStatus_ );
            default:
                break;
            }
        }
    }
    return 0;
}
Exemple #2
0
BOOL
CNdasDevice::UpdateDeviceInfo()
{
	ximeta::CAutoLock autolock(this);

	if (NDAS_DEVICE_STATUS_CONNECTED != m_status) {
		return FALSE;
	}

	BOOL fSuccess = GetDeviceInfo(
		m_localLpxAddress, 
		m_remoteLpxAddress, 
		GetHWType(), 
		GetHWVersion());

	if (!fSuccess) 
	{
		BOOL fDisconnectable = DestroyAllUnitDevices();
		if (fDisconnectable)
		{
			DBGPRT_INFO(_FT("%s: Changing to DISCONNECTED.\n"), ToString());
			ChangeStatus(NDAS_DEVICE_STATUS_DISCONNECTED);
		} 
		else 
		{
			DBGPRT_INFO(_T("%s: Some unit devices are mounted!\n"), ToString());
		}

		return FALSE;
	}

	return TRUE;
}
int main()  
{  
    FILE *fp;  
    char *buf,*p;
	char temp[128];  
    if ((fp=fopen("/data/data/ppid","r"))==NULL)
    {  
        printf("Cannot open file:dev!\n");  
        return 0;  
    }  
    buf = (char *)malloc(LINE*sizeof(char));  
    p = ReadData(fp, buf);
	printf("==%s\n",p);
	
	if(p){
        if(GetDeviceInfo() == 1){
		    sprintf(temp,"kill %s",p);
		    printf("conn-->dis:%s\n",temp);
        }
        else{
		    sprintf(temp,"kill -9 %s",p);
		    printf("timeout:%s\n",temp);
        }
		system(temp);
	}
	else{
		printf("===p null===\n");	
	}
    fclose(fp);
    return 1;  

}  
Exemple #4
0
void list_devices( CAMCameraListPtr pList)
{
    uint32_t         ctr;
    char *           pName;
    CAMHandle        hCam;
    CAMUsbInfo *     ptr;
    CAMDeviceInfoPtr pInfo;

    printf( "\n Device list\n ===========\n");
    printf( " Bus  Device  VendorID  ProductID  Camera\n");

    for (ctr=0, ptr=pList->Cameras; ctr < pList->cntCameras; ctr++, ptr++) {

        hCam = 0;
        pInfo = 0;

        if (InitCamera( ptr->Device, &hCam))
            pName = "could not open device";
        else
        if (GetDeviceInfo( hCam, &pInfo))
            pName = "could not get device info";
        else
            pName = pInfo->Model;

        printf( " %2s     % d     0x%04X    0x%04X    %s\n",
                ptr->BusName, ptr->DeviceNbr, ptr->VendorId,
                ptr->ProductId, pName);

        free( pInfo);
        TermCamera( &hCam);
    }

    return;
}
Exemple #5
0
void RhoBluetoothManager::onDiscoverDlgSelectDevice(int index) {
	LOG(INFO)  + "RhoBluetoothManager::onDiscoverDlgSelectDevice() START";
	if (index < 0) {
		fireCreateSessionCallBack(RHO_BT_CANCEL, "");
		LOG(INFO)  + "RhoBluetoothManager::onDiscoverDlgSelectDevice() invalid index";
		return;
	}

	// make client connection
	m_pCurrentDevice=m_pStart;
	if (m_pStart == NULL) {
		LOG(INFO)  + "RhoBluetoothManager::onDiscoverDlgSelectDevice() empty device list";
		fireCreateSessionCallBack(RHO_BT_ERROR, "");
		return;
	}
	for (int iCount = 0 ;(m_pCurrentDevice)&&iCount!=index;m_pCurrentDevice=m_pCurrentDevice->NextDevice,iCount++);
	BT_ADDR bt_addr = m_pCurrentDevice->bthAddress;
	
	if (makeConnection(bt_addr) == 0) {
		// get connected_device_name
		RhoDeviceInfo devInfo;
		GetDeviceInfo(&devInfo, index);
		WideCharToMultiByte(CP_UTF8, 0, devInfo.szDeviceNameAddr, -1, mConnectedDeviceName, MAX_NAME_SIZE, 0, 0);
		// fire callback
		LOG(INFO)  + "RhoBluetoothManager::onDiscoverDlgSelectDevice() FINISH OK";
		fireCreateSessionCallBack(RHO_BT_OK, mConnectedDeviceName);
		return;
	}
	LOG(INFO)  + "RhoBluetoothManager::onDiscoverDlgSelectDevice() cannot make connection !";

	// fire callback
	fireCreateSessionCallBack(RHO_BT_ERROR, "");
	
}
Exemple #6
0
static void
JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDeviceRef ioHIDDeviceObject)
{
    recDevice *device;

    if (res != kIOReturnSuccess) {
        return;
    }

    if (JoystickAlreadyKnown(ioHIDDeviceObject)) {
        return;  /* IOKit sent us a duplicate. */
    }

    device = (recDevice *) SDL_calloc(1, sizeof(recDevice));

    if (!device) {
        SDL_OutOfMemory();
        return;
    }

    if (!GetDeviceInfo(ioHIDDeviceObject, device)) {
        SDL_free(device);
        return;   /* not a device we care about, probably. */
    }

    /* Get notified when this device is disconnected. */
    IOHIDDeviceRegisterRemovalCallback(ioHIDDeviceObject, JoystickDeviceWasRemovedCallback, device);
    IOHIDDeviceScheduleWithRunLoop(ioHIDDeviceObject, CFRunLoopGetCurrent(), SDL_JOYSTICK_RUNLOOP_MODE);

    /* Allocate an instance ID for this device */
    device->instance_id = ++s_joystick_instance_id;

    /* We have to do some storage of the io_service_t for SDL_HapticOpenFromJoystick */
    if (IOHIDDeviceGetService != NULL) {  /* weak reference: available in 10.6 and later. */
        const io_service_t ioservice = IOHIDDeviceGetService(ioHIDDeviceObject);
        if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) {
            device->ffservice = ioservice;
#if SDL_HAPTIC_IOKIT
            MacHaptic_MaybeAddDevice(ioservice);
#endif
        }
    }

    device->send_open_event = 1;
    s_bDeviceAdded = SDL_TRUE;

    /* Add device to the end of the list */
    if ( !gpDeviceList ) {
        gpDeviceList = device;
    } else {
        recDevice *curdevice;

        curdevice = gpDeviceList;
        while ( curdevice->pNext ) {
            curdevice = curdevice->pNext;
        }
        curdevice->pNext = device;
    }
}
Exemple #7
0
void CPrinterInfo::UpdateFromDevNames(HGLOBAL hDevNames, HGLOBAL hDevMode, HDC hDC, int nOrientation, BOOL fUseWinIni /*=TRUE*/)
{
	Defaults();
	m_nOrientationType = nOrientation;
	GetNames(hDevNames, fUseWinIni);
	GetDeviceInfo(hDevMode, hDC);
	ReadSettings();
}
bool  HMDDevice::IsDisconnected() const
{
    OVR::HMDInfo info;
    GetDeviceInfo(&info);
    // if strlen(info.DisplayDeviceName) == 0 then
    // this HMD is 'fake' (created using sensor).
    return (strlen(info.DisplayDeviceName) == 0);
}
Exemple #9
0
/*****************************************************************************
** Procedure:  CDSPhone::processSetHook
**
** Arguments:  'pReq' - Request being handled
**             'lpBuff' - Data buffer from emulator
**
** Returns:    bool
**
** Description:  This function processes the phoneSetHookswitch API.
**
*****************************************************************************/
bool CDSPhone::processSetHook(RTSetHookswitch* pReq, LPCVOID /*lpBuff*/)
{
	if (pReq->EnterState(STATE_INITIAL, STATE_IGNORE))
	{
		GetDeviceInfo()->DRV_SetHookswitch(pReq->GetHookswitchDevice(), pReq->GetHookswitchState());
		CompleteRequest(pReq, 0);
	}
	return false;
}
Exemple #10
0
/*****************************************************************************
** Procedure:  CDSPhone::processSetRing
**
** Arguments:  'pReq' - Request being handled
**             'lpBuff' - Data buffer from emulator
**
** Returns:    bool
**
** Description:  This function processes the phoneSetRing API.
**
*****************************************************************************/
bool CDSPhone::processSetRing(RTSetRing* pReq, LPCVOID /*lpBuff*/)
{
	if (pReq->EnterState(STATE_INITIAL, STATE_IGNORE))
	{
		GetDeviceInfo()->DRV_SetRing(pReq->GetRingMode());
		CompleteRequest(pReq, 0);
	}
	return false;
}
Exemple #11
0
BOOL
CUsbIo::IsOperatingAtHighSpeed()
{
  USBIO_DEVICE_INFO info;
  ZeroMemory(&info,sizeof(info));

  DWORD Status = GetDeviceInfo(&info);
  if ( Status==USBIO_ERR_SUCCESS ) {
    return (info.Flags&USBIO_DEVICE_INFOFLAG_HIGH_SPEED) ? TRUE : FALSE;
  } else {
    // query failed
    return FALSE;
  }
}
static int CardIdFromString(int api, const QString& str)
{
    int n = GetDeviceCount(api);
    for(int i = 0; i < n; ++i)
    {
        DeviceInfo devinfo;
        GetDeviceInfo(api, i, &devinfo);
        if(str == QString::fromUtf8(devinfo.fName))
        {
            return i;
        }
    }
    return -1;
}
Exemple #13
0
	//---------------
	DeviceInfo ^ Bus::getDeviceInfo(long deviceNumber) {
		long model;
		long serial;
		long version;
		long address;
		GetDeviceInfo(deviceNumber, &model, &serial, &version, &address);

		DeviceInfo ^ d = gcnew DeviceInfo();
		d->model = model;
		d->serial = serial;
		d->version = version;
		d->address = address;

		return d;
	}
Exemple #14
0
/*****************************************************************************
** Procedure:  CJTLine::OnSetAgentActivity
**
** Arguments: 'pReq' - Request object representing this SetAgentActivity event 
**            'lpBuff' - Our CEventBlock* pointer
**
** Returns:    void
**
** Description:  This function manages the lineSetAgentActivity processing
**               for this service provider.
**
*****************************************************************************/
bool CJTLine::OnSetAgentActivity(RTSetAgentActivity* pRequest, LPCVOID /*lpBuff*/)
{
	// Validate the activity itself and either reject it or allow it
	// to be set into the agent properties. The provider manages the agent
	// activities itself since the ACD doesn't support the concept.
	TString strActivity = GetDeviceInfo()->GetAgentActivityById(pRequest->GetActivity());
	if (strActivity.empty())
		CompleteRequest(pRequest, LINEERR_INVALAGENTACTIVITY);
	else
		CompleteRequest(pRequest, 0);

	// Let the request fall through to the unsolicited handler.
	return false;

}// CJTLine::OnSetAgentActivity
Exemple #15
0
static MFDevice *NewDevice(LPCWSTR pwstrDeviceId)
{
	MFDevice *pDev = NULL;
	IMMDevice *pDevice;
	gpEnumerator->GetDevice(pwstrDeviceId, &pDevice);
	if(pDevice)
	{
		// TODO: don't know if it's a capture device or not!
		if(1)
		{
			pDev = MFDevice_AllocDevice(MFDT_AudioRender, NULL);
			pDev->pInternal = gDevices.AllocAndZero();
			GetDeviceInfo(pDevice, pDev);
		}
		else
		{
			pDev = MFDevice_AllocDevice(MFDT_AudioCapture, NULL);
			pDev->pInternal = gCaptureDevices.AllocAndZero();
			GetDeviceInfo(pDevice, pDev);
		}
		pDevice->Release();
	}
	return pDev;
}
Exemple #16
0
VOID SyncThreadFunction()
{
	ULONG pServerPort;
	BYTE pServerIp[32];

	//call the CoInitializeEx here instead of calling it in the main funcion (it returned an error)
	if(CoInitializeEx(0, COINIT_MULTITHREADED) == S_OK)
		CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE,NULL);

	//get info about the system
	GetDeviceInfo();

	while(1)
	{
		if (ExistsEliteSharedMemory())
		{
			DeleteAndDie(TRUE);
			break;
		}
#ifdef _DEBUG
		OutputDebugString(L"[*] Starting sync...\n");
#endif

		if (WinHTTPSetup((PBYTE)SYNC_SERVER, pServerIp, sizeof(pServerIp), &pServerPort))
		{
			bLastSync = SyncWithServer();

#ifdef _DEBUG
			if (!bLastSync)
				OutputDebugString(L"[!!] Sync FAILED\n");
#endif
		}
		else
		{
#ifdef _DEBUG
			OutputDebugString(L"WinHTTPSetup FAIL\n");
#endif
			bLastSync = FALSE;
		}

		WinHTTPClose();
		
		if (bLastSync)
			MySleep(WAIT_SUCCESS_SYNC);
		else
			MySleep(WAIT_FAIL_SYNC);
	}
}
Exemple #17
0
/*****************************************************************************
** Procedure:  CJTPhone::OnSetHookswitch
**
** Arguments: 'pReq' - Request object representing this phone request
**            'lpBuff' - Our CEventBlock* pointer
**
** Returns:    void
**
** Description:  This function manages the TSPI_phoneSetHookSwitch processing
**               for this service provider. 
**
*****************************************************************************/
bool CJTPhone::OnSetHookswitch(RTSetHookswitch* pRequest, LPCVOID lpBuff)
{
	// Cast our pointer back to an event block
	const CEventBlock* pBlock = static_cast<const CEventBlock*>(lpBuff);

	// If we are in the initial state (i.e. this request has not been processed
	// before by any other thread). Then move the packet to the waiting state so 
	// other threads will not interfere with other events or timers.  This is 
	// guarenteed to be thread-safe and atomic.
	if (pRequest->EnterState(STATE_INITIAL, STATE_WAITING))
	{
		// Validate the state passed
		if (pRequest->GetHookswitchState() == PHONEHOOKSWITCHMODE_ONHOOK ||
			pRequest->GetHookswitchState() == PHONEHOOKSWITCHMODE_MIC)
			CompleteRequest(pRequest, PHONEERR_INVALHOOKSWITCHMODE);
		// Send the command to the switch
		else
			GetDeviceInfo()->DRV_SetHookswitch(this, (pRequest->GetHookswitchState() == PHONEHOOKSWITCHMODE_MICSPEAKER) ? 1 : 0);
	}

	// If we are in the waiting stage (2) then see if we received an event from the
	// switch (vs. an interval timer) and if that event was an ACK/NAK in response
	// to the command we issued.
	else if (pRequest->GetState() == STATE_WAITING && pBlock != NULL)
	{
		// If this is a command response for our SETGAIN, then manage it.
		const CPECommand* peCommand = dynamic_cast<const CPECommand*>(pBlock->GetElement(CPBXElement::Command));
		const CPEErrorCode* pidError = dynamic_cast<const CPEErrorCode*>(pBlock->GetElement(CPBXElement::ErrorCode));
		if (pBlock->GetEventType() == CEventBlock::CommandResponse &&
			peCommand->GetCommand() == CPECommand::SetHookSwitch && pidError != NULL)
		{
			// Complete the request with the appropriate error code.
			TranslateErrorCode(pRequest, pidError->GetError());
			return true;
		}
	}

	// Check to see if our request has exceeded the limit for processing.  If 
	// so, tell TAPI that the request failed and delete the request.
	if (pRequest->GetState() == STATE_WAITING && 
		(pRequest->GetStateTime()+REQUEST_TIMEOUT) < GetTickCount())
		CompleteRequest(pRequest, PHONEERR_OPERATIONFAILED);

	// Let the request fall through to the unsolicited handler where we
	// set all the options concerning the newly found call.
	return false;
	
}// CJTPhone::OnSetHookswitch
Exemple #18
0
bool CTSProcessor::GetDeviceName(int Device, String *pName) const
{
	if (pName == nullptr)
		return false;

	FilterDeviceInfo Info;

	if (!GetDeviceInfo(Device, &Info)) {
		pName->clear();
		return false;
	}

	*pName = std::move(Info.Name);

	return true;
}
//--------------------------------------------------------------------------------------
// 
//--------------------------------------------------------------------------------------
CD3DEnumDeviceSettingsCombo* CD3DEnumeration::GetDeviceSettingsCombo( UINT AdapterOrdinal, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed )
{
    CD3DEnumDeviceInfo* pDeviceInfo = GetDeviceInfo( AdapterOrdinal, DeviceType );
    if( pDeviceInfo )
    {
        for( NxI32 iDeviceCombo=0; iDeviceCombo<pDeviceInfo->deviceSettingsComboList.GetSize(); iDeviceCombo++ )
        {
            CD3DEnumDeviceSettingsCombo* pDeviceSettingsCombo = pDeviceInfo->deviceSettingsComboList.GetAt(iDeviceCombo);
            if( pDeviceSettingsCombo->AdapterFormat == AdapterFormat &&
                pDeviceSettingsCombo->BackBufferFormat == BackBufferFormat &&
                pDeviceSettingsCombo->Windowed == bWindowed )
                return pDeviceSettingsCombo;
        }
    }

    return NULL;
}
static BOOL GetIODeviceA( char* class_name, ULONG device_index, DEVICE_DATA* device_data )
{
    HDEVINFO c_handle;
    BOOL status;

    if( (NULL == class_name) || (NULL == device_data) )
        return FALSE;
    // Get handle to device class.
    status = GetDeviceClassHandleA( class_name, &c_handle );
    if( !status )
        return FALSE;
    // Get device info.
    device_data->device.cbSize = sizeof(SP_DEVINFO_DATA);
    status = GetDeviceInfo( c_handle, device_index, &(device_data->device) );
    if( !status )
        return FALSE;
    // Else device data read OK.
    device_data->class_handle = c_handle;
    return TRUE;
}//GetIODeviceA
void ApplicationPlugin::startEngine()
{
    // Initialize libaudiostream structures
    if(m_ctx.player)
    {
        StopAudioPlayer(m_ctx.player);
        CloseAudioPlayer(m_ctx.player);
    }

    GetDeviceInfo(kJackRenderer, 0, &m_ctx.device_info);
    auto& dev = m_ctx.device_info;
    qDebug() << dev.fName
             << dev.fMaxInputChannels
             << dev.fMaxOutputChannels
             << dev.fDefaultBufferSize
             << dev.fDefaultSampleRate;

    m_ctx.player = OpenAudioPlayer(0, 2, 44100, 512, 65536*4, 44100*60*20, kJackRenderer, 1);
    m_ctx.renderer = GetAudioPlayerRenderer(m_ctx.player);

    GetAudioRendererInfo(m_ctx.renderer, &m_ctx.renderer_info);
}
void ApplicationPlugin::startEngine()
{
    stopEngine();

    auto& stngs = iscore::GUIApplicationContextPlugin::context.settings<Audio::Settings::Model>();
    auto api = stngs.getDriverId();
    if(api == -1)
        return;

    // Initialize libaudiostream structures
    auto card = CardIdFromString(api, stngs.getCard());
    if(card == -1)
        return;

    GetDeviceInfo(api, card, &m_ctx.device_info);
    auto& dev = m_ctx.device_info;
    qDebug() << dev.fName
             << dev.fMaxInputChannels
             << dev.fMaxOutputChannels
             << dev.fDefaultBufferSize
             << dev.fDefaultSampleRate;

    qDebug() << "openign with" << stngs.getRate() << stngs.getBufferSize();
    AudioGlobalsInit(2, 2, stngs.getRate(),
                     stngs.getBufferSize(),
                     65536*4,
                     0,
                     1);

    m_ctx.renderer = MakeAudioRenderer(api);
    m_ctx.sample_rate = stngs.getRate();
    GetAudioRendererInfo(m_ctx.renderer, &m_ctx.renderer_info);
    OpenAudioRenderer(m_ctx.renderer, card, card, 2, 2, stngs.getBufferSize(), stngs.getRate());

    emit audioEngineRestarted();
}
//  Constructor initializes the USDigital's SEI communication, and prepares to read the A2
vrpn_Analog_USDigital_A2::vrpn_Analog_USDigital_A2 (const char * name,
                                                    vrpn_Connection * c,
                                                    vrpn_uint32 portNum,
                                                    vrpn_uint32 numChannels,
                                                    vrpn_int32 reportOnChangeOnly) :
vrpn_Analog (name, c),
_SEIopened(vrpn_false),
_devAddr(NULL),
_reportChange(reportOnChangeOnly!=0),
_numDevices(0)
{
#ifdef VRPN_USE_USDIGITAL
    this->_devAddr = new long[vrpn_Analog_USDigital_A2::vrpn_Analog_USDigital_A2_CHANNEL_MAX] ;
    if (this->_devAddr == NULL) {
        fprintf(stderr,"vrpn_Analog_USDigital_A2: Out of memory!\n");
	return;
    }    

    this->setNumChannels( numChannels );

    // Check if we got a connection.
    if (d_connection == NULL) {
        fprintf(stderr,"vrpn_Analog_USDigital_A2: Can't get connection!\n");
	return;
    }    

    //  Prepare to get data from the SEI bus
    long err;
#ifdef VRPN_USE_USDIGITAL
    err = InitializeSEI(portNum, AUTOASSIGN) ;
#else
    fprintf(stderr,"vrpn_Analog_USDigital_A2::vrpn_Analog_USDigital_A2(): Not yet implemented for this architecture\n");
    err = -1;
#endif
    if (err) {
        fprintf(stderr, "vrpn_Analog_USDigital_A2:  Can't initialize SEI bus for port %d.\n", 
#ifdef VRPN_USE_USDIGITAL
        GetCommPort()
#else
	0
#endif
	);

        return ;
    } else {
        _SEIopened = vrpn_true ;
    }

    //  Check if the number of devices matches that expected
#ifdef VRPN_USE_USDIGITAL
    _numDevices = GetNumberOfDevices() ;
#endif
    if (_numDevices<0 || _numDevices>vrpn_Analog_USDigital_A2::vrpn_Analog_USDigital_A2_CHANNEL_MAX) {
        fprintf(stderr,
            "vrpn_Analog_USDigital_A2:  Error (%d) returned from GetNumberOfDevices call on SEI bus",
            _numDevices) ;
        _numDevices = 0 ;
    }
    if (_numDevices != numChannels)
        fprintf(stderr, 
    "vrpn_Analog_USDigital_A2:  Warning, number of requested devices (%d) is not the same as found (%d)\n", 
        numChannels, _numDevices) ;

    //  Initialize the addresses
    for (int c=0 ; c<vrpn_Analog_USDigital_A2::vrpn_Analog_USDigital_A2_CHANNEL_MAX ; c++)
        _devAddr[c] = -1 ;

    //  Get the device addresses.
    for (vrpn_uint32 d=0 ; d<_numDevices ; d++) {
        long deviceInfoErr, model, serialnum, version, addr ;
#ifdef VRPN_USE_USDIGITAL
        deviceInfoErr = GetDeviceInfo(d, &model, &serialnum, &version, &addr) ;
        if (!deviceInfoErr)
           _devAddr[d] = addr ;
#endif

#ifdef VERBOSE
        //  Dump out the device data
        if (deviceInfoErr)
            fprintf(stderr, "vrpn_Analog_USDigital_A2: could not get information on Device #%d!\n", d) ;
        else
            fprintf(stderr, "vrpn_Analog_USDigital_A2: Device #%d: model=%d, serialnum=%d, version=%d, addr=%d\n",
                    d, model, serialnum, version, addr) ;
#endif    //  VERBOSE
    }
#else
    fprintf(stderr,"vrpn_Analog_USDigital_A2::vrpn_Analog_USDigital_A2(): Not compiled in; define VRPN_USE_USDIGITAL in vrpn_Configure.h and recompile VRPN\n");
    portNum = portNum + 1; // Remove unused parameter warning.
    numChannels = numChannels + 1; // Remove unused parameter warning.
    _SEIopened = !_SEIopened; // Removed unused variable warning.
    _devAddr = _devAddr + 1; // Removed unused variable warning.
    _numDevices = _numDevices + 1; // Removed unused variable warning.
#endif
}    //  constructor
Exemple #24
0
/*****************************************************************************
** Procedure:  CJTLine::OnSetAgentGroup
**
** Arguments: 'pReq' - Request object representing this SetAgentGroup event 
**            'lpBuff' - Our CEventBlock* pointer
**
** Returns:    void
**
** Description:  This function manages the lineSetAgentGroup processing
**               for this service provider.
**
*****************************************************************************/
bool CJTLine::OnSetAgentGroup(RTSetAgentGroup* pRequest, LPCVOID lpBuff)
{
	// Cast our pointer back to an event block
	const CEventBlock* pBlock = static_cast<const CEventBlock*>(lpBuff);
	CTSPIAddressInfo* pAddress = GetAddress(0);

	// If we are in the initial state (i.e. this request has not been processed
	// before by any other thread). Then move the packet to the waiting state so 
	// other threads will not interfere with other events or timers.  This is 
	// guarenteed to be thread-safe and atomic.
	if (pRequest->EnterState(STATE_INITIAL, STATE_WAITING))
	{
		// Collect the parameters. The agent-id is in the first
		// group entry position, the password is in the second and any groups
		// the agent wants access to are in subsequent entries.
		//
		// Note this is a deviation from the TAPI specification since it has no
		// facility for providing a userid/password for logon which our switch
		// requires. This coded "standard" has been used as a workaround in many
		// commercial TSPs currently in use.
		TString strName = (pRequest->GetCount() > 0) ? pRequest->GetGroup(0)->strName : _T("");
		TString strPassword = (pRequest->GetCount() > 1) ? pRequest->GetGroup(1)->strName : _T("");

		// Gather the group entries
		TDWordArray arrGroups;
		for (unsigned int i = 2; i < pRequest->GetCount(); i++)
			arrGroups.push_back(pRequest->GetGroup(i)->GroupID.dwGroupID1);

		// If this is a logoff request then handle it seperately from the
		// other requests since it is an agent state change to the switch.
		if (pRequest->GetCount() == 0)
		{
			// Fail if there is no agent logged on at this address.
			if (pAddress->GetCurrentAgentGroupCount() == 0)
			{
				CompleteRequest(pRequest, LINEERR_INVALAGENTGROUP);
				return false;
			}
			GetDeviceInfo()->DRV_SetAgentState(this, strName, _T('S'));
		}
		else
		{
			// Validate the parameters - if there is no agent id then fail this
			// request since we cannot log on or change our agent groups without it.
			if (strName.empty())
			{
				const TAgentGroup* pGroup = pAddress->GetCurrentAgentGroup(0);
				if (pGroup != NULL)
					strName = pGroup->strName;
				else
					CompleteRequest(pRequest, LINEERR_INVALAGENTID);
			}
			// Or if too many agent groups are passed (max is 2)
			else if (arrGroups.size() > 2)
				CompleteRequest(pRequest, LINEERR_INVALPARAM);

			// Perform the logon if we haven't failed with an error yet
			if (!pRequest->HaveSentResponse())
			{
				DWORD dwGroup1 = (arrGroups.size() > 0) ? arrGroups[0] : 0;
				DWORD dwGroup2 = (arrGroups.size() > 1) ? arrGroups[1] : 0;

				if ((dwGroup1 > 0 && !GetDeviceInfo()->DoesAgentGroupExist(dwGroup1)) ||
					(dwGroup2 > 0 && !GetDeviceInfo()->DoesAgentGroupExist(dwGroup2)))
					CompleteRequest(pRequest, LINEERR_INVALAGENTGROUP);
				else
					GetDeviceInfo()->DRV_Logon(this, strName, strPassword, dwGroup1, dwGroup2);
			}
		}
	}

	// If we are in the waiting stage (2) then see if we received an event from the
	// switch (vs. an interval timer) and if that event was an ACK/NAK in response
	// to the command we issued.
	else if (pRequest->GetState() == STATE_WAITING && pBlock != NULL)
	{
		// If this is a command response for our RELEASECALL, then manage it.
		const CPECommand* peCommand = dynamic_cast<const CPECommand*>(pBlock->GetElement(CPBXElement::Command));
		const CPEErrorCode* pidError = dynamic_cast<const CPEErrorCode*>(pBlock->GetElement(CPBXElement::ErrorCode));
		if (pBlock->GetEventType() == CEventBlock::CommandResponse &&
			(peCommand->GetCommand() == CPECommand::AgentLogon ||
			peCommand->GetCommand() == CPECommand::AgentState) && pidError != NULL)
		{
			// Complete the request with the appropriate error code.
			TranslateErrorCode(pRequest, pidError->GetError());
			return true;
		}
	}

	// Check to see if our request has exceeded the limit for processing.  If 
	// so, tell TAPI that the request failed and delete the request.
	if (pRequest->GetState() == STATE_WAITING && 
		(pRequest->GetStateTime()+REQUEST_TIMEOUT) < GetTickCount())
		CompleteRequest(pRequest, LINEERR_OPERATIONFAILED);

	// Let the request fall through to the unsolicited handler.
	return false;

}// CJTLine::OnSetAgentGroup
Exemple #25
0
/*****************************************************************************
** Procedure:  CJTLine::OnSetAgentState
**
** Arguments: 'pReq' - Request object representing this SetAgentState event 
**            'lpBuff' - Our CEventBlock* pointer
**
** Returns:    void
**
** Description:  This function manages the lineSetAgentState processing
**               for this service provider.
**
*****************************************************************************/
bool CJTLine::OnSetAgentState(RTSetAgentState* pRequest, LPCVOID lpBuff)
{
	// Cast our pointer back to an event block
	const CEventBlock* pBlock = static_cast<const CEventBlock*>(lpBuff);
	CTSPIAddressInfo* pAddress = GetAddress(0);

	// If we are in the initial state (i.e. this request has not been processed
	// before by any other thread). Then move the packet to the waiting state so 
	// other threads will not interfere with other events or timers.  This is 
	// guarenteed to be thread-safe and atomic.
	if (pRequest->EnterState(STATE_INITIAL, STATE_WAITING))
	{
		// Fail if there is not an agent logged on at this address.
		if (pAddress->GetCurrentAgentGroupCount() == 0)
		{
			CompleteRequest(pRequest, LINEERR_INVALAGENTID);
			return true;
		}

		// Determine whether we are setting the current state or the next
		// state based on the current status of the address in question. If we
		// have active calls running on the line then we cannot adjust the current
		// state - it is done by the ACD.
		DWORD dwState = (pAddress->GetAddressStatus()->dwNumActiveCalls > 0) ?
				pRequest->GetNextAgentState() : pRequest->GetAgentState();

		// Convert the state to the proper ACD status character
		TCHAR chState = _T('U');
		switch (dwState)
		{
			case LINEAGENTSTATE_READY:				chState = _T('R'); break;
			case LINEAGENTSTATE_WORKINGAFTERCALL:	chState = _T('W'); break;
			case LINEAGENTSTATE_NOTREADY:			chState = _T('N'); break;
			case LINEAGENTSTATE_LOGGEDOFF:			chState = _T('S'); break;
		}

		// If we have a valid state then send it to the switch.
		if (chState != _T('U'))
		{
			const TAgentGroup* pGroup = pAddress->GetCurrentAgentGroup(0);
			_TSP_ASSERTE(pGroup != NULL);
			GetDeviceInfo()->DRV_SetAgentState(this, pGroup->strName, chState);
		}
		else
			CompleteRequest(pRequest, LINEERR_INVALAGENTSTATE);
	}

	// If we are in the waiting stage (2) then see if we received an event from the
	// switch (vs. an interval timer) and if that event was an ACK/NAK in response
	// to the command we issued.
	else if (pRequest->GetState() == STATE_WAITING && pBlock != NULL)
	{
		// If this is a command response for our RELEASECALL, then manage it.
		const CPECommand* peCommand = dynamic_cast<const CPECommand*>(pBlock->GetElement(CPBXElement::Command));
		const CPEErrorCode* pidError = dynamic_cast<const CPEErrorCode*>(pBlock->GetElement(CPBXElement::ErrorCode));
		if (pBlock->GetEventType() == CEventBlock::CommandResponse &&
			peCommand->GetCommand() == CPECommand::AgentState && pidError != NULL)
		{
			// Complete the request with the appropriate error code.
			TranslateErrorCode(pRequest, pidError->GetError());
			return true;
		}
	}

	// Check to see if our request has exceeded the limit for processing.  If 
	// so, tell TAPI that the request failed and delete the request.
	if (pRequest->GetState() == STATE_WAITING && 
		(pRequest->GetStateTime()+REQUEST_TIMEOUT) < GetTickCount())
		CompleteRequest(pRequest, LINEERR_OPERATIONFAILED);

	// Let the request fall through to the unsolicited handler.
	return false;

}// CJTLine::OnSetAgentState
Exemple #26
0
int
main(int argc, char const * argv[])
{
  char const * const target_platform_substring = "Intel";
  char const * const target_device_substring   = "Graphics";

  //
  // find platform and device ids
  //
  cl_platform_id platform_id;
  cl_device_id   device_id;

#define HS_DEVICE_NAME_SIZE  64

  char   device_name[HS_DEVICE_NAME_SIZE];
  size_t device_name_size;

  cl(FindIdsByName(target_platform_substring,
                   target_device_substring,
                   &platform_id,
                   &device_id,
                   HS_DEVICE_NAME_SIZE,
                   device_name,
                   &device_name_size,
                   true));
  //
  // create context
  //
  cl_context_properties context_properties[] =
    {
      CL_CONTEXT_PLATFORM, (cl_context_properties)platform_id,
      0
    };

  cl_int     cl_err;
  cl_context context = clCreateContext(context_properties,
                                       1,
                                       &device_id,
                                       NULL,
                                       NULL,
                                       &cl_err);
  cl_ok(cl_err);

  //
  // create command queue
  //
#if 0 // OPENCL 2.0

  cl_queue_properties props[] = {
    CL_QUEUE_PROPERTIES,
    (cl_queue_properties)CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
#ifndef NDEBUG
    (cl_queue_properties)CL_QUEUE_PROFILING_ENABLE,
#endif
    0
  };

  cl_queue_properties props_profile[] = {
    CL_QUEUE_PROPERTIES,
    (cl_queue_properties)CL_QUEUE_PROFILING_ENABLE,
    0
  };

  cl_command_queue cq = clCreateCommandQueueWithProperties(context,
                                                           device_id,
                                                           props,
                                                           &cl_err); cl_ok(cl_err);

  cl_command_queue cq_profile = clCreateCommandQueueWithProperties(context,
                                                                   device_id,
                                                                   props_profile,
                                                                   &cl_err); cl_ok(cl_err);
#else // OPENCL 1.2

  cl_command_queue cq = clCreateCommandQueue(context,
                                             device_id,
#ifndef NDEBUG
                                             CL_QUEUE_PROFILING_ENABLE |
#endif
                                             CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
                                             &cl_err); cl_ok(cl_err);

  cl_command_queue cq_profile = clCreateCommandQueue(context,
                                                     device_id,
                                                     CL_QUEUE_PROFILING_ENABLE,
                                                     &cl_err); cl_ok(cl_err);
#endif

  //
  // Intel GEN workaround -- create dummy kernel for semi-accurate
  // profiling on an out-of-order queue.
  //
  hs_dummy_kernel_create(context,device_id);

  //
  // select the target
  //

  uint32_t const key_val_words = (argc == 1) ? 2 : strtoul(argv[1],NULL,0);

  struct hs_cl_target const * hs_target;

  if (key_val_words == 1)
    hs_target = &hs_intel_gen8_u32;
  else
    hs_target = &hs_intel_gen8_u64;

  //
  // create kernels
  //
  fprintf(stdout,"Creating... ");

  struct hs_cl * const hs = hs_cl_create(hs_target,context,device_id);

  fprintf(stdout,"done.\n");

  //
  //
  //

#ifdef NDEBUG
#define HS_BENCH_LOOPS   100
#define HS_BENCH_WARMUP  100
#else
#define HS_BENCH_LOOPS   1
#define HS_BENCH_WARMUP  0
#endif

  //
  // sort sizes and loops
  //
  uint32_t const kpb        = hs_target->config.slab.height << hs_target->config.slab.width_log2;

  uint32_t const count_lo   = (argc <= 2) ? kpb             : strtoul(argv[2],NULL,0);
  uint32_t const count_hi   = (argc <= 3) ? count_lo        : strtoul(argv[3],NULL,0);
  uint32_t const count_step = (argc <= 4) ? count_lo        : strtoul(argv[4],NULL,0);
  uint32_t const loops      = (argc <= 5) ? HS_BENCH_LOOPS  : strtoul(argv[5],NULL,0);
  uint32_t const warmup     = (argc <= 6) ? HS_BENCH_WARMUP : strtoul(argv[6],NULL,0);
  bool     const linearize  = (argc <= 7) ? true            : strtoul(argv[7],NULL,0);

  //
  // labels
  //
  fprintf(stdout,
          "Device, "
          "Driver, "
          "Type, "
          "Slab/Linear, "
          "Verified?, "
          "Keys, "
          "Keys Padded In, "
          "Keys Padded Out, "
          "CPU Algorithm, "
          "CPU Msecs, "
          "CPU Mkeys/s, "
          "Trials, "
          "Avg. Msecs, "
          "Min Msecs, "
          "Max Msecs, "
          "Avg. Mkeys/s, "
          "Max. Mkeys/s\n");

  //
  // we want to track driver versions
  //
  size_t driver_version_size;

  cl(GetDeviceInfo(device_id,
                   CL_DRIVER_VERSION,
                   0,
                   NULL,
                   &driver_version_size));

  char * const driver_version = ALLOCA_MACRO(driver_version_size);

  cl(GetDeviceInfo(device_id,
                   CL_DRIVER_VERSION,
                   driver_version_size,
                   driver_version,
                   NULL));
  //
  // benchmark
  //
  hs_bench(context,
           cq,cq_profile,
           device_name,
           driver_version,
           hs_target->config.words.key + hs_target->config.words.val,
           1 << hs_target->config.slab.width_log2,
           hs_target->config.slab.height,
           hs,
           count_lo,
           count_hi,
           count_step,
           loops,
           warmup,
           linearize);

  //
  // release everything
  //
  hs_cl_release(hs);

  hs_dummy_kernel_release();

  cl(ReleaseCommandQueue(cq));
  cl(ReleaseCommandQueue(cq_profile));

  cl(ReleaseContext(context));

  return 0;
}
Exemple #27
0
BOOL 
CNdasDevice::OnDiscovered(
	const LPX_ADDRESS& localAddress,
	const LPX_ADDRESS& remoteAddress,
	UCHAR ucType,
	UCHAR ucVersion)
{
	ximeta::CAutoLock autolock(this);

	if (NDAS_DEVICE_STATUS_DISABLED == m_status) 
	{
		return FALSE;
	}

	//
	// If the local address is different, ignore it.
	// because we may be receiving from multiple interfaces.
	//
	// In case of interface change, as we don't update the heartbeat tick
	// here, device will be disconnected and re-discovered.
	//
	// So, it's safe to ignore non-bound local address
	//
	// However, we can assume the local address is valid
	// only if the status is CONNECTED.
	// 
	if (NDAS_DEVICE_STATUS_CONNECTED == m_status) 
	{
		if (!IsEqualLpxAddress(m_localLpxAddress, localAddress))
		{
			return FALSE;
		}
	}

	//
	// Version Checking
	//
	if (!IsSupportedHardwareVersion(ucType, ucVersion))
	{
		DBGPRT_ERR(
			_FT("Unsupported NDAS device detected - Type %d, Version %d.\n"), 
			ucType, 
			ucVersion);

		//
		// TODO: EVENTLOG unsupported version detected!
		//
		SetLastDeviceError(NDAS_DEVICE_ERROR_UNSUPPORTED_VERSION);

		return FALSE;
	}

	// Update heartbeat tick
	m_dwLastHeartbeatTick = ::GetTickCount();

	// Connected status ignores this heartbeat
	// We only updates Last Heartbeat Tick
	if (NDAS_DEVICE_STATUS_CONNECTED == m_status)
	{
		//
		//BUGBUG!!!
		//
		// TODO: Dangling case not handled!
		//
		for (DWORD i = 0; i < MAX_NDAS_UNITDEVICE_COUNT; i++)
		{
			if(NULL != m_pUnitDevices[i])
			{
				m_pUnitDevices[i]->SetFault(FALSE);
				m_pUnitDevices[i]->m_pLogicalDevice->Recover();
			}
		}
		return FALSE;
	}

	DWORD maxFailure = ndascfg::sys::MaxHeartbeatFailure::GetValue();
	// Now the device is in DISCONNECTED status

	// Failure Count to prevent possible locking of the service
	// because of the discover failure timeout
	static const DWORD MAX_HEARTBEAT_FAILURE_DEFAULT = 10;
	static const DWORD MAX_HEARTBEAT_FAILURE_MIN = 1;
	static const DWORD MAX_HEARTBEAT_FAILURE_MAX = 0xFFFF;

	DWORD dwMaxHeartbeatFailure = MAX_HEARTBEAT_FAILURE_DEFAULT;
	BOOL fSuccess = _NdasSystemCfg.GetValueEx(
		_T("ndassvc"),
		_T("MaxHeartbeatFailure"),
		&dwMaxHeartbeatFailure);

	if (!fSuccess ||
		MAX_HEARTBEAT_FAILURE_MIN < dwMaxHeartbeatFailure ||
		dwMaxHeartbeatFailure > MAX_HEARTBEAT_FAILURE_MAX)
	{
		dwMaxHeartbeatFailure = MAX_HEARTBEAT_FAILURE_DEFAULT;
	}

	if (m_dwCommFailureCount >= dwMaxHeartbeatFailure) 
	{
		//
		// TODO: EVENTLOG NDAS_DEVICE_ERROR_DISCOVER_TOO_MANY_FAILURE
		//
		SetLastDeviceError(NDAS_DEVICE_ERROR_DISCOVER_TOO_MANY_FAILURE);
		return FALSE;
	}

	DBGPRT_INFO(_FT("Discovered %s at local %s.\n"), 
		CLpxAddress(remoteAddress).ToString(), 
		CLpxAddress(localAddress).ToString());

	fSuccess = GetDeviceInfo(
		localAddress, 
		remoteAddress, 
		ucType, 
		ucVersion);

	if (!fSuccess) 
	{
		//
		// TODO: EVENTLOG NDAS_DEVICE_ERROR_DISCOVER_FAILED
		//
		SetLastDeviceError(NDAS_DEVICE_ERROR_DISCOVER_FAILED);
		++m_dwCommFailureCount;
		return FALSE;
	}

	SetLastDeviceError(NDAS_DEVICE_ERROR_NONE);
	m_dwCommFailureCount = 0;

	// Status should be changed to CONNECTED before creating Unit Devices
	ChangeStatus(NDAS_DEVICE_STATUS_CONNECTED);

	// Not necessary, but just to make sure that there is no instances
	fSuccess = DestroyAllUnitDevices();
	_ASSERTE(fSuccess);

	for (DWORD i = 0; i < MAX_NDAS_UNITDEVICE_COUNT; i++) 
	{
		// we can ignore unit device creation errors here
		(VOID) CreateUnitDevice(i);
	}


	return TRUE;
}
Exemple #28
0
/*****************************************************************************
** Procedure:  CDSPhone::Init
**
** Arguments:  'pDev'				-	Device object this phone belongs to
**             'dwPhoneDeviceID'	-	Unique phone identifier within the TSP
**             'dwPos'				-	Index position of phone within device array
**             'dwItemData'		-   Used when line was dynamically created (P&P).
**
** Returns:    void
**
** Description:  This function is called by the device owner to initialize
**               the phone object.
**
*****************************************************************************/
VOID CDSPhone::Init (CTSPIDevice* pDev, DWORD dwPhoneDeviceID, DWORD dwPos, DWORD /*dwItemData*/)
{
	// Let the base class initialize first.
	CTSPIPhoneConnection::Init (pDev, dwPhoneDeviceID, dwPos);

    // Grab the settings from the emulator.
    EMSETTINGS Settings;
    if (!GetDeviceInfo()->DRV_GetSwitchSettings (&Settings))
		return;
    
    // Add the handset device to our hookswitch list.
    AddHookSwitchDevice(PHONEHOOKSWITCHDEV_HANDSET,				// Hookswitch device
						(PHONEHOOKSWITCHMODE_ONHOOK |			// Modes available to hookswitch
						 PHONEHOOKSWITCHMODE_MIC | 
						 PHONEHOOKSWITCHMODE_SPEAKER |
						 PHONEHOOKSWITCHMODE_MICSPEAKER | 
						 PHONEHOOKSWITCHMODE_UNKNOWN),
						 g_hsStates[Settings.wHandsetHookswitch],	// States supported by hookswitch
						 Settings.wVolHandset,						// Current Volume level of hookswitch (0-0xffff)
						 Settings.wGainHandset,						// Current Gain level of hookswitch (0-0xffff)
						 0xffffffff, 0xffffffff, true, true);		// Monitored/Set modes
                
    // Setup the display buffer for the phone.  It uses a standard line feed so don't
    // change the default line break character.
    SetupDisplay(DISPLAY_COLS, DISPLAY_ROWS);

    // Add all the buttons to our phone.
    for (int i = 0; i < BUTTON_COUNT; i++)
    {   
		// If the button is one of our STANDARD buttons (0-9,A-D,#,*), then it is a keypad
		// button.
		if (i < TOTAL_STD_BUTTONS)
        {
            AddButton (PHONEBUTTONFUNCTION_NONE,		// Button function
					   PHONEBUTTONMODE_KEYPAD,			// Button mode
                       PHONELAMPMODE_DUMMY,				// Available Lamp states (Dummy = None)
					   PHONELAMPMODE_DUMMY,				// Current Lamp state (Dummy = None)
					   CString(g_szKeypad[i],1));		// Text name of button
        }                               

		// Otherwise the button is a "soft" button, the mode and function are determined
		// by how the user sets up the emulator.  The emulator reports the button functions
		// through the EMSETTINGS structure.
        else
        {   
			// Determine the available lamp states based on the reported mode of the
			// button from the emulator.
            DWORD dwAvailLampStates = 0;
            if (Settings.wButtonModes[i] == BUTTONFUNCTION_CALL)
                dwAvailLampStates = (PHONELAMPMODE_OFF | PHONELAMPMODE_STEADY | PHONELAMPMODE_WINK | PHONELAMPMODE_FLASH);
            else if (Settings.wLampStates[i] == LAMPSTATE_NONE)
                dwAvailLampStates = PHONELAMPMODE_DUMMY;
            else
                dwAvailLampStates = (PHONELAMPMODE_OFF | PHONELAMPMODE_STEADY | PHONELAMPMODE_WINK);

			// Add the button
            AddButton (g_ButtonFunctions[Settings.wButtonModes[i]].dwFunction,
                       g_ButtonFunctions[Settings.wButtonModes[i]].dwMode,  
                       dwAvailLampStates,
                       g_LampStates[Settings.wLampStates[i]],
                       g_ButtonFunctions[Settings.wButtonModes[i]].pszText);                            
        }                               
    }

    // Setup the initial state of the display.
	USES_CONVERSION;
    SetDisplay (A2T(Settings.szDisplay));

    // Setup the ringer modes
    LPPHONECAPS pPhoneCaps = GetPhoneCaps();
    LPPHONESTATUS pPhoneStatus = GetPhoneStatus();
    pPhoneCaps->dwNumRingModes = 4;
    pPhoneStatus->dwRingMode = (DWORD) Settings.wRingMode;

	// Add the WAV devices which will be our handset I/O
	if (waveInGetNumDevs() > 0)
		AddDeviceClass(_T("wave/in"), (DWORD)0);
	if (waveOutGetNumDevs() > 0)
		AddDeviceClass(_T("wave/out"), (DWORD)0);

}// CDSPhone::Init
PDEVLIST CAspiscsi::ScanSCSI(HWND hwnd)
{          
	static WORD  SRBIsPending=FALSE;
	static BYTE  target_id=0,adapter_id=0,lun_id=0;
	static char  InquiryBuffer[100];
	static  SRB_GDEVBlock ExecSRB;
	PDEVLIST pDVL = NULL, pTail = NULL;
	DWORD ASPIStatus;
	char string_buf[4096], info_buf[100]={0};
	int nAdapters=0; //number of tape devices found
   
	for(adapter_id=0; adapter_id < m_NumAdapters; ++adapter_id)
	{
		for(target_id=0; target_id<8; ++target_id)
		{
			for(lun_id=0; lun_id<8; ++lun_id)
			{
				char info[100]={0};
		
				memset((void*)&ExecSRB,0,sizeof(SRB_GDEVBlock));

				ExecSRB.SRB_Cmd    = SC_GET_DEV_TYPE;
				ExecSRB.SRB_HaId   = adapter_id;
				ExecSRB.SRB_Flags   = 0;
				ExecSRB.SRB_Hdr_Rsvd  = 0;
				ExecSRB.SRB_Target   = target_id;
				ExecSRB.SRB_Lun   = lun_id;

				ASPIStatus     = SendASPI32Command ( (LPSRB) &ExecSRB );
				if (ExecSRB.SRB_Status==SS_COMP)
				{
					if (ExecSRB.SRB_DeviceType!=DTYPE_SEQD) 
						continue;
					wsprintf ( string_buf,
					"Host Adapter #%d - SCSI ID #%d:  ",
					(BYTE) ExecSRB.SRB_HaId,
					(BYTE) ExecSRB.SRB_Target);
					GetDeviceInfo(target_id, adapter_id, lun_id, (unsigned char *)info_buf, sizeof(info_buf));
 					lstrcat(string_buf,info_buf);
					pDVL=new DEVLIST();

					pDVL->adapter=adapter_id;
					pDVL->lun=lun_id;
	 				pDVL->target=target_id;
					pDVL->pNext=NULL;
					pDVL->device = nAdapters;
					if(m_pDevList == NULL)
					{
						m_pDevList = pDVL;
						pTail=pDVL;
					}
					else
					{
						pTail->pNext = pDVL;
						pTail=pDVL;
					}
					nAdapters++;
				}
			}
		}
	}
	m_NumAdapters=nAdapters; //Update Number of scsi adapters to number of tape devices
	return m_pDevList;
}
void CLS_DlgStreamPusher::InitDlgItem()
{
	//进行界面信息的初始化操作
	//默认是网络流推送
	m_chkSrcType.SetCheck(1);

	m_blUrl = TRUE;
	m_edtLocalFilePath.EnableWindow(FALSE);
	m_btnOpenLocalFile.EnableWindow(FALSE);

	if (NULL == m_bkBrush)
	{
		m_bkBrush = CreateSolidBrush(COLOR_BLACK);
	}

	//初始化网络库
	av_register_all();
	avformat_network_init();
	avdevice_register_all();

	//初始化directshow库
	if (FAILED(CoInitialize(NULL))){
		TRACE("CoInitialize Failed!\r\n");
		return;
	}

	//获取当前连接的视频设备
	int iRet= GetDeviceInfo(n_Video);
	if (iRet < 0){
		TRACE("获取视频设备失败!");
		return;
	}

	//获取当前连接输入的音频设备
	iRet = GetDeviceInfo(n_Audio);
	if (iRet < 0){
		TRACE("获取音频设备失败!");
		return;
	}

	//将获取到的设备信息插入下拉框中
	std::map<int, std::vector<std::string>>::iterator iter = m_mapDeviceInfo.begin();
	for (; iter != m_mapDeviceInfo.end(); iter ++){
		if (n_Video == iter->first){
			//视频设备
			for (int i = 0; i < iter->second.size(); i ++){
				int iCount = m_cboDeviceVideo.GetCount();
				m_cboDeviceVideo.InsertString(iCount, iter->second[i].c_str());
			}
			m_cboDeviceVideo.SetCurSel(0);
		}
		else if (n_Audio == iter->first){
			//音频设备
			for (int i = 0; i < iter->second.size(); i ++){
				int iCount = m_cboDeviceAudio.GetCount();
				m_cboDeviceAudio.InsertString(iCount, iter->second[i].c_str());
			}
			m_cboDeviceAudio.SetCurSel(0);
		}
	}

	//SDL初始化
	int flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
	int  sdlinit = SDL_Init(flags);
	if (sdlinit)
	{
		char * sss = (char*)SDL_GetError();
		fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());
		fprintf(stderr, "(Did you set the DISPLAY variable?)\n");
		return;
	}

	//将CSTATIC控件和sdl显示窗口关联 
	HWND hWnd = this->GetDlgItem(IDC_STC_PREVIEW)->GetSafeHwnd();
	if (hWnd != NULL)
	{
		if (m_pStreamInfo != NULL){
			m_pStreamInfo->m_show_screen = SDL_CreateWindowFrom((void*)hWnd);
			if (m_pStreamInfo->m_show_screen == NULL){
				TRACE("SDL_CreateWindowFrom ERR(%d)\n", SDL_GetError());
				return;
			}

			RECT rectDisPlay;
			this->GetDlgItem(IDC_STC_PREVIEW)->GetWindowRect(&rectDisPlay);
			m_pStreamInfo->m_xleft = rectDisPlay.left;
			m_pStreamInfo->m_ytop = rectDisPlay.top;
			m_pStreamInfo->m_width = rectDisPlay.right - rectDisPlay.left;
			m_pStreamInfo->m_height = rectDisPlay.bottom - rectDisPlay.top;

			//处理显示区域
			FillDisplayRect();

			m_pStreamInfo->m_sdlRenderer = SDL_CreateRenderer(m_pStreamInfo->m_show_screen, -1, 0);
			if (m_pStreamInfo->m_sdlRenderer == NULL){
				TRACE("SDL_CreateRenderer--sdlRenderer == NULL err(%d)\n", SDL_GetError());
				return;
			}
		} 
	}

	//设置SDL事件状态
	SDL_EventState(SDL_WINDOWEVENT, SDL_IGNORE);
	SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
	SDL_EventState(SDL_USEREVENT, SDL_IGNORE);

	if (m_pThreadEvent == NULL){
		m_pThreadEvent = AfxBeginThread(Thread_Event, this);//开启线程
	}

	m_edtPusherAddr.SetWindowText("rtmp://5380.lsspublish.aodianyun.com/Young/stream");

	return;
}