Re: custom source filter implementation



On Thu, 5 May 2005 15:15:36 -0600, Jeremy Noring wrote:

> IBaseFilter *pAS = NULL;
> IFileSourceFilter *pFS = NULL;
> HRESULT hr = CoCreateInstance(CLSID_AsyncSample, NULL, CLSCTX_INPROC_SERVER,
> IID_IBaseFilter, (void **)&pAS);
> if( FAILED( hr ) )
> return;
> hr = pGB->AddSourceFilter(wFile, L"Source", &pAS);
> if( FAILED( hr ) )
> return;
> hr = pAS->QueryInterface(IID_IFileSourceFilter, (void **)&pFS);
> if( FAILED( hr ) )
> return;
> hr = pGB->Render(pAS->GetPin(0));
> if( FAILED( hr ) )
> return;

Yuck! Better:

CComPtr<IBaseFilter> pAS;
pAS.CoCreateInstance(CLSID_AsyncSample);
if (!pAS)
return E_NOINTERFACE;

hr = pGB->AddSourceFilter(wFile, L"Source", &pAS);
CComQIPtr<IFileSourceFilter> pFS(pAS);
if(!pFS)
return E_NOINTERFACE;

hr = pGB->Render(pAS->GetPin(0));
if(FAILED(hr))
return hr;



--
Please read this before replying:
1. Dshow & posting help: http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others: follow up if you are helped or you found a solution
.



Relevant Pages