Microsoft DirectX 9.0


The GetBuffer method retrieves a media sample that contains an empty buffer.


HRESULT GetBuffer(
  IMediaSample **ppBuffer,
  DWORD dwFlags



[out] Address of a variable that receives a pointer to the buffer's IMediaSample interface.


[in] Pointer to the start time of the sample, or NULL.


[in] Pointer to the ending time of the sample, or NULL.


[in] Bitwise combination of zero or more of the following flags:

Flag Description
AM_GBF_NOTASYNCPOINT This sample is not a synchronization point. Dynamic format changes are not allowed on this sample. When called on the Overlay Mixer or VMR, this flag implies that the buffer returned will contain an image that is identical to the last image delivered.
AM_GBF_PREVFRAMESKIPPED This sample is the first after a discontinuity. (Only the video renderer uses this flag.)
AM_GBF_NOWAIT Do not wait for a buffer to become available.
AM_GBF_NODDSURFACELOCK Used with the Video Mixing Renderer Filter 7 (Microsoft® Windows® XP only) to request an unlocked DirectDraw surface. For more information, see Working with Direct3D Render Targets.

Return Value

Returns an HRESULT value. Possible values include those shown in the following table.

Value Description
S_OK Success.
VFW_E_NOT_COMMITTED Allocator is decommitted.
VFW_E_TIMEOUT Timed out.


By default, this method blocks until a free sample is available or the allocator is decommitted. If the caller specifies the AM_GBF_NOWAIT flag and no sample is available, the allocator can return immediately with a return value of VFW_E_TIMEOUT. However, allocators are not required to support this flag.

The sample returned in ppBuffer has a valid buffer pointer. The caller is responsible for setting any other properties on the sample, such as the time stamps, the media times, or the sync-point property. (For more information, see IMediaSample.)

The pStartTime and pEndTime parameters are not applied to the sample. The allocator might use these values to determine which buffer it retrieves. For example, the Video Renderer filter uses these values to synchronize switching between Microsoft® DirectDraw® surfaces. To set the time stamp on the sample, call the IMediaSample::SetTime method.

You must call the IMemAllocator::Commit method before calling this method. This method fails after the IMemAllocator::Decommit method is called. If the method succeeds, the IMediaSample interface that it returns has an outstanding reference count. Be sure to release the interface when you are done using it.

See Also