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


C++ IEnumFilters::Skip方法代码示例

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


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

示例1: Play

//-------------------------------------------------------------------------------------------------
HRESULT classMMPLAYER::Play (LPSTR argName)
{
	WCHAR wFileName[MAX_PATH];
	HRESULT hr;
	IPin	*pPin = NULL;

	DWORD dwAttr = GetFileAttributes(argName);
	if (dwAttr == (DWORD) -1)
		return ERROR_FILE_NOT_FOUND;

	#ifndef UNICODE
		MultiByteToWideChar(CP_ACP, 0, argName, -1, wFileName, MAX_PATH);
	#else
		lstrcpy(wFileName, argName);
	#endif

	hr = m_pGraphBuilder->AddSourceFilter(wFileName, wFileName, &m_pSourceNext);
	if ( SUCCEEDED(hr) ) 
	{
		hr = m_pSourceNext->FindPin(L"Output", &pPin);
	}

	if ( SUCCEEDED(hr) )
	{
		hr = m_pMediaControl->Stop();
	}
	
	if (SUCCEEDED(hr)) {
		IEnumFilters *pFilterEnum = NULL;
		IBaseFilter  *pFilterTemp = NULL;
		if(SUCCEEDED(hr = m_pGraphBuilder->EnumFilters(&pFilterEnum))){
			int iFiltCount = 0;
			int iPos = 0;
			while( S_OK == pFilterEnum->Skip(1)){
				iFiltCount++;
			}
			IBaseFilter **ppFilters = reinterpret_cast<IBaseFilter **>(_alloca(sizeof(IBaseFilter *) *iFiltCount));
			pFilterEnum->Reset();
			while(S_OK == pFilterEnum->Next(1, &(ppFilters[iPos++]), NULL));
			SAFE_RELEASE(pFilterEnum);
			for(iPos = 0;iPos < iFiltCount; iPos++){
				m_pGraphBuilder->RemoveFilter(ppFilters[iPos]);
				if(ppFilters[iPos] != m_pSourceCurrent)
				{
					m_pGraphBuilder->AddFilter(ppFilters[iPos], NULL);
				}
				SAFE_RELEASE(ppFilters[iPos]);
			}
		}
	}
	
	if ( SUCCEEDED(hr) ) {
		hr = m_pGraphBuilder->Render(pPin);
		m_pSourceCurrent = m_pSourceNext;
		m_pSourceNext    = NULL;
	}
	SAFE_RELEASE(pPin);

	if ( SUCCEEDED(hr) ) {
		LONGLONG IIPos = 0;
		hr = m_pMediaSeeking->SetPositions(&IIPos, AM_SEEKING_AbsolutePositioning,
			&IIPos, AM_SEEKING_NoPositioning);
	}

	if ( SUCCEEDED(hr) ) {
		hr = m_pMediaControl->Run();
	}

	SAFE_RELEASE(m_pSourceCurrent);
	return S_OK;
}
开发者ID:PurpleYouko,项目名称:Wibble_Wibble,代码行数:72,代码来源:CMMPlayer.cpp

示例2: GetFileAttributes

BOOL CMP3Player::OnPlayAudio( TCHAR* szName, BOOL bLooped /*= FALSE */ )
{					
	//WCHAR wstrFileName[MAX_PATH];    
	HRESULT hr;
	IPin *pPin = NULL;

	// Make sure that this file exists
	DWORD dwAttr = GetFileAttributes(szName);
	if (dwAttr == (DWORD) -1)
	{
		return FALSE;
	}

	// OPTIMIZATION OPPORTUNITY
	// This will open the file, which is expensive. To optimize, this
	// should be done earlier, ideally as soon as we knew this was the
	// next file to ensure that the file load doesn't add to the
	// filter swapping time & cause a hiccup.
	//
	// Add the new source filter to the graph. (Graph can still be running)
	hr = m_pGraphBuilder->AddSourceFilter(szName,szName, &m_pSourceNext);

	// Get the first output pin of the new source filter. Audio sources 
	// typically have only one output pin, so for most audio cases finding 
	// any output pin is sufficient.
	if (SUCCEEDED(hr)) {
		hr = m_pSourceNext->FindPin(L"Output", &pPin);  
	}

	// Stop the graph
	if (SUCCEEDED(hr)) {
		hr = m_pMediaControl->Stop();
	}

	// Break all connections on the filters. You can do this by adding 
	// and removing each filter in the graph
	if (SUCCEEDED(hr)) {
		IEnumFilters *pFilterEnum = NULL;

		if (SUCCEEDED(hr = m_pGraphBuilder->EnumFilters(&pFilterEnum))) {
			int iFiltCount = 0;
			int iPos = 0;

			// Need to know how many filters. If we add/remove filters during the
			// enumeration we'll invalidate the enumerator
			while (S_OK == pFilterEnum->Skip(1)) {
				iFiltCount++;
			}

			// Allocate space, then pull out all of the 
			IBaseFilter **ppFilters = reinterpret_cast<IBaseFilter **>
				(_alloca(sizeof(IBaseFilter *) * iFiltCount));
			pFilterEnum->Reset();

			while (S_OK == pFilterEnum->Next(1, &(ppFilters[iPos++]), NULL));
			SAFE_RELEASE(pFilterEnum);

			for (iPos = 0; iPos < iFiltCount; iPos++) {
				m_pGraphBuilder->RemoveFilter(ppFilters[iPos]);
				// Put the filter back, unless it is the old source
				if (ppFilters[iPos] != m_pSourceCurrent) {
					m_pGraphBuilder->AddFilter(ppFilters[iPos], NULL);
				}
				SAFE_RELEASE(ppFilters[iPos]);
			}
		}
	}

	// We have the new ouput pin. Render it
	if (SUCCEEDED(hr)) {
		hr = m_pGraphBuilder->Render(pPin);
		m_pSourceCurrent = m_pSourceNext;
		m_pSourceNext = NULL;
	}

	SAFE_RELEASE(pPin);
	SAFE_RELEASE(m_pSourceNext); // In case of errors

	// Re-seek the graph to the beginning
	if (SUCCEEDED(hr)) {
		LONGLONG llPos = 0;
		hr = m_pMediaSeeking->SetPositions(&llPos, AM_SEEKING_AbsolutePositioning,
			&llPos, AM_SEEKING_NoPositioning);
	} 

	// Start the graph
	if (SUCCEEDED(hr)) {
		hr = m_pMediaControl->Run();
	}

	// Release the old source filter.
	SAFE_RELEASE(m_pSourceCurrent);

	return TRUE;
}
开发者ID:Buffer429,项目名称:CGSF,代码行数:95,代码来源:MP3Player.cpp


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