初始化 BDA 微型驱动程序
BDA 微型驱动程序的初始化方式与其他 AVStream 微型驱动程序类似。 BDA 微型驱动程序的 DriverEntry 函数调用 AVStream KsInitializeDriver 函数来初始化 BDA 微型驱动程序的驱动程序对象。 在此调用中,BDA 微型驱动程序将指针传递给指定设备特征 的KSDEVICE_DESCRIPTOR 结构,其中可能包括:
指向包含 BDA 设备的调度表 的 KSDEVICE_DISPATCH 结构的指针。 BDA 微型驱动程序至少应提供用于创建和启动设备的例程,并在KSDEVICE_DISPATCH结构的 Add 和 Start 成员中分别指定这些例程。 BDA 微型驱动程序的创建例程应为设备类分配内存,并将指向 BDA 设备的 KSDEVICE 结构的指针引用到此设备类。 BDA 微型驱动程序的启动例程应从注册表获取有关设备的信息,设置有关设备的信息,然后向 BDA 支持库注册一组静态模板结构。 有关详细信息 ,请参阅启动 BDA 微型驱动程序 。
此设备支持的单个筛选器类型的 KSFILTER_DESCRIPTOR 结构的数组。 此结构类型描述由给定筛选器工厂创建的筛选器的特征。 如果创建 BDA 微型驱动程序,使其不使用 BDA 支持库 (Bdasup.lib) 来处理 BDA 微型驱动程序的属性和方法集,则应在此数组中指定此类型结构的成员。 如果创建 BDA 微型驱动程序以便它使用 BDA 支持库,则 BDA 微型驱动程序应改为调用 BdaCreateFilterFactory 支持函数,以添加筛选器工厂描述符 (KSFILTER_DESCRIPTOR设备) 结构。 有关详细信息 ,请参阅启动 BDA 微型驱动程序 。
以下代码片段演示筛选器描述符数组、BDA 设备的调度表和 BDA 设备的描述符的示例:
//
// Array containing descriptors for all filter factories
// available on the device.
//
// Note! Only used when dynamic topology is not used (that is,
// only when filters and pins are fixed). Typically, this
// is when the network provider is not present.
//
DEFINE_KSFILTER_DESCRIPTOR_TABLE(FilterDescriptors)
{
&TemplateTunerFilterDescriptor
};
//
// Device Dispatch Table
//
// Lists the dispatch routines for the major events related to
// the underlying device.
//
extern
const
KSDEVICE_DISPATCH
DeviceDispatch =
{
CDevice::Create, // Add
CDevice::Start, // Start
NULL, // PostStart
NULL, // QueryStop
NULL, // CancelStop
NULL, // Stop
NULL, // QueryRemove
NULL, // CancelRemove
NULL, // Remove
NULL, // QueryCapabilities
NULL, // SurpriseRemoval
NULL, // QueryPower
NULL // SetPower
};
//
// Device Descriptor
//
// Brings together the data structures that define the device and
// the initial filter factories that can be created on it.
// Note that because template topology structures are specific
// to BDA, the device descriptor does not include them.
// Note also that if BDA dynamic topology is used, the device
// descriptor does not specify a list of filter factory descriptors.
// If BDA dynamic topology is used, the BDA minidriver calls
// BdaCreateFilterFactory to add filter factory descriptors.
extern
const
KSDEVICE_DESCRIPTOR
DeviceDescriptor =
{
&DeviceDispatch, // Dispatch
#ifdef DYNAMIC_TOPOLOGY // network provider is present
0, // FilterDescriptorsCount
NULL, // FilterDescriptors
#else // network provider is not present
SIZEOF_ARRAY( FilterDescriptors), // FilterDescriptorsCount
FilterDescriptors // FilterDescriptors
#endif // DYNAMIC_TOPOLOGY