这篇教程C++ CHECK_HR函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CHECK_HR函数的典型用法代码示例。如果您正苦于以下问题:C++ CHECK_HR函数的具体用法?C++ CHECK_HR怎么用?C++ CHECK_HR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CHECK_HR函数的21个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CHECK_HRHRESULT FakeContent::GetValue( REFPROPERTYKEY Key, __out IPortableDeviceValues* pStore){ HRESULT hr = S_OK; PropVariantWrapper pvValue; if(pStore == NULL) { hr = E_POINTER; CHECK_HR(hr, "Cannot have NULL parameter"); return hr; } if (IsEqualPropertyKey(Key, WPD_OBJECT_ID)) { // Add WPD_OBJECT_ID pvValue = ObjectID; hr = pStore->SetValue(WPD_OBJECT_ID, &pvValue); CHECK_HR(hr, ("Failed to set WPD_OBJECT_ID")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_PERSISTENT_UNIQUE_ID)) { // Add WPD_OBJECT_PERSISTENT_UNIQUE_ID pvValue = this->PersistentUniqueID; hr = pStore->SetValue(WPD_OBJECT_PERSISTENT_UNIQUE_ID, &pvValue); CHECK_HR(hr, ("Failed to set WPD_OBJECT_PERSISTENT_UNIQUE_ID")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_PARENT_ID)) { // Add WPD_OBJECT_PARENT_ID pvValue = ParentID; hr = pStore->SetValue(WPD_OBJECT_PARENT_ID, &pvValue); CHECK_HR(hr, ("Failed to set WPD_OBJECT_PARENT_ID")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_NAME)) { // Add WPD_OBJECT_NAME pvValue = Name; hr = pStore->SetValue(WPD_OBJECT_NAME, &pvValue); CHECK_HR(hr, ("Failed to set WPD_OBJECT_NAME")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_CONTENT_TYPE)) { // Add WPD_OBJECT_CONTENT_TYPE hr = pStore->SetGuidValue(WPD_OBJECT_CONTENT_TYPE, ContentType); CHECK_HR(hr, ("Failed to set WPD_OBJECT_CONTENT_TYPE")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_FORMAT)) { // Add WPD_OBJECT_FORMAT hr = pStore->SetGuidValue(WPD_OBJECT_FORMAT, Format); CHECK_HR(hr, ("Failed to set WPD_OBJECT_FORMAT")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_CAN_DELETE)) { // Add WPD_OBJECT_CAN_DELETE hr = pStore->SetBoolValue(WPD_OBJECT_CAN_DELETE, CanDelete); CHECK_HR(hr, ("Failed to set WPD_OBJECT_CAN_DELETE")); } else { hr = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); CHECK_HR(hr, "Property {%ws}.%d is not supported", CComBSTR(Key.fmtid), Key.pid); } return hr;}
开发者ID:kcrazy,项目名称:winekit,代码行数:67,
示例2: CHECK_HR//---------------------------------------------------------------------------// wxActiveXContainer::CreateActiveX//// Actually creates the ActiveX container through the FrameSite// and sets up ActiveX events//// TODO: Document this more//---------------------------------------------------------------------------void wxActiveXContainer::CreateActiveX(REFIID iid, IUnknown* pUnk){ HRESULT hret; hret = m_ActiveX.QueryInterface(iid, pUnk); CHECK_HR(hret); // FrameSite m_frameSite = new FrameSite(m_realparent, this); // oleClientSite hret = m_clientSite.QueryInterface( IID_IOleClientSite, (IDispatch *) m_frameSite); CHECK_HR(hret); // adviseSink wxAutoIAdviseSink adviseSink(IID_IAdviseSink, (IDispatch *) m_frameSite); wxASSERT(adviseSink.IsOk()); // Get Dispatch interface hret = m_Dispatch.QueryInterface(IID_IDispatch, m_ActiveX); CHECK_HR(hret); // // SETUP TYPEINFO AND ACTIVEX EVENTS // // get type info via class info wxAutoIProvideClassInfo classInfo(IID_IProvideClassInfo, m_ActiveX); wxASSERT(classInfo.IsOk()); // type info wxAutoITypeInfo typeInfo; hret = classInfo->GetClassInfo(typeInfo.GetRef()); CHECK_HR(hret); wxASSERT(typeInfo.IsOk()); // TYPEATTR TYPEATTR *ta = NULL; hret = typeInfo->GetTypeAttr(&ta); CHECK_HR(hret); // this should be a TKIND_COCLASS wxASSERT(ta->typekind == TKIND_COCLASS); // iterate contained interfaces for (int i = 0; i < ta->cImplTypes; i++) { HREFTYPE rt = 0; // get dispatch type info handle hret = typeInfo->GetRefTypeOfImplType(i, &rt); if (! SUCCEEDED(hret)) continue; // get dispatch type info interface wxAutoITypeInfo ti; hret = typeInfo->GetRefTypeInfo(rt, ti.GetRef()); if (! ti.IsOk()) continue; CHECK_HR(hret); // check if default event sink bool defEventSink = false; int impTypeFlags = 0; typeInfo->GetImplTypeFlags(i, &impTypeFlags); if (impTypeFlags & IMPLTYPEFLAG_FDEFAULT) { if (impTypeFlags & IMPLTYPEFLAG_FSOURCE) { // WXOLE_TRACEOUT("Default Event Sink"); defEventSink = true; if (impTypeFlags & IMPLTYPEFLAG_FDEFAULTVTABLE) { // WXOLE_TRACEOUT("*ERROR* - Default Event Sink is via vTable"); defEventSink = false; wxFAIL_MSG(wxT("Default event sink is in vtable!")); } } } // wxAutoOleInterface<> assumes a ref has already been added // TYPEATTR TYPEATTR *ta = NULL; hret = ti->GetTypeAttr(&ta); CHECK_HR(hret); if (ta->typekind == TKIND_DISPATCH) { // WXOLE_TRACEOUT("GUID = " << GetIIDName(ta->guid).c_str()); if (defEventSink) {//.........这里部分代码省略.........
开发者ID:mark711,项目名称:Cafu,代码行数:101,
示例3: CheckPointerHRESULT StaticSourceVideoPin::FillBuffer(IMediaSample * pSample){ CheckPointer(pSample, E_POINTER); HRESULT hr = S_OK; DWORD frameDataCount; BYTE * frameData; //Nastavenie hodnoty casu zaciatku a konca snimky REFERENCE_TIME rtStart = this->m_rtLastFrame; REFERENCE_TIME rtStop = rtStart + this->m_pFilter->m_params->m_rtFrameLength; pSample->SetTime(&rtStart, &rtStop); if (this->m_pFilter->m_rtStop > 0 && rtStop >= this->m_pFilter->m_rtStop) { //Ak je nastaveny cas konca a prekroci sa, ukonci sa stream hr = S_FALSE; goto done; } this->m_rtLastFrame = rtStop; CHECK_HR(hr = pSample->GetPointer(&frameData)); frameDataCount = pSample->GetSize(); //Ak je nastavena bitmapa, pouzi tu, inak nastav sum if (this->m_pFilter->m_params->m_bitmapData == NULL) { for (DWORD i = 0; i < frameDataCount; i++) frameData[i] = (BYTE)(rand() % 256); } else { if (this->m_mt.subtype == MEDIASUBTYPE_RGB32) { //Na vystup ide RGB32 typ if (this->m_pFilter->m_params->m_bitmapInfo.biBitCount == 32) { CopyMemory(frameData, this->m_pFilter->m_params->m_bitmapData, frameDataCount); } else { BITMAPINFOHEADER dstBmi = this->m_pFilter->m_params->m_bitmapInfo; dstBmi.biBitCount = 32; RGBtoRGB(this->m_pFilter->m_params->m_bitmapInfo, this->m_pFilter->m_params->m_bitmapData, frameData, dstBmi); } } else if (this->m_mt.subtype == MEDIASUBTYPE_RGB24) { //Na vystup ide RGB24 typ if (this->m_pFilter->m_params->m_bitmapInfo.biBitCount == 24) { CopyMemory(frameData, this->m_pFilter->m_params->m_bitmapData, frameDataCount); } else { BITMAPINFOHEADER dstBmi = this->m_pFilter->m_params->m_bitmapInfo; dstBmi.biBitCount = 24; RGBtoRGB(this->m_pFilter->m_params->m_bitmapInfo, this->m_pFilter->m_params->m_bitmapData, frameData, dstBmi); } } else if (this->m_mt.subtype == MEDIASUBTYPE_YUY2) { //Na vystup ide YUY2 typ RGBtoYUY2(this->m_pFilter->m_params->m_bitmapInfo, this->m_pFilter->m_params->m_bitmapData, frameData); } else if (this->m_mt.subtype == MEDIASUBTYPE_YV12) { //Na vystup ide YV12 typ RGBtoYV12(this->m_pFilter->m_params->m_bitmapInfo, this->m_pFilter->m_params->m_bitmapData, frameData); } } CHECK_HR(hr = pSample->SetSyncPoint(TRUE)); CHECK_HR(hr = pSample->SetActualDataLength(frameDataCount)); done: return hr;}
开发者ID:tomaspsenak,项目名称:hmc,代码行数:80,
示例4: CHECK_HR/** * This method is called when we receive a WPD_COMMAND_OBJECT_RESOURCES_READ * command. * * The parameters sent to us are: * - WPD_PROPERTY_OBJECT_RESOURCES_CONTEXT: the context the driver returned to * the client in OnOpenResource. * - WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_READ: the number of bytes to * read from the resource. * * The driver should: * - Read data associated with the resource and return it back to the caller in * WPD_PROPERTY_OBJECT_RESOURCES_DATA. * - Report the number of bytes actually read from the resource in * WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_READ. This number may be smaller * than WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_READ when reading the last * chunk of data from the resource. */HRESULT WpdObjectResources::OnReadResource( _In_ IPortableDeviceValues* pParams, _In_ IPortableDeviceValues* pResults){ HRESULT hr = S_OK; LPWSTR wszResourceContext = NULL; DWORD dwNumBytesToRead = 0; DWORD dwNumBytesRead = 0; BYTE* pBuffer = NULL; WpdObjectResourceContext* pResourceContext = NULL; ContextMap* pContextMap = NULL; // Get the enumeration context identifier for this enumeration operation. We will // need this to lookup the specific enumeration context in the client context map. hr = pParams->GetStringValue(WPD_PROPERTY_OBJECT_RESOURCES_CONTEXT, &wszResourceContext); if (hr != S_OK) { hr = E_INVALIDARG; CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_RESOURCES_CONTEXT"); } // Get the number of bytes to read if (hr == S_OK) { hr = pParams->GetUnsignedIntegerValue(WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_READ, &dwNumBytesToRead); CHECK_HR(hr, "Missing value for WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_TO_READ"); } // Allocate the destination buffer if (hr == S_OK) { pBuffer = reinterpret_cast<BYTE *>(CoTaskMemAlloc(dwNumBytesToRead)); if (pBuffer == NULL) { hr = E_OUTOFMEMORY; CHECK_HR(hr, "Failed to allocate the destination buffer"); } } // Get the client context map so we can retrieve the resource context for this resource // operation using the WPD_PROPERTY_OBJECT_RESOURCES_CONTEXT property value obtained above. if (hr == S_OK) { hr = pParams->GetIUnknownValue(PRIVATE_SAMPLE_DRIVER_CLIENT_CONTEXT_MAP, (IUnknown**)&pContextMap); CHECK_HR(hr, "Failed to get PRIVATE_SAMPLE_DRIVER_CLIENT_CONTEXT_MAP"); } if (hr == S_OK) { pResourceContext = (WpdObjectResourceContext*)pContextMap->GetContext(wszResourceContext); if (pResourceContext == NULL) { hr = E_INVALIDARG; CHECK_HR(hr, "Missing resource context"); } } // Read the next chunk of data for this request if (hr == S_OK && pBuffer != NULL) { hr = ReadDataFromResource(pResourceContext, pBuffer, dwNumBytesToRead, &dwNumBytesRead); CHECK_HR(hr, "Failed to read %d bytes from resource", dwNumBytesToRead); } if (hr == S_OK && pBuffer != NULL) { hr = pResults->SetBufferValue(WPD_PROPERTY_OBJECT_RESOURCES_DATA, pBuffer, dwNumBytesRead); CHECK_HR(hr, "Failed to set WPD_PROPERTY_OBJECT_RESOURCES_DATA"); } if (hr == S_OK) { hr = pResults->SetUnsignedIntegerValue(WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_READ, dwNumBytesRead); CHECK_HR(hr, "Failed to set WPD_PROPERTY_OBJECT_RESOURCES_NUM_BYTES_READ"); } // Free the memory. CoTaskMemFree ignores NULLs so no need to check. CoTaskMemFree(wszResourceContext); // Free the memory. CoTaskMemFree ignores NULLs so no need to check. CoTaskMemFree(pBuffer);//.........这里部分代码省略.........
开发者ID:340211173,项目名称:Windows-driver-samples,代码行数:101,
示例5: mainint main(){ UINT dpi = SetupDPI(); gRenderScale = 96.0 / double(dpi); // Scale default window size based on dpi gWindowWidth *= dpi / 96; gWindowHeight *= dpi / 96; // Create window { WNDCLASSEX wc; ZeroMemory(&wc, sizeof(wc)); wc.cbSize = sizeof(wc); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = MyWndProc; wc.hInstance = GetModuleHandle(NULL); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND; wc.lpszClassName = TEXT("WindowClass"); CHECK_WIN32(RegisterClassEx(&wc)); RECT wr = { 0, 0, gWindowWidth, gWindowHeight }; CHECK_WIN32(AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE)); ghWnd = CHECK_WIN32(CreateWindowEx( 0, TEXT("WindowClass"), TEXT("Spooky"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, wr.right - wr.left, wr.bottom - wr.top, 0, 0, GetModuleHandle(NULL), 0)); } // Create D3D11 device and swap chain { ComPtr<IDXGIFactory> pFactory; CHECK_HR(CreateDXGIFactory(IID_PPV_ARGS(&pFactory))); UINT deviceFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;#ifdef _DEBUG deviceFlags |= D3D11_CREATE_DEVICE_DEBUG;#endif RECT clientRect; GetClientRect(ghWnd, &clientRect); DXGI_SWAP_CHAIN_DESC scd{}; scd.BufferCount = kSwapChainBufferCount; scd.BufferDesc.Format = kSwapChainFormat; scd.BufferDesc.Width = clientRect.right - clientRect.left; scd.BufferDesc.Height = clientRect.bottom - clientRect.top; scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; scd.OutputWindow = ghWnd; scd.Windowed = TRUE; scd.SampleDesc.Count = 1; scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; CHECK_HR(D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, deviceFlags, NULL, 0, D3D11_SDK_VERSION, &scd, &gpSwapChain, &gpDevice, NULL, &gpDeviceContext)); CHECK_HR(gpDevice.As(&gpDxgiDevice)); } InitApp(dpi); ShowWindow(ghWnd, SW_SHOWNORMAL); EnableMouseInPointer(TRUE); while (!gShouldClose) { // Handle all events MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } UpdateApp(); RenderApp(); // Swap buffers CHECK_HR(gpSwapChain->Present(0, 0)); } CoUninitialize(); // <- this currently creates problems with the WIC Factory. CHECK_HR(gpSwapChain->SetFullscreenState(FALSE, NULL));}
开发者ID:nlguillemot,项目名称:spooky,代码行数:88,
示例6: CHECK_HR/** * This method is called when we receive a WPD_COMMAND_OBJECT_PROPERTIES_BULK_SET_VALUES_BY_OBJECT_LIST_NEXT * command. * * The parameters sent to us are: * - WPD_PROPERTY_OBJECT_PROPERTIES_BULK_CONTEXT: the context the driver returned to * the client in OnGetValuesByObjectListStart. * * The driver should: * - Write the next set of property values, and return the write results in WPD_PROPERTY_OBJECT_PROPERTIES_BULK_WRITE_RESULTS. * If there are no more properties to be written, an empty collection should be returned. * - It is up to the driver to write as many object property values as it wants. If zero write results are returned * it is assumed the bulk operation is complete and the WPD_COMMAND_OBJECT_PROPERTIES_BULK_SET_VALUES_BY_OBJECT_LIST_END * will be called next. * * - S_OK should be returned if the collection can be returned successfully. * - Any error return indicates that the driver did not fill in any results, and the caller will * not attempt to unpack any property values. */HRESULT WpdObjectPropertiesBulk::OnSetValuesByObjectListNext( _In_ IPortableDeviceValues* pParams, _In_ IPortableDeviceValues* pResults){ HRESULT hr = S_OK; LPWSTR pwszContext = NULL; BulkPropertiesContext* pContext = NULL; DWORD cObjects = 0; CComPtr<IPortableDeviceValues> pEventParams; CComPtr<IPortableDeviceValuesCollection> pWriteResults; CComPtr<IPortableDeviceValuesCollection> pValuesCollection; hr = pParams->GetStringValue(WPD_PROPERTY_OBJECT_PROPERTIES_BULK_CONTEXT, &pwszContext); CHECK_HR(hr, "Failed to get WPD_PROPERTY_OBJECT_PROPERTIES_BULK_CONTEXT from IPortableDeviceValues"); // Get the bulk property operation context if (SUCCEEDED(hr)) { hr = GetClientContext(pParams, pwszContext, (IUnknown**) &pContext); CHECK_HR(hr, "Failed to get bulk property context"); } // Make sure the the collection holds a ValuesCollection, then get the number of elements. if (SUCCEEDED(hr)) { if(pContext->ValuesCollection != NULL) { hr = pContext->ValuesCollection->GetCount(&cObjects); CHECK_HR(hr, "Failed to get number of objectIDs from bulk properties context"); } else { hr = E_INVALIDARG; CHECK_HR(hr, "Incorrect context specified - this context does not contain a values collection"); } } // Create the collection to hold the write results if (SUCCEEDED(hr)) { hr = CoCreateInstance(CLSID_PortableDeviceValuesCollection, NULL, CLSCTX_INPROC_SERVER, IID_IPortableDeviceValuesCollection, (VOID**) &pWriteResults); CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValuesCollection"); } // Create the collection to hold the event parameters if (SUCCEEDED(hr)) { hr = CoCreateInstance(CLSID_PortableDeviceValues, NULL, CLSCTX_INPROC_SERVER, IID_IPortableDeviceValues, (VOID**) &pEventParams); CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues"); } if (SUCCEEDED(hr)) { for (DWORD dwIndex = pContext->NextObject; dwIndex < cObjects; dwIndex++) { CComPtr<IPortableDeviceValues> pValues; CComPtr<IPortableDeviceValues> pSetResults; bool bObjectChanged = false; hr = pContext->ValuesCollection->GetAt(dwIndex, &pValues); CHECK_HR(hr, "Failed to get next values from bulk properties context"); // CoCreate a collection to store the per object results. if (SUCCEEDED(hr)) { hr = CoCreateInstance(CLSID_PortableDeviceValues, NULL, CLSCTX_INPROC_SERVER, IID_IPortableDeviceValues, (VOID**) &pSetResults); CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues"); }//.........这里部分代码省略.........
开发者ID:340211173,项目名称:Windows-driver-samples,代码行数:101,
示例7: CHECK_HRHRESULT WpdServiceMethods::DispatchMethod( _In_ LPCWSTR pwszContext, _In_ IPortableDeviceValues* pStartParams, _Outptr_ IPortableDeviceValues** ppResults){ HRESULT hr = S_OK; HRESULT hrStatus = S_OK; GUID Method = GUID_NULL; CComPtr<IPortableDeviceValues> pMethodParams; CComPtr<IPortableDeviceValues> pMethodResults; *ppResults = NULL; // Get the method GUID hr = pStartParams->GetGuidValue(WPD_PROPERTY_SERVICE_METHOD, &Method); CHECK_HR(hr, "Failed to get WPD_PROPERTY_SERVICE_METHOD"); // Get the method parameters. These can be optional if the methods don't require parameters if (hr == S_OK) { HRESULT hrTemp = pStartParams->GetIPortableDeviceValuesValue(WPD_PROPERTY_SERVICE_METHOD_PARAMETER_VALUES, &pMethodParams); CHECK_HR(hrTemp, "Failed to get WPD_PROPERTY_SERVICE_METHOD_PARAMETER_VALUES (ok if method does not require parameters)"); } // Prepare the results collection if (hr == S_OK) { hr = CoCreateInstance(CLSID_PortableDeviceValues, NULL, CLSCTX_INPROC_SERVER, IID_IPortableDeviceValues, (VOID**)ppResults); CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues"); } if (hr == S_OK) { // Invoke the method to the service m_pGattService->OnMethodInvoke(Method, pMethodParams, *ppResults); } // Post the completion event if the method has failed. { if (hr == S_OK) { hr = (*ppResults)->SetGuidValue(WPD_EVENT_PARAMETER_EVENT_ID, WPD_EVENT_SERVICE_METHOD_COMPLETE); CHECK_HR(hr, "Failed to set the event id to WPD_EVENT_SERVICE_METHOD_COMPLETE"); } if (hr == S_OK) { hr = (*ppResults)->SetStringValue(WPD_EVENT_PARAMETER_SERVICE_METHOD_CONTEXT, pwszContext); CHECK_HR(hr, "Failed to set the method context for WPD_EVENT_SERVICE_METHOD_COMPLETE"); } if (hr == S_OK) { hr = PostWpdEvent(pStartParams, *ppResults); CHECK_HR(hr, "Failed to post WPD_EVENT_SERVICE_METHOD_COMPLETE"); } } if (hr == S_OK) { hr = hrStatus; } return hr;}
开发者ID:uri247,项目名称:wdk80,代码行数:70,
示例8: XCHECK_HR/////////////////////////////////////////////////////////////////// myGetProperty//// This function gets the BOOL value for the specified property// and returns the result in *pbValue.///////////////////////////////////////////////////////////////////HRESULT myGetProperty ( IUnknown * pIUnknown, REFIID riid, DBPROPID dwPropertyID, REFGUID guidPropertySet, BOOL * pbValue ){ HRESULT hr; DBPROPID rgPropertyIDs[1]; DBPROPIDSET rgPropertyIDSets[1]; ULONG cPropSets = 0; DBPROPSET * rgPropSets = NULL; IDBProperties * pIDBProperties = NULL; ISessionProperties * pISesProps = NULL; ICommandProperties * pICmdProps = NULL; IRowsetInfo * pIRowsetInfo = NULL; // Initialize the output value *pbValue = FALSE; // Set up the property ID array rgPropertyIDs[0] = dwPropertyID; // Set up the Property ID Set rgPropertyIDSets[0].rgPropertyIDs = rgPropertyIDs; rgPropertyIDSets[0].cPropertyIDs = 1; rgPropertyIDSets[0].guidPropertySet = guidPropertySet; // Get the property value for this property from the provider, but // don't try to display extended error information, since this may // not be a supported property: a failure is, in fact, expected if // the property is not supported if( riid == IID_IDBProperties ) { XCHECK_HR(hr = pIUnknown->QueryInterface(IID_IDBProperties, (void**)&pIDBProperties)); CHECK_HR(hr = pIDBProperties->GetProperties( 1, //cPropertyIDSets rgPropertyIDSets, //rgPropertyIDSets &cPropSets, //pcPropSets &rgPropSets //prgPropSets )); } else if( riid == IID_ISessionProperties ) { XCHECK_HR(hr = pIUnknown->QueryInterface(IID_ISessionProperties, (void**)&pISesProps)); CHECK_HR(hr = pISesProps->GetProperties( 1, //cPropertyIDSets rgPropertyIDSets, //rgPropertyIDSets &cPropSets, //pcPropSets &rgPropSets //prgPropSets )); } else if( riid == IID_ICommandProperties ) { XCHECK_HR(hr = pIUnknown->QueryInterface(IID_ICommandProperties, (void**)&pICmdProps)); CHECK_HR(hr = pICmdProps->GetProperties( 1, //cPropertyIDSets rgPropertyIDSets, //rgPropertyIDSets &cPropSets, //pcPropSets &rgPropSets //prgPropSets )); } else { XCHECK_HR(hr = pIUnknown->QueryInterface(IID_IRowsetInfo, (void**)&pIRowsetInfo)); CHECK_HR(hr = pIRowsetInfo->GetProperties( 1, //cPropertyIDSets rgPropertyIDSets, //rgPropertyIDSets &cPropSets, //pcPropSets &rgPropSets //prgPropSets )); } // Return the value for this property to the caller if // it's a VT_BOOL type value, as expected if( V_VT(&rgPropSets[0].rgProperties[0].vValue) == VT_BOOL ) *pbValue = V_BOOL(&rgPropSets[0].rgProperties[0].vValue);CLEANUP: if( rgPropSets ) { CoTaskMemFree(rgPropSets[0].rgProperties); CoTaskMemFree(rgPropSets); } if( pIDBProperties )//.........这里部分代码省略.........
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:101,
示例9: SetPortState/*-----------------------------------------------------------------------------FUNCTION: SetPortState( void )PURPOSE: Sets port state based on settings from the userCOMMENTS: Sets up DCB structure and calls SetCommState. Sets up new timeouts by calling SetCommTimeouts.HISTORY: Date: Author: Comment: 1/9/96 AllenD Wrote it 12/06/06 DonnMo Replaced calls to ErrorReporter() with CHECK_HR()-----------------------------------------------------------------------------*/HRESULT RS232Connection::SetPortState(){ HRESULT hr = S_OK; DCB dcb = {0}; DWORD dwLastError = 0; dcb.DCBlength = sizeof(dcb); // // get current DCB settings // if (!GetCommState(m_hCommPort, &dcb)) { dwLastError = GetLastError(); hr = HRESULT_FROM_WIN32(dwLastError); CHECK_HR(hr, "GetCommState() failed within SetPortState()."); return hr; } // // update DCB rate, byte size, parity, and stop bits size // dcb.BaudRate = m_dwBaudRate; dcb.ByteSize = m_bByteSize; dcb.Parity = m_bParity; dcb.StopBits = m_bStopBits; // // update event flags // if (m_dwEventFlags & EV_RXFLAG) { dcb.EvtChar = m_chFlag; } else { dcb.EvtChar = '/0'; } dcb.EofChar = '/n'; // // update flow control settings // dcb.fDtrControl = m_fDtrControl; dcb.fRtsControl = m_fRtsControl; dcb.fOutxCtsFlow = m_fCTSOutFlow; dcb.fOutxDsrFlow = m_fDSROutFlow; dcb.fDsrSensitivity = m_fDSRInFlow; dcb.fOutX = m_fXonXoffOutFlow; dcb.fInX = m_fXonXoffInFlow; dcb.fTXContinueOnXoff = m_fTXafterXoffSent; dcb.XonChar = m_chXON; dcb.XoffChar = m_chXOFF; dcb.XonLim = m_wXONLimit; dcb.XoffLim = m_wXOFFLimit; // // DCB settings not in the user's control // dcb.fParity = TRUE; // // set new state // if (!SetCommState(m_hCommPort, &dcb)) { dwLastError = GetLastError(); hr = HRESULT_FROM_WIN32(dwLastError); CHECK_HR(hr, "SetCommState() failed within SetPortState() when setting the new state."); return hr; } // // set new timeouts // if (!SetCommTimeouts(m_hCommPort, &m_timeoutsnew)) { dwLastError = GetLastError(); hr = HRESULT_FROM_WIN32(dwLastError); CHECK_HR(hr, "SetCommTimeouts() failed within SetPortState() when setting the new timeouts."); return hr; }//.........这里部分代码省略.........
开发者ID:340211173,项目名称:Windows-driver-samples,代码行数:101,
示例10: CHECK_HRHRESULT CMFCamCapture::init(){ IMFMediaType *pType = NULL; HRESULT hr; CHECK_HR(hr = CoInitializeEx(NULL, COINIT_MULTITHREADED)); CHECK_HR(hr = MFStartup(MF_VERSION)); // Configure the media type that the Sample Grabber will receive. // Setting the major and subtype is usually enough for the topology loader // to resolve the topology. CHECK_HR(hr = MFCreateMediaType(&pType)); CHECK_HR(hr = pType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video)); CHECK_HR(hr = pType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_RGB24)); // Create the sample grabber sink. CHECK_HR(hr = SampleGrabberCB::CreateInstance(&m_spSampleGrabber)); CHECK_HR(hr = MFCreateSampleGrabberSinkActivate(pType, m_spSampleGrabber, &m_spSinkActivate)); // To run as fast as possible, set this attribute (requires Windows 7): CHECK_HR(hr = m_spSinkActivate->SetUINT32(MF_SAMPLEGRABBERSINK_IGNORE_CLOCK, TRUE)); // Create the Media Session. CHECK_HR(hr = MFCreateMediaSession(NULL, &m_spSession)); CHECK_HR(hr = enumVideoDevices()); CHECK_HR(hr = setupVideoDevice()); CHECK_HR(hr = setupMfSession()); done: SafeRelease(&pType); return hr;}
开发者ID:cchang326,项目名称:2p5D,代码行数:36,
示例11: Connect/*-----------------------------------------------------------------------------FUNCTION: Connect( void )PURPOSE: Setup Communication Port with our settingsRETURN: S_OK and handle of com port if successful-----------------------------------------------------------------------------*/HRESULT RS232Connection::Connect(_In_ LPCWSTR wszPortName, _Out_ HANDLE *phCommPort){ HRESULT hr = S_OK; DWORD dwLastError = 0; if (phCommPort == NULL) { hr = E_POINTER; CHECK_HR(hr, "A NULL phCommPort parameter was received"); return hr; } *phCommPort = NULL; // // retrieve a handle for the com port // and configure the port for asynchronous // communications. // m_hCommPort = CreateFileW(wszPortName, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, 0); if (m_hCommPort == NULL) { dwLastError = GetLastError(); hr = HRESULT_FROM_WIN32(dwLastError); CHECK_HR(hr, "CreateFileW() failed in RS232Connection::Connect"); return hr; } // // Save original comm timeouts and set new ones // if (!GetCommTimeouts( m_hCommPort, &(m_timeoutsorig))) { dwLastError = GetLastError(); hr = HRESULT_FROM_WIN32(dwLastError); CHECK_HR(hr, "GetCommTimeouts() failed within RS232Connection::Connect"); return hr; } // // Set port state // hr = SetPortState(); if (FAILED(hr)) { CHECK_HR(hr, "SetPortState() failed within RS232Connection::Connect"); return hr; } // // set comm buffer sizes // if (!SetupComm(m_hCommPort, MAX_READ_BUFFER, MAX_WRITE_BUFFER)) { dwLastError = GetLastError(); hr = HRESULT_FROM_WIN32(dwLastError); CHECK_HR(hr, "SetupComm(SETDTR) failed within RS232Connection::Connect"); return hr; } // // raise DTR // if (!EscapeCommFunction(m_hCommPort, SETDTR)) { dwLastError = GetLastError(); hr = HRESULT_FROM_WIN32(dwLastError); CHECK_HR(hr, "EscapeCommFunction() failed within RS232Connection::Connect"); return hr; } // // set overall connect flag // m_fConnected = TRUE; // // set the return value // *phCommPort = m_hCommPort; if (SUCCEEDED(hr))//.........这里部分代码省略.........
开发者ID:340211173,项目名称:Windows-driver-samples,代码行数:101,
示例12: CHECK_HRHRESULT WpdBaseDriver::DispatchWpdMessage(_In_ IPortableDeviceValues* pParams, _In_ IPortableDeviceValues* pResults){ HRESULT hr = S_OK; GUID guidCommandCategory = {0}; DWORD dwCommandID = 0; PROPERTYKEY CommandKey = WPD_PROPERTY_NULL; if (hr == S_OK) { hr = pParams->GetGuidValue(WPD_PROPERTY_COMMON_COMMAND_CATEGORY, &guidCommandCategory); CHECK_HR(hr, "Failed to get WPD_PROPERTY_COMMON_COMMAND_CATEGORY from input parameters"); } if (hr == S_OK) { hr = pParams->GetUnsignedIntegerValue(WPD_PROPERTY_COMMON_COMMAND_ID, &dwCommandID); CHECK_HR(hr, "Failed to get WPD_PROPERTY_COMMON_COMMAND_ID from input parameters"); } // If WPD_PROPERTY_COMMON_COMMAND_CATEGORY or WPD_PROPERTY_COMMON_COMMAND_ID could not be extracted // properly then we should return E_INVALIDARG to the client. if (FAILED(hr)) { hr = E_INVALIDARG; CHECK_HR(hr, "Failed to get WPD_PROPERTY_COMMON_COMMAND_CATEGORY or WPD_PROPERTY_COMMON_COMMAND_ID from input parameters"); } if (hr == S_OK) { CommandKey.fmtid = guidCommandCategory; CommandKey.pid = dwCommandID; if (CommandKey.fmtid == WPD_CATEGORY_OBJECT_ENUMERATION) { hr = m_ObjectEnum.DispatchWpdMessage(CommandKey, pParams, pResults); } else if (CommandKey.fmtid == WPD_CATEGORY_OBJECT_PROPERTIES) { hr = m_ObjectProperties.DispatchWpdMessage(CommandKey, pParams, pResults); } else if (CommandKey.fmtid == WPD_CATEGORY_OBJECT_RESOURCES) { hr = m_ObjectResources.DispatchWpdMessage(CommandKey, pParams, pResults); } else if (CommandKey.fmtid == WPD_CATEGORY_CAPABILITIES) { hr = m_Capabilities.DispatchWpdMessage(CommandKey, pParams, pResults); } else if (IsEqualPropertyKey(CommandKey, WPD_COMMAND_COMMON_GET_OBJECT_IDS_FROM_PERSISTENT_UNIQUE_IDS)) { hr = OnGetObjectIDsFromPersistentUniqueIDs(pParams, pResults); } else { hr = E_NOTIMPL; CHECK_HR(hr, "Unknown command %ws.%d received",CComBSTR(CommandKey.fmtid), CommandKey.pid); } } HRESULT hrTemp = pResults->SetErrorValue(WPD_PROPERTY_COMMON_HRESULT, hr); CHECK_HR(hrTemp, ("Failed to set WPD_PROPERTY_COMMON_HRESULT")); // Set to a success code, to indicate that the message was received. // the return code for the actual command's results is stored in the // WPD_PROPERTY_COMMON_HRESULT property. hr = S_OK; return hr;}
开发者ID:340211173,项目名称:Windows-driver-samples,代码行数:70,
示例13: CHECK_HRHRESULT WpdObjectPropertiesBulk::CreateBulkPropertiesContext( __in ACCESS_SCOPE Scope, __inout ContextMap* pContextMap, __in REFGUID guidObjectFormat, __in LPCWSTR pszParentObjectID, __in DWORD dwDepth, __in IPortableDeviceKeyCollection* pProperties, __deref_out_opt LPWSTR* ppszBulkPropertiesContext){ HRESULT hr = S_OK; BulkPropertiesContext* pContext = NULL; CAtlStringW strKey; CComPtr<IPortableDevicePropVariantCollection> pObjectIDs; if((pContextMap == NULL) || (pszParentObjectID == NULL) || (ppszBulkPropertiesContext == NULL)) { hr = E_POINTER; CHECK_HR(hr, "Cannot have NULL parameter"); return hr; } *ppszBulkPropertiesContext = NULL; hr = CoCreateInstance(CLSID_PortableDevicePropVariantCollection, NULL, CLSCTX_INPROC_SERVER, IID_IPortableDevicePropVariantCollection, (VOID**) &pObjectIDs); CHECK_HR(hr, "Failed to CoCreate CLSID_IPortableDevicePropVariantCollection"); if (hr == S_OK) { hr = m_pDevice->GetObjectIDsByFormat(Scope, guidObjectFormat, pszParentObjectID, dwDepth, pObjectIDs); CHECK_HR(hr, "Faield to get list of object ids by format"); } if (hr == S_OK) { pContext = new BulkPropertiesContext(); if(pContext == NULL) { hr = E_OUTOFMEMORY; CHECK_HR(hr, "Failed to allocate new bulk properties context"); } } if (hr == S_OK) { pContext->Properties = pProperties; pContext->ObjectIDs = pObjectIDs; pContext->Scope = Scope; hr = pContextMap->Add(pContext, strKey); CHECK_HR(hr, "Failed to insert bulk property operation context into our context Map"); } if (hr == S_OK) { *ppszBulkPropertiesContext = AtlAllocTaskWideString(strKey); if (*ppszBulkPropertiesContext == NULL) { hr = E_OUTOFMEMORY; CHECK_HR(hr, "Failed to allocate bulk properties context"); } } SAFE_RELEASE(pContext); return hr;}
开发者ID:kcrazy,项目名称:winekit,代码行数:73,
示例14: CopyComPointerHRESULT Scheduler::StartScheduler(IMFClock *pClock){ if (m_hSchedulerThread != NULL) { return E_UNEXPECTED; } HRESULT hr = S_OK; DWORD dwID = 0; CopyComPointer(m_pClock, pClock); // Set a high the timer resolution (ie, short timer period). timeBeginPeriod(1); // Create an event to wait for the thread to start. m_hThreadReadyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); if (m_hThreadReadyEvent == NULL) { CHECK_HR(hr = HRESULT_FROM_WIN32(GetLastError())); } // Create an event to wait for flush commands to complete. m_hFlushEvent = CreateEvent(NULL, FALSE, FALSE, NULL); if (m_hFlushEvent == NULL) { CHECK_HR(hr = HRESULT_FROM_WIN32(GetLastError())); } // Create the scheduler thread. m_hSchedulerThread = CreateThread(NULL, 0, SchedulerThreadProc, (LPVOID)this, 0, &dwID); if (m_hSchedulerThread == NULL) { CHECK_HR(hr = HRESULT_FROM_WIN32(GetLastError())); } HANDLE hObjects[] = { m_hThreadReadyEvent, m_hSchedulerThread }; DWORD dwWait = 0; // Wait for the thread to signal the "thread ready" event. dwWait = WaitForMultipleObjects(2, hObjects, FALSE, INFINITE); // Wait for EITHER of these handles. if (WAIT_OBJECT_0 != dwWait) { // The thread terminated early for some reason. This is an error condition. CloseHandle(m_hSchedulerThread); m_hSchedulerThread = NULL; CHECK_HR(hr = E_UNEXPECTED); } m_dwThreadID = dwID;done: // Regardless success/failure, we are done using the "thread ready" event. if (m_hThreadReadyEvent) { CloseHandle(m_hThreadReadyEvent); m_hThreadReadyEvent = NULL; } return hr;}
开发者ID:babgvant,项目名称:EVR-Presenter,代码行数:62,
示例15: CHECK_HRHRESULT WpdObjectProperties::DispatchWpdMessage(const PROPERTYKEY& Command, IPortableDeviceValues* pParams, IPortableDeviceValues* pResults){ HRESULT hr = S_OK; if (hr == S_OK) { if (Command.fmtid != WPD_CATEGORY_OBJECT_PROPERTIES) { hr = E_INVALIDARG; CHECK_HR(hr, "This object does not support this command category %ws",CComBSTR(Command.fmtid)); } } if (hr == S_OK) { if (IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_GET_SUPPORTED)) { hr = OnGetSupportedProperties(pParams, pResults); CHECK_HR(hr, "Failed to get supported properties"); } else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_GET)) { hr = OnGetValues(pParams, pResults); if(FAILED(hr)) { CHECK_HR(hr, "Failed to read properties"); } } else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_GET_ALL)) { hr = OnGetAllValues(pParams, pResults); if(FAILED(hr)) { CHECK_HR(hr, "Failed to read all properties"); } } else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_SET)) { hr = OnWriteProperties(pParams, pResults); if(FAILED(hr)) { CHECK_HR(hr, "Failed to write properties"); } } else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_GET_ATTRIBUTES)) { hr = OnGetAttributes(pParams, pResults); if(FAILED(hr)) { CHECK_HR(hr, "Failed to get property attributes"); } } else if(IsEqualPropertyKey(Command, WPD_COMMAND_OBJECT_PROPERTIES_DELETE)) { hr = OnDelete(pParams, pResults); if(FAILED(hr)) { CHECK_HR(hr, "Failed to delete properties"); } } else { hr = E_NOTIMPL; CHECK_HR(hr, "This object does not support this command id %d", Command.pid); } } return hr;}
开发者ID:kcrazy,项目名称:winekit,代码行数:71,
示例16: CHECK_HRHRESULT CLAVOutputPin::DeliverPacket(Packet *pPacket){ HRESULT hr = S_OK; IMediaSample *pSample = nullptr; long nBytes = (long)pPacket->GetDataSize(); if(nBytes == 0) { goto done; } CHECK_HR(hr = GetDeliveryBuffer(&pSample, nullptr, nullptr, 0)); if (m_bPacketAllocator) { ILAVMediaSample *pLAVSample = nullptr; CHECK_HR(hr = pSample->QueryInterface(&pLAVSample)); CHECK_HR(hr = pLAVSample->SetPacket(pPacket)); SafeRelease(&pLAVSample); } else { // Resize buffer if it is too small // This can cause a playback hick-up, we should avoid this if possible by setting a big enough buffer size if(nBytes > pSample->GetSize()) { SafeRelease(&pSample); ALLOCATOR_PROPERTIES props, actual; CHECK_HR(hr = m_pAllocator->GetProperties(&props)); // Give us 2 times the requested size, so we don't resize every time props.cbBuffer = nBytes*2; if(props.cBuffers > 1) { CHECK_HR(hr = __super::DeliverBeginFlush()); CHECK_HR(hr = __super::DeliverEndFlush()); } CHECK_HR(hr = m_pAllocator->Decommit()); CHECK_HR(hr = m_pAllocator->SetProperties(&props, &actual)); CHECK_HR(hr = m_pAllocator->Commit()); CHECK_HR(hr = GetDeliveryBuffer(&pSample, nullptr, nullptr, 0)); } // Fill the sample BYTE* pData = nullptr; if(FAILED(hr = pSample->GetPointer(&pData)) || !pData) goto done; memcpy(pData, pPacket->GetData(), nBytes); } if(pPacket->pmt) { DbgLog((LOG_TRACE, 10, L"::DeliverPacket() - sending new media type to decoder")); pSample->SetMediaType(pPacket->pmt); pPacket->bDiscontinuity = true; CAutoLock cAutoLock(m_pLock); CMediaType pmt = *(pPacket->pmt); m_mts.clear(); m_mts.push_back(pmt); pPacket->pmt = nullptr; SetMediaType(&pmt); } bool fTimeValid = pPacket->rtStart != Packet::INVALID_TIME; // IBitRateInfo m_BitRate.nBytesSinceLastDeliverTime += nBytes; if (fTimeValid) { if (m_BitRate.rtLastDeliverTime == Packet::INVALID_TIME) { m_BitRate.rtLastDeliverTime = pPacket->rtStart; m_BitRate.nBytesSinceLastDeliverTime = 0; } if (m_BitRate.rtLastDeliverTime + 10000000 < pPacket->rtStart) { REFERENCE_TIME rtDiff = pPacket->rtStart - m_BitRate.rtLastDeliverTime; double dSecs, dBits; dSecs = rtDiff / 10000000.0; dBits = 8.0 * m_BitRate.nBytesSinceLastDeliverTime; m_BitRate.nCurrentBitRate = (DWORD)(dBits / dSecs); m_BitRate.rtTotalTimeDelivered += rtDiff; m_BitRate.nTotalBytesDelivered += m_BitRate.nBytesSinceLastDeliverTime; dSecs = m_BitRate.rtTotalTimeDelivered / 10000000.0; dBits = 8.0 * m_BitRate.nTotalBytesDelivered; m_BitRate.nAverageBitRate = (DWORD)(dBits / dSecs); m_BitRate.rtLastDeliverTime = pPacket->rtStart; m_BitRate.nBytesSinceLastDeliverTime = 0; } } CHECK_HR(hr = pSample->SetActualDataLength(nBytes)); CHECK_HR(hr = pSample->SetTime(fTimeValid ? &pPacket->rtStart : nullptr, fTimeValid ? &pPacket->rtStop : nullptr)); CHECK_HR(hr = pSample->SetMediaTime(nullptr, nullptr)); CHECK_HR(hr = pSample->SetDiscontinuity(pPacket->bDiscontinuity)); CHECK_HR(hr = pSample->SetSyncPoint(pPacket->bSyncPoint)); CHECK_HR(hr = pSample->SetPreroll(fTimeValid && pPacket->rtStart < 0)); // Deliver CHECK_HR(hr = Deliver(pSample));done://.........这里部分代码省略.........
开发者ID:Nevcairiel,项目名称:LAVFilters,代码行数:101,
示例17: StartXAudio2void StartXAudio2() { IXAudio2MasteringVoice* pMasterVoice = nullptr; CoInitializeEx(NULL, COINIT_MULTITHREADED); CHECK_HR(XAudio2Create(&gpXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR)); CHECK_HR(gpXAudio2->CreateMasteringVoice(&pMasterVoice));}
开发者ID:nlguillemot,项目名称:spooky,代码行数:6,
示例18: CHECK_HRHRESULT CLAVOutputPin::DeliverPacket(Packet *pPacket){ HRESULT hr = S_OK; IMediaSample *pSample = NULL; long nBytes = (long)pPacket->GetDataSize(); if(nBytes == 0) { goto done; } CHECK_HR(hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0)); if (m_bPacketAllocator) { ILAVMediaSample *pLAVSample = NULL; CHECK_HR(hr = pSample->QueryInterface(&pLAVSample)); CHECK_HR(hr = pLAVSample->SetPacket(pPacket)); SafeRelease(&pLAVSample); } else { // Resize buffer if it is too small // This can cause a playback hick-up, we should avoid this if possible by setting a big enough buffer size if(nBytes > pSample->GetSize()) { SafeRelease(&pSample); ALLOCATOR_PROPERTIES props, actual; CHECK_HR(hr = m_pAllocator->GetProperties(&props)); // Give us 2 times the requested size, so we don't resize every time props.cbBuffer = nBytes*2; if(props.cBuffers > 1) { CHECK_HR(hr = __super::DeliverBeginFlush()); CHECK_HR(hr = __super::DeliverEndFlush()); } CHECK_HR(hr = m_pAllocator->Decommit()); CHECK_HR(hr = m_pAllocator->SetProperties(&props, &actual)); CHECK_HR(hr = m_pAllocator->Commit()); CHECK_HR(hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0)); } // Fill the sample BYTE* pData = NULL; if(FAILED(hr = pSample->GetPointer(&pData)) || !pData) goto done; memcpy(pData, pPacket->GetData(), nBytes); } if(pPacket->pmt) { DbgLog((LOG_TRACE, 10, L"::DeliverPacket() - sending new media type to decoder")); pSample->SetMediaType(pPacket->pmt); pPacket->bDiscontinuity = true; CAutoLock cAutoLock(m_pLock); CMediaType pmt = *(pPacket->pmt); m_mts.clear(); m_mts.push_back(pmt); pPacket->pmt = NULL; SetMediaType(&pmt); } bool fTimeValid = pPacket->rtStart != Packet::INVALID_TIME; CHECK_HR(hr = pSample->SetActualDataLength(nBytes)); CHECK_HR(hr = pSample->SetTime(fTimeValid ? &pPacket->rtStart : NULL, fTimeValid ? &pPacket->rtStop : NULL)); CHECK_HR(hr = pSample->SetMediaTime(NULL, NULL)); CHECK_HR(hr = pSample->SetDiscontinuity(pPacket->bDiscontinuity)); CHECK_HR(hr = pSample->SetSyncPoint(pPacket->bSyncPoint)); CHECK_HR(hr = pSample->SetPreroll(fTimeValid && pPacket->rtStart < 0)); // Deliver CHECK_HR(hr = Deliver(pSample));done: if (!m_bPacketAllocator) SAFE_DELETE(pPacket); SafeRelease(&pSample); return hr;}
开发者ID:cynics,项目名称:LAVFilters,代码行数:75,
示例19: lock// Creates video samples based on a specified media type.HRESULT D3DPresentEngine::CreateVideoSamples(IMFMediaType *pFormat, VideoSampleList& videoSampleQueue){ if (pFormat == NULL) { return MF_E_UNEXPECTED; } HRESULT hr = S_OK; D3DFORMAT d3dFormat = D3DFMT_UNKNOWN; IMFSample *pVideoSample = NULL; AutoLock lock(m_ObjectLock); ReleaseResources(); // Helper object for reading the proposed type. VideoType videoType(pFormat); // Get some information about the video format. hr = videoType.GetFrameDimensions(&m_Width, &m_Height); CHECK_HR(hr, "D3DPresentEngine::CreateVideoSamples VideoType::GetFrameDimensions() failed"); hr = GetAspectRatio(pFormat, m_ArX, m_ArY); if (FAILED(hr)) { m_ArX = m_Width; m_ArY = m_Height; } //hr = videoType.GetFourCC((DWORD*)&d3dFormat); //CHECK_HR(hr, "D3DPresentEngine::CreateVideoSamples VideoType::GetFourCC() failed"); // Morpheus_xx, 2016-08-14: we force a format without alpha channel here, because rendering subtitles with MPC-HC engine expects this format. Actually I can't imagine a video format // that actually delivers alpha channel information. d3dFormat = D3DFMT_X8R8G8B8; for (int i = 0; i < NUM_PRESENTER_BUFFERS; i++) { CComPtr<IDirect3DTexture9> texture; hr = m_pDevice->CreateTexture(m_Width, m_Height, 1, D3DUSAGE_RENDERTARGET, d3dFormat, D3DPOOL_DEFAULT, &texture, NULL); if (FAILED(hr)) { Log("D3DPresentEngine::CreateVideoSamples Could not create texture %d. Error 0x%x", i, hr); break; } CComPtr<IDirect3DSurface9> surface; hr = texture->GetSurfaceLevel(0, &surface); if (FAILED(hr)) { Log("D3DPresentEngine::CreateVideoSamples Could not get surface from texture. Error 0x%x", hr); break; } hr = MFCreateVideoSampleFromSurface(surface, &pVideoSample); if (FAILED(hr)) { Log("D3DPresentEngine::CreateVideoSamples CreateVideoSampleFromSurface failed: 0x%x", hr); break; } // Add it to the list. hr = videoSampleQueue.InsertBack(pVideoSample); if (FAILED(hr)) { SAFE_RELEASE(pVideoSample); ReleaseResources(); return hr; } SAFE_RELEASE(pVideoSample); } return hr;}
开发者ID:MediaPortal,项目名称:MediaPortal-2,代码行数:75,
示例20: CHECK_HRHRESULT FakeContactsServiceContent::GetValue( REFPROPERTYKEY Key, __out IPortableDeviceValues* pStore){ HRESULT hr = S_OK; PropVariantWrapper pvValue; if (IsEqualPropertyKey(Key, WPD_OBJECT_ID)) { // Add WPD_OBJECT_ID pvValue = ObjectID; hr = pStore->SetValue(WPD_OBJECT_ID, &pvValue); CHECK_HR(hr, ("Failed to set WPD_OBJECT_ID")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_NAME)) { // Add WPD_OBJECT_NAME pvValue = Name; hr = pStore->SetValue(WPD_OBJECT_NAME, &pvValue); CHECK_HR(hr, ("Failed to set WPD_OBJECT_NAME")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_PERSISTENT_UNIQUE_ID)) { // Add WPD_OBJECT_PERSISTENT_UNIQUE_ID pvValue = PersistentUniqueID; hr = pStore->SetValue(WPD_OBJECT_PERSISTENT_UNIQUE_ID, &pvValue); CHECK_HR(hr, ("Failed to set WPD_OBJECT_PERSISTENT_UNIQUE_ID")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_PARENT_ID)) { // Add WPD_OBJECT_PARENT_ID pvValue = ParentID; hr = pStore->SetValue(WPD_OBJECT_PARENT_ID, &pvValue); CHECK_HR(hr, ("Failed to set WPD_OBJECT_PARENT_ID")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_FORMAT)) { // Add WPD_OBJECT_FORMAT hr = pStore->SetGuidValue(WPD_OBJECT_FORMAT, Format); CHECK_HR(hr, ("Failed to set WPD_OBJECT_FORMAT")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_CONTENT_TYPE)) { // Add WPD_OBJECT_CONTENT_TYPE hr = pStore->SetGuidValue(WPD_OBJECT_CONTENT_TYPE, ContentType); CHECK_HR(hr, ("Failed to set WPD_OBJECT_CONTENT_TYPE")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_CAN_DELETE)) { // Add WPD_OBJECT_CAN_DELETE hr = pStore->SetBoolValue(WPD_OBJECT_CAN_DELETE, CanDelete); CHECK_HR(hr, ("Failed to set WPD_OBJECT_CAN_DELETE")); } else if (IsEqualPropertyKey(Key, WPD_FUNCTIONAL_OBJECT_CATEGORY)) { // Add WPD_FUNCTIONAL_OBJECT_CATEGORY hr = pStore->SetGuidValue(WPD_FUNCTIONAL_OBJECT_CATEGORY, FunctionalCategory); CHECK_HR(hr, ("Failed to set WPD_FUNCTIONAL_OBJECT_CATEGORY")); } else if (IsEqualPropertyKey(Key, WPD_OBJECT_CONTAINER_FUNCTIONAL_OBJECT_ID)) { // Add WPD_OBJECT_CONTAINER_FUNCTIONAL_OBJECT_ID hr = pStore->SetStringValue(WPD_OBJECT_CONTAINER_FUNCTIONAL_OBJECT_ID, ContainerFunctionalObjectID); CHECK_HR(hr, ("Failed to set WPD_OBJECT_CONTAINER_FUNCTIONAL_OBJECT_ID")); } else if (IsEqualPropertyKey(Key, WPD_SERVICE_VERSION)) { // Add WPD_SERVICE_VERSION hr = pStore->SetStringValue(WPD_SERVICE_VERSION, Version); CHECK_HR(hr, ("Failed to set WPD_SERVICE_VERSION")); } else if (IsEqualPropertyKey(Key, PKEY_Services_ServiceDisplayName)) { pvValue = HumanReadableName; hr = pStore->SetValue(PKEY_Services_ServiceDisplayName, &pvValue); CHECK_HR(hr, ("Failed to set PKEY_Services_ServiceDisplayName")); } else if (IsEqualPropertyKey(Key, PKEY_FullEnumSyncSvc_SyncFormat)) { hr = pStore->SetGuidValue(PKEY_FullEnumSyncSvc_SyncFormat, PreferredSyncFormat); CHECK_HR(hr, ("Failed to set PKEY_FullEnumSyncSvc_SyncFormat")); } else if (IsEqualPropertyKey(Key, PKEY_Services_ServiceIcon)) { hr = GetIconData(pStore); CHECK_HR(hr, "Failed to set PKEY_Services_ServiceIcon"); } else if (IsEqualPropertyKey(Key, PKEY_FullEnumSyncSvc_VersionProps)) { hr = GetVICData(pStore); CHECK_HR(hr, "Failed to set PKEY_FullEnumSyncSvc_VersionProps"); } else { hr = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); CHECK_HR(hr, "Property {%ws}.%d is not supported", CComBSTR(Key.fmtid), Key.pid); } return hr;//.........这里部分代码省略.........
开发者ID:kcrazy,项目名称:winekit,代码行数:101,
示例21: testerHRESULT CPyCOMTest::TestMyInterface( IUnknown *unktester){ if (!unktester) return E_POINTER; CComQIPtr<IPyCOMTest, &IID_IPyCOMTest> tester(unktester); if (!tester) return E_NOINTERFACE; HRESULT hr; // TEST QsBoolean i = 0, o = 0; CComVariant var(99); CHECK_HR(tester->Test( var, i, &o)); CHECK_TRUE( o ); i = 1, o = 1; CHECK_HR(tester->Test( var, i, &o)); CHECK_TRUE( !o ); // TEST2 QsAttribute ret_attr; QsAttribute attr = Attr1; CHECK_HR(tester->Test2( attr, &ret_attr)); CHECK_TRUE( attr == ret_attr ); attr = Attr3; CHECK_HR(tester->Test2( attr, &ret_attr)); CHECK_TRUE( attr == ret_attr ); // TEST6 QsAttributeWide ret_wideAttr; QsAttributeWide wideAttr; wideAttr = WideAttr1; CHECK_HR(tester->Test6( wideAttr, &ret_wideAttr)); CHECK_TRUE( wideAttr == ret_wideAttr ); wideAttr = WideAttr2; CHECK_HR(tester->Test6( wideAttr, &ret_wideAttr)); CHECK_TRUE( wideAttr == ret_wideAttr ); wideAttr = WideAttr3; CHECK_HR(tester->Test6( wideAttr, &ret_wideAttr)); CHECK_TRUE( wideAttr == ret_wideAttr ); wideAttr = WideAttr4; CHECK_HR(tester->Test6( wideAttr, &ret_wideAttr)); CHECK_TRUE( wideAttr == ret_wideAttr ); wideAttr = WideAttr5; CHECK_HR(tester->Test6( wideAttr, &ret_wideAttr)); CHECK_TRUE( wideAttr == ret_wideAttr ); // TEST5 TestAttributes1 tattr = TestAttr1; CHECK_HR(tester->Test5( &tattr )); CHECK_TRUE( tattr == TestAttr1_1 ); tattr = TestAttr1_1; CHECK_HR(tester->Test5( &tattr )); CHECK_TRUE( tattr == TestAttr1 ); // STRINGS CComBSTR instr("Foo"); CComBSTR outstr; CHECK_HR(tester->DoubleString(instr, &outstr)); CHECK_TRUE(outstr == L"FooFoo"); instr = L"Foo"; CHECK_HR(tester->TestByRefString(&instr)); CHECK_TRUE(instr == L"FooFoo"); // Arrays int result; SAFEARRAY *array; CHECK_HR(MakeFillIntArray(&array, 5, VT_INT)); CHECK_HR(tester->CheckVariantSafeArray(&array, &result)); CHECK_TRUE(result==1); CHECK_HR(tester->SetIntSafeArray(array, &result)); SafeArrayDestroy(array); CHECK_HR(MakeFillIntArray(&array, 5, VT_I8)); CHECK_HR(tester->CheckVariantSafeArray(&array, &result)); CHECK_TRUE(result==1); CHECK_HR(tester->SetLongLongSafeArray(array, &result)); SafeArrayDestroy(array); CHECK_HR(MakeFillIntArray(&array, 5, VT_UI8)); CHECK_HR(tester->CheckVariantSafeArray(&array, &result)); CHECK_TRUE(result==1); CHECK_HR(tester->SetULongLongSafeArray(array, &result)); SafeArrayDestroy(array); long lresult; CHECK_HR(tester->put_LongProp(4)); CHECK_HR(tester->get_LongProp(&lresult)); CHECK_TRUE(lresult==4); CHECK_HR(tester->put_LongProp(-4)); CHECK_HR(tester->get_LongProp(&lresult));//.........这里部分代码省略.........
开发者ID:Dechy,项目名称:pywin32,代码行数:101,
注:本文中的CHECK_HR函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CHECK_HRESULT函数代码示例 C++ CHECK_HANDLE函数代码示例 |