A Fast Bresenham Type Algorithm For Drawing Ellipses by John Kennedy
[xy_vsfilter.git] / src / filters / BaseClasses / amextra.cpp
blob40f57ce5f7379d083b28226e9b30fe75deb65c3c
1 //------------------------------------------------------------------------------
2 // File: AMExtra.cpp
3 //
4 // Desc: DirectShow base classes - implements CRenderedInputPin class.
5 //
6 // Copyright (c) 1992-2002 Microsoft Corporation. All rights reserved.
7 //------------------------------------------------------------------------------
10 #include <streams.h> // DirectShow base class definitions
11 #include <mmsystem.h> // Needed for definition of timeGetTime
12 #include <limits.h> // Standard data type limit definitions
13 #include <measure.h> // Used for time critical log functions
15 #include "amextra.h"
17 #pragma warning(disable:4355)
19 // Implements CRenderedInputPin class
21 CRenderedInputPin::CRenderedInputPin(TCHAR *pObjectName,
22 CBaseFilter *pFilter,
23 CCritSec *pLock,
24 HRESULT *phr,
25 LPCWSTR pName) :
26 CBaseInputPin(pObjectName, pFilter, pLock, phr, pName),
27 m_bAtEndOfStream(FALSE),
28 m_bCompleteNotified(FALSE)
31 #ifdef UNICODE
32 CRenderedInputPin::CRenderedInputPin(CHAR *pObjectName,
33 CBaseFilter *pFilter,
34 CCritSec *pLock,
35 HRESULT *phr,
36 LPCWSTR pName) :
37 CBaseInputPin(pObjectName, pFilter, pLock, phr, pName),
38 m_bAtEndOfStream(FALSE),
39 m_bCompleteNotified(FALSE)
42 #endif
44 // Flush end of stream condition - caller should do any
45 // necessary stream level locking before calling this
47 STDMETHODIMP CRenderedInputPin::EndOfStream()
49 HRESULT hr = CheckStreaming();
51 // Do EC_COMPLETE handling for rendered pins
52 if (S_OK == hr && !m_bAtEndOfStream) {
53 m_bAtEndOfStream = TRUE;
54 FILTER_STATE fs;
55 EXECUTE_ASSERT(SUCCEEDED(m_pFilter->GetState(0, &fs)));
56 if (fs == State_Running) {
57 DoCompleteHandling();
60 return hr;
64 // Called to complete the flush
66 STDMETHODIMP CRenderedInputPin::EndFlush()
68 CAutoLock lck(m_pLock);
70 // Clean up renderer state
71 m_bAtEndOfStream = FALSE;
72 m_bCompleteNotified = FALSE;
74 return CBaseInputPin::EndFlush();
78 // Notify of Run() from filter
80 HRESULT CRenderedInputPin::Run(REFERENCE_TIME tStart)
82 UNREFERENCED_PARAMETER(tStart);
83 m_bCompleteNotified = FALSE;
84 if (m_bAtEndOfStream) {
85 DoCompleteHandling();
87 return S_OK;
91 // Clear status on going into paused state
93 HRESULT CRenderedInputPin::Active()
95 m_bAtEndOfStream = FALSE;
96 m_bCompleteNotified = FALSE;
97 return CBaseInputPin::Active();
101 // Do stuff to deliver end of stream
103 void CRenderedInputPin::DoCompleteHandling()
105 ASSERT(m_bAtEndOfStream);
106 if (!m_bCompleteNotified) {
107 m_bCompleteNotified = TRUE;
108 m_pFilter->NotifyEvent(EC_COMPLETE, S_OK, (LONG_PTR)(IBaseFilter *)m_pFilter);