2个输入引脚的CTeeOutputPin :: NonDelegatingQueryInterface的修改 [英] Modification of CTeeOutputPin::NonDelegatingQueryInterface for 2 input pins

查看:148
本文介绍了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

推荐答案

此处必须返回每个引脚2个接口.但是我们只能返回1个接口.那就是问题所在.要控制2个输入引脚上的搜索,我们必须有2对接口.但是我们只能返回1.那么如何获取需要引脚的信息呢?
Here 2 interfaces for each pin must be returned. But we can return only 1 interface. That is the problem. To control seeking on 2 input pins, we must have 2 pairs of interfaces. But we can return only 1. So how can we get information of requiring pin?


我修改了项目BaseClasses,所以现在我可以管理2个引脚.可能的目的是创建2个输出引脚(每个输入引脚1个)以设置1个输入-1个输出.输出是相同的^立体图片.
有什么想法吗?
I have modified project BaseClasses so now i can manage 2 pins. May be the desigion is to create 2 output pin (1 for each input pin) to set 1 input - 1 output. Output are same^ stereo picture.
Any ideas?
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


我试图在Filter类中实现IMediaSeeking.
我已经实现了接口请求,大部分功能.
创建过滤器时,在我的过滤器中启用此接口的请求后,出现ASSERT消息.
禁用此接口的请求后,筛选器将挂起进行搜索操作.

为什么会这样呢?

I tryed to implement IMediaSeeking in Filter class.
I have implemented interface request, most of functions.
When request of this interface is enabled in my Filter appears ASSERT message when creating Filter.
When request of this interface is disabled Filter hungs on seeking operation.

Why could it be?

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的修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