IMemAllocator Interface

 
Microsoft DirectShow 9.0

IMemAllocator Interface

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:

  1. Call the IMemAllocator::SetProperties method to specify the buffer requirements, including the number of buffers and the size of each buffer.
  2. Call the IMemAllocator::Commit method to allocate the buffers.
  3. Call the IMemAllocator::GetBuffer method to retrieve media samples. This method blocks until the next sample becomes available.
  4. 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.
  5. When you are done using the allocator, call the IMemAllocator::Decommit method to release the memory for the buffers.

In addition to the methods inherited from IUnknown, the interface exposes the following methods.

Method Description
SetProperties Specifies the number of buffers to allocate and the size of each buffer.
GetProperties Retrieves the number of buffers that the allocator will create, and the buffer properties.
Commit Allocates the buffer memory.
Decommit Releases the buffer memory.
GetBuffer Retrieves a media sample that contains an empty buffer.
ReleaseBuffer Releases a media sample.

Requirements

Header: Declared in Strmif.h; include Dshow.h.

Library: Use Strmiids.lib.