📄 filter.cpp
字号:
// commit a new set of BDA topology changes.
//
Status = BdaCommitChanges( pIrp);
return Status;
}
/*
** GetChangeState() method of the CFilter class
**
** Returns the current BDA change state.
**
*/
NTSTATUS
CFilter::GetChangeState(
IN PIRP pIrp,
IN PKSMETHOD pKSMethod,
OUT PULONG pulChangeState
)
{
NTSTATUS Status = STATUS_SUCCESS;
CFilter * pFilter;
BDA_CHANGE_STATE topologyChangeState;
ASSERT( pIrp);
ASSERT( pKSMethod);
// pulChangeState needs to be verified because minData is zero
// in the KSMETHOD_ITEM definition in bdamedia.h
if (!pulChangeState)
{
pIrp->IoStatus.Information = sizeof(ULONG);
return STATUS_MORE_ENTRIES;
}
// Obtain a "this" pointer to the filter object.
//
// Because the property dispatch table calls the CFilter::GetChangeState() method
// directly, the method must retrieve a pointer to the underlying filter object.
//
pFilter = reinterpret_cast<CFilter *>(KsGetFilterFromIrp(pIrp)->Context);
ASSERT( pFilter);
// Call the BDA support library to
// verify for any pending BDA topology changes.
//
Status = BdaGetChangeState( pIrp, &topologyChangeState);
if (NT_SUCCESS( Status))
{
// Figure out if there are changes pending.
//
if ( (topologyChangeState == BDA_CHANGES_PENDING)
|| (pFilter->m_BdaChangeState == BDA_CHANGES_PENDING)
)
{
*pulChangeState = BDA_CHANGES_PENDING;
}
else
{
*pulChangeState = BDA_CHANGES_COMPLETE;
}
}
return Status;
}
/*
** GetMedium() method of the CFilter class
**
** Identifies specific connection on a communication bus
**
*/
NTSTATUS
CFilter::GetMedium(
IN PIRP pIrp,
IN PKSMETHOD pKSProperty,
OUT KSPIN_MEDIUM * pKSMedium
)
{
NTSTATUS Status = STATUS_SUCCESS;
CFilter * pFilter;
ULONG ulPinType;
PKSFILTER pKSFilter;
KSP_PIN * pKSPPin = (KSP_PIN *) pKSProperty;
ASSERT( pIrp);
ASSERT( pKSProperty);
// pulChangeState needs to be verified because minData is zero
// in the KSMETHOD_ITEM definition in bdamedia.h
if (!pKSMedium)
{
pIrp->IoStatus.Information = sizeof(KSPIN_MEDIUM);
return STATUS_MORE_ENTRIES;
}
// Obtain a "this" pointer to the filter object.
//
// Because the property dispatch table calls the CFilter::CreateTopology() method
// directly, the method must retrieve a pointer to the underlying filter object.
//
pFilter = reinterpret_cast<CFilter *>(KsGetFilterFromIrp(pIrp)->Context);
ASSERT( pFilter);
// Because there is a max of one instance of each pin for a given filter
// instance, we can use the same GUID for the medium on each pin.
//
// We use a GUID specific to this implementation of the
// device to differentiate from other implemenations of the same
// device.
//
Status = pFilter->m_pDevice->GetImplementationGUID( &pKSMedium->Set);
if (!NT_SUCCESS( Status))
{
pKSMedium->Set = KSMEDIUMSETID_Standard;
Status = STATUS_SUCCESS;
}
// Further, we must differentiate this instance of this implementation
// from other intances of the same implementation. We use a device
// instance number to do this.
//
Status = pFilter->m_pDevice->GetDeviceInstance( &pKSMedium->Id);
if (!NT_SUCCESS( Status))
{
pKSMedium->Id = 0;
Status = STATUS_SUCCESS;
}
// Across all filters that represent this device there can only be one
// input pin instance and one output pin instance with the same
// media type so we don't have to distinguish between pin instances.
//
pKSMedium->Flags = 0;
return Status;
}
/*
** CreateTopology() method of the CFilter class
**
** Keeps track of the topology association between input and output pins
**
*/
NTSTATUS
CFilter::CreateTopology(
IN PIRP pIrp,
IN PKSMETHOD pKSMethod,
PVOID pvIgnored
)
{
NTSTATUS Status = STATUS_SUCCESS;
CFilter * pFilter;
ULONG ulPinType;
PKSFILTER pKSFilter;
ASSERT( pIrp);
ASSERT( pKSMethod);
// Obtain a "this" pointer to the filter object.
//
// Because the property dispatch table calls the CFilter::CreateTopology() method
// directly, the method must retrieve a pointer to the underlying filter object.
//
pFilter = reinterpret_cast<CFilter *>(KsGetFilterFromIrp(pIrp)->Context);
ASSERT( pFilter);
//
// Configure the hardware to complete its internal connection between
// the input pin and output pin here.
//
// Call the BDA support library to create the standard topology and
// validate the method, instance count, etc.
//
Status = BdaMethodCreateTopology( pIrp, pKSMethod, pvIgnored);
return Status;
}
/*
** SetDemodulator ()
**
** Sets the type of the demodulator.
**
** Arguments:
**
**
** Returns:
**
** Side Effects: none
*/
STDMETHODIMP_(NTSTATUS)
CFilter::SetDemodulator(
IN const GUID * pguidDemodulator
)
{
NTSTATUS Status = STATUS_SUCCESS;
ASSERT (pguidDemodulator);
if (!pguidDemodulator)
{
return STATUS_INVALID_PARAMETER;
}
// Make sure the demodulator is supported.
//
#if ATSC_RECEIVER
if (IsEqualGUID( pguidDemodulator, &KSNODE_BDA_8VSB_DEMODULATOR))
#elif DVBT_RECEIVER
if (IsEqualGUID( pguidDemodulator, &KSNODE_BDA_COFDM_DEMODULATOR))
#elif DVBS_RECEIVER
if (IsEqualGUID( pguidDemodulator, &KSNODE_BDA_QPSK_DEMODULATOR))
#elif CABLE_RECEIVER
if (IsEqualGUID( pguidDemodulator, &KSNODE_BDA_QAM_DEMODULATOR))
#endif
{
m_NewResource.guidDemodulator = *pguidDemodulator;
m_BdaChangeState = BDA_CHANGES_PENDING;
}
else
{
Status = STATUS_NOT_SUPPORTED;
}
return Status;
}
/*
** GetStatus() method of the CFilter class
**
** Gets the current device status for this filter instance.
**
*/
NTSTATUS
CFilter::GetStatus(
PBDATUNER_DEVICE_STATUS pDeviceStatus
)
{
if (m_KsState == KSSTATE_STOP)
{
// If we're in stop state then the device status
// doesn't reflect our resource list.
//
pDeviceStatus->fCarrierPresent = FALSE;
pDeviceStatus->fSignalLocked = FALSE;
return STATUS_SUCCESS;
}
else
{
ASSERT( m_pDevice);
return m_pDevice->GetStatus( pDeviceStatus);
}
};
/*
** AcquireResources() method of the CFilter class
**
** Acquires resources for the underlying device.
**
*/
NTSTATUS
CFilter::AcquireResources(
)
{
NTSTATUS Status = STATUS_SUCCESS;
if (m_fResourceAcquired)
{
Status = m_pDevice->UpdateResources(
&m_CurResource,
m_ulResourceID
);
}
else
{
// Commit the resources on the underlying device
//
Status = m_pDevice->AcquireResources(
&m_CurResource,
&m_ulResourceID
);
m_fResourceAcquired = NT_SUCCESS( Status);
}
return Status;
}
/*
** ReleaseResources() method of the CFilter class
**
** Releases resources from the underlying device.
**
*/
NTSTATUS
CFilter::ReleaseResources(
)
{
NTSTATUS Status = STATUS_SUCCESS;
// Release the resources on the underlying device
//
if (m_fResourceAcquired)
{
Status = m_pDevice->ReleaseResources(
m_ulResourceID
);
m_ulResourceID = 0;
m_fResourceAcquired = FALSE;
}
return Status;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -