迎风向前,是唯一的方向
移动平台开发:iPhone,Brew等。多媒体方面开发,涉及DirectShow,Direct3D,ffmpeg等

导航

 

这两天碰到了奇怪的问题,加入DeleteMediaType()释放内存后,编绎成功,但链接失败,找到N个重名符号.查找帮助文档,依葫芦画瓢,替换成以下代码就正常了,看来DirectShow也知道会有这个问题吧:

Use this function to release any media type structure that was allocated using either CoTaskMemAlloc or CreateMediaType.

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


void MyDeleteMediaType(AM_MEDIA_TYPE *pmt)
{
    if (pmt != NULL)
    {
        MyFreeMediaType(*pmt); // See FreeMediaType for the implementation.
        CoTaskMemFree(pmt);
    }
}
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;
    }
}

posted on 2006-11-15 13:10  cyrys  阅读(956)  评论(0编辑  收藏  举报