void CBonSrcPin::Flush() { TRACE(TEXT("CBonSrcPin::Flush()\n")); Reset(); DeliverBeginFlush(); DeliverEndFlush(); }
void mmSource::UpdateFromSeek() { if (ThreadExists()) { DeliverBeginFlush(); Stop(); DeliverEndFlush(); Run(); } }
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(); } }
STDMETHODIMP OggDemuxFilter::Stop() { CAutoLock locLock(m_pLock); LOG(logDEBUG) << __FUNCTIONW__; CallWorker(THREAD_EXIT); Close(); DeliverBeginFlush(); //mSetIgnorePackets = true; DeliverEndFlush(); return CBaseFilter::Stop(); }
STDMETHODIMP CBaseSplitterFilter::Stop() { CAutoLock cAutoLock(this); DeliverBeginFlush(); CallWorker(CMD_EXIT); DeliverEndFlush(); HRESULT hr; if(FAILED(hr = __super::Stop())) return hr; return S_OK; }
STDMETHODIMP OggDemuxFilter::SetPositions(LONGLONG *pCurrent,DWORD dwCurrentFlags,LONGLONG *pStop,DWORD dwStopFlags) { CAutoLock locLock(m_pLock); LOG(logDEBUG3) << "IMediaSeeking::SetPositions(" << ReferenceTime(*pCurrent) << ", " << dwCurrentFlags << ", " << ReferenceTime(*pStop) << ", " << dwStopFlags << ") -> 0x" << std::hex << S_OK; if (m_seekTable == NULL || !m_seekTable->enabled()) { return E_NOTIMPL; } DeliverBeginFlush(); //Find the byte position for this time. if (*pCurrent > m_seekTable->fileDuration()) { *pCurrent = m_seekTable->fileDuration(); } else if (*pCurrent < 0) { *pCurrent = 0; } OggGranuleSeekTable::tSeekPair locStartPos = m_seekTable->seekPos(*pCurrent); //For now, seek to the position directly, later we will discard the preroll //Probably don't ever want to do this. We want to record the desired time, // and it will be up to the decoders to drop anything that falls before it. DeliverEndFlush(); DeliverNewSegment(*pCurrent, m_seekTable->fileDuration(), 1.0); // Second is the file position. SetRequestedSeekPos(locStartPos.second.first); if (CallWorker(THREAD_SEEK) == E_FAIL) { // Thread not running, we're changing the current position ourselfs SetCurrentReaderPos(GetRequestedSeekPos()); } return S_OK; }
void CSubtitleStream::UpdateFromSeek() { if (ThreadExists()) { // next time around the loop, the worker thread will // pick up the position change. // We need to flush all the existing data - we must do that here // as our thread will probably be blocked in GetBuffer otherwise m_bFlushing = TRUE; DeliverBeginFlush(); // make sure we have stopped pushing Stop(); // complete the flush DeliverEndFlush(); m_bFlushing = FALSE; // restart Run(); } }
//****************************************************** /// Called when thread is about to start delivering data to the codec /// HRESULT CVideoPin::OnThreadStartPlay() { DWORD thrdID = GetCurrentThreadId(); LogDebug("vidPin:OnThreadStartPlay(%f), rate:%02.2f, threadID:0x%x, GET_TIME_NOW:0x%x", (float)m_rtStart.Millisecs()/1000.0f, m_dRateSeeking, thrdID, GET_TIME_NOW()); //set discontinuity flag indicating to codec that the new data //is not belonging to any previous data m_bDiscontinuity=TRUE; m_bPresentSample=false; m_delayedDiscont = 0; m_FillBuffSleepTime = 1; m_LastFillBuffTime = GET_TIME_NOW(); m_sampleCount = 0; m_bInFillBuffer=false; m_pTsReaderFilter->m_ShowBufferVideo = INIT_SHOWBUFFERVIDEO; m_llLastComp = 0; m_llLastMTDts = 0; m_nNextMTD = 0; m_fMTDMean = 0; m_llMTDSumAvg = 0; ZeroMemory((void*)&m_pllMTD, sizeof(REFERENCE_TIME) * NB_MTDSIZE); //get file-duration and set m_rtDuration GetDuration(NULL); if( !m_bPinNoNewSegFlush ) //MS DTV video decoder can hang if we flush here... { //Downstream flush DeliverBeginFlush(); DeliverEndFlush(); } //start playing DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking); return CSourceStream::OnThreadStartPlay( ); }
//****************************************************** /// Called when thread is about to start delivering data to the codec /// HRESULT CAudioPin::OnThreadStartPlay() { DWORD thrdID = GetCurrentThreadId(); LogDebug("audPin:OnThreadStartPlay(%f), rate:%02.2f, threadID:0x%x, GET_TIME_NOW:0x%x", (float)m_rtStart.Millisecs()/1000.0f, m_dRateSeeking, thrdID, GET_TIME_NOW()); //set flag to compensate any differences in the stream time & file time m_pTsReaderFilter->m_bStreamCompensated = false; m_pTsReaderFilter->m_bForcePosnUpdate = true; m_pTsReaderFilter->WakeThread(); m_pTsReaderFilter->m_ShowBufferAudio = INIT_SHOWBUFFERAUDIO; //set discontinuity flag indicating to codec that the new data //is not belonging to any previous data m_bDiscontinuity = TRUE; m_bPresentSample = false; m_sampleCount = 0; m_bInFillBuffer=false; m_pTsReaderFilter->m_audioReady = false; m_FillBuffSleepTime = 1; m_LastFillBuffTime = GET_TIME_NOW(); ClearAverageFtime(); //get file-duration and set m_rtDuration GetDuration(NULL); //Downstream flush DeliverBeginFlush(); DeliverEndFlush(); //start playing DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking); return CSourceStream::OnThreadStartPlay( ); }
STDMETHODIMP FakeOutputPin::Flush () { DeliverBeginFlush(); DeliverEndFlush(); return S_OK; }
HRESULT CBaseSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags) { CAutoLock cAutoLock(this); if (!pCurrent && !pStop || (dwCurrentFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning && (dwStopFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning) { return S_OK; } REFERENCE_TIME rtCurrent = m_rtCurrent; REFERENCE_TIME rtStop = m_rtStop; if (pCurrent) switch (dwCurrentFlags & AM_SEEKING_PositioningBitsMask) { case AM_SEEKING_NoPositioning: break; case AM_SEEKING_AbsolutePositioning: rtCurrent = *pCurrent; break; case AM_SEEKING_RelativePositioning: rtCurrent = rtCurrent + *pCurrent; break; case AM_SEEKING_IncrementalPositioning: rtCurrent = rtCurrent + *pCurrent; break; } if (pStop) switch (dwStopFlags & AM_SEEKING_PositioningBitsMask) { case AM_SEEKING_NoPositioning: break; case AM_SEEKING_AbsolutePositioning: rtStop = *pStop; break; case AM_SEEKING_RelativePositioning: rtStop += *pStop; break; case AM_SEEKING_IncrementalPositioning: rtStop = rtCurrent + *pStop; break; } if (m_rtCurrent == rtCurrent && m_rtStop == rtStop) { return S_OK; } if (m_rtLastStart == rtCurrent && m_rtLastStop == rtStop && !m_LastSeekers.Find(id)) { m_LastSeekers.AddTail(id); return S_OK; } m_rtLastStart = rtCurrent; m_rtLastStop = rtStop; m_LastSeekers.RemoveAll(); m_LastSeekers.AddTail(id); DbgLog((LOG_TRACE, 0, _T("Seek Started %I64d"), rtCurrent)); m_rtNewStart = m_rtCurrent = rtCurrent; m_rtNewStop = rtStop; if (ThreadExists()) { DeliverBeginFlush(); CallWorker(CMD_SEEK); DeliverEndFlush(); } DbgLog((LOG_TRACE, 0, _T("Seek Ended"))); return S_OK; }
STDMETHODIMP CBDReaderFilter::SetPositionsInternal(void *caller, LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags) { #ifdef LOG_SEEK_INFORMATION LogDebug(" ::SetPositions() - seek request - current: %I64d; start: %I64d; stop: %I64d; flags: %ul m_bRebuildOngoing: %d m_bStopping: %d", m_rtCurrent, pCurrent ? *pCurrent : -1, pStop ? *pStop : -1, dwStopFlags, m_bRebuildOngoing, m_bStopping); #endif CAutoLock cAutoLock(this); // - Graph rebuild triggers seeking when stopping the graph - ignore, we are going to seek // to a correct position after the rebuild has been done // // - Ignore seek request when playback is stopping if (m_bRebuildOngoing || m_bStopping) { m_eSeekDone.Set(); return S_OK; } if (!pCurrent && !pStop || (dwCurrentFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning && (dwStopFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning) { m_eSeekDone.Set(); return S_OK; } REFERENCE_TIME rtCurrent = m_rtCurrent, rtStop = m_rtStop; bool fakeSeek = (dwCurrentFlags & AM_SEEKING_FakeSeek) == AM_SEEKING_FakeSeek; bool resetStreamPosition = caller == m_pVideoPin && fakeSeek; if (pCurrent) { switch(dwCurrentFlags&AM_SEEKING_PositioningBitsMask) { case AM_SEEKING_NoPositioning: break; case AM_SEEKING_AbsolutePositioning: rtCurrent = *pCurrent; break; case AM_SEEKING_RelativePositioning: rtCurrent = rtCurrent + *pCurrent; break; case AM_SEEKING_IncrementalPositioning: rtCurrent = rtCurrent + *pCurrent; break; } } if (pStop) { switch(dwStopFlags&AM_SEEKING_PositioningBitsMask) { case AM_SEEKING_NoPositioning: break; case AM_SEEKING_AbsolutePositioning: rtStop = *pStop; break; case AM_SEEKING_RelativePositioning: rtStop += *pStop; break; case AM_SEEKING_IncrementalPositioning: rtStop = rtCurrent + *pStop; break; } } // Allow consecutive fake seeks to be done to the zero position bool alreadySeekedPos = m_rtCurrent == rtCurrent && m_rtStop == rtStop && !resetStreamPosition && !m_bFirstSeek; m_bFirstSeek = false; if (alreadySeekedPos) { #ifdef LOG_SEEK_INFORMATION LogDebug(" ::SetPositions() - already seeked to pos - mark 1"); #endif m_eSeekDone.Set(); return S_OK; } if (alreadySeekedPos && m_lastSeekers.find(caller) == m_lastSeekers.end()) { #ifdef LOG_SEEK_INFORMATION LogDebug(" ::SetPositions() - already seeked to pos - mark 2"); #endif m_eSeekDone.Set(); m_lastSeekers.insert(caller); return S_OK; } m_rtLastStart = rtCurrent; m_rtLastStop = rtStop; m_lastSeekers.clear(); m_lastSeekers.insert(caller); m_rtNewStart = m_rtCurrent = rtCurrent; m_rtNewStop = rtStop; if (ThreadExists()) { m_eEndNewSegment.Reset(); DeliverBeginFlush(); CallWorker(CMD_SEEK); DeliverEndFlush(); // Do not allow new seek to happen before the old one is completed m_eEndNewSegment.Wait(); } else { #ifdef LOG_SEEK_INFORMATION LogDebug(" ::SetPositions() - no ThreadExists()"); #endif } m_eSeekDone.Set(); return S_OK; }
STDMETHODIMP VideoFakeSrcPin::Flush () { DeliverBeginFlush(); DeliverEndFlush(); return S_OK; }
//---------------------------------------------------------------------------- //! @brief シークからの変更を反映する //! @return エラーコード //---------------------------------------------------------------------------- void CDemuxSource::UpdateFromSeek() { DeliverBeginFlush(); Stop(); DeliverEndFlush(); }