本文介绍了2个输入引脚的CTeeOutputPin :: NonDelegatingQueryInterface的修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在开始播放电影时,Graph Edit由于此功能而挂起.
怎么了?
Graph Edit hangs because of this function, when begining to play movies.
What is wrong?
STDMETHODIMP
CEncOutPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
{
CheckPointer(ppv,E_POINTER);
ASSERT(ppv);
*ppv = NULL;
HRESULT hr = S_OK;
// See what interface the caller is interested in.
if(riid == IID_IMediaPosition || riid == IID_IMediaSeeking)
{
if(m_pPosition_1)
{
if(m_bHoldsSeek == FALSE)
return E_NOINTERFACE;
return m_pPosition_1->QueryInterface(riid, ppv);
}
if(m_pPosition_2)
{
if(m_bHoldsSeek == FALSE)
return E_NOINTERFACE;
return m_pPosition_2->QueryInterface(riid, ppv);
}
}
else
{
return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
}
CAutoLock lock_it(m_pLock);
ASSERT(m_pPosition_1 == NULL);
ASSERT(m_pPosition_2 == NULL);
IUnknown *pMediaPosition = NULL;
// Try to create a seeking implementation
// if(InterlockedExchange(&m_pParent->m_lCanSeek, FALSE) == FALSE)
BOOL local_bool = m_pParent->m_lCanSeek;
m_pParent->m_lCanSeek = FALSE;
if(local_bool==FALSE)
return E_NOINTERFACE;
// Create implementation of this dynamically as sometimes we may never
// try and seek. The helper object implements IMediaPosition and also
// the IMediaSelection control interface and simply takes the calls
// normally from the downstream filter and passes them upstream
for(size_t local_counter=0;local_counter<m_pParent->m_pFirstInPins.size();local_counter++)
{
hr = CreatePosPassThru(GetOwner(),
FALSE,
(IPin *)&m_pParent->m_pFirstInPins[local_counter],
&pMediaPosition);
// hr = m_pParent->m_pFirstInPins[local_counter]->QueryInterface(IID_ISeekingPassThru,(void **)&pMediaPosition);
if(pMediaPosition == NULL)
{
// InterlockedExchange(&m_pParent->m_lCanSeek, TRUE);
m_pParent->m_lCanSeek = TRUE;
return E_OUTOFMEMORY;
}
if(FAILED(hr))
{
// InterlockedExchange(&m_pParent->m_lCanSeek, TRUE);
m_pParent->m_lCanSeek = TRUE;
pMediaPosition->Release();
return hr;
}
hr = ((ISeekingPassThru*)(pMediaPosition))->Init(FALSE,m_pParent->m_pFirstInPins[local_counter]);
if(FAILED(hr))
{
// InterlockedExchange(&m_pParent->m_lCanSeek, TRUE);
m_pParent->m_lCanSeek = TRUE;
pMediaPosition->Release();
return hr;
}
if(local_counter==0)
{
m_pPosition_1 = pMediaPosition;
}
if(local_counter==1)
{
m_pPosition_2 = pMediaPosition;
}
}
m_bHoldsSeek = TRUE;
return NonDelegatingQueryInterface(riid, ppv);
} // NonDelegatingQueryInterface
推荐答案
STDMETHODIMP
CEncOutPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
{
CheckPointer(ppv,E_POINTER);
ASSERT(ppv);
*ppv = NULL;
HRESULT hr = S_OK;
// See what interface the caller is interested in.
if(riid == IID_IMediaPosition || riid == IID_IMediaSeeking)
{
}
else
{
return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
}
CAutoLock lock_it(m_pLock);
ASSERT(m_pPosition_1 == NULL);
ASSERT(m_pPosition_2 == NULL);
IUnknown *pMediaPosition = NULL;
// Try to create a seeking implementation
// if(InterlockedExchange(&m_pParent->m_lCanSeek, FALSE) == FALSE)
BOOL local_bool = m_pParent->m_lCanSeek;
m_pParent->m_lCanSeek = FALSE;
if(local_bool==FALSE)
return E_NOINTERFACE;
// Create implementation of this dynamically as sometimes we may never
// try and seek. The helper object implements IMediaPosition and also
// the IMediaSelection control interface and simply takes the calls
// normally from the downstream filter and passes them upstream
for(size_t local_counter=0;local_counter<m_pParent->m_pFirstInPins.size();local_counter++)
{
hr = CreatePosPassThru(GetOwner(),
FALSE,
(IPin *)&m_pParent->m_pFirstInPins[local_counter],
&pMediaPosition);
if(pMediaPosition == NULL)
{
// InterlockedExchange(&m_pParent->m_lCanSeek, TRUE);
m_pParent->m_lCanSeek = TRUE;
return E_OUTOFMEMORY;
}
if(FAILED(hr))
{
// InterlockedExchange(&m_pParent->m_lCanSeek, TRUE);
m_pParent->m_lCanSeek = TRUE;
pMediaPosition->Release();
return hr;
}
m_bHoldsSeek = TRUE;
if(local_counter==0)
{
m_pPosition_1 = pMediaPosition;
if(m_pPosition_1)
{
if(m_bHoldsSeek == FALSE)
return E_NOINTERFACE;
return ((CSeekingPassThru*)m_pPosition_1)->NonDelegatingQueryInterface(riid, ppv);
}
}
if(local_counter==1)
{
m_pPosition_2 = pMediaPosition;
if(m_pPosition_2)
{
if(m_bHoldsSeek == FALSE)
return E_NOINTERFACE;
return ((CSeekingPassThru*)m_pPosition_2)->NonDelegatingQueryInterface2(riid, ppv);
}
}
}
return NonDelegatingQueryInterface(riid, ppv);
} // NonDelegatingQueryInterface
STDMETHODIMP CEncStreamsStereoTransformationFilter::NonDelegatingQueryInterface(REFIID riid, void **ppv)
{
#ifdef INFORMATION_MESSAGE
::MessageBoxW(0,L"STDMETHODIMP CEncStreamsStereoTransformationFilter::NonDelegatingQueryInterface(REFIID riid, void **ppv)",L"Information",MB_ICONINFORMATION);
#endif
/*/
if (riid == IID_IMediaSeeking)
{
*ppv = (IMediaSeeking*)this;
((IUnknown*)*ppv)->AddRef();
return S_OK;
}
/*/
return CBaseFilter::NonDelegatingQueryInterface(riid, ppv);
}
这篇关于2个输入引脚的CTeeOutputPin :: NonDelegatingQueryInterface的修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!