예제 #1
0
파일: pullpin.cpp 프로젝트: hiplayer/mpc_hc
HRESULT
CPullPin::StopThread()
{
    CAutoLock lock(&m_AccessLock);

    if (!ThreadExists()) {
	return S_FALSE;
    }

    // need to flush to ensure the thread is not blocked
    // in WaitForNext
    HRESULT hr = m_pReader->BeginFlush();
    if (FAILED(hr)) {
	return hr;
    }

    m_State = TM_Exit;
    hr = CallWorker(TM_Exit);

    m_pReader->EndFlush();

    // wait for thread to completely exit
    Close();

    // decommit allocator
    if (m_pAlloc) {
	m_pAlloc->Decommit();
    }

    return S_OK;
}
예제 #2
0
STDMETHODIMP OggDemuxFilter::Pause() 
{
	CAutoLock locLock(m_pLock);
    LOG(logDEBUG) << __FUNCTIONW__;

	if (m_State == State_Stopped) 
    {
        LOG(logDEBUG) <<L"Pause -- was stopped";

		if (ThreadExists() == FALSE) 
        {
            LOG(logDEBUG) << L"Pause -- CREATING THREAD";
			Create();
		}

        LOG(logDEBUG) << L"Pause -- RUNNING THREAD";
		CallWorker(THREAD_RUN);
	}

	HRESULT hr = CBaseFilter::Pause();

    LOG(logDEBUG) << __FUNCTIONW__ << L"Base class returned: 0x" << std::hex << hr;
	
	return hr;	
}
예제 #3
0
STDMETHODIMP CAMRSplitter::Pause()
{
	CAutoLock lck(&lock_filter);

	if (m_State == State_Stopped) {

		ev_abort.Reset();

		// activate pins
		for (int i=0; i<output.GetCount(); i++) {
			output[i]->Active();
		}

		if (input) {
			input->Active();
		}

		// seekneme na danu poziciu
		DoNewSeek();

		// pustime parser thread
		if (!ThreadExists()) {
			Create();
			CallWorker(CMD_RUN);
		}
	}

	m_State = State_Paused;
	return NOERROR;
}
예제 #4
0
HRESULT CAMROutputPin::Active()
{
	if (active) {
		return NOERROR;
	}
	
	FlushQueue();
	if (!IsConnected()) {
		return VFW_E_NOT_CONNECTED;
	}

	ev_abort.Reset();

	HRESULT hr = CBaseOutputPin::Active();
	if (FAILED(hr)) {
		active = FALSE;
		return hr;
	}

	// new segment
	DoNewSegment(rtStart, rtStop, rate);

	// vytvorime novu queue
	if (!ThreadExists()) {
		Create();
		CallWorker(CMD_RUN);
	}

	active = TRUE;
	return hr;
}
예제 #5
0
파일: pullpin.cpp 프로젝트: hiplayer/mpc_hc
HRESULT
CPullPin::StartThread()
{
    CAutoLock lock(&m_AccessLock);

    if (!m_pAlloc || !m_pReader) {
	return E_UNEXPECTED;
    }

    HRESULT hr;
    if (!ThreadExists()) {

	// commit allocator
	hr = m_pAlloc->Commit();
	if (FAILED(hr)) {
	    return hr;
	}

	// start thread
	if (!Create()) {
	    return E_FAIL;
	}
    }

    m_State = TM_Start;
    hr = (HRESULT) CallWorker(m_State);
    return hr;
}
예제 #6
0
HRESULT CLAVOutputPin::QueuePacket(Packet *pPacket)
{
  if(!ThreadExists()) return S_FALSE;

  CLAVSplitter *pSplitter = static_cast<CLAVSplitter*>(m_pFilter);

  // While everything is good AND no pin is drying AND the queue is full .. sleep
  // The queu has a "soft" limit of MAX_PACKETS_IN_QUEUE, and a hard limit of MAX_PACKETS_IN_QUEUE * 2
  // That means, even if one pin is drying, we'll never exceed MAX_PACKETS_IN_QUEUE * 2
  while(S_OK == m_hrDeliver 
    && (m_queue.DataSize() > m_dwQueueMaxMem
    || m_queue.Size() > 2*m_dwQueueHigh
    || (m_queue.Size() > m_dwQueueHigh && !pSplitter->IsAnyPinDrying())))
    Sleep(10);

  if(S_OK != m_hrDeliver) {
    SAFE_DELETE(pPacket);
    return m_hrDeliver;
  }

  {
    CAutoLock lock(&m_csMT);
    if(m_newMT && pPacket) {
      DbgLog((LOG_TRACE, 10, L"::QueuePacket() - Found new Media Type"));
      pPacket->pmt = CreateMediaType(m_newMT);
      SetStreamMediaType(m_newMT);
      SAFE_DELETE(m_newMT);
    }
  }

  m_Parser.Parse(m_StreamMT.subtype, pPacket);

  return m_hrDeliver;
}
예제 #7
0
파일: wxutil.cpp 프로젝트: Samangan/mpc-hc
BOOL
CAMThread::Create()
{
    DWORD threadid;

    CAutoLock lock(&m_AccessLock);

    if (ThreadExists()) {
	return FALSE;
    }

    m_hThread = CreateThread(
		    NULL,
		    0,
		    CAMThread::InitialThreadProc,
		    this,
		    0,
		    &threadid);

    if (!m_hThread) {
	return FALSE;
    }

    return TRUE;
}
예제 #8
0
파일: source.cpp 프로젝트: 9crk/EasyClient
//
// Active
//
// The pin is active - start up the worker thread
HRESULT CSourceStream::Active(void) {

    CAutoLock lock(m_pFilter->pStateLock());

    HRESULT hr;

    if (m_pFilter->IsActive()) {
	return S_FALSE;	// succeeded, but did not allocate resources (they already exist...)
    }

    // do nothing if not connected - its ok not to connect to
    // all pins of a source filter
    if (!IsConnected()) {
        return NOERROR;
    }

    hr = CBaseOutputPin::Active();
    if (FAILED(hr)) {
        return hr;
    }

    ASSERT(!ThreadExists());

    // start the thread
    if (!Create()) {
        return E_FAIL;
    }

    // Tell thread to initialize. If OnThreadCreate Fails, so does this.
    hr = Init();
    if (FAILED(hr))
	return hr;

    return Pause();
}
예제 #9
0
HRESULT CBaseSplitterOutputPin::Inactive()
{
    CAutoLock cAutoLock(m_pLock);

	if(ThreadExists())
		CallWorker(CMD_EXIT);

	return __super::Inactive();
}
예제 #10
0
void mmSource::UpdateFromSeek()
{
	if (ThreadExists())	
	{
		DeliverBeginFlush();
		Stop();
		DeliverEndFlush();
		Run();
	}
}
예제 #11
0
HRESULT CBaseSplitterOutputPin::DeliverEndFlush()
{
	if(!ThreadExists()) return S_FALSE;
	HRESULT hr = IsConnected() ? GetConnected()->EndFlush() : S_OK;
	m_hrDeliver = S_OK;
	m_fFlushing = false;
	m_fFlushed = true;
	m_eEndFlush.Set();
	return hr;
}
예제 #12
0
HRESULT CTTASplitterInputPin::Inactive()
{
	if (ThreadExists()) {
		m_bAbort = TRUE;
		CallWorker(CMD_EXIT);
		Close();
	}

	return CBasePin::Inactive();
}
예제 #13
0
CAsyncUrlReader::~CAsyncUrlReader()
{
    if (ThreadExists()) {
        CallWorker(CMD_EXIT);
    }

    if (!m_fn.IsEmpty()) {
        CMultiFiles::Close();
        DeleteFile(m_fn);
    }
}
예제 #14
0
HRESULT CWavPackSplitterFilterInputPin::Inactive()
{
	// Stop the thread
	if (ThreadExists()) {
		m_bAbort = TRUE;
		CallWorker(CMD_EXIT);
		Close();
	}

	return CBasePin::Inactive();
}
예제 #15
0
HRESULT CBaseSplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
	m_brs.rtLastDeliverTime = Packet::INVALID_TIME;
	if(m_fFlushing) return S_FALSE;
	m_rtStart = tStart;
	if(!ThreadExists()) return S_FALSE;
	HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
	if(S_OK != hr) return hr;
	MakeISCRHappy();
	return hr;
}
예제 #16
0
void my12doomImageStream::UpdateFromSeek()
{
	if (ThreadExists()) 
	{
		DeliverBeginFlush();
		// Shut down the thread and stop pushing data.
		Stop();
		DeliverEndFlush();
		// Restart the thread and start pushing data again.
		Pause();
	}
}
예제 #17
0
STDMETHODIMP CWavPackSplitterFilterInputPin::EndFlush()
{
	HRESULT hr = CBaseInputPin::EndFlush();
	if (FAILED(hr)) {
		return hr;
	}

	if (ThreadExists()) {
		CallWorker(CMD_RUN);
	}

	return NOERROR;
}
예제 #18
0
STDMETHODIMP CWavPackDSSplitterInputPin::EndFlush()
{
    HRESULT hr = CBaseInputPin::EndFlush();
    if (FAILED(hr))
        return hr;

    DebugLog("CWavPackDSSplitterInputPin::EndFlush 0x%08X", GetCurrentThreadId());

    if (ThreadExists())
        CallWorker(CMD_RUN);

    return NOERROR; 
}
예제 #19
0
HRESULT CWavPackDSSplitterInputPin::Inactive()
{
    DebugLog("CWavPackDSSplitterInputPin::Inactive 0x%08X", GetCurrentThreadId());

    // Stop the thread
    if (ThreadExists())
    { 
        m_bAbort = TRUE;
        CallWorker(CMD_EXIT);
        Close();
    }

    return CBasePin::Inactive();
}
예제 #20
0
STDMETHODIMP CWavPackDSSplitterInputPin::BeginFlush()
{
    HRESULT hr = CBaseInputPin::BeginFlush();
    if (FAILED(hr))
        return hr;

    DebugLog("CWavPackDSSplitterInputPin::BeginFlush 0x%08X", GetCurrentThreadId());

    if (!ThreadExists())
        return NOERROR;     
    m_bAbort = TRUE;
    CallWorker(CMD_STOP);
    return  NOERROR;
}
예제 #21
0
//
// Inactive
//
// Pin is inactive - shut down the worker thread
// Waits for the worker to exit before returning.
HRESULT CSourceStream::Inactive(void)
{

    CAutoLock lock(m_pFilter->pStateLock());

    HRESULT hr;

    // do nothing if not connected - its ok not to connect to
    // all pins of a source filter
    if(!IsConnected())
    {
        return NOERROR;
    }

    // !!! need to do this before trying to stop the thread, because
    // we may be stuck waiting for our own allocator!!!

    hr = CBaseOutputPin::Inactive();  // call this first to Decommit the allocator
    if(FAILED(hr))
    {
        return hr;
    }

    if(ThreadExists())
    {
        hr = Stop();

        if(FAILED(hr))
        {
            return hr;
        }

        hr = Exit();
        if(FAILED(hr))
        {
            return hr;
        }

        Close();	// Wait for the thread to exit, then tidy up.
    }

    // hr = CBaseOutputPin::Inactive();  // call this first to Decommit the allocator
    //if (FAILED(hr)) {
    //	return hr;
    //}

    return NOERROR;
}
예제 #22
0
HRESULT CBaseSplitterOutputPin::QueuePacket(CAutoPtr<Packet> p)
{
	if(!ThreadExists()) return S_FALSE;

	while(S_OK == m_hrDeliver 
	&& (!((CBaseSplitterFilter*)m_pFilter)->IsAnyPinDrying()
		|| m_queue.GetSize() > MAXPACKETSIZE*100))
		Sleep(1);

	if(S_OK != m_hrDeliver)
		return m_hrDeliver;

	m_queue.Add(p);

	return m_hrDeliver;
}
예제 #23
0
STDMETHODIMP CWavPackSplitterFilterInputPin::BeginFlush()
{
	HRESULT hr = CBaseInputPin::BeginFlush();
	if (FAILED(hr)) {
		return hr;
	}

	if (!ThreadExists()) {
		return NOERROR;
	}

	m_bAbort = TRUE;
	CallWorker(CMD_STOP);

	return  NOERROR;
}
예제 #24
0
HRESULT CLAVOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
  HRESULT hr = S_OK;
  DbgLog((LOG_TRACE, 20, L"::DeliverNewSegment on %s Pin (rtStart: %I64d; rtStop: %I64d)", CBaseDemuxer::CStreamList::ToStringW(m_pinType), tStart, tStop));
  m_rtPrev = m_bFirstPin ? 0 : AV_NOPTS_VALUE;
  if(m_fFlushing) return S_FALSE;
  if(!ThreadExists()) return S_FALSE;

  m_BitRate.rtLastDeliverTime = Packet::INVALID_TIME;
  hr = __super::DeliverNewSegment(tStart, tStop, dRate);
  if (hr != S_OK)
    return hr;

  MakeISCRHappy();

  return hr;
}
예제 #25
0
HRESULT CLAVOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
  HRESULT hr = S_OK;
  DbgLog((LOG_TRACE, 20, L"::DeliverNewSegment on %s Pin (rtStart: %I64d; rtStop: %I64d)", CBaseDemuxer::CStreamList::ToStringW(m_pinType), tStart, tStop));
  m_rtPrev = 0;
  if(m_fFlushing) return S_FALSE;
  m_rtStart = tStart;
  if(!ThreadExists()) return S_FALSE;

  hr = __super::DeliverNewSegment(tStart, tStop, dRate);
  if (hr != S_OK)
    return hr;

  MakeISCRHappy();

  return hr;
}
HRESULT CAVISplitter::PauseThread()
{
	CAutoLock lock(&m_AccessLock);

	if (!ThreadExists()) {
		return E_UNEXPECTED;
	}

	HRESULT hr = S_OK;

	// Need to flush to ensure the thread is not blocked
	// in WaitForNext
	m_scanner.BeginFlush();
	m_thread_state = tm_pause;
	hr = CallWorker(tm_pause);
	//WriteToLog("<CAVISplitter::PauseThread> CallWorker(tm_pause)");
	m_scanner.EndFlush();
	return hr;
}
예제 #27
0
HRESULT CVideoPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
  if (m_bFlushing || !ThreadExists()) 
  {
    m_bSeekDone = true;
    return S_FALSE;
  }

  LogDebug("vid: DeliverNewSegment start: %6.3f stop: %6.3f rate: %6.3f", tStart / 10000000.0, tStop / 10000000.0, dRate);
  m_rtStart = tStart;
  m_bInitDuration = true;
  
  HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
  if (FAILED(hr))
    LogDebug("vid: DeliverNewSegment - error: %08lX", hr);

  m_bSeekDone = true;

  return hr;
}
예제 #28
0
HRESULT CBaseSplitterOutputPin::QueuePacket(CAutoPtr<Packet> p)
{
    if (!ThreadExists()) {
        return S_FALSE;
    }

    while (S_OK == m_hrDeliver
            && ((m_queue.GetCount() > (m_QueueMaxPackets * 2) || m_queue.GetSize() > (MAXPACKETSIZE * 3 / 2))
                || ((m_queue.GetCount() > m_QueueMaxPackets || m_queue.GetSize() > MAXPACKETSIZE) && !(static_cast<CBaseSplitterFilter*>(m_pFilter))->IsAnyPinDrying()))) {
        Sleep(10);
    }

    if (S_OK != m_hrDeliver) {
        return m_hrDeliver;
    }

    m_queue.Add(p);

    return m_hrDeliver;
}
예제 #29
0
DWORD
CAMThread::CallWorker(DWORD dwParam) {
    // lock access to the worker thread for scope of this object
    CAutoLock lock(&m_AccessLock);

    if(!ThreadExists()) {
        return (DWORD) E_FAIL;
    }

    // set the parameter
    m_dwParam = dwParam;

    // signal the worker thread
    m_EventSend.Set();

    // wait for the completion to be signalled
    m_EventComplete.Wait();

    // done - this is the thread's return value
    return m_dwReturnVal;
}
예제 #30
0
HRESULT CAMROutputPin::Inactive()
{
	if (!active) {
		return NOERROR;
	}
	active = FALSE;

	// destroy everything
	ev_abort.Set();
	HRESULT hr = CBaseOutputPin::Inactive();
	ASSERT(SUCCEEDED(hr));

	if (ThreadExists()) {
		CallWorker(CMD_EXIT);
		Close();
	}
	FlushQueue();
	ev_abort.Reset();

	return NOERROR;
}