当前位置: 首页>>代码示例>>C++>>正文


C++ CBasePin::AddRef方法代码示例

本文整理汇总了C++中CBasePin::AddRef方法的典型用法代码示例。如果您正苦于以下问题:C++ CBasePin::AddRef方法的具体用法?C++ CBasePin::AddRef怎么用?C++ CBasePin::AddRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CBasePin的用法示例。


在下文中一共展示了CBasePin::AddRef方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

STDMETHODIMP
CEnumPins::Next(ULONG cPins,        // place this many pins...
				IPin **ppPins,      // ...in this array
				ULONG *pcFetched)   // actual count passed returned here
{
	CheckPointer(ppPins,E_POINTER);
	ValidateReadWritePtr(ppPins,cPins * sizeof(IPin *));

	ASSERT(ppPins);

	if (pcFetched!=NULL) {
		ValidateWritePtr(pcFetched, sizeof(ULONG));
		*pcFetched = 0;           // default unless we succeed
	}
	// now check that the parameter is valid
	else if (cPins>1) {   // pcFetched == NULL
		return E_INVALIDARG;
	}
	ULONG cFetched = 0;           // increment as we get each one.

	/* Check we are still in sync with the filter */
	if (AreWeOutOfSync() == TRUE) {
		// If we are out of sync, we should refresh the enumerator.
		// This will reset the position and update the other members, but
		// will not clear cache of pins we have already returned.
		Refresh();
	}

	/* Calculate the number of available pins */

	int cRealPins = min(m_PinCount - m_Position, (int) cPins);
	if (cRealPins == 0) {
		return S_FALSE;
	}

	/* Return each pin interface NOTE GetPin returns CBasePin * not addrefed
	so we must QI for the IPin (which increments its reference count)
	If while we are retrieving a pin from the filter an error occurs we
	assume that our internal state is stale with respect to the filter
	(for example someone has deleted a pin) so we
	return VFW_E_ENUM_OUT_OF_SYNC                            */

	while (cRealPins && (m_PinCount - m_Position)) {

		/* Get the next pin object from the filter */

		CBasePin *pPin = m_pFilter->GetPin(m_Position++);
		if (pPin == NULL) {
			// If this happend, and it's not the first time through, then we've got a problem,
			// since we should really go back and release the iPins, which we have previously
			// AddRef'ed.
			ASSERT( cFetched==0 );
			return VFW_E_ENUM_OUT_OF_SYNC;
		}

		/* We only want to return this pin, if it is not in our cache */
		if (0 == m_PinCache.Find(pPin))
		{
			/* From the object get an IPin interface */

			*ppPins = pPin;
			pPin->AddRef();

			cFetched++;
			ppPins++;

			m_PinCache.AddTail(pPin);

			cRealPins--;

		}
	}

	if (pcFetched!=NULL) {
		*pcFetched = cFetched;
	}

	return (cPins==cFetched ? NOERROR : S_FALSE);
}
开发者ID:EnoroF,项目名称:easygamelibs,代码行数:79,代码来源:EnumPins.cpp


注:本文中的CBasePin::AddRef方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。