ErrorCode ComProxyStatelessServiceFactory::CreateInstance( wstring const & serviceType, wstring const & serviceName, vector<byte> const & initializationData, Guid const & partitionId, const FABRIC_INSTANCE_ID instanceId, __out IStatelessServiceInstancePtr & ) { HRESULT hr; ComPointer<IFabricStatelessServiceInstance> comService; hr = comImpl_->CreateInstance( serviceType.c_str(), serviceName.c_str(), (ULONG)initializationData.size(), initializationData.data(), partitionId.AsGUID(), instanceId, comService.InitializationAddress()); if(SUCCEEDED(hr)) { ASSERT_IFNOT(comService, "Instance create returned a null service."); // TODO: create proxy for the stateless service // service = make_unique<ComProxyStatelessService>(comService); // } return ErrorCode::FromHResult(hr); }
HRESULT ComWinFabStoreLayoutSpecification::FabricCreateWinFabStoreLayoutSpecification( /* [in] */ REFIID riid, /* [retval][out] */ void **fabricLayoutSpecification) { ComPointer<ComWinFabStoreLayoutSpecification> comWinFabStoreLayoutSpecificationCPtr = make_com<ComWinFabStoreLayoutSpecification>(); return comWinFabStoreLayoutSpecificationCPtr->QueryInterface(riid, (LPVOID*)fabricLayoutSpecification); }
HRESULT STDMETHODCALLTYPE ComTestStoreService::BeginUpdateEpoch( /* [in] */ FABRIC_EPOCH const * epoch, /* [in] */ FABRIC_SEQUENCE_NUMBER previousEpochLastSequenceNumber, /* [in] */ IFabricAsyncOperationCallback *callback, /* [retval][out] */ IFabricAsyncOperationContext **context) { if (epoch == NULL || callback == NULL || context == NULL) { return E_POINTER; } WAIT_FOR_SIGNAL_RESET(StateProviderBeginUpdateEpochBlock) CheckForReportFaultsAndDelays(testStoreService_.GetPartition(), ApiFaultHelper::Provider, L"BeginUpdateEpoch"); if (testStoreService_.ShouldFailOn(ApiFaultHelper::Provider, L"BeginUpdateEpoch")) return E_FAIL; HRESULT hr; if (testStoreService_.ShouldFailOn(ApiFaultHelper::Provider, L"EndUpdateEpoch")) { hr = E_FAIL; } else { hr = testStoreService_.UpdateEpoch(epoch, previousEpochLastSequenceNumber); } ComPointer<ComCompletedAsyncOperationContext> operation = make_com<ComCompletedAsyncOperationContext>(); hr = operation->Initialize(hr, root_, callback); TestSession::FailTestIf(FAILED(hr), "operation->Initialize should not fail"); return ComAsyncOperationContext::StartAndDetach<ComCompletedAsyncOperationContext>(std::move(operation), context); }
void VideoRendererEVR::repaintCurrentFrame(QWidget *target, const QRect &rect) { // repaint the video ComPointer<IMFVideoDisplayControl> filterControl = getService<IMFVideoDisplayControl>(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); // All failed results can be safely ignored filterControl->RepaintVideo(); }
void EngineService::AcceptVisitor( JobFiber& /*fiber*/, const ConfigurationBroadcastVisitor ) { enum : UINT32 { XAudio2CreateFlags = (ETIsDebugModeEnabled() ? XAUDIO2_DEBUG_ENGINE : 0) }; ComPointer<IXAudio2> audio; _log( MessageSeverity::Message, "Creating XAudio2 instance." ET_UTF8_NEWLINE_LITERAL ); if( FAILED( XAudio2Create( audio.GetInterfacePointer(), XAudio2CreateFlags, XAUDIO2_DEFAULT_PROCESSOR ) ) ) { _log( MessageSeverity::Error, "Unable to create XAudio2 instance!" ET_UTF8_NEWLINE_LITERAL ); return; } if( FAILED( audio->RegisterForCallbacks( this ) ) ) { _log( MessageSeverity::Error, "Unable to register XAudio2 device callbacks!" ET_UTF8_NEWLINE_LITERAL ); return; } if( FAILED( audio->StartEngine() ) ) { _log( MessageSeverity::Error, "Unable to start XAudio2 engine!" ET_UTF8_NEWLINE_LITERAL ); return; } _log( MessageSeverity::Message, "Created XAudio2 instance." ET_UTF8_NEWLINE_LITERAL ); // Commit changes to the service. _audio = eastl::move( audio ); }
HRESULT ComTestStoreService::BeginClose( /* [in] */ IFabricAsyncOperationCallback *callback, /* [retval][out] */ IFabricAsyncOperationContext **context) { if (context == NULL) { return E_POINTER; } CheckForReportFaultsAndDelays(testStoreService_.GetPartition(), ApiFaultHelper::Service, L"BeginClose"); HRESULT beginResult = testStoreService_.ShouldFailOn(ApiFaultHelper::Service, L"BeginClose") ? E_FAIL : S_OK; HRESULT endResult = testStoreService_.ShouldFailOn(ApiFaultHelper::Service, L"EndClose") ? E_FAIL : S_OK; if(!isClosedCalled_) { isClosedCalled_ = true; ErrorCode error = testStoreService_.OnClose(); TestSession::FailTestIfNot(error.IsSuccess(), "testStoreService_.OnClose failed with error {0}", error); } if(FAILED(beginResult)) return E_FAIL; ComPointer<ComCompletedAsyncOperationContext> operation = make_com<ComCompletedAsyncOperationContext>(); HRESULT hr = operation->Initialize(endResult, root_, callback); TestSession::FailTestIf(FAILED(hr), "operation->Initialize should not fail"); return ComAsyncOperationContext::StartAndDetach<ComCompletedAsyncOperationContext>(std::move(operation), context); }
ErrorCode ComProxyXmlLiteWriter::Create( __in std::wstring const & outputName, __out ComProxyXmlLiteWriterUPtr & xmlLiteWriter, bool writeByteOrderMark, bool indent) { #if !defined(PLATFORM_UNIX) ComPointer<IStream> xmlFileStream; auto error = ComXmlFileStream::Open(outputName, true, xmlFileStream); if (!error.IsSuccess()) { return error; } ComPointer<IUnknown> comPointer; HRESULT hr = xmlFileStream->QueryInterface(IID_IUnknown, reinterpret_cast<void**>(comPointer.InitializationAddress())); if (!SUCCEEDED(hr)) { return ErrorCode::FromHResult(hr); } error = ComProxyXmlLiteWriter::Create(comPointer, xmlLiteWriter, writeByteOrderMark, indent); if (!error.IsSuccess()) { return error; } #else ComPointer<IXmlWriter> writer; auto hr = ::CreateXmlWriter( ::IID_IXmlWriter, outputName.c_str(), writer.VoidInitializationAddress(), NULL); auto error = ToErrorCode(hr, L"CreateXmlWriter", L"", true, false); if (!error.IsSuccess()) { return error; } xmlLiteWriter = move(make_unique<ComProxyXmlLiteWriter>(writer)); #endif return ErrorCode(ErrorCodeValue::Success); }
HRESULT ComTestStoreService::BeginChangeRole( /* [in] */ FABRIC_REPLICA_ROLE newRole, /* [in] */ IFabricAsyncOperationCallback *callback, /* [retval][out] */ IFabricAsyncOperationContext **context) { if (callback == NULL || context == NULL) { return E_POINTER; } WAIT_FOR_SIGNAL_RESET(ServiceBeginChangeRoleBlock) CheckForReportFaultsAndDelays(testStoreService_.GetPartition(), ApiFaultHelper::Service, L"BeginChangeRole"); if (testStoreService_.ShouldFailOn(ApiFaultHelper::Service, L"BeginChangeRole")) return E_FAIL; ComPointer<ComCompletedAsyncOperationContext> operation = make_com<ComCompletedAsyncOperationContext>(); HRESULT hr = E_FAIL; if (testStoreService_.ShouldFailOn(ApiFaultHelper::Service, L"EndChangeRole")) { hr = operation->Initialize(E_FAIL, ApiFaultHelper::Get().GetAsyncCompleteDelayTime(), root_, callback); } else { ErrorCode error = testStoreService_.OnChangeRole(newRole); TestSession::FailTestIfNot(error.IsSuccess(), "testStoreService_.OnChangeRole failed with error {0}", error); hr = operation->Initialize(root_, callback); } TestSession::FailTestIf(FAILED(hr), "operation->Initialize should not fail"); return ComAsyncOperationContext::StartAndDetach<ComCompletedAsyncOperationContext>(std::move(operation), context); }
static HRESULT End(__in IFabricAsyncOperationContext * context, __out IFabricInfrastructureTaskQueryResult ** result) { if ((context == NULL) || (result == NULL)) { return E_POINTER; } ComPointer<ComQueryInfrastructureTaskAsyncOperation> thisCPtr(context, CLSID_ComQueryInfrastructureTaskAsyncOperation); auto hr = thisCPtr->Result; if (SUCCEEDED(hr)) { vector<InfrastructureTaskQueryResult> resultList; auto error = thisCPtr->nativeResult_.MoveList(resultList); if (error.IsSuccess()) { ComPointer<IFabricInfrastructureTaskQueryResult> cPtr = make_com<ComQueryResult, IFabricInfrastructureTaskQueryResult>(move(resultList)); hr = cPtr->QueryInterface(IID_IFabricInfrastructureTaskQueryResult, reinterpret_cast<void**>(result)); } else { hr = error.ToHResult(); } } return hr; }
QSize VideoRendererEVR::videoSize() const { SIZE nativeSize; SIZE aspectRatioSize; ComPointer<IMFVideoDisplayControl> filterControl = getService<IMFVideoDisplayControl>(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); filterControl->GetNativeVideoSize(&nativeSize, &aspectRatioSize); return QSize(nativeSize.cx, nativeSize.cy); }
template <typename T> ComPointer<T> getService(const Filter &filter, REFGUID guidService, REFIID riid) { //normally we should use IID_IMFGetService but this introduces another dependency //so here we simply define our own IId with the same value ComPointer<T> ret; ComPointer<IMFGetService> getService(filter, IID_IMFGetService); if (getService) { getService->GetService(guidService, riid, reinterpret_cast<void**>(ret.pparam())); } return ret; }
VideoRendererEVR::VideoRendererEVR(QWidget *target) : m_target(target) { m_filter = Filter(CLSID_EnhancedVideoRenderer, IID_IBaseFilter); if (!m_filter) { return; } ComPointer<IMFVideoDisplayControl> filterControl = getService<IMFVideoDisplayControl>(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); filterControl->SetVideoWindow(reinterpret_cast<HWND>(target->winId())); filterControl->SetAspectRatioMode(MFVideoARMode_None); // We're in control of the size }
ComPointer<IFabricStateProvider2Factory> TestComStateProvider2Factory::Create( __in Data::StateManager::IStateProvider2Factory & factory, __in KAllocator & allocator) { TestComStateProvider2Factory * pointer = _new(TEST_COM_STATE_PROVIDER_FACTORY_TAG, allocator) TestComStateProvider2Factory(factory); ASSERT_IF(pointer == nullptr, "OOM while allocating TestComStateProvider2Factory"); ASSERT_IFNOT(NT_SUCCESS(pointer->Status()), "Unsuccessful initialization while allocating TestComStateProvider2Factory {0}", pointer->Status()); ComPointer<IFabricStateProvider2Factory> result; result.SetAndAddRef(pointer); return result; }
ErrorCode ComProxyFabricTransportCallbackMessageHandler::HandleOneWay( wstring const & , MessageUPtr && message) { ComPointer<IFabricTransportMessage> msgCPointer = make_com<ComFabricTransportMessage, IFabricTransportMessage>(move(message)); auto hr = comImpl_->HandleOneWay( msgCPointer.GetRawPointer()); return ErrorCode::FromHResult(hr); }
HRESULT STDMETHODCALLTYPE ComServiceEndpointsVersion::Compare( __in /* [in] */ IFabricServiceEndpointsVersion * other, __out /* [out, retval] */ LONG * result) { if (other == NULL || result == NULL) { return E_POINTER; } ComPointer<ComServiceEndpointsVersion> comPtr; auto hr = other->QueryInterface(CLSID_ComServiceEndpointsVersion, comPtr.VoidInitializationAddress()); if (FAILED(hr)) { return hr; } *result = impl_->Compare(*(comPtr->get_Impl().get())); return S_OK; }
HRESULT ComTestStoreService::EndChangeRole( /* [in] */ IFabricAsyncOperationContext *context, /* [retval][out] */ IFabricStringResult **serviceEndpoint) { if (context == NULL || serviceEndpoint == NULL) { return E_POINTER; } CheckForReportFaultsAndDelays(testStoreService_.GetPartition(), ApiFaultHelper::Service, L"endchangerole"); HRESULT hr = ComCompletedAsyncOperationContext::End(context); if (FAILED(hr)) return hr; ComPointer<IFabricStringResult> stringResult = make_com<ComStringResult,IFabricStringResult>(testStoreService_.ServiceLocation); *serviceEndpoint = stringResult.DetachNoRelease(); return S_OK; }
HRESULT ComReplicator::OpenOperation::End( __in IFabricAsyncOperationContext * context, __out IFabricStringResult **replicationEndpoint) { if (replicationEndpoint == NULL) { return E_POINTER; } *replicationEndpoint = NULL; ComPointer<ComReplicator::OpenOperation> asyncOperation( context, CLSID_ComReplicator_OpenOperation); HRESULT hr = asyncOperation->ComReplicator::BaseOperation::End(); if (FAILED(hr)) { return hr; } ComPointer<IFabricStringResult> stringResult = make_com<ComStringResult, IFabricStringResult>(asyncOperation->replicationEndpoint_); *replicationEndpoint = stringResult.DetachNoRelease(); return S_OK; }
HRESULT ComStatefulServiceFactory::CreateReplica( /* [in] */ LPCWSTR serviceType, /* [in] */ FABRIC_URI serviceName, /* [in] */ ULONG initializationDataLength, /* [size_is][in] */ const byte *initializationData, /* [in] */ FABRIC_PARTITION_ID partitionId, /* [in] */ FABRIC_REPLICA_ID replicaId, /* [retval][out] */ IFabricStatefulServiceReplica **serviceReplica) { if (serviceType == NULL || serviceName == NULL || serviceReplica == NULL) { return ComUtility::OnPublicApiReturn(E_POINTER); } wstring parsedServiceType; auto hr = StringUtility::LpcwstrToWstring(serviceType, false, parsedServiceType); if (FAILED(hr)) { return ComUtility::OnPublicApiReturn(hr); } NamingUri parsedServiceName; hr = NamingUri::TryParse(serviceName, "serviceName", parsedServiceName).ToHResult(); if (FAILED(hr)) { return ComUtility::OnPublicApiReturn(hr); } std::vector<byte> initializationDataBytes; if (initializationDataLength > 0) { initializationDataBytes.insert( initializationDataBytes.end(), initializationData, initializationData + initializationDataLength); } IStatefulServiceReplicaPtr serviceReplicaImpl; auto error = impl_->CreateReplica( parsedServiceType, parsedServiceName, initializationDataBytes, Guid(partitionId), replicaId, serviceReplicaImpl); if (!error.IsSuccess()) { return ComUtility::OnPublicApiReturn(error.ToHResult()); } ComPointer<ComStatefulServiceReplica> result = make_com<ComStatefulServiceReplica>(serviceReplicaImpl); return result->QueryInterface(IID_IFabricStatefulServiceReplica, reinterpret_cast<void**>(serviceReplica)); }
ErrorCode ComProxyXmlLiteWriter::WriteNode(ComPointer<IXmlReader> const& reader, bool writeDefaultAttributes) { HRESULT hr = writer_->WriteNode(reader.GetRawPointer(), writeDefaultAttributes); // The ToErrorCode method below has an option to accept S_FALSE as a success HRESULT value. This parameter must be set to true, or else // this method returns an error. // While XMLWriter normally returns S_OK as a success value, WriteNode does not. return ToErrorCode(hr, L"WriteNode", true, true); }
VideoRendererEVR::VideoRendererEVR(QWidget *target) : m_target(target) { if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) return; m_filter = Filter(CLSID_EnhancedVideoRenderer, IID_IBaseFilter); if (!m_filter) { return; } ComPointer<IMFVideoDisplayControl> filterControl = getService<IMFVideoDisplayControl>(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); if (!filterControl || FAILED(filterControl->SetVideoWindow(reinterpret_cast<HWND>(target->winId()))) || FAILED(filterControl->SetAspectRatioMode(MFVideoARMode_None)) || // We're in control of the size !getService<IMFVideoMixerControl>(m_filter, MR_VIDEO_MIXER_SERVICE, IID_IMFVideoMixerControl) || !getService<IMFVideoProcessor>(m_filter, MR_VIDEO_MIXER_SERVICE, IID_IMFVideoProcessor)) { m_filter = Filter(); //will release the interface } }
ErrorCode ComProxyXmlLiteWriter::SetOutput(wstring const & outputName, ComPointer<IUnknown> const & output) { auto hr = writer_->SetOutput(output.GetRawPointer()); auto error = ToErrorCode(hr, L"SetOutput", outputName, true, false); if (error.IsSuccess()) { outputName_ = outputName; } return error; }
int main() { IFabricRuntime* pRuntime; HRESULT hr = FabricCreateRuntime(IID_IFabricRuntime, (void**)(&pRuntime)); auto serviceFactory = make_com<ResourceMonitorServiceFactory, IFabricStatelessServiceFactory>(pRuntime); auto &ipc = (dynamic_cast<ComFabricRuntime*>(pRuntime))->Runtime->Host.Client; ComPointer<IFabricRuntime> spFabricRuntime; spFabricRuntime.SetNoAddRef(pRuntime); serviceFactory.GetRawPointer(); hr = spFabricRuntime->RegisterStatelessServiceFactory(ResourceMonitorTypeName, serviceFactory.GetRawPointer()); UNREFERENCED_PARAMETER(hr); UNREFERENCED_PARAMETER(ipc); while (1) { Sleep(10000); } }
QList<InputPin> BackendNode::pins(const Filter &filter, PIN_DIRECTION wantedDirection) { QList<InputPin> ret; if (filter) { ComPointer<IEnumPins> enumPin; HRESULT hr = filter->EnumPins(enumPin.pparam()); Q_UNUSED(hr); Q_ASSERT( SUCCEEDED(hr)); InputPin pin; while (enumPin->Next(1, pin.pparam(), 0) == S_OK) { PIN_DIRECTION dir; hr = pin->QueryDirection(&dir); Q_ASSERT( SUCCEEDED(hr)); if (dir == wantedDirection) { ret.append(pin); } } } return ret; }
HRESULT ComProxyStatefulService::ChangeRoleAsyncOperation::EndComAsyncOperation(IFabricAsyncOperationContext * context) { HRESULT hr; ComPointer<IFabricStringResult> stringResult; hr = owner_.service_->EndChangeRole(context, stringResult.InitializationAddress()); if(SUCCEEDED(hr)) { if (stringResult.GetRawPointer() != nullptr) { hr = StringUtility::LpcwstrToWstring(stringResult->get_String(), true /*acceptNull*/, 0 /*minSize*/, ParameterValidator::MaxEndpointSize, serviceLocation_); } else { serviceLocation_ = L""; } } return hr; }
HRESULT ComInfrastructureServiceAgentFactory::CreateFabricInfrastructureServiceAgent( /* [in] */ __RPC__in REFIID riid, /* [out, retval] */ __RPC__deref_out_opt void ** fabricInfrastructureServiceAgent) { if (riid != IID_IFabricInfrastructureServiceAgent) { return ComUtility::OnPublicApiReturn(E_NOINTERFACE); } if (fabricInfrastructureServiceAgent == NULL) { return ComUtility::OnPublicApiReturn(E_POINTER); } IInfrastructureServiceAgentPtr agentPtr; ErrorCode error = impl_->CreateInfrastructureServiceAgent(agentPtr); if (!error.IsSuccess()) { return ComUtility::OnPublicApiReturn(error.ToHResult()); } ComPointer<IFabricInfrastructureServiceAgent> agentCPtr = WrapperFactory::create_com_wrapper(agentPtr); *fabricInfrastructureServiceAgent = agentCPtr.DetachNoRelease(); return ComUtility::OnPublicApiReturn(S_OK); }
void ComTestStoreService::CheckForReportFaultsAndDelays(ComPointer<IFabricStatefulServicePartition> partition, ApiFaultHelper::ComponentName compName, std::wstring operationName) { if (testStoreService_.ShouldFailOn(compName, operationName, ApiFaultHelper::ReportFaultPermanent)) { if (partition.GetRawPointer() != nullptr) { partition->ReportFault(FABRIC_FAULT_TYPE::FABRIC_FAULT_TYPE_PERMANENT); } }; if (testStoreService_.ShouldFailOn(compName, operationName, ApiFaultHelper::ReportFaultTransient)) { if (partition.GetRawPointer() != nullptr) { partition->ReportFault(FABRIC_FAULT_TYPE::FABRIC_FAULT_TYPE_TRANSIENT); } }; if (testStoreService_.ShouldFailOn(compName, operationName, ApiFaultHelper::Delay)) { ::Sleep(static_cast<DWORD>(ApiFaultHelper::Get().GetApiDelayInterval().TotalMilliseconds())); } }
QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(Phonon::ObjectDescriptionType type, int index) const { QMutexLocker locker(&m_directShowMutex); QHash<QByteArray, QVariant> ret; switch (type) { case Phonon::AudioOutputDeviceType: { #ifdef Q_OS_WINCE ret["name"] = QLatin1String("default audio device"); #else const AudioMoniker &mon = m_audioOutputs[index]; LPOLESTR str = 0; HRESULT hr = mon->GetDisplayName(0,0, &str); if (SUCCEEDED(hr)) { QString name = QString::fromUtf16((const unsigned short*) str); ComPointer<IMalloc> alloc; ::CoGetMalloc(1, alloc.pparam()); alloc->Free(str); ret["name"] = name.mid(name.indexOf('\\') + 1); } #endif } break; #ifndef QT_NO_PHONON_EFFECT case Phonon::EffectType: { WCHAR name[80]; // 80 is clearly stated in the MSDN doc HRESULT hr = ::DMOGetName(m_audioEffects[index], name); if (SUCCEEDED(hr)) { ret["name"] = QString::fromUtf16((const unsigned short*) name); } } break; #endif //QT_NO_PHONON_EFFECT default: break; } return ret; }
void VideoRendererEVR::notifyResize(const QSize &size, Phonon::VideoWidget::AspectRatio aspectRatio, Phonon::VideoWidget::ScaleMode scaleMode) { if (!isActive()) { RECT dummyRect = { 0, 0, 0, 0}; ComPointer<IMFVideoDisplayControl> filterControl = getService<IMFVideoDisplayControl>(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); filterControl->SetVideoPosition(0, &dummyRect); return; } const QSize vsize = videoSize(); internalNotifyResize(size, vsize, aspectRatio, scaleMode); RECT dstRectWin = { 0, 0, size.width(), size.height()}; // Resize the Stream output rect instead of the destination rect. // Hacky workaround for flicker in the areas outside of the destination rect // This way these areas don't exist MFVideoNormalizedRect streamOutputRect = { float(m_dstX) / float(size.width()), float(m_dstY) / float(size.height()), float(m_dstWidth + m_dstX) / float(size.width()), float(m_dstHeight + m_dstY) / float(size.height())}; ComPointer<IMFVideoMixerControl> filterMixer = getService<IMFVideoMixerControl>(m_filter, MR_VIDEO_MIXER_SERVICE, IID_IMFVideoMixerControl); ComPointer<IMFVideoDisplayControl> filterControl = getService<IMFVideoDisplayControl>(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); filterMixer->SetStreamOutputRect(0, &streamOutputRect); filterControl->SetVideoPosition(0, &dstRectWin); }
//The test does not recover from data loss HRESULT ComTestStoreService::BeginOnDataLoss( /* [in] */ IFabricAsyncOperationCallback *callback, /* [retval][out] */ IFabricAsyncOperationContext **context) { if (context == NULL) { return E_POINTER; } CheckForReportFaultsAndDelays(testStoreService_.GetPartition(), ApiFaultHelper::Provider, L"BeginOnDataLoss"); if (testStoreService_.ShouldFailOn(ApiFaultHelper::Provider, L"BeginOnDataLoss")) return E_FAIL; if (testStoreService_.ShouldFailOn(ApiFaultHelper::Provider, L"EndOnDataLoss")) { ComPointer<ComCompletedAsyncOperationContext> operation = make_com<ComCompletedAsyncOperationContext>(); HRESULT hr = operation->Initialize(E_FAIL, ApiFaultHelper::Get().GetAsyncCompleteDelayTime(), root_, callback); TestSession::FailTestIf(FAILED(hr), "operation->Initialize should not fail"); return ComAsyncOperationContext::StartAndDetach<ComCompletedAsyncOperationContext>(std::move(operation), context); } else { return testStoreService_.BeginOnDataLoss(callback, context); } }
QImage VideoRendererEVR::snapshot() const { // This will always capture black areas where no video is drawn, if any are present. // Due to the hack in notifyResize() ComPointer<IMFVideoDisplayControl> filterControl = getService<IMFVideoDisplayControl>(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl); if (filterControl) { BITMAPINFOHEADER bmi; BYTE *buffer = 0; DWORD bufferSize; LONGLONG timeStamp; bmi.biSize = sizeof(BITMAPINFOHEADER); HRESULT hr = filterControl->GetCurrentImage(&bmi, &buffer, &bufferSize, &timeStamp); if (SUCCEEDED(hr)) { const int w = qAbs(bmi.biWidth), h = qAbs(bmi.biHeight); // Create image and copy data into image. QImage ret(w, h, QImage::Format_RGB32); if (!ret.isNull()) { uchar *data = buffer; const int bytes_per_line = w * sizeof(QRgb); for (int y = h - 1; y >= 0; --y) { qMemCopy(ret.scanLine(y), //destination data, //source bytes_per_line); data += bytes_per_line; } } ::CoTaskMemFree(buffer); return ret; } } return QImage(); }