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


C++ IEvent::ToFill方法代码示例

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


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

示例1: WaitForGeneric

IEventSPtr OMXComponent::WaitForGeneric(const list<IEventSPtr> &lstEvents, unsigned int uTimeoutMs)
{
	IEventSPtr pRes;
	uint32_t u32Sec;
	uint32_t u32NanoSec;

	m_pClock->GetCurrent(&u32Sec, &u32NanoSec);

	add_milliseconds(&u32Sec, &u32NanoSec, uTimeoutMs);

	bool bMatch = false;
	bool bFailure = false;

	// go until we either fail or succeed
	while ((!bFailure) && (!bMatch))
	{
		// go through all things we _can_ match with ...
		for (list<IEventSPtr>::const_iterator lsi = lstEvents.begin(); lsi != lstEvents.end(); lsi++)
		{
			// determine what type of event this is
			IEvent *pEvent = lsi->get();
			OMXEventData *pOMX = pEvent->ToEvent();
			EmptyBufferDoneData *pEmpty = pEvent->ToEmpty();
			FillBufferDoneData *pFill = pEvent->ToFill();

			Lock();

			if (pEmpty != NULL)
			{
				for (list<EmptyBufferDoneData>::iterator li = m_lstEmpty.begin(); li != m_lstEmpty.end(); li++)
				{
					if (li->pBuffer == pEmpty->pBuffer)
					{
						bMatch = true;
						m_lstEmpty.erase(li);
						pRes = *lsi;
						break;
					}
				}
			}

			// if we are waiting for an OMXEvent
			else if (pOMX != NULL)
			{
				for (list<OMXEventData>::iterator li = m_lstEvents.begin(); li != m_lstEvents.end(); li++)
				{
					// if we found the match
					if ((li->eEvent == pOMX->eEvent) && (pOMX->nData1 == li->nData1) && (pOMX->nData2 == li->nData2))
					{
						bMatch = true;
						m_lstEvents.erase(li);	// remove this item from the list because the caller knows about it now
						pRes = *lsi;
						break;	// must break here to about segfault since we just called erase()
					}
				}
			}
			else if (pFill != NULL)
			{
				for (list<FillBufferDoneData>::iterator li = m_lstFill.begin(); li != m_lstFill.end(); li++)
				{
					if (li->pBuffer == pFill->pBuffer)
					{
						bMatch = true;
						m_lstFill.erase(li);
						pRes = *lsi;
						break;
					}
				}
			}
			// else this should never happen
			else
			{
				assert(false);
			}

			Unlock();

			// if we found a match, we're done
			if (bMatch)
			{
				break;
			}
		}	// end for

		// if we didn't get a match we need to wait for success or a timeout
		if (!bMatch)
		{
			Lock();

			// If we got an error or timed out, then we're done
			// (this implicitly unlocks the mutex during the waiting period, then relocks it upon returning!)
			if (!m_pLocker->WaitForEvent(u32Sec, u32NanoSec))
			{
				bFailure = true;
			}

			Unlock();
		}

	} // end while we haven't succeeded or failed
//.........这里部分代码省略.........
开发者ID:Charles32,项目名称:SyncVideoPi,代码行数:101,代码来源:OMXComponent.cpp


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