I have a transform filter which exposes a custom interface says IMyInit
. This interface used to be configured some basic setup setting before streaming.
DECLARE_INTERFACE_(IMyInit, IUnknown) {
STDMETHOD HRESULT SetPath(const wchar_t* wcsPath) PURE;
STDMETHOD HRESULT SetMode(UINT uMode) PURE;
};
Client code like:
CComPtr<IBaseFilter> pMyFilter;
HRESULT hr = CoCreateInstance(CLSID_MYFILTER, IID_MYFILTER, ..., (void**)&pMyFilter);
// hr is S_OK
CComPtr<IMyInit> pMyInit;
hr = pMyFilter->QueryInterface(IID_IMyInit, (void**)&pMyInit);
// hr is S_OK
hr = pMyInit->SetMode(1);
// hr is 0x80040213/VFW_E_NO_CLOCK
In my CMyFilter::SetMode(UINT uMode), there are only E_POINTER, E_INVALIDARG for parameters checking, and S_OK if uMode is set. It is not possible to return such error code, VFW_E_NO_CLOCK, related to transform filter.
Why?
I have implemented the IMyInit interface dispatch in NonDelegatingQueryInterface, and it seems like
if(riid == IID_IMyInit) {
return GetInterface((IMyInit*)this, ppv);
}
But! I forgot to let my CMyFilter concrete class inherit from the IMyInit interface. So there is no connection between IMyInit and CMyFilter.
The C style casting, (IMyInit*)this
, then casts the ppv to CMyFilter
's some base class, may be the direct show's CTransformFilter
. The unknown method pointered by IMyInit::SetMode(UINT)
may require clock to exist. This is why the VFW_E_NO_CLOCK will return.
User contributions licensed under CC BY-SA 3.0