Exemple #1
0
HRESULT
BaseFilter::NotifyEvent(long aEventCode,
                          LONG_PTR aEventParam1,
                          LONG_PTR aEventParam2)
{
  IMediaEventSink* sink = mEventSink;
  if (sink) {
    if (EC_COMPLETE == aEventCode) {
      aEventParam2 = (LONG_PTR)(static_cast<IBaseFilter*>(this));
    }
    return sink->Notify(aEventCode, aEventParam1, aEventParam2);
  }
  return E_NOTIMPL;
}
Exemple #2
0
void gui::dx::audio_playerX::end_thread() 
{
	if (hEventHandler==NULL) return;

	amis::util::Log* p_log = amis::util::Log::Instance();
	//p_log->writeMessage("Wait for thread end.", "audio_playerX::end_thread");
	TRACE(L"%s", "\nWAIT for thread end.\n");

	IMediaEventSink *pIMES = NULL;
	m_graph_builder->QueryInterface(IID_IMediaEventSink, (void**) &pIMES);
	pIMES->Notify(EC_USER + 4, 0, 0);
	pIMES->Release();
	pIMES = NULL;

	//Sleep(200);

	DWORD hr = WaitForSingleObject(hEventHandler, 10000);
	switch (hr) 
	{
		case WAIT_FAILED: 
		{
			int i = 0;
			break;
		}
		case WAIT_ABANDONED: 
		{
			int i = 0;
			break;
		}
		case WAIT_OBJECT_0: 
		{
			int i = 0;
			break;
		}
		case WAIT_TIMEOUT: 
		{
			int i = 0;
			break;
		}
	}
	p_log->writeTrace("Wait for thread end: DONE.", "audio_playerX::end_thread");
	TRACE(L"%s", "\nWAIT for thread end DONE.\n");
	hEventHandler = NULL;
}
Exemple #3
0
void gui::dx::audio_playerX::stop(bool fromPlay, bool fromThread) 
{

#ifdef SINGLE_THREAD_HACK
	ResetEvent(m_hEventWakeup);
#endif

		if (fromThread) 
		{

#ifndef SINGLE_THREAD_HACK
			hEventHandler = NULL;
#endif
			return;
		}

		amis::util::Log* p_log = amis::util::Log::Instance();
		p_log->writeTrace("Stop DX", "audio_playerX::stop");
		TRACE(L"%s", L"\n####### -- STOP DX\n");

		if(m_media_control == 0) 
		{			
			TRACE(L"%s", L"\n####### -- STOP DX || m_media_control == 0\n");
			p_log->writeTrace("Stop DX, m_media_control == 0", "audio_playerX::stop");
			return;
		}
		{ //TODO: what is this curly brace for??  i left it in ...
		if (!fromPlay) 
		{
			TRACE(L"%s", L"\n####### -- STOP DX || CS IN\n");
			p_log->writeTrace("Stop DX, CS IN", "audio_playerX::stop");
			EnterCriticalSection(&m_csSequence);
		}

#ifndef SINGLE_THREAD_HACK
		TRACE(L"%s", L"\n####### -- STOP DX || BEFORE END THREAD\n");
		end_thread();
#else
	IMediaEventSink *pIMES = NULL;
	m_graph_builder->QueryInterface(IID_IMediaEventSink, (void**) &pIMES);
	pIMES->Notify(EC_USER + 5, 0, 0);
	pIMES->Release();
	pIMES = NULL;
#endif

	//Sleep(100);

	TRACE(L"%s", L"\n####### -- STOP DX || AFTER END THREAD\n");
	//p_log->writeMessage("Stop DX, after thread end", "audio_playerX::stop");

	HRESULT hr = m_media_control->Stop();
	if(FAILED(hr)) 
	{
		win_report_error("IMediaControl::stop()", hr);	
	}
	TRACE(L"%s", L"\n####### -- STOP DX || AFTER STOP\n");
	p_log->writeTrace("Stop DX, After stop", "audio_playerX::stop");

	if (m_media_control->StopWhenReady() != S_OK) 
	{
		long state, i;
		for (i = 0; i < 100; i++) 
		{
			m_media_control->GetState(10, &state);
			if (state == State_Stopped) break;
		}
		if (i == 100) 
		{
			int debug = 0;
		}
	}
	TRACE(L"%s", L"\n####### -- STOP DX || AFTER STOP WHEN READY\n");
	//p_log->writeMessage("Stop DX, After stop when ready", "audio_playerX::stop");
	release_player();
	//p_log->writeMessage("Stop DX, After release", "audio_playerX::stop");
	TRACE(L"%s", L"\n####### -- STOP DX || AFTER RELEASE\n");

	if (!fromPlay) 
	{
		LeaveCriticalSection(&m_csSequence);	
		//p_log->writeMessage("Stop DX, CS out", "audio_playerX::stop");
		TRACE(L"%s", L"\n####### -- STOP DX ||  CS OUT\n");
	}
	} //counterpart to mysterious lone curly brace seen earlier
}