2008年1月17日 星期四

[DirectShow] Release VMR-9

The VMR-9 is a render object which is used in DirectShow for display the video stream. However, the high performance is relative to the hardware depend. In general, the number of VMR-9 instances you can  crated is limited. VMR-7 has no this limited to your graphic card but only for XP application usage.

So, how to  maintain your VMR-9 resource is an important aspect.

 

Create a VMR-9 and add it to the Graphic Manager. the code is presented as following.

hr=AddFilterByCLSID(pBuilder,CLSID_VideoMixingRenderer9,

                                               _T("Video Render 9"),&m_pVR);

if(FAILED(hr))       return hr;

If you get another interface from the VMR object, like this.

hr = m_pVR->QueryInterface(IID_IVMRFilterConfig9,

                                                              (LPVOID *)&pConfig9);

if(FAILED(hr))       return hr;

 

then the reference count will be increased.

 

How to completely release the VMR object?

Step 1: all interfaces to the object should be released.

Step 2:  Remove the VMR from the Graphic Manager and release the object.

The example code is listed as follow.

if(m_pVR!=NULL){
            hr=pFG->RemoveFilter(m_pVR);

            ULONG count;

           // release the interface and check the reference count.
            count=pConfig9->Release();             

            TRACE(_T("VMR filter's reference count=%d\n"),count);
            count=m_pVR->Release();
            TRACE(_T("VMR filter's reference count=%d\n"),count);
        }

 

 

by Jing

沒有留言:

張貼留言