Ejemplo n.º 1
0
long getOpenCLRawProcessorID(int device, const char **cpuname)
{
  static cl_char device_name[256+130];
  strcpy((char*)device_name, "Unknown");

  if (cpuname)
    *cpuname = (const char*)device_name;

  ocl_context_t *cont = ocl_get_context(device);
  if (cont)
  {
    clGetDeviceInfo(cont->deviceID, CL_DEVICE_NAME, sizeof(device_name)-130, device_name, NULL);

    //retrieve card info, if available
    u32 off = strlen((const char*)device_name);
    device_name[off++]=' '; device_name[off++]='\0';
#ifdef CL_DEVICE_BOARD_NAME_AMD
    if (clGetDeviceInfo(cont->deviceID, CL_DEVICE_BOARD_NAME_AMD, sizeof(device_name)-off, &device_name[off], NULL) == CL_SUCCESS)
    {
      device_name[off-1]='(';
      u32 off2 = strlen((const char*)device_name);
      device_name[off2] = ')';
      device_name[off2+1] = '\0';
    }
#endif
// ??? Never used
/*
    cl_uint vendor_id=0;
    clGetDeviceInfo(cont->deviceID, CL_DEVICE_VENDOR_ID, sizeof(vendor_id), &vendor_id, NULL);

    cl_uint cunits=0;
    clGetDeviceInfo(cont->deviceID, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(cunits), &cunits, NULL);
*/
    return GetDeviceID(/* vendor_id, device_name, cunits, */ cont);
  }

  return -1;
}
Ejemplo n.º 2
0
inline s32 Factory::AddDevice(DeviceParam & pParam)
{
    s32 nId = GetDeviceID();
    FactoryDeviceChangeData change;

    Lock();
    pParam.m_Conf.data.conf.nId = nId;
    if (pParam.m_Conf.data.conf.nType == VSC_DEVICE_CAM)
    {
    	m_DeviceMap[nId] = new Device(*m_pVdb, *m_pVHdfsdb, pParam);
    }else
    {
	m_DeviceMap[nId] = NULL;
    }
    m_DeviceParamMap[nId] = pParam;
    m_Conf.AddDevice(pParam.m_Conf, nId);

    UnLock();
    change.id = nId;
    change.type = FACTORY_DEVICE_ADD;
    CallDeviceChange(change);
	
    return nId;
}
Ejemplo n.º 3
0
void CInputProviderMacOsHid::OnDeviceMatched(IOReturn result, void* sender, IOHIDDeviceRef device)
{
	m_devices.push_back(DEVICE_INFO());
	auto& deviceInfo = *m_devices.rbegin();
	deviceInfo.provider = this;
	deviceInfo.device = device;
	deviceInfo.deviceId = GetDeviceID(device);

	auto InputReportCallbackStub = GetCallback(device);
	if(InputReportCallbackStub)
	{
		uint32_t max_input_report_size = GetIntProperty(device, CFSTR(kIOHIDMaxInputReportSizeKey));
		uint8_t* report_buffer = static_cast<uint8_t*>(calloc(max_input_report_size, sizeof(uint8_t)));
		IOHIDDeviceRegisterInputReportCallback(device, report_buffer, max_input_report_size, InputReportCallbackStub, &deviceInfo);
	}
	else
	{
		if(OnInput)
		{
			SetInitialBindValues(device);
		}
		IOHIDDeviceRegisterInputValueCallback(device, &InputValueCallbackStub, &deviceInfo);
	}
}
Ejemplo n.º 4
0
IPCCommandResult CWII_IPC_HLE_Device_di::Open(u32 _CommandAddress, u32 _Mode)
{
    Memory::Write_U32(GetDeviceID(), _CommandAddress + 4);
    m_Active = true;
    return GetDefaultReply();
}
Ejemplo n.º 5
0
void CoreAudioOutDriver::open(device_id_t device,
			      int sample_rate,
			      sample_format form,
			      int channels,
			      int num_samples,
			      int num_periods)
{
  if (this->is_open())
    throw std::logic_error("Device already open");


  if (form != SF_16LE)
    throw std::invalid_argument("Unknown sample format");

  m_impl->m_logger = logger;

  AudioDeviceID devid = GetDeviceID(logger, device);

  if (devid == kAudioDeviceUnknown)
    throw std::invalid_argument("Unknown device id");

  OSStatus err;
  const bool isInput = false;
  UInt32 propsize;
  
  AudioValueRange bufferRange;

  // check that the desired value is within the allowed range
  propsize = sizeof(bufferRange);
  err = AudioDeviceGetProperty(devid, 0, false,
			       kAudioDevicePropertyBufferFrameSizeRange,
			       &propsize,
			       &bufferRange);


  if (err != kAudioHardwareNoError)
    {
      throw std::runtime_error("Could not get buffer range");
    }

  propsize = sizeof(UInt32);
  UInt32 frames = my_min<int>(my_max<int>(num_samples,
					  (int) bufferRange.mMinimum),
			      (int) bufferRange.mMaximum);

  err = AudioDeviceSetProperty(devid, NULL, 0, isInput,
			       kAudioDevicePropertyBufferFrameSize,
			       propsize, &frames);
    
  if (err != kAudioHardwareNoError)
    {
      throw std::runtime_error("Could not set buffer size");
    }


  propsize = sizeof(frames);
  err = AudioDeviceGetProperty(devid, 0, isInput,
			       kAudioDevicePropertyBufferFrameSize,
			       &propsize, &frames);
    
  if (err != kAudioHardwareNoError)
    {
      throw std::runtime_error("Could not read buffer size");
    }

  char bbc[256] = {0};
  sprintf(bbc, "Buffer size in frames: %i", frames);
  logger(2, bbc);

  Float64 sampleRate = sample_rate;
  propsize = sizeof(sampleRate);
  err = AudioDeviceSetProperty(devid, NULL, 0, isInput,
			       kAudioDevicePropertyNominalSampleRate,
			       propsize, &sampleRate);
    
  if (err != kAudioHardwareNoError)
    {
      throw std::runtime_error("Could not set sample rate");
    }

  print_info(devid, logger, isInput);

  propsize = sizeof(m_impl->m_format);
  err = AudioDeviceGetProperty(devid, 0, isInput,
			       kAudioDevicePropertyStreamFormat,
			       &propsize,
			       &m_impl->m_format);

  if (err != kAudioHardwareNoError)
    {
      throw std::runtime_error("Could not get audio format");
    }


  // Desired format
  memset(&m_impl->m_input_format, 0, sizeof(m_impl->m_input_format));
  

  // set channels, format to SF_16LE

  m_impl->m_input_format.mSampleRate       = sample_rate;
  m_impl->m_input_format.mFormatID         = kAudioFormatLinearPCM;
  m_impl->m_input_format.mFormatFlags
         = kLinearPCMFormatFlagIsSignedInteger |
           kLinearPCMFormatFlagIsPacked;

  m_impl->m_input_format.mBytesPerPacket   = 2*channels;
  m_impl->m_input_format.mFramesPerPacket  = 1;
  m_impl->m_input_format.mBytesPerFrame    = m_impl->m_input_format.mBytesPerPacket;
  m_impl->m_input_format.mChannelsPerFrame = channels;
  m_impl->m_input_format.mBitsPerChannel   = 16;

#define USE_COMPLEX_AUDIO_CONVERTER
  //#define USE_SIMPLE_AUDIO_CONVERTER

#if defined(USE_SIMPLE_AUDIO_CONVERTER)
  m_impl->m_converter = new SimpleConverter(m_impl->m_input_format,
					    m_impl->m_format);
#elif defined (USE_COMPLEX_AUDIO_CONVERTER)
  m_impl->m_converter = new ComplexConverter(m_impl->m_input_format,
					     m_impl->m_format);
#else
    // TODO: this works only for 2 channels float to 1 channel mono 16LE!
  m_impl->m_converter = new Mono16LEPCMToStereoFloat;
#endif

  print_format pf1(logger, "Device Format\n");
  pf1(m_impl->m_format);

  print_format pf2(logger, "Input Format\n");
  pf2(m_impl->m_input_format);

  // Set the buffer latency (audio output is only started after
  // the buffer contains m_min_buffer samples).
  m_impl->m_min_buffer = num_samples*num_periods;
  m_impl->m_ID = devid;

  AudioDeviceAddIOProc(devid, Impl::OutputIOProc, m_impl.get());
}
Ejemplo n.º 6
0
inline s32 Factory::AddDevice(DeviceParam & pParam)
{
    s32 nId = GetDeviceID();
    FactoryDeviceChangeData change;
    Device *pDevice = NULL;
    DeviceParam pParam2;

    Lock();
    pParam.m_Conf.data.conf.nId = nId;
    if (pParam.m_Conf.data.conf.nType == VSC_DEVICE_CAM)
    {
        m_DeviceMap[nId] = new Device(*m_pVdb, *m_pVHdfsdb, pParam);
        pDevice = m_DeviceMap[nId];
    } else
    {
        m_DeviceMap[nId] = NULL;
        UnLock();
        return -1;
    }
    m_DeviceParamMap[nId] = pParam;
    m_DeviceOnlineMap[nId] = 0;
    m_Conf.AddDevice(pParam.m_Conf, nId);

    UnLock();
    change.id = nId;
    change.type = FACTORY_DEVICE_ADD;
    CallDeviceChange(change);
#if 0
    /* Try to online the device and lock */
    Lock();
    pDevice->GetDeviceParam(pParam2);
    UnLock();

    pParam2.m_wipOnline = pParam2.CheckOnline();
    if (pParam2.m_OnlineUrl == FALSE)
    {
        pParam2.m_wipOnlineUrl = pParam2.UpdateUrl();
    }

    /* Try to make the device online */
    Lock();
    DeviceStatus bCheck = pDevice->CheckDevice(pParam2.m_strUrl,
                          pParam2.m_strUrlSubStream, pParam2.m_bHasSubStream,
                          pParam2.m_wipOnline, pParam2.m_wipOnlineUrl);

    FactoryDeviceChangeData change2;
    change2.id = nId;

    if (bCheck == DEV_OFF2ON)
    {
        change.type = FACTORY_DEVICE_ONLINE;
        m_DeviceOnlineMap[nId] = 1;
        UnLock();
        CallDeviceChange(change);
        Lock();
    }
    UnLock();
#endif

    return nId;
}
Ejemplo n.º 7
0
static HRESULT DSPROPERTY_DescriptionW(
    LPVOID pPropData,
    ULONG cbPropData,
    PULONG pcbReturned )
{
    PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA ppd = pPropData;
    GUID dev_guid;
    IMMDevice *mmdevice;
    IPropertyStore *ps;
    PROPVARIANT pv;
    DWORD desclen;
    HRESULT hr;

    TRACE("pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
          pPropData,cbPropData,pcbReturned);

    TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
    if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
        /* default device of type specified by ppd->DataFlow */
        if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
            TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
            ppd->DeviceId = DSDEVID_DefaultCapture;
        } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
            TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
            ppd->DeviceId = DSDEVID_DefaultPlayback;
        } else {
            WARN("DataFlow=Unknown(%d)\n", ppd->DataFlow);
            return E_PROP_ID_UNSUPPORTED;
        }
    }

    setup_dsound_options();

    GetDeviceID(&ppd->DeviceId, &dev_guid);

    hr = get_mmdevice(eRender, &dev_guid, &mmdevice);
    if(FAILED(hr)){
        hr = get_mmdevice(eCapture, &dev_guid, &mmdevice);
        if(FAILED(hr))
            return hr;
    }

    hr = IMMDevice_OpenPropertyStore(mmdevice, STGM_READ, &ps);
    if(FAILED(hr)){
        IMMDevice_Release(mmdevice);
        WARN("OpenPropertyStore failed: %08x\n", hr);
        return hr;
    }

    hr = IPropertyStore_GetValue(ps,
            (const PROPERTYKEY *)&DEVPKEY_Device_FriendlyName, &pv);
    if(FAILED(hr)){
        IPropertyStore_Release(ps);
        IMMDevice_Release(mmdevice);
        WARN("GetValue(FriendlyName) failed: %08x\n", hr);
        return hr;
    }

    desclen = lstrlenW(pv.u.pwszVal) + 1;
    /* FIXME: Still a memory leak.. */
    ppd->Description = HeapAlloc(GetProcessHeap(), 0, desclen * sizeof(WCHAR));
    memcpy(ppd->Description, pv.u.pwszVal, desclen * sizeof(WCHAR));
    ppd->Module = wine_vxd_drv;
    ppd->Interface = wInterface;
    ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;

    PropVariantClear(&pv);
    IPropertyStore_Release(ps);
    IMMDevice_Release(mmdevice);

    if (pcbReturned) {
        *pcbReturned = sizeof(*ppd);
        TRACE("*pcbReturned=%d\n", *pcbReturned);
    }

    return S_OK;
}
Ejemplo n.º 8
0
/***************************************************************************
 * DirectSoundCaptureEnumerateW [DSOUND.8]
 *
 * Enumerate all DirectSound drivers installed in the system.
 *
 * PARAMS
 *    lpDSEnumCallback  [I] Address of callback function.
 *    lpContext         [I] Address of user defined context passed to callback function.
 *
 * RETURNS
 *    Success: DS_OK
 *    Failure: DSERR_INVALIDPARAM
 */
