CBaseAllocator.Alloc method
[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
The Alloc
method allocates memory for the buffers.
Syntax
virtual HRESULT Alloc();
Parameters
This method has no parameters.
Return value
Returns one of the following HRESULT values.
Return code | Description |
---|---|
|
Buffer requirements have not changed. |
|
Buffer requirements have changed. |
|
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:
- Call the base class implementation, to determine whether the memory truly needs allocating.
- Allocate memory.
- Create CMediaSample objects that contain chunks of memory from step 2.
- Add each CMediaSample object to the list of free samples (CBaseAllocator::m_lFree).
For an example, see CMemAllocator::Alloc.
Requirements
Requirement | Value |
---|---|
Header |
|
Library |
|