Partager via


CBaseAllocator::Alloc

 
Microsoft DirectShow 9.0

CBaseAllocator::Alloc

The Alloc method allocates memory for the buffers.

Syntax

  virtual HRESULT Alloc(void);

Return Value

Returns one of the following HRESULT values.

Value Description
S_FALSE Buffer requirements have not changed.
S_OK Buffer requirements have changed.
VFW_E_SIZENOTSET Buffer requirements were not set.

Remarks

This method is called by the CBaseAllocator::Commit method.

In the base class, this method does not allocate any memory. It returns an error if the buffer requirements were not set, S_FALSE if the requirements have not changed, and S_OK if the requirements have changed.

A derived class should override this method to perform the actual memory allocation. Typically, the derived class will perform the following steps:

  1. Call the base class implementation, to determine whether the memory truly needs allocating.
  2. Allocate memory.
  3. Create CMediaSample objects that contain chunks of memory from step 2.
  4. Add each CMediaSample object to the list of free samples (CBaseAllocator::m_lFree).

For an example, see CMemAllocator::Alloc.

Requirements

**  Header:** Declared in Amfilter.h; include Streams.h.

**  Library:** Use Strmbase.lib (retail builds) or Strmbasd.lib (debug builds).

See Also