PFN_GET_NEXT_CHUNK_DATA callback function

Provides info about the next Miracast encode chunk that was reported to the Microsoft DirectX graphics kernel subsystem when the DXGK_INTERRUPT_TYPE interrupt type is DXGK_INTERRUPT_MICACAST_CHUNK_PROCESSING_COMPLETE.

The data type of this function is PFN_GET_NEXT_CHUNK_DATA.



NTSTATUS GetNextChunkData(
  _In_     HANDLE              hMiracastDeviceHandle,
  _In_     UINT                TimeoutInMilliseconds,
  _In_     UINT                AdditionalWaitEventCount,
  _In_opt_ HANDLE              *pAdditionalWaitEvents,
  _Inout_  UINT                *pChunkDataBufferSize,
  _Out_    MIRACAST_CHUNK_DATA *pChunkDataBuffer,
  _Out_    UINT                *pOutstandingChunksToProcess
{ ... }


hMiracastDeviceHandle [in]

A handle that represents a Miracast device. The Miracast user-mode driver previously obtained this handle as the hMiracastDeviceHandle parameter in a call to the CreateMiracastContext function.

TimeoutInMilliseconds [in]

The timeout interval value, in milliseconds, supplied by the Miracast user-mode driver.

If this value is INFINITE, the operating system blocks calls to GetNextChunkData until a chunk becomes available.

If this value is zero and a chunk is not ready, the operating system will not block a call to GetNextChunkData.

AdditionalWaitEventCount [in]

The number of additional events that are supplied in the pAdditionalWaitEvents parameter.

A maximum of 4 wait events can be supplied.

pAdditionalWaitEvents [in, optional]

An optional pointer to an array of events that GetNextChunkData will wait on while waiting for a new encode chunk.

pChunkDataBufferSize [in, out]

A pointer to a variable that contains the size, in bytes, of the pChunkDataBuffer buffer.

When GetNextChunkData is called, this parameter contains the size of pChunkDataBuffer.

When GetNextChunkData returns a success code, this parameter contains the size of actual encode chunk data returned in pChunkDataBuffer.

pChunkDataBuffer [out]

A pointer to a buffer of type MIRACAST_CHUNK_DATA that the operating system provides to store information about the next encode chunk. This parameter is provided only if the call to GetNextChunkData is successful.

pOutstandingChunksToProcess [out]

A pointer to a variable that contains the number of outstanding encode chunks that are available for the driver at the time this call returned. This parameter is provided only if the call to GetNextChunkData is successful.

Note that as chunks are completed by the GPU asynchronously, this parameter only gives an indication of the number of outstanding chunks.

Return value

If info on an encode chunk was returned successfully, the STATUS_SUCCESS status code is returned, and the value of *pChunkDataBufferSize is non-zero.

These additional status codes can be returned:


A chunk was available, but the provided buffer was not large enough to contain the chunk data.


The operating system ran out of free encode chunks to satisfy all chunk requests. In this case all outstanding chunks are lost, and the driver should generate a new I-Frame. Using the dropped chunks, this I-Frame will recover the image that the sink displayed.


The Miracast connect session was destroyed.


A chunk was not available within the specified timeout period.


One of the additional supplied events caused the wait criterion to be satisfied, and the value of *pChunkDataBufferSize is zero. The STATUS_WAIT_X value will match the specified index of the pAdditionalWaitEvents array.

For example, if the second event in the array caused the wait to be satisfied, then STATUS_WAIT_1 would be returned.

STATUS_WAIT_0 has the same value as STATUS_SUCCESS, so check *pChunkDataBufferSize to determine if the return value was STATUS_WAIT_0 (a user event signaled the event) or STATUS_SUCCESS (a new chunk is ready).


This function is optional. The user-mode display driver should only call it if the display miniport driver responds to interrupts from the GPU when the GPU completes the encoding of a chunk by passing data in the MIRACAST_CHUNK_DATA.PrivateDriverData member at that interrupt time.

The user-mode display driver can use the sizes of the MIRACAST_CHUNK_DATA structure and the MIRACAST_CHUNK_DATA.PrivateDriverData member to compute the size of a chunk and hence how to move from chunk to chunk in the returned buffer.

In a call to this function, as many available packets as can fit will be placed sequentially in the supplied buffer. This code snippet shows how to calculate the size of each packet:

    (D3DKMT_MIRACAST_CHUNK_DATA, PrivateDriverData) \
    + Chunk->ChunkData.PrivateDriverDataSize;

Thread Safety

Only one thread should call this function at a time. Otherwise it's unpredictable which call would receive chunk info and which call would fail.


Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Target platform



Netdispumdddi.h (include Netdispumdddi.h)

See also




Send comments about this topic to Microsoft