Microsoft DirectX 9.0

IMemAllocator::GetBuffer

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

Syntax

HRESULT GetBuffer(
  IMediaSample **ppBuffer,
  REFERENCE_TIME *pStartTime,
  REFERENCE_TIME *pEndTime,
  DWORD dwFlags
);

Parameters

ppBuffer

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

pStartTime

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

pEndTime

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

dwFlags

[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.

Remarks

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