SYSVAD - IID_IPortClsStreamResourceManager2 failed

  • Thread starter Thread starter NathanMAd
  • Start date Start date
N

NathanMAd

Guest
Please can you anyone clarify purpose of below code. As i am new to driver development, counot get more clarification.

I can see these code after InstallEndpointFilters only for Render. Why not used for Capture?

IID_IPortClsStreamResourceManager2 - failed what could be the reason?

===========================================================================================================================
if (unknownWave) // IID_IPortClsEtwHelper and IID_IPortClsRuntimePower interfaces are only exposed on the WaveRT port.
{
ntStatus = unknownWave->QueryInterface (IID_IPortClsEtwHelper, (PVOID *)&pPortClsEtwHelper);
if (NT_SUCCESS(ntStatus))
{
_pAdapterCommon->SetEtwHelper(pPortClsEtwHelper);
ASSERT(pPortClsEtwHelper != NULL);
pPortClsEtwHelper->Release();
}

#ifdef _USE_IPortClsRuntimePower
// Let's get the runtime power interface on PortCls.
ntStatus = unknownWave->QueryInterface(IID_IPortClsRuntimePower, (PVOID *)&pPortClsRuntimePower);
if (NT_SUCCESS(ntStatus))
{
// This interface would typically be stashed away for later use. Instead,
// let's just send an empty control with GUID_NULL.
NTSTATUS ntStatusTest =
pPortClsRuntimePower->SendPowerControl
(
_pDeviceObject,
&GUID_NULL,
NULL,
0,
NULL,
0,
NULL
);

if (NT_SUCCESS(ntStatusTest) || STATUS_NOT_IMPLEMENTED == ntStatusTest || STATUS_NOT_SUPPORTED == ntStatusTest)
{
ntStatus = pPortClsRuntimePower->RegisterPowerControlCallback(_pDeviceObject, &PowerControlCallback, NULL);
if (NT_SUCCESS(ntStatus))
{
ntStatus = pPortClsRuntimePower->UnregisterPowerControlCallback(_pDeviceObject);
}
}
else
{
ntStatus = ntStatusTest;
}

pPortClsRuntimePower->Release();
}
#endif // _USE_IPortClsRuntimePower

//
// Test: add and remove current thread as streaming audio resource.
// In a real driver you should only add interrupts and driver-owned threads
// (i.e., do NOT add the current thread as streaming resource).
//
// testing IPortClsStreamResourceManager:
ntStatus = unknownWave->QueryInterface(IID_IPortClsStreamResourceManager, (PVOID *)&pPortClsResMgr);
if (NT_SUCCESS(ntStatus))
{
PCSTREAMRESOURCE_DESCRIPTOR res;
PCSTREAMRESOURCE hRes = NULL;
PDEVICE_OBJECT pdo = NULL;

PcGetPhysicalDeviceObject(_pDeviceObject, &pdo);
PCSTREAMRESOURCE_DESCRIPTOR_INIT(&res);
res.Pdo = pdo;
res.Type = ePcStreamResourceThread;
res.Resource.Thread = PsGetCurrentThread();

NTSTATUS ntStatusTest = pPortClsResMgr->AddStreamResource(NULL, &res, &hRes);
if (NT_SUCCESS(ntStatusTest))
{
pPortClsResMgr->RemoveStreamResource(hRes);
hRes = NULL;
}

pPortClsResMgr->Release();
pPortClsResMgr = NULL;
}

// testing IPortClsStreamResourceManager2:
ntStatus = unknownWave->QueryInterface(IID_IPortClsStreamResourceManager2, (PVOID *)&pPortClsResMgr2);
if (NT_SUCCESS(ntStatus))
{
PCSTREAMRESOURCE_DESCRIPTOR res;
PCSTREAMRESOURCE hRes = NULL;
PDEVICE_OBJECT pdo = NULL;

PcGetPhysicalDeviceObject(_pDeviceObject, &pdo);
PCSTREAMRESOURCE_DESCRIPTOR_INIT(&res);
res.Pdo = pdo;
res.Type = ePcStreamResourceThread;
res.Resource.Thread = PsGetCurrentThread();

NTSTATUS ntStatusTest = pPortClsResMgr2->AddStreamResource2(pdo, NULL, &res, &hRes);
if (NT_SUCCESS(ntStatusTest))
{
pPortClsResMgr2->RemoveStreamResource(hRes);
hRes = NULL;
}

pPortClsResMgr2->Release();
pPortClsResMgr2 = NULL;
}
}
===========================================================================================================================

Continue reading...
 
Back
Top