IMemAllocator interface (strmif.h)
[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 IMemAllocator
interface allocates media samples, for moving data between pins.
This interface is used by pins that share allocators, when the input pin exposes the IMemInputPin interface. The pins negotiate which pin will provide the allocator. The allocator is used to allocate memory buffers, retrieve empty buffers, and release buffers. Not every filter creates its own allocator, so one allocator might be used by several filters. For more information, see How Filters Connect.
Applications typically do not use this interface.
To use an allocator, perform the following steps:
- Call the IMemAllocator::SetProperties method to specify the buffer requirements, including the number of buffers and the size of each buffer.
- Call the IMemAllocator::Commit method to allocate the buffers.
- Call the IMemAllocator::GetBuffer method to retrieve media samples. This method blocks until the next sample becomes available.
- When you are done with each sample, call the IUnknown::Release method on the sample. The sample is not deleted when its reference count reaches zero. Instead, the sample returns to the allocator's free list.
- When you are done using the allocator, call the IMemAllocator::Decommit method to release the memory for the buffers.
Inheritance
The IMemAllocator interface inherits from the IUnknown interface. IMemAllocator also has these types of members:
Methods
The IMemAllocator interface has these methods.
IMemAllocator::Commit The Commit method allocates the buffer memory. |
IMemAllocator::Decommit The Decommit method releases the buffer memory. |
IMemAllocator::GetBuffer The GetBuffer method retrieves a media sample that contains an empty buffer. |
IMemAllocator::GetProperties The GetProperties method retrieves the number of buffers that the allocator will create, and the buffer properties. |
IMemAllocator::ReleaseBuffer The ReleaseBuffer method releases a media sample. |
IMemAllocator::SetProperties The SetProperties method specifies the number of buffers to allocate and the size of each buffer. |
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | strmif.h (include Dshow.h) |