共用方式為


在 64 位 AVStream 驅動程式中支援 DMA

AVStream 支援 32 位和 64 位可定址裝置上的 DMA。

針對 Win64 平臺編譯的所有驅動程式都應該使用 IKsDeviceFunctions::RegisterAdapterObjectEx ,而不是 KsDeviceRegisterAdapterObject

IKsDeviceFunctions::RegisterAdapterObjectEx 僅適用于 Microsoft Windows Server 2003 SP1 和更新版本。

下列程式碼範例說明如何在 x64 型用戶端版本和 32 位平臺上支援 DMA:

NTSTATUS MyDeviceStart (...) {
// Get the DMA adapter object and store it in the Context member of the I/O stack location.
Context -> AdapterObject = IoGetDmaAdapter (
Device -> PhysicalDeviceObject,
&DeviceDesc,
&Context -> NumberOfMapRegisters
);

PUNKNOWN DeviceUnk =
KsDeviceGetOuterUnknown (
Device
);

// Register the DMA adapter with AVStream
IKsDeviceFunctions *DeviceFunctions;
NTSTATUS Status = DeviceUnk -> QueryInterface (
__uuidof (IKsDeviceFunctions),
(PVOID *)&DeviceFunctions
);

// Conditionally, call IksDeviceFunctions::RegisterAdapterObjectEx, 
// which will not break downlevel load compatibility.

if (NT_SUCCESS (Status)) {
DeviceFunctions -> RegisterAdapterObjectEx (
Context -> AdapterObject,
&DeviceDesc,
Context -> NumMapRegisters,
MAX_MAPPING,
sizeof (KSMAPPING)
);
DeviceFunctions -> Release ();
}

// If this call fails, call KsDeviceRegisterAdapterObject to
// preserve downlevel load compatibility.
else {
KsDeviceRegisterAdapterObject (
Device,
Context -> AdapterObject,
MAX_MAPPING,
sizeof (KSMAPPING)
);
}
...

此程式碼範例適用于 64 位和 32 位平臺。 如果驅動程式找不到 IKsDeviceFunctions::RegisterAdapterObjectEx,它仍會呼叫 KsDeviceRegisterAdapter

此外,在撰寫 64 位 AVStream 驅動程式時,請將保留的並行畫面鎖定數目降到最低。 由於 AVStream 會在迷你驅動程式第一次鎖定畫面格時產生散佈/收集對應,因此如果驅動程式未遵循此指導方針,您的驅動程式可能會用盡資源。 特別是,如果您要撰寫驅動程式以在具有 32 位卡片的 Win64 平臺上執行,增加同時鎖定的數目會增加鎖定失敗的機會,因為低記憶體緩衝區是有限的資源。