Microsoft DirectX 8.0 |
Implements an allocator that supports the IMemAllocator interface.
Declaration: Amfilter.h
This class derives from CBaseAllocator. For more information about allocators, refer to the documentation for CBaseAllocator.
Protected Member Variables | |
---|---|
m_pBuffer | Pointer to the memory block that contains the buffers. |
Protected Methods | |
Free | Called during a decommit operation. |
ReallyFree | Releases the memory for the buffers. |
Alloc | Allocates memory for the buffers. |
Public Methods | |
CMemAllocator | Constructor method. |
~CMemAllocator | Destructor method. |
CreateInstance | Creates a new instance of the CMemAllocator class. |
IMemAllocator Methods | |
SetProperties | Specifies the number of buffers to allocate and the size of each buffer. |
Pointer to the memory block that contains the buffers.
Syntax
LPBYTE m_pBuffer;
Remarks
Sample buffers are calculated as offsets from this pointer.
Allocates memory for the buffers.
Syntax
HRESULT Alloc(void);
Return Value
Returns one of the HRESULT values shown in the following table.
S_OK Success. E_OUTOFMEMORY Insufficient memory. VFW_E_SIZENOTSET Buffer requirements were not set.
Remarks
This method is called by the CBaseAllocator::Commit method. It allocates a contiguous block of memory sufficient for the buffer requirements given in the SetProperties method.
Constructor method.
Syntax
CMemAllocator( TCHAR *pName, LPUNKNOWN pUnk, HRESULT *phr, );
Parameters
- pName
- Pointer to a string containing the name of the allocator.
- pUnk
- Pointer to the owner of this object. If the object is aggregated, pass a pointer to the aggregating object's IUnknown interface. Otherwise, set this parameter to NULL.
- phr
- Pointer to a variable that receives an HRESULT value indicating the success or failure of the method.
Destructor method.
Syntax
~CMemAllocator(void);
Syntax
This method overrides the base-class destructor to call Decommit and ReallyFree.
Creates a new instance of the CMemAllocator class.
Syntax
static CUnknown *CreateInstance( LPUNKNOWN pUnk, HRESULT *phr );
Parameters
Return Value
Returns a pointer to a new CMemAllocator object, typed as a CUnknown object.
Called during a decommit operation.
Syntax
void Free(void);
Remarks
This method overrides the pure virtual method CBaseAllocator::Free, which is called during a decommit operation. In the CMemAllocator class, this method does not do anything. Memory is freed in the destructor method, by calling the ReallyFree method.
Releases the memory for the buffers.
Syntax
void ReallyFree (void);
Remarks
The CMemAllocator class holds memory until the object is deleted.
Specifies the number of buffers to allocate and the size of each buffer.
Syntax
HRESULT SetProperties( ALLOCATOR_PROPERTIES *pRequest, ALLOCATOR_PROPERTIES *pActual );
Parameters
- pRequest
- Pointer to an ALLOCATOR_PROPERTIES structure that contains the buffer requirements.
- pActual
- Pointer to an ALLOCATOR_PROPERTIES structure that receives the actual buffer properties.
Return Value
Returns one of the HRESULT values shown in the following table.
S_OK Success. E_POINTER NULL pointer argument. VFW_E_ALREADY_COMMITTED Cannot change allocated memory while the filter is active. VFW_E_BADALIGN An invalid alignment was specified. VFW_E_BUFFERS_OUTSTANDING One or more buffers are still active.
Remarks
This method overrides the CBaseAllocator::SetProperties method.
The buffer alignment, specified by the cbAlign member of the ALLOCATOR_PROPERTIES structure, must be an even power of two.