HRESULT WINAPI
DirectSoundCaptureEnumerateW(
    LPDSENUMCALLBACKW lpDSEnumCallback,
    LPVOID lpContext)
{
    unsigned devs, wid;
    DSDRIVERDESC desc;
    GUID guid;
    int err;
    WCHAR wDesc[MAXPNAMELEN];
    WCHAR wName[MAXPNAMELEN];

    TRACE("(%p,%p)\n", lpDSEnumCallback, lpContext );

    if (lpDSEnumCallback == NULL) {
	WARN("invalid parameter: lpDSEnumCallback == NULL\n");
        return DSERR_INVALIDPARAM;
    }

    setup_dsound_options();

    devs = waveInGetNumDevs();
    if (devs > 0) {
	if (GetDeviceID(&DSDEVID_DefaultCapture, &guid) == DS_OK) {
	    for (wid = 0; wid < devs; ++wid) {
                if (IsEqualGUID( &guid, &DSOUND_capture_guids[wid] ) ) {
                    err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,ds_hw_accel));
                    if (err == DS_OK) {
                        TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
                              "Primary Sound Capture Driver",desc.szDrvname,lpContext);
                        MultiByteToWideChar( CP_ACP, 0, "Primary Sound Capture Driver", -1,
                                             wDesc, sizeof(wDesc)/sizeof(WCHAR) );
                        MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
                                             wName, sizeof(wName)/sizeof(WCHAR) );
                        wName[(sizeof(wName)/sizeof(WCHAR)) - 1] = '\0';

                        if (lpDSEnumCallback(NULL, wDesc, wName, lpContext) == FALSE)
                            return DS_OK;
                    }
                }
	    }
	}
    }

    for (wid = 0; wid < devs; ++wid) {
        err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,ds_hw_accel));
	if (err == DS_OK) {
            TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
                  debugstr_guid(&DSOUND_capture_guids[wid]),desc.szDesc,desc.szDrvname,lpContext);
            MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1,
                                 wDesc, sizeof(wDesc)/sizeof(WCHAR) );
            wDesc[(sizeof(wDesc)/sizeof(WCHAR)) - 1] = '\0';

            MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
                                 wName, sizeof(wName)/sizeof(WCHAR) );
            wName[(sizeof(wName)/sizeof(WCHAR)) - 1] = '\0';

            if (lpDSEnumCallback(&DSOUND_capture_guids[wid], wDesc, wName, lpContext) == FALSE)
                return DS_OK;
	}
    }

    return DS_OK;
}
Ejemplo n.º 9
0
	void TestMemory::RecvMsg(const BaseMsg* msg, int connectionID)
	{
		DebugAssert(msg);
		TimeDelta replyTime = 0;
		BaseMsg* reply = NULL;

		switch(msg->Type())
		{
		case(mt_Read):
			{
				readsReceived++;
				ReadMsg* rm = (ReadMsg*)msg;
				replyTime = readTime;
				ReadResponseMsg* m = EM().CreateReadResponseMsg(GetDeviceID(),msg->GeneratingPC());
				m->addr = rm->addr;
				m->size = rm->size;
				m->blockAttached = true;
				m->directoryLookup = rm->directoryLookup;
				m->exclusiveOwnership = true;
				m->satisfied = true;
				m->solicitingMessage = rm->MsgID();
				rm->SignalComplete();

				reply = m;
				break;
			}
		case(mt_Write):
			{
				writesReceived++;
				WriteMsg* wm = (WriteMsg*)msg;
				replyTime = writeTime;
				WriteResponseMsg* m = EM().CreateWriteResponseMsg(GetDeviceID(),msg->GeneratingPC());
				m->addr = wm->addr;
				m->size = wm->size;
				m->solicitingMessage = wm->MsgID();
				wm->SignalComplete();
				reply = m;
				break;
			}
		case(mt_Eviction):
			{
				evictionsReceived++;
				EvictionMsg* em = (EvictionMsg*)msg;
				EvictionResponseMsg* m = EM().CreateEvictionResponseMsg(GetDeviceID(),msg->GeneratingPC());
				m->addr = em->addr;
				m->size = em->size;
				m->solicitingMessage = em->MsgID();
				reply = m;
				break;
			}
		case(mt_Invalidate):
         {
			   DebugFail("TestMemory::RecvMsg: Main memory being told to invalidate");
			   break;
         }
      case(mt_EvictionResponse):
         {
            DebugFail("TestMemory::RecvMsg: Main memory received eviction response message");
            break;
         }
      case(mt_InvalidateResponse):
         {
            DebugFail("TestMemory::RecvMsg: Main memory received invalidate response message");
            break;
         }
      case(mt_Network):
         {
            DebugFail("TestMemory::RecvMsg: Main memory received network message");
            break;
         }
      case(mt_ReadResponse):
         {
            DebugFail("TestMemory::RecvMsg: Main memory received read response message");
            break;
         }
      case(mt_WriteResponse):
         {
            DebugFail("TestMemory::RecvMsg: Main memory received write response message");
            break;
         }
      default:
         {
            DebugFail("TestMemory::RecvMsg: Main memory received message with unknown message type");
            break;
         }
		}
		// end switch(msg->Type())
		if(reply)
		{
			DebugAssert(reply->IsResponse());
			GetConnection(connectionID).SendMsg(reply,replyTime);
		}
		EM().DisposeMsg(msg);
	}
Ejemplo n.º 10
0
static HRESULT DirectSoundCaptureDevice_Initialize(
    DirectSoundCaptureDevice ** ppDevice,
    LPCGUID lpcGUID)
{
    HRESULT hr;
    GUID devGUID;
    IMMDevice *mmdevice;
    struct _TestFormat *fmt;
    DirectSoundCaptureDevice *device;
    IAudioClient *client;

    TRACE("(%p, %s)\n", ppDevice, debugstr_guid(lpcGUID));

    /* Default device? */
    if ( !lpcGUID || IsEqualGUID(lpcGUID, &GUID_NULL) )
        lpcGUID = &DSDEVID_DefaultCapture;

    if(IsEqualGUID(lpcGUID, &DSDEVID_DefaultPlayback) ||
            IsEqualGUID(lpcGUID, &DSDEVID_DefaultVoicePlayback))
        return DSERR_NODRIVER;

    if (GetDeviceID(lpcGUID, &devGUID) != DS_OK) {
        WARN("invalid parameter: lpcGUID\n");
        return DSERR_INVALIDPARAM;
    }

    hr = get_mmdevice(eCapture, &devGUID, &mmdevice);
    if(FAILED(hr))
        return hr;

    EnterCriticalSection(&DSOUND_capturers_lock);

    hr = DirectSoundCaptureDevice_Create(&device);
    if (hr != DS_OK) {
        WARN("DirectSoundCaptureDevice_Create failed\n");
        LeaveCriticalSection(&DSOUND_capturers_lock);
        return hr;
    }

    device->guid = devGUID;

    device->mmdevice = mmdevice;

    device->drvcaps.dwFlags = 0;

    device->drvcaps.dwFormats = 0;
    device->drvcaps.dwChannels = 0;
    hr = IMMDevice_Activate(mmdevice, &IID_IAudioClient,
            CLSCTX_INPROC_SERVER, NULL, (void**)&client);
    if(FAILED(hr)){
        device->lock.DebugInfo->Spare[0] = 0;
        DeleteCriticalSection(&device->lock);
        HeapFree(GetProcessHeap(), 0, device);
        LeaveCriticalSection(&DSOUND_capturers_lock);
        return DSERR_NODRIVER;
    }

    for(fmt = formats_to_test; fmt->flag; ++fmt){
        if(DSOUND_check_supported(client, fmt->rate, fmt->depth, fmt->channels)){
            device->drvcaps.dwFormats |= fmt->flag;
            if(fmt->channels > device->drvcaps.dwChannels)
                device->drvcaps.dwChannels = fmt->channels;
        }
    }
    IAudioClient_Release(client);

    list_add_tail(&DSOUND_capturers, &device->entry);

    *ppDevice = device;

    LeaveCriticalSection(&DSOUND_capturers_lock);

    return S_OK;
}
bool CWII_IPC_HLE_Device_net_ssl::Open(u32 _CommandAddress, u32 _Mode)
{
	Memory::Write_U32(GetDeviceID(), _CommandAddress+4);
	m_Active = true;
	return true;
}
Ejemplo n.º 12
0
HRESULT
WINAPI
KSPropertySetImpl_Get(
    LPKSPROPERTYSET iface,
    REFGUID guidPropSet,
    ULONG dwPropID,
    LPVOID pInstanceData,
    ULONG cbInstanceData,
    LPVOID pPropData,
    ULONG cbPropData,
    PULONG pcbReturned )
{
    LPOLESTR pStr;
    //HRESULT hr;
    MMRESULT Result;
    WAVEINCAPSW CapsIn;
    WAVEOUTCAPSW CapsOut;

    GUID DeviceGuid;
    LPFILTERINFO Filter = NULL;
    PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA Desc;

    StringFromIID(guidPropSet, &pStr);

    //DPRINT("Requested Property %ws dwPropID %u pInstanceData %p cbInstanceData %u pPropData %p cbPropData %u pcbReturned %p\n",
    //       pStr, dwPropID, pInstanceData, cbInstanceData, pPropData, cbPropData, pcbReturned);
    CoTaskMemFree(pStr);

    if (!IsEqualGUID(guidPropSet, &DSPROPSETID_DirectSoundDevice))
    {
        /* unsupported property set */
        return E_PROP_ID_UNSUPPORTED;
    }

    if (dwPropID == DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1)
    {
        if (cbPropData < sizeof(DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA))
        {
            /* invalid parameter */
            return DSERR_INVALIDPARAM;
        }

        Desc = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA)pPropData;

        if (IsEqualGUID(&Desc->DeviceId, &GUID_NULL))
        {
            if (Desc->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE)
            {
                DPRINT("Using default capture guid\n");
                CopyMemory(&DeviceGuid, &DSDEVID_DefaultCapture, sizeof(GUID));
            }
            else
            {
                DPRINT("Using default playback guid\n");
                CopyMemory(&DeviceGuid, &DSDEVID_DefaultPlayback, sizeof(GUID));
            }
        }
        else
        {
            /* use provided guid */
            CopyMemory(&DeviceGuid, &Desc->DeviceId, sizeof(GUID));
        }

        if (GetDeviceID(&DeviceGuid, &Desc->DeviceId) != DS_OK)
        {
            DPRINT("Unknown device guid\n");
            return DSERR_INVALIDPARAM;
        }

         /* sanity check */
         ASSERT(FindDeviceByGuid(&Desc->DeviceId, &Filter));
         ASSERT(Filter != NULL);

         /* fill in description */
         if (IsEqualGUID(&Desc->DeviceId, &Filter->DeviceGuid[0]))
         {
             /* capture device */
             Desc->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
             Desc->WaveDeviceId = Filter->MappedId[0];

             Result = waveInGetDevCapsW(Filter->MappedId[0], &CapsIn, sizeof(WAVEINCAPSW));
             if (Result != MMSYSERR_NOERROR)
             {
                 CapsIn.szPname[0] = 0;
                 DPRINT("waveInGetDevCaps Device %u failed with %x\n", Filter->MappedId[0], Result);
             }

             CapsIn.szPname[MAXPNAMELEN-1] = 0;
             wcscpy(Desc->DescriptionW, CapsIn.szPname);
             WideCharToMultiByte(CP_ACP, 0, CapsIn.szPname, -1, Desc->DescriptionA, sizeof(Desc->DescriptionA), NULL, NULL);

         }
         else
         {
             /* render device */
             Desc->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
             Desc->WaveDeviceId = Filter->MappedId[1];

             Result = waveOutGetDevCapsW(Filter->MappedId[1], &CapsOut, sizeof(WAVEOUTCAPSW));
             if (Result != MMSYSERR_NOERROR)
             {
                 CapsOut.szPname[0] = 0;
                 DPRINT("waveOutGetDevCaps Device %u failed with %x\n", Filter->MappedId[1], Result);
             }

             CapsOut.szPname[MAXPNAMELEN-1] = 0;
             wcscpy(Desc->DescriptionW, CapsOut.szPname);
             WideCharToMultiByte(CP_ACP, 0, CapsOut.szPname, -1, Desc->DescriptionA, sizeof(Desc->DescriptionA), NULL, NULL);
         }

          /* ReactOS doesnt support vxd or emulated */
          Desc->Type = DIRECTSOUNDDEVICE_TYPE_WDM;
          Desc->ModuleA[0] = 0;
          Desc->ModuleW[0] = 0;

          *pcbReturned = sizeof(DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA);
          return S_OK;
    }


    UNIMPLEMENTED
    return E_PROP_ID_UNSUPPORTED;
}
Ejemplo n.º 13
0
static HRESULT DSPROPERTY_DescriptionW(
    LPVOID pPropData,
    ULONG cbPropData,
    PULONG pcbReturned )
{
    PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA ppd = pPropData;
    HRESULT err;
    GUID dev_guid;
    ULONG wod, wid, wodn, widn;
    DSDRIVERDESC desc;

    TRACE("pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
          pPropData,cbPropData,pcbReturned);

    TRACE("DeviceId=%s\n",debugstr_guid(&ppd->DeviceId));
    if ( IsEqualGUID( &ppd->DeviceId , &GUID_NULL) ) {
        /* default device of type specified by ppd->DataFlow */
        if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE) {
            TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE\n");
            ppd->DeviceId = DSDEVID_DefaultCapture;
        } else if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER) {
            TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
            ppd->DeviceId = DSDEVID_DefaultPlayback;
        } else {
            WARN("DataFlow=Unknown(%d)\n", ppd->DataFlow);
            return E_PROP_ID_UNSUPPORTED;
        }
    }

    setup_dsound_options();

    GetDeviceID(&ppd->DeviceId, &dev_guid);

    wodn = waveOutGetNumDevs();
    widn = waveInGetNumDevs();
    wid = wod = dev_guid.Data4[7];
    if (!memcmp(&dev_guid, &DSOUND_renderer_guids[0], sizeof(GUID)-1)
        && wod < wodn)
    {
        ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_RENDER;
        ppd->WaveDeviceId = wod;
    }
    else if (!memcmp(&dev_guid, &DSOUND_capture_guids[0], sizeof(GUID)-1)
             && wid < widn)
    {
        ppd->DataFlow = DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE;
        ppd->WaveDeviceId = wid;
    }
    else
    {
        WARN("Device not found\n");
        return E_PROP_ID_UNSUPPORTED;
    }

    if (ppd->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER)
        err = waveOutMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,ds_hw_accel);
    else
        err = waveInMessage(UlongToHandle(wod),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,ds_hw_accel);

    if (err != MMSYSERR_NOERROR)
    {
        WARN("waveMessage(DRV_QUERYDSOUNDDESC) failed!\n");
        return E_PROP_ID_UNSUPPORTED;
    }
    else
    {
        /* FIXME: Still a memory leak.. */
        int desclen, modlen;
        static WCHAR wInterface[] = { 'I','n','t','e','r','f','a','c','e',0 };

        modlen = MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, NULL, 0 );
        desclen = MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, NULL, 0 );
        ppd->Module = HeapAlloc(GetProcessHeap(),0,modlen*sizeof(WCHAR));
        ppd->Description = HeapAlloc(GetProcessHeap(),0,desclen*sizeof(WCHAR));
        ppd->Interface = wInterface;
        if (!ppd->Description || !ppd->Module)
        {
            WARN("Out of memory\n");
            HeapFree(GetProcessHeap(), 0, ppd->Description);
            HeapFree(GetProcessHeap(), 0, ppd->Module);
            ppd->Description = ppd->Module = NULL;
            return E_OUTOFMEMORY;
        }

        MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1, ppd->Module, modlen );
        MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->Description, desclen );
    }

    ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;

    if (pcbReturned) {
        *pcbReturned = sizeof(*ppd);
        TRACE("*pcbReturned=%d\n", *pcbReturned);
    }

    return S_OK;
}
Ejemplo n.º 14
0
HRESULT
WINAPI
IDirectSound8_fnInitialize(
    LPDIRECTSOUND8 iface,
    LPCGUID pcGuidDevice)
{
    GUID DeviceGuid;
    LPOLESTR pGuidStr;
    HRESULT hr;
    LPCDirectSoundImpl This = (LPCDirectSoundImpl)CONTAINING_RECORD(iface, CDirectSoundImpl, lpVtbl);

    if (!RootInfo)
    {
        EnumAudioDeviceInterfaces(&RootInfo);
    }

    /* sanity check */
    ASSERT(RootInfo);

    if (This->bInitialized)
    {
        /* object has already been initialized */
        return DSERR_ALREADYINITIALIZED;
    }

    /* fixme mutual exlucsion */

    if (pcGuidDevice == NULL || IsEqualGUID(pcGuidDevice, &GUID_NULL))
    {
        /* use default playback device id */
        pcGuidDevice = &DSDEVID_DefaultPlayback;
    }

    if (IsEqualIID(pcGuidDevice, &DSDEVID_DefaultCapture) || IsEqualIID(pcGuidDevice, &DSDEVID_DefaultVoiceCapture))
    {
        /* this has to be a winetest */
        return DSERR_NODRIVER;
    }

    /* now verify the guid */
    if (GetDeviceID(pcGuidDevice, &DeviceGuid) != DS_OK)
    {
        if (SUCCEEDED(StringFromIID(pcGuidDevice, &pGuidStr)))
        {
            DPRINT("IDirectSound8_fnInitialize: Unknown GUID %ws\n", pGuidStr);
            CoTaskMemFree(pGuidStr);
        }
        return DSERR_INVALIDPARAM;
    }

    hr = FindDeviceByGuid(&DeviceGuid, &This->Filter);

    if (SUCCEEDED(hr))
    {
        This->bInitialized = TRUE;
        return DS_OK;	
    }

    DPRINT("Failed to find device\n");
    return DSERR_INVALIDPARAM;
}
Ejemplo n.º 15
0
IPCCommandResult CWII_IPC_HLE_Device_usb_ven::Open(u32 command_address, u32 mode)
{
  Memory::Write_U32(GetDeviceID(), command_address + 4);
  m_Active = true;
  return GetDefaultReply();
}
Ejemplo n.º 16
0
/** Verify the I2C connection.
 * Make sure the device is connected and responds as expected.
 * @return True if connection is valid, FALSE otherwise
 */
bool clMPU6050::TestConnection(){
	if(GetDeviceID() == 0x34) //0b110100; 8-bit representation in hex = 0x34
		return true;
	else
		return false;
}
IPCCommandResult CWII_IPC_HLE_Device_net_ssl::Open(u32 _CommandAddress, u32 _Mode)
{
	Memory::Write_U32(GetDeviceID(), _CommandAddress+4);
	m_Active = true;
	return IPC_DEFAULT_REPLY;
}
Ejemplo n.º 18
0
/*!
Mandatory call to be inserted in derived constructor.
This method tries to establish communications with printer and identify it.
The derived SystemServices constructor must call this base-class routine.
*/
DRIVER_ERROR SystemServices::InitDeviceComm()
// Must be called from derived class constructor.
// (Base class must be constructed before system calls
//  below can be made.)
// Opens the port, looks for printer and
// dialogues with user if none found;
// then attempts to read and parse device ID string --
// if successful, sets IOMode.bDevID to TRUE (strings stored
// for retrieval by PrintContext).
// Returns an error only if user cancelled. Otherwise
// no error even if unidi.
//
// Calls: OpenPort,PrinterIsAlive,DisplayPrinterStatus,BusyWait,
//   GetDeviceID,DeviceRegistry::ParseDevIDString.
// Sets:    hPort,IOMode, strModel, strPens
{
    DRIVER_ERROR err = NO_ERROR;
    BOOL ErrorDisplayed = FALSE;
    BYTE temp;

    // Check whether this system supports passing back a status-byte
    if( GetStatusInfo(&temp) == FALSE )
    {
        DBG1("InitDeviceComm:  No Status-Byte Available\n");
    }
    else IOMode.bStatus = TRUE;

    // Check whether we can get a DeviceID - this may
    // still fail if the device is just turned off
    err = GetDeviceID(strDevID, DevIDBuffSize, TRUE);

    if ( err == NO_ERROR )
    {
        DBG1("InitDeviceComm:  DevID request successful\n");
        IOMode.bDevID = TRUE;
    }


    // PrinterIsAlive is arbitrary if we can't get the status-byte.
    // This check is also critical so a true uni-di system does not sit
    // in a loop informing the user to turn on the printer.
    if ( IOMode.bStatus == TRUE )
    {
        // Make sure a printer is there, turned on and connected
        // before we go any further.  This takes some additional checking
        // due to the fact that the 895 returns a status byte of F8 when
        // it's out of paper, the same as a 600 when it's turned off.
        // 895 can get a devID even when 'off' so we'll key off that logic.
        if ( (err != NO_ERROR) && (PrinterIsAlive() == FALSE) )
        {
            // Printer is actually turned off
            while(PrinterIsAlive() == FALSE)
            {
                DBG1("PrinterIsAlive returned FALSE\n");
                ErrorDisplayed = TRUE;
                DisplayPrinterStatus(DISPLAY_NO_PRINTER_FOUND);

                if(BusyWait(500) == JOB_CANCELED)
                    return JOB_CANCELED;
            }
            if(ErrorDisplayed == TRUE)
            {
                DisplayPrinterStatus(DISPLAY_PRINTING);
                // if they just turned on/connected the printer,
                // delay a bit to let it initialize
                if(BusyWait(2000) == JOB_CANCELED)
                    return JOB_CANCELED;

                err = GetDeviceID(strDevID, DevIDBuffSize, TRUE);
                if ( err == NO_ERROR )
                {
                    DBG1("InitDeviceComm:  DevID request successful\n");
                    IOMode.bDevID = TRUE;
                }
            }
        }
        // else... we have 8xx/9xx with an out-of-paper error
        // which we will catch in the I/O handling

    }

    if (err!=NO_ERROR)
    {
        DBG1("InitDeviceComm:  No DeviceID Available\n");
        return NO_ERROR;
    }

    err = DR->ParseDevIDString((const char*)strDevID, strModel, &VIPVersion, strPens);

    if (err!=NO_ERROR)
    {
        // The DevID we got is actually garbage!
        DBG1("InitDeviceComm:  The DevID string is invalid!\n");
        IOMode.bDevID=FALSE;
    }

    return NO_ERROR;
}
Ejemplo n.º 19
0
jstring Java_com_thinkware_i3dlite_AuthConfirm_GetAuthParam(JNIEnv *env, jobject thiz, jobject activity)
{

	char AllPropString[512];
	char PropName[32];
	char PropValue[32];
	char DeviceID[32];
	char Mdn[32];

	int index = 0;
	int i = 0;
	int retry = 0;

	memset(AllPropString, 0, sizeof(AllPropString));
	memset(PropName, 0, sizeof(PropName));
	memset(PropValue, 0, sizeof(PropValue));
	memset(DeviceID, 0, sizeof(DeviceID));	//IMEI
	memset(Mdn, 0, sizeof(Mdn));

	for(i=0; i<DEVICE_PROPERTY_COUNT; i++) {

		memset(PropName, 0, sizeof(PropName));
		memset(PropValue, 0, sizeof(PropValue));

		sprintf(PropName, "val%d", i+1);
		strcpy(AllPropString+index, PropName);
		index += strlen(PropName);
		AllPropString[index] = '=';
		index++;
		__system_property_get(PropNameList[i], PropValue);
		if( strcmp(PropNameList[i], "ril.wifi_macaddr") == 0 ) {
			if( strlen(PropValue) == 0 ) {	// ril.wifi_macaddr로 못가져왔을때
				while(retry < GET_WIFI_MAC_RETRY_CNT) {
					GetWifiMac(env, activity, PropValue);
					if(strlen(PropValue) >= 12) break;
					else Delay(1000);

					retry++;
				}
			}
			ToUpperString(PropValue, strlen(PropValue));
			RemoveColonDashSpace(PropValue, strlen(PropValue));
			//if(strlen(PropValue)<12) {		// 최종적으로 WIFI MAC을 못가져왔을때 "NONE"으로 채워서 내보낸다.
			//	strcpy(PropValue, NONE_VALUE_STRING);
			//}

		} else if( strcmp(PropNameList[i], "ro.serialno") == 0 ) {	// ro.serialno로 못가져왔을때
			if( strlen(PropValue) == 0 ) {
				GetBuildSerial(env, activity, PropValue);
			}
			ToUpperString(PropValue, strlen(PropValue));
		} else if( strcmp(PropNameList[i], "ro.product.model") == 0 ) {
			ToUpperString(PropValue, strlen(PropValue));
		}

		// 값이 없는것들은 "NONE"으로 내보내기
		if(strlen(PropValue) == 0) {
			strcpy(PropValue, NONE_VALUE_STRING);
		}

		strcpy(AllPropString+index, PropValue);
		index += strlen(PropValue);

		AllPropString[index] = '|';
		index++;
	}

	// DeviceID(IMEI)
	GetDeviceID(env, activity, DeviceID);
	strcpy(AllPropString+index, "val5");
	index += strlen("val5");
	AllPropString[index] = '=';
	index++;
	if(strlen(DeviceID) == 0) {	// 값 없으면 "NONE"으로 내보내기
		strcpy(DeviceID, NONE_VALUE_STRING);
	}
	strcpy(AllPropString+index, DeviceID);
	index += strlen(DeviceID);
	AllPropString[index] = '|';
	index++;

	// MDN
	GetMdn(env, activity, Mdn);
	verifyMdn(Mdn);		// 전화번보 +82로 시작하는거 0으로 바꾸기
	strcpy(AllPropString+index, "val6");
	index += strlen("val6");
	AllPropString[index] = '=';
	index++;
	if(strlen(Mdn) == 0) {	// 값 없으면 "NONE"으로 내보내기
		strcpy(Mdn, NONE_VALUE_STRING);
	}
	strcpy(AllPropString+index, Mdn);
	index += strlen(Mdn);
	AllPropString[index] = '|';
	index++;

	return (*env)->NewStringUTF(env, AllPropString);
}
Ejemplo n.º 20
0
IPCCommandResult CWII_IPC_HLE_Device_usb_oh0_46d_a03::Open(u32 CommandAddress, u32 Mode)
{
	Memory::Write_U32(GetDeviceID(), CommandAddress + 4);
	m_Active = true;
	return GetDefaultReply();
}