IMFDXGIDeviceManager::LockDevice method

Gives the caller exclusive access to the Microsoft Direct3D device.


HRESULT LockDevice(
  [in]  HANDLE hDevice,
  [in]  REFIID riid,
  [out] void   **ppUnkDevice,
  [in]  BOOL   fBlock


hDevice [in]

A handle to the Direct3D device. To get the device handle, call IMFDXGIDeviceManager::OpenDeviceHandle.

riid [in]

The interface identifier (IID) of the requested interface. The Direct3D device will support the following interfaces:

ppUnkDevice [out]

Receives a pointer to the requested interface. The caller must release the interface.

fBlock [in]

Specifies whether to wait for the device lock. If the device is already locked and this parameter is TRUE, the method blocks until the device is unlocked. Otherwise, if the device is locked and this parameter is FALSE, the method returns immediately with the error code DXVA2_E_VIDEO_DEVICE_LOCKED.

Return value

This method can return one of these values.

Return codeDescription



The specified handle is not a Direct3D device handle.


The DXGI Device Manager was not initialized. The owner of the device must call IMFDXGIDeviceManager::ResetDevice.


The device handle is invalid.


The device is locked and fBlock is FALSE.



When you are done using the Direct3D device, call IMFDXGIDeviceManager::UnlockDevice to unlock the device.

If the method returns MF_E_DXGI_NEW_VIDEO_DEVICE, call IMFDXGIDeviceManager::CloseDeviceHandle to close the handle and then call OpenDeviceHandle again to get a new handle. The IMFDXGIDeviceManager::ResetDevice method invalidates all open device handles.

If fBlock is TRUE, this method can potentially deadlock. For example, it will deadlock if a thread calls LockDevice and then waits on another thread that calls LockDevice. It will also deadlock if a thread calls LockDevice twice without calling UnlockDevice in between.


Minimum supported client

Windows 8 [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2012 [desktop apps | Windows Store apps]


Mfobjects.h (include Mfidl.h)

See also