Async filter sample and AVI files

The Async filter sample contains the comment "NOTE: This filter does NOT support AVI format." That's only half true. The Async sample (like the official Async File Source filter) doesn't care about the stream format. It just delivers a stream of bytes. However, the AVI Splitter won't connect unless the Async filter offers MEDIASUBTYPE_Avi as its output subtype. [Corrected 3/18]

The Async filter gets its media type from the 2d parameter of IFileSourceFilter::Load. If you add the filter via GraphEdit, that parameter is NULL and the filter defaults to MEDIASUBTYPE_NULL. On the other hand, if you call Load from your app and pass in the correct media type, it will render fine. You can see this in the little console app that comes with the sample (see memfile.cpp).

The official Async File Source filter is smart enough to parse the file extension and offer an appropriate type.

If you want the sample to support AVI files in GraphEdit, add the following to the Load method:

 CMediaType cmt;
if (NULL == pmt) 
{
    GUID subtype = MEDIASUBTYPE_NULL;

    // Workaround to support AVI files in this sample.
    TCHAR *szExtension = PathFindExtension(lpszFileName);
    if (szExtension && _tcscmp(szExtension, TEXT(".avi")) == 0)
    {
        subtype = MEDIASUBTYPE_Avi;
    }

    cmt.SetType(&MEDIATYPE_Stream);
    cmt.SetSubtype(&subtype);
} 
else 
{
    cmt = *pmt;
}

If you're supporting a custom protocol or file type, read the topic "Registering a Custom File Type" in the SDK.