FreeMediaType

 
Microsoft DirectShow 9.0

FreeMediaType

The FreeMediaType function frees the format block in an AM_MEDIA_TYPE structure.

Syntax

  void WINAPI FreeMediaType(
    AM_MEDIA_TYPE& mt
);

Parameters

mt

Reference to an AM_MEDIA_TYPE structure.

Return Value

No return value.

Remarks

Use this function to free just the format block. To delete an allocated AM_MEDIA_TYPE structure, call DeleteMediaType.

If you prefer not to link to the base class library, you can use the following code directly:

void MyFreeMediaType(AM_MEDIA_TYPE& mt)
{
    if (mt.cbFormat != 0)
    {
        CoTaskMemFree((PVOID)mt.pbFormat);
        mt.cbFormat = 0;
        mt.pbFormat = NULL;
    }
    if (mt.pUnk != NULL)
    {
        // Unecessary because pUnk should not be used, but safest.
        mt.pUnk->Release();
        mt.pUnk = NULL;
    }
}

Requirements

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

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

See Also