Microsoft DirectX 9.0

ISampleGrabber::GetCurrentBuffer

The GetCurrentBuffer method retrieves a copy of the buffer associated with the most recent sample.

Syntax

HRESULT GetCurrentBuffer(
  long *pBufferSize,
  long *pBuffer
);

Parameters

pBufferSize

[in, out] Pointer to the size of the buffer. If pBuffer is NULL, this parameter receives the required buffer size. If pBuffer is not NULL, set this parameter to the size of the buffer. On output, the parameter receives the size of the data copied into the buffer. This might be smaller than the size of the buffer.

pBuffer

[out] Pointer to a buffer to receive a copy of the sample, or NULL.

Return Value

Returns one of the following values.

Return code Description
E_INVALIDARG Samples are not being buffered.
E_OUTOFMEMORY The specified buffer is not large enough.
E_POINTER NULL pointer argument.
S_OK Success.
VFW_E_NOT_CONNECTED The filter is not connected.
VFW_E_WRONG_STATE The filter has not received any samples yet. To deliver a sample, run or pause the graph.

Remarks

To activate buffering, call ISampleGrabber::SetBufferSamples with a value of TRUE.

Call this method twice. On the first call, set pBuffer to NULL. The size of the buffer is returned in pBufferSize. Then allocate the buffer and call the method again. On the second call, pass the size of you buffer in pBufferSize, and pass the address of the buffer in pBuffer. If the buffer that you provide is not large enough, the method returns E_OUTOFMEMORY.

The filter does not buffer preroll samples, or samples in which the dwStreamId member of the AM_SAMPLE2_PROPERTIES structure is anything other than AM_STREAM_MEDIA.

See Also