//------------------------------------------------------------------------------ // Deliver // Attach the supplied buffer to a free media sample. Add media sample to delivery // queue so that the streaming thread can deliver the sample downstream. If there // are no free samples, all have been delivered downstream, block until one is returned // to the free list. If the streaming thread is blocked, waiting for a sample to // become available on the delivery queue, signal the thread when a new sample is added. STDMETHODIMP CCustomAllocator::Deliver(unsigned char* pBuffer) { HRESULT hr = S_OK; if (pBuffer) { CMediaSample* pSample = NULL; for (;;) { { // scope for lock CAutoLock cObjectLock(this); /* Check we are committed */ if (!m_bCommitted) { return VFW_E_NOT_COMMITTED; } pSample = (CMediaSample*)m_lFree.RemoveHead(); if (pSample == NULL) { SetWaitingFree(); } } if (pSample) { hr = pSample->SetPointer(pBuffer, m_lSize); if (SUCCEEDED(hr)) { CAutoLock cObjectLock(this); m_lDeliver.AddTail(pSample); NotifySample(); DbgLog((LOG_TRACE, DBG_MEM, TEXT("CCustomAllocator::Deliver(): m_lFree: %d m_lDeliver: %d"), m_lFree.GetCount(), m_lDeliver.GetCount())); } break; } /* If we didn't get a sample then wait for the list to signal */ ASSERT(m_hSemFree); WaitForSingleObject(m_hSemFree, INFINITE); } } else { hr = E_POINTER; } return hr; }
//---------------------------------------------------------------------------- //! @brief 要求するメモリの詳細を設定する。 //! @param pRequest : バッファ要求を含む ALLOCATOR_PROPERTIES 構造体のポインタ //! @param pActual : 実際のバッファ プロパティを受け取る ALLOCATOR_PROPERTIES 構造体のポインタ //! @return エラーコード //---------------------------------------------------------------------------- STDMETHODIMP TBufferRendererAllocator::SetProperties( ALLOCATOR_PROPERTIES* pRequest, ALLOCATOR_PROPERTIES* pActual ) { CheckPointer( pActual, E_POINTER ); ValidateReadWritePtr( pActual, sizeof(ALLOCATOR_PROPERTIES) ); CAutoLock cObjectLock(this); ZeroMemory( pActual, sizeof(ALLOCATOR_PROPERTIES) ); if( m_bCommitted == TRUE) return VFW_E_ALREADY_COMMITTED; if( m_lFree.GetCount() < m_lAllocated ) // m_lAllocatedが1個以上の時はエラーにした方がよい? return VFW_E_BUFFERS_OUTSTANDING; if( pRequest->cBuffers == 1 && pRequest->cbBuffer == m_pRenderer->GetBufferSize() && pRequest->cbAlign == 1 && pRequest->cbPrefix == 0 ) { *pActual = *pRequest; m_lSize = pRequest->cbBuffer; m_lCount = pRequest->cBuffers; m_lAlignment = pRequest->cbAlign; m_lPrefix = pRequest->cbPrefix; m_bChanged = TRUE; return S_OK; } return VFW_E_BADALIGN; }
// // Run // STDMETHODIMP CDVBSub::Run( REFERENCE_TIME tStart ) { CAutoLock cObjectLock( m_pLock ); LogDebug( "CDVBSub::Run" ); m_startTimestamp = tStart; HRESULT hr = CBaseFilter::Run( tStart ); if( hr != S_OK ) { LogDebug( "CDVBSub::Run - BaseFilter returned %i", hr ); return hr; } // Get media seeking interface if missing if( !m_pIMediaSeeking ) { IFilterGraph *pGraph = GetFilterGraph(); if( pGraph ) { pGraph->QueryInterface( &m_pIMediaSeeking ); pGraph->Release(); } } LogDebug( "CDVBSub::Run - done" ); return hr; }
STDMETHODIMP CWavPackSplitterFilter::Pause(void) { CAutoLock cObjectLock(m_pLock); // notify all pins of the change to active state if (m_State == State_Stopped) { // Order is important, the output pin allocator need to be commited // when we activate the input pin // First the output pin if (m_pOutputPin->IsConnected()) { HRESULT hr = m_pOutputPin->Active(); if (FAILED(hr)) { return hr; } } // Then the input pin if (m_pInputPin->IsConnected()) { HRESULT hr = m_pInputPin->Active(); if (FAILED(hr)) { return hr; } } } m_State = State_Paused; return S_OK; }
STDMETHODIMP CBDReaderFilter::Stop() { CAutoLock cObjectLock(m_pLock); m_bStopping = true; LogDebug("CBDReaderFilter::Stop()"); lib.SetState(State_Stopped); if (!m_bRebuildOngoing) { if (m_pSubtitlePin) m_pSubtitlePin->SetRunningStatus(false); m_demultiplexer.m_bVideoRequiresRebuild = false; m_demultiplexer.m_bAudioRequiresRebuild = false; m_demultiplexer.m_bVideoClipSeen = false; if (m_pVideoPin) m_pVideoPin->StopWait(); if (m_demultiplexer.m_eAudioClipSeen) m_demultiplexer.m_eAudioClipSeen->Set(); } LogDebug("CBDReaderFilter::Stop() -stop source"); HRESULT hr = CSource::Stop(); LogDebug("CBDReaderFilter::Stop() -stop source done"); m_bStopping = false; LogDebug("CBDReaderFilter::Stop() done"); return hr; }
//------------------------------------------------------------------------------ // GetFreeCount // STDMETHODIMP CCustomAllocator::GetFreeCount(LONG* plBuffersFree) { ASSERT(m_fEnableReleaseCallback); CAutoLock cObjectLock(this); *plBuffersFree = m_lCount - m_lAllocated + m_lFree.GetCount(); return NOERROR; }
// // Run // // Overriden to open the dump file // STDMETHODIMP CMpTsFilter::Run(REFERENCE_TIME tStart) { LogDebug("CMpTsFilter::Run()"); CAutoLock cObjectLock(m_pLock); return CBaseFilter::Run(tStart); }
STDMETHODIMP CTransInPlaceInputPin::GetAllocator(IMemAllocator ** ppAllocator) { CheckPointer(ppAllocator,E_POINTER); ValidateReadWritePtr(ppAllocator,sizeof(IMemAllocator *)); CAutoLock cObjectLock(m_pLock); HRESULT hr; if ( m_pTIPFilter->m_pOutput->IsConnected() ) { // Store the allocator we got hr = m_pTIPFilter->OutputPin()->ConnectedIMemInputPin() ->GetAllocator( ppAllocator ); if (SUCCEEDED(hr)) { m_pTIPFilter->OutputPin()->SetAllocator( *ppAllocator ); } } else { // Help upstream filter (eg TIP filter which is having to do a copy) // by providing a temp allocator here - we'll never use // this allocator because when our output is connected we'll // reconnect this pin hr = CTransformInputPin::GetAllocator( ppAllocator ); } return hr; } // GetAllocator
STDMETHODIMP CTTASplitter::Pause(void) { CAutoLock cObjectLock(m_pLock); if (m_State == State_Stopped) { if (m_pOutputPin->IsConnected()) { HRESULT hr = m_pOutputPin->Active(); if (FAILED(hr)) { return hr; } } if (m_pInputPin->IsConnected()) { HRESULT hr = m_pInputPin->Active(); if (FAILED(hr)) { return hr; } } } m_State = State_Paused; return S_OK; }
int CDictionary::Load(LOADINFO* pInfo) { CAutoLock cObjectLock(this); if (!pInfo) { return E_FAIL; } if (IsLoaded(pInfo->pDictionaryName)) { return S_OK; } CSubDictionary* pSD = new CSubDictionary(pInfo->pDictionaryName); AssertValid(pSD); if (pSD->Load(pInfo) != S_OK) { delete pSD; Log("Can't load %s\n", pInfo->pDictionaryName); return E_FAIL; } m_vecDicts.push_back(pSD); Log("Load %s successful!\n", pInfo->pDictionaryName); return S_OK; }
// // Pause // STDMETHODIMP CDVBSub::Pause() { CAutoLock cObjectLock( m_pLock ); LogDebug( "CDVBSub::Pause" ); HRESULT hr = CBaseFilter::Pause(); LogDebug( "CDVBSub::Pause - done" ); return hr; }
// // Stop // // Overriden to close the dump file // STDMETHODIMP CNetworkProviderFilter::Stop() { CAutoLock cObjectLock(m_pLock); LOG4CPLUS_DEBUG(logger,"CNetworkProviderFilter::Stop()"); HRESULT result = CBaseFilter::Stop(); LOG4CPLUS_DEBUG(logger,"CNetworkProviderFilter::Stop() completed"); return result; }
STDMETHODIMP CBasePin::SetSink(IQualityControl * piqc) { CComAutoLock cObjectLock(m_pLock); if (piqc) ValidateReadPtr(piqc,sizeof(IQualityControl)); m_pQSink = piqc; return NOERROR; } // SetSink
// Run // // the start parameter is the difference to be added to the // sample's stream time to get the reference time for // its presentation STDMETHODIMP CWasapiFilter::Run(REFERENCE_TIME tStart) { bStarted=true; DebugPrintf(L"CWasapiFilter::Run \n"); CAutoLock cObjectLock(m_pLock); HRESULT hr=CBaseFilter::Run(tStart); m_pManager->StartRendering(); return hr; }
// // Stop // // Overriden to close the dump file // STDMETHODIMP CDumpFilter::Stop() { CAutoLock cObjectLock(m_pLock); if (m_pDump) m_pDump->CloseFile(); return CBaseFilter::Stop(); }
// // Run // // Overriden to open the dump file // STDMETHODIMP EMReadFrameFilter::Run(REFERENCE_TIME tStart) { IReferenceClock *pClock = m_pClock; CAutoLock cObjectLock(m_pLock); CRefTime agnusStreamTimeObject; StreamTime(agnusStreamTimeObject); long millisekunder = agnusStreamTimeObject.Millisecs(); return CBaseFilter::Run(tStart); }
// // Run // // Overriden to open the dump file // STDMETHODIMP CNetworkProviderFilter::Run(REFERENCE_TIME tStart) { LOG4CPLUS_DEBUG(logger,"CNetworkProviderFilter::Run()"); CAutoLock cObjectLock(m_pLock); if(m_pNetworkProvider!=NULL){ m_pNetworkProvider->Retune(); } return CBaseFilter::Run(tStart); }
// // Pause // // Overriden to open the dump file // STDMETHODIMP CNetworkProviderFilter::Pause() { LOG4CPLUS_DEBUG(logger,"CNetworkProviderFilter::Pause()"); CAutoLock cObjectLock(m_pLock); if (m_pNetworkProvider != NULL){ } LOG4CPLUS_DEBUG(logger,"CNetworkProviderFilter::Pause() finished"); return CBaseFilter::Pause(); }
STDMETHODIMP CMPEGFilter::Stop() { TraceVerbose("Entered CMPEGFilter::Stop\n"); CAutoLock cObjectLock(m_pLock); HRESULT hr = m_pMPEGObj->Stop(); hr = CBaseFilter::Stop(); TraceVerbose("Exited CMPEGFilter::Stop\n"); return hr; }
HRESULT CSyncClock::Reset(REFERENCE_TIME tStart) { CAutoLock cObjectLock(this); m_SynchCorrection.Reset(m_dBias, tStart); m_SynchCorrection.SetPresenterInducedAudioDelay(m_dEVRDelay); m_bDiscontinuity = true; return S_OK; }
STDMETHODIMP CWasapiFilter::Stop() { bStarted=false; DebugPrintf(L"CWasapiFilter::Stop \n"); CAutoLock cObjectLock(m_pLock); m_pManager->StopRendering(true,false); HRESULT hr=CBaseFilter::Stop(); return hr; }
STDMETHODIMP CWasapiFilter::Pause() { DebugPrintf(L"CWasapiFilter::Pause \n"); CAutoLock cObjectLock(m_pLock); HRESULT hr=CBaseFilter::Pause(); m_pManager->PauseRendering(); DebugPrintf(L"CWasapiFilter::Pause returning\n"); bStarted=false; return hr; }
//------------------------------------------------------------------------------ // IDecklinkPushSource2 interface //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // GetFrameBuffer // Provide the caller with a free media sample. If there are no free samples, // all have been delivered downstream, block until one is returned to the free list. STDMETHODIMP CCustomAllocator::GetFrameBuffer(IMediaSample** ppSample) { HRESULT hr = S_OK; if (ppSample) { CAutoLock lck(this); unsigned char* pBuffer = m_lBuffers.RemoveHead(); // retrieve a frame buffer if (pBuffer) { // attempt to retrieve a free media sample CMediaSample* pSample = NULL; for (;;) { { // scope for lock CAutoLock cObjectLock(this); /* Check we are committed */ if (!m_bCommitted) { return VFW_E_NOT_COMMITTED; } pSample = (CMediaSample*)m_lFree.RemoveHead(); if (pSample == NULL) { SetWaitingFree(); } } if (pSample) { // return the sample to the caller hr = pSample->SetPointer(pBuffer, m_lSize); *ppSample = pSample; break; } /* If we didn't get a sample then wait for the list to signal */ ASSERT(m_hSemFree); WaitForSingleObject(m_hSemFree, INFINITE); } } else { hr = E_FAIL; } } else { hr = E_POINTER; } return hr; }
HRESULT CBaseReferenceClock::GetDefaultTimerResolution( __out REFERENCE_TIME* pTimerResolution // in 100ns ) { if( !pTimerResolution ) { return E_POINTER; } CAutoLock cObjectLock(this); *pTimerResolution = m_TimerResolution * 10000; return S_OK; }
STDMETHODIMP CBasePin::Disconnect() { CComAutoLock cObjectLock(m_pLock); /* See if the filter is active */ if (!IsStopped()) { return VFW_E_NOT_STOPPED; } return DisconnectInternal(); }
STDMETHODIMP CBDReaderFilter::Pause() { LogDebug("CBDReaderFilter::Pause() - state = %d", m_State); CAutoLock cObjectLock(m_pLock); lib.SetState(State_Paused); HRESULT hr = CSource::Pause(); LogDebug("CBDReaderFilter::Pause() - END - state = %d", m_State); return hr; }
// // Pause // // Overriden to handle no input connections // STDMETHODIMP CTee::Pause() { CAutoLock cObjectLock(m_pLock); HRESULT hr = CBaseFilter::Pause(); if (m_Input.IsConnected() == FALSE) { m_Input.EndOfStream(); } return hr; }
// // Run // // Overriden to handle no input connections // STDMETHODIMP CTee::Run(REFERENCE_TIME tStart) { CAutoLock cObjectLock(m_pLock); HRESULT hr = CBaseFilter::Run(tStart); if (m_Input.IsConnected() == FALSE) { m_Input.EndOfStream(); } return hr; }
//------------------------------------------------------------------------------ // GetBuffer // get container for a sample. Blocking, synchronous call to get the // next free buffer (as represented by an IMediaSample interface). // on return, the time etc properties will be invalid and in this case // the buffer pointer and size will be set when the app returns a buffer. HRESULT CCustomAllocator::GetBuffer(IMediaSample** ppBuffer, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags) { UNREFERENCED_PARAMETER(pStartTime); UNREFERENCED_PARAMETER(pEndTime); UNREFERENCED_PARAMETER(dwFlags); CMediaSample* pSample; *ppBuffer = NULL; for (;;) { { // scope for lock CAutoLock cObjectLock(this); /* Check we are committed */ if (!m_bCommitted) { return VFW_E_NOT_COMMITTED; } pSample = (CMediaSample*)m_lDeliver.RemoveHead(); if (pSample == NULL) { SetWaiting(); } } /* If we didn't get a sample then wait for the list to signal */ if (pSample) { break; } if (dwFlags & AM_GBF_NOWAIT) { return VFW_E_TIMEOUT; } ASSERT(m_hSem != NULL); WaitForSingleObject(m_hSem, INFINITE); } /* Addref the buffer up to one. On release back to zero instead of being deleted, it will requeue itself by calling the ReleaseBuffer member function. NOTE the owner of a media sample must always be derived from CBaseAllocator */ ASSERT(pSample->m_cRef == 0); pSample->m_cRef = 1; *ppBuffer = pSample; DbgLog((LOG_TRACE, DBG_MEM, TEXT("CCustomAllocator::GetBuffer(): m_lFree: %d m_lDeliver: %d"), m_lFree.GetCount(), m_lDeliver.GetCount())); return NOERROR; }
STDMETHODIMP CBaseReferenceClock::SetTimeDelta(const REFERENCE_TIME & TimeDelta) { #ifdef DEBUG // Just break if passed an improper time delta value LONGLONG llDelta = TimeDelta > 0 ? TimeDelta : -TimeDelta; if (llDelta > UNITS * 1000) { DbgLog((LOG_TRACE, 0, TEXT("Bad Time Delta"))); //DebugBreak(); } // We're going to calculate a "severity" for the time change. Max -1 // min 8. We'll then use this as the debug logging level for a // debug log message. const LONG usDelta = LONG(TimeDelta/10); // Delta in micro-secs DWORD delta = abs(usDelta); // varying delta // Severity == 8 - ceil(log<base 8>(abs( micro-secs delta))) int Severity = 8; while ( delta > 0 ) { delta >>= 3; // div 8 Severity--; } // Sev == 0 => > 2 second delta! DbgLog((LOG_TIMING, Severity < 0 ? 0 : Severity, TEXT("Sev %2i: CSystemClock::SetTimeDelta(%8ld us) %lu -> %lu ms."), Severity, usDelta, DWORD(ConvertToMilliseconds(m_rtPrivateTime)), DWORD(ConvertToMilliseconds(TimeDelta+m_rtPrivateTime)) )); // Don't want the DbgBreak to fire when running stress on debug-builds. #ifdef BREAK_ON_SEVERE_TIME_DELTA if (Severity < 0) DbgBreakPoint(TEXT("SetTimeDelta > 16 seconds!"), TEXT(__FILE__),__LINE__); #endif #endif CAutoLock cObjectLock(this); m_rtPrivateTime += TimeDelta; // If time goes forwards, and we have advises, then we need to // trigger the thread so that it can re-evaluate its wait time. // Since we don't want the cost of the thread switches if the change // is really small, only do it if clock goes forward by more than // 0.5 millisecond. If the time goes backwards, the thread will // wake up "early" (relativly speaking) and will re-evaluate at // that time. if ( TimeDelta > 5000 && m_pSchedule->GetAdviseCount() > 0 ) TriggerThread(); return NOERROR; }