Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortetsuo55 <tetsuo55@users.sourceforge.net>2010-04-09 01:14:58 +0400
committertetsuo55 <tetsuo55@users.sourceforge.net>2010-04-09 01:14:58 +0400
commita9b7bf3fb3e1334d8defd05ca4cfae870b4912e5 (patch)
tree2dab453d94d5e003379a6cc895eceb84c80e23ec /src/filters/BaseClasses
parentaafd49a91f7c2fa9c7103971c16fa6e1b29e8bfd (diff)
astyle formatting cleanup to make the sourcecode more accessible
switch used: astyle --style=ansi --min-conditional-indent=0 --pad=oper --unpad=paren http://astyle.sourceforge.net/ git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1783 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/BaseClasses')
-rw-r--r--src/filters/BaseClasses/amextra.cpp12
-rw-r--r--src/filters/BaseClasses/amextra.h2
-rw-r--r--src/filters/BaseClasses/amfilter.cpp2053
-rw-r--r--src/filters/BaseClasses/amfilter.h229
-rw-r--r--src/filters/BaseClasses/amvideo.cpp117
-rw-r--r--src/filters/BaseClasses/arithutil.cpp167
-rw-r--r--src/filters/BaseClasses/cache.h10
-rw-r--r--src/filters/BaseClasses/checkbmi.h164
-rw-r--r--src/filters/BaseClasses/combase.cpp88
-rw-r--r--src/filters/BaseClasses/combase.h37
-rw-r--r--src/filters/BaseClasses/cprop.cpp167
-rw-r--r--src/filters/BaseClasses/cprop.h46
-rw-r--r--src/filters/BaseClasses/ctlutil.cpp1712
-rw-r--r--src/filters/BaseClasses/ctlutil.h366
-rw-r--r--src/filters/BaseClasses/ddmm.cpp175
-rw-r--r--src/filters/BaseClasses/ddmm.h10
-rw-r--r--src/filters/BaseClasses/dllentry.cpp211
-rw-r--r--src/filters/BaseClasses/dllsetup.cpp957
-rw-r--r--src/filters/BaseClasses/dllsetup.h10
-rw-r--r--src/filters/BaseClasses/dxmperf.h24
-rw-r--r--src/filters/BaseClasses/fourcc.h8
-rw-r--r--src/filters/BaseClasses/measure.h26
-rw-r--r--src/filters/BaseClasses/msgthrd.h55
-rw-r--r--src/filters/BaseClasses/mtype.cpp193
-rw-r--r--src/filters/BaseClasses/mtype.h38
-rw-r--r--src/filters/BaseClasses/outputq.cpp406
-rw-r--r--src/filters/BaseClasses/outputq.h29
-rw-r--r--src/filters/BaseClasses/perflog.cpp182
-rw-r--r--src/filters/BaseClasses/perflog.h23
-rw-r--r--src/filters/BaseClasses/perfstruct.h76
-rw-r--r--src/filters/BaseClasses/pstream.cpp72
-rw-r--r--src/filters/BaseClasses/pstream.h89
-rw-r--r--src/filters/BaseClasses/pullpin.cpp569
-rw-r--r--src/filters/BaseClasses/pullpin.h50
-rw-r--r--src/filters/BaseClasses/refclock.cpp153
-rw-r--r--src/filters/BaseClasses/refclock.h22
-rw-r--r--src/filters/BaseClasses/renbase.cpp963
-rw-r--r--src/filters/BaseClasses/renbase.h100
-rw-r--r--src/filters/BaseClasses/schedule.cpp138
-rw-r--r--src/filters/BaseClasses/schedule.h29
-rw-r--r--src/filters/BaseClasses/seekpt.cpp65
-rw-r--r--src/filters/BaseClasses/source.cpp326
-rw-r--r--src/filters/BaseClasses/source.h70
-rw-r--r--src/filters/BaseClasses/streams.h68
-rw-r--r--src/filters/BaseClasses/strmctl.cpp327
-rw-r--r--src/filters/BaseClasses/strmctl.h71
-rw-r--r--src/filters/BaseClasses/sysclock.cpp17
-rw-r--r--src/filters/BaseClasses/transfrm.cpp386
-rw-r--r--src/filters/BaseClasses/transfrm.h42
-rw-r--r--src/filters/BaseClasses/transip.cpp405
-rw-r--r--src/filters/BaseClasses/transip.h34
-rw-r--r--src/filters/BaseClasses/videoctl.cpp261
-rw-r--r--src/filters/BaseClasses/videoctl.h72
-rw-r--r--src/filters/BaseClasses/vtrans.cpp270
-rw-r--r--src/filters/BaseClasses/vtrans.h13
-rw-r--r--src/filters/BaseClasses/winctrl.cpp825
-rw-r--r--src/filters/BaseClasses/winctrl.h67
-rw-r--r--src/filters/BaseClasses/winutil.cpp716
-rw-r--r--src/filters/BaseClasses/winutil.h47
-rw-r--r--src/filters/BaseClasses/wxdebug.cpp979
-rw-r--r--src/filters/BaseClasses/wxdebug.h265
-rw-r--r--src/filters/BaseClasses/wxlist.cpp168
-rw-r--r--src/filters/BaseClasses/wxlist.h228
-rw-r--r--src/filters/BaseClasses/wxutil.cpp401
-rw-r--r--src/filters/BaseClasses/wxutil.h219
65 files changed, 9324 insertions, 6796 deletions
diff --git a/src/filters/BaseClasses/amextra.cpp b/src/filters/BaseClasses/amextra.cpp
index af0de96d1..d0bbcd429 100644
--- a/src/filters/BaseClasses/amextra.cpp
+++ b/src/filters/BaseClasses/amextra.cpp
@@ -49,11 +49,13 @@ STDMETHODIMP CRenderedInputPin::EndOfStream()
HRESULT hr = CheckStreaming();
// Do EC_COMPLETE handling for rendered pins
- if (S_OK == hr && !m_bAtEndOfStream) {
+ if(S_OK == hr && !m_bAtEndOfStream)
+ {
m_bAtEndOfStream = TRUE;
FILTER_STATE fs;
EXECUTE_ASSERT(SUCCEEDED(m_pFilter->GetState(0, &fs)));
- if (fs == State_Running) {
+ if(fs == State_Running)
+ {
DoCompleteHandling();
}
}
@@ -81,7 +83,8 @@ HRESULT CRenderedInputPin::Run(REFERENCE_TIME tStart)
{
UNREFERENCED_PARAMETER(tStart);
m_bCompleteNotified = FALSE;
- if (m_bAtEndOfStream) {
+ if(m_bAtEndOfStream)
+ {
DoCompleteHandling();
}
return S_OK;
@@ -103,7 +106,8 @@ HRESULT CRenderedInputPin::Active()
void CRenderedInputPin::DoCompleteHandling()
{
ASSERT(m_bAtEndOfStream);
- if (!m_bCompleteNotified) {
+ if(!m_bCompleteNotified)
+ {
m_bCompleteNotified = TRUE;
m_pFilter->NotifyEvent(EC_COMPLETE, S_OK, (LONG_PTR)(IBaseFilter *)m_pFilter);
}
diff --git a/src/filters/BaseClasses/amextra.h b/src/filters/BaseClasses/amextra.h
index 5a861bf12..07bf71789 100644
--- a/src/filters/BaseClasses/amextra.h
+++ b/src/filters/BaseClasses/amextra.h
@@ -34,7 +34,7 @@ public:
__inout HRESULT *phr,
__in_opt LPCWSTR pName);
#endif
-
+
// Override methods to track end of stream state
STDMETHODIMP EndOfStream();
STDMETHODIMP EndFlush();
diff --git a/src/filters/BaseClasses/amfilter.cpp b/src/filters/BaseClasses/amfilter.cpp
index e3c7fa658..e0df540c5 100644
--- a/src/filters/BaseClasses/amfilter.cpp
+++ b/src/filters/BaseClasses/amfilter.cpp
@@ -64,19 +64,22 @@ STDAPI CreatePosPassThru(
IID_IUnknown,
(void **)&pUnkSeek
);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
ISeekingPassThru *pPassThru;
hr = pUnkSeek->QueryInterface(IID_ISeekingPassThru, (void**)&pPassThru);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
pUnkSeek->Release();
return hr;
}
hr = pPassThru->Init(bRenderer, pPin);
pPassThru->Release();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
pUnkSeek->Release();
return hr;
}
@@ -98,9 +101,9 @@ STDAPI CreatePosPassThru(
/* Constructor */
CBaseMediaFilter::CBaseMediaFilter(__in_opt LPCTSTR pName,
- __inout_opt LPUNKNOWN pUnk,
- __in CCritSec *pLock,
- REFCLSID clsid) :
+ __inout_opt LPUNKNOWN pUnk,
+ __in CCritSec *pLock,
+ REFCLSID clsid) :
CUnknown(pName, pUnk),
m_pLock(pLock),
m_clsid(clsid),
@@ -119,7 +122,8 @@ CBaseMediaFilter::~CBaseMediaFilter()
/* Release any clock we were using */
- if (m_pClock) {
+ if(m_pClock)
+ {
m_pClock->Release();
m_pClock = NULL;
}
@@ -133,11 +137,16 @@ CBaseMediaFilter::NonDelegatingQueryInterface(
REFIID riid,
__deref_out void ** ppv)
{
- if (riid == IID_IMediaFilter) {
+ if(riid == IID_IMediaFilter)
+ {
return GetInterface((IMediaFilter *) this, ppv);
- } else if (riid == IID_IPersist) {
+ }
+ else if(riid == IID_IPersist)
+ {
return GetInterface((IPersist *) this, ppv);
- } else {
+ }
+ else
+ {
return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -146,8 +155,8 @@ CBaseMediaFilter::NonDelegatingQueryInterface(
STDMETHODIMP
CBaseMediaFilter::GetClassID(__out CLSID *pClsID)
{
- CheckPointer(pClsID,E_POINTER);
- ValidateReadWritePtr(pClsID,sizeof(CLSID));
+ CheckPointer(pClsID, E_POINTER);
+ ValidateReadWritePtr(pClsID, sizeof(CLSID));
*pClsID = m_clsid;
return NOERROR;
}
@@ -158,8 +167,8 @@ STDMETHODIMP
CBaseMediaFilter::GetState(DWORD dwMSecs, __out FILTER_STATE *State)
{
UNREFERENCED_PARAMETER(dwMSecs);
- CheckPointer(State,E_POINTER);
- ValidateReadWritePtr(State,sizeof(FILTER_STATE));
+ CheckPointer(State, E_POINTER);
+ ValidateReadWritePtr(State, sizeof(FILTER_STATE));
*State = m_State;
return S_OK;
@@ -174,12 +183,14 @@ CBaseMediaFilter::SetSyncSource(__inout_opt IReferenceClock *pClock)
CAutoLock cObjectLock(m_pLock);
// Ensure the new one does not go away - even if the same as the old
- if (pClock) {
+ if(pClock)
+ {
pClock->AddRef();
}
// if we have a clock, release it
- if (m_pClock) {
+ if(m_pClock)
+ {
m_pClock->Release();
}
@@ -194,11 +205,12 @@ CBaseMediaFilter::SetSyncSource(__inout_opt IReferenceClock *pClock)
STDMETHODIMP
CBaseMediaFilter::GetSyncSource(__deref_out_opt IReferenceClock **pClock)
{
- CheckPointer(pClock,E_POINTER);
- ValidateReadWritePtr(pClock,sizeof(IReferenceClock *));
+ CheckPointer(pClock, E_POINTER);
+ ValidateReadWritePtr(pClock, sizeof(IReferenceClock *));
CAutoLock cObjectLock(m_pLock);
- if (m_pClock) {
+ if(m_pClock)
+ {
// returning an interface... addref it...
m_pClock->AddRef();
}
@@ -248,10 +260,12 @@ CBaseMediaFilter::Run(REFERENCE_TIME tStart)
// remember the stream time offset
m_tStart = tStart;
- if (m_State == State_Stopped){
+ if(m_State == State_Stopped)
+ {
HRESULT hr = Pause();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
}
@@ -270,13 +284,15 @@ CBaseMediaFilter::StreamTime(CRefTime& rtStream)
// We can't grab the filter lock because we want to be able to call
// this from worker threads without deadlocking
- if (m_pClock == NULL) {
+ if(m_pClock == NULL)
+ {
return VFW_E_NO_CLOCK;
}
// get the current reference time
HRESULT hr = m_pClock->GetTime((REFERENCE_TIME*)&rtStream);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -297,19 +313,28 @@ CBaseMediaFilter::StreamTime(CRefTime& rtStream)
/* Override this to say what interfaces we support and where */
STDMETHODIMP CBaseFilter::NonDelegatingQueryInterface(REFIID riid,
- __deref_out void **ppv)
+ __deref_out void **ppv)
{
/* Do we have this interface */
- if (riid == IID_IBaseFilter) {
+ if(riid == IID_IBaseFilter)
+ {
return GetInterface((IBaseFilter *) this, ppv);
- } else if (riid == IID_IMediaFilter) {
+ }
+ else if(riid == IID_IMediaFilter)
+ {
return GetInterface((IMediaFilter *) this, ppv);
- } else if (riid == IID_IPersist) {
+ }
+ else if(riid == IID_IPersist)
+ {
return GetInterface((IPersist *) this, ppv);
- } else if (riid == IID_IAMovieSetup) {
+ }
+ else if(riid == IID_IAMovieSetup)
+ {
return GetInterface((IAMovieSetup *) this, ppv);
- } else {
+ }
+ else
+ {
return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -317,7 +342,8 @@ STDMETHODIMP CBaseFilter::NonDelegatingQueryInterface(REFIID riid,
#ifdef _DEBUG
STDMETHODIMP_(ULONG) CBaseFilter::NonDelegatingRelease()
{
- if (m_cRef == 1) {
+ if(m_cRef == 1)
+ {
KASSERT(m_pGraph == NULL);
}
return CUnknown::NonDelegatingRelease();
@@ -328,10 +354,10 @@ STDMETHODIMP_(ULONG) CBaseFilter::NonDelegatingRelease()
/* Constructor */
CBaseFilter::CBaseFilter(__in_opt LPCTSTR pName,
- __inout_opt LPUNKNOWN pUnk,
- __in CCritSec *pLock,
- REFCLSID clsid) :
- CUnknown( pName, pUnk ),
+ __inout_opt LPUNKNOWN pUnk,
+ __in CCritSec *pLock,
+ REFCLSID clsid) :
+ CUnknown(pName, pUnk),
m_pLock(pLock),
m_clsid(clsid),
m_State(State_Stopped),
@@ -342,7 +368,7 @@ CBaseFilter::CBaseFilter(__in_opt LPCTSTR pName,
m_PinVersion(1)
{
#ifdef DXMPERF
- PERFLOG_CTOR( pName ? pName : L"CBaseFilter", (IBaseFilter *) this );
+ PERFLOG_CTOR(pName ? pName : L"CBaseFilter", (IBaseFilter *) this);
#endif // DXMPERF
ASSERT(pLock != NULL);
@@ -355,7 +381,7 @@ CBaseFilter::CBaseFilter(__in_opt LPCTSTR pName,
__in CCritSec *pLock,
REFCLSID clsid,
__inout HRESULT *phr) :
- CUnknown( pName, pUnk ),
+ CUnknown(pName, pUnk),
m_pLock(pLock),
m_clsid(clsid),
m_State(State_Stopped),
@@ -366,7 +392,7 @@ CBaseFilter::CBaseFilter(__in_opt LPCTSTR pName,
m_PinVersion(1)
{
#ifdef DXMPERF
- PERFLOG_CTOR( pName ? pName : L"CBaseFilter", (IBaseFilter *) this );
+ PERFLOG_CTOR(pName ? pName : L"CBaseFilter", (IBaseFilter *) this);
#endif // DXMPERF
ASSERT(pLock != NULL);
@@ -375,10 +401,10 @@ CBaseFilter::CBaseFilter(__in_opt LPCTSTR pName,
#ifdef UNICODE
CBaseFilter::CBaseFilter(__in_opt LPCSTR pName,
- __in_opt LPUNKNOWN pUnk,
- __in CCritSec *pLock,
- REFCLSID clsid) :
- CUnknown( pName, pUnk ),
+ __in_opt LPUNKNOWN pUnk,
+ __in CCritSec *pLock,
+ REFCLSID clsid) :
+ CUnknown(pName, pUnk),
m_pLock(pLock),
m_clsid(clsid),
m_State(State_Stopped),
@@ -389,7 +415,7 @@ CBaseFilter::CBaseFilter(__in_opt LPCSTR pName,
m_PinVersion(1)
{
#ifdef DXMPERF
- PERFLOG_CTOR( L"CBaseFilter", (IBaseFilter *) this );
+ PERFLOG_CTOR(L"CBaseFilter", (IBaseFilter *) this);
#endif // DXMPERF
ASSERT(pLock != NULL);
@@ -399,7 +425,7 @@ CBaseFilter::CBaseFilter(__in_opt LPCSTR pName,
__in CCritSec *pLock,
REFCLSID clsid,
__inout HRESULT *phr) :
- CUnknown( pName, pUnk ),
+ CUnknown(pName, pUnk),
m_pLock(pLock),
m_clsid(clsid),
m_State(State_Stopped),
@@ -410,7 +436,7 @@ CBaseFilter::CBaseFilter(__in_opt LPCSTR pName,
m_PinVersion(1)
{
#ifdef DXMPERF
- PERFLOG_CTOR( L"CBaseFilter", (IBaseFilter *) this );
+ PERFLOG_CTOR(L"CBaseFilter", (IBaseFilter *) this);
#endif // DXMPERF
ASSERT(pLock != NULL);
@@ -423,7 +449,7 @@ CBaseFilter::CBaseFilter(__in_opt LPCSTR pName,
CBaseFilter::~CBaseFilter()
{
#ifdef DXMPERF
- PERFLOG_DTOR( L"CBaseFilter", (IBaseFilter *) this );
+ PERFLOG_DTOR(L"CBaseFilter", (IBaseFilter *) this);
#endif // DXMPERF
// NOTE we do NOT hold references on the filtergraph for m_pGraph or m_pSink
@@ -435,7 +461,8 @@ CBaseFilter::~CBaseFilter()
// our critsec has been destroyed.
/* Release any clock we were using */
- if (m_pClock) {
+ if(m_pClock)
+ {
m_pClock->Release();
m_pClock = NULL;
}
@@ -445,8 +472,8 @@ CBaseFilter::~CBaseFilter()
STDMETHODIMP
CBaseFilter::GetClassID(__out CLSID *pClsID)
{
- CheckPointer(pClsID,E_POINTER);
- ValidateReadWritePtr(pClsID,sizeof(CLSID));
+ CheckPointer(pClsID, E_POINTER);
+ ValidateReadWritePtr(pClsID, sizeof(CLSID));
*pClsID = m_clsid;
return NOERROR;
}
@@ -456,8 +483,8 @@ STDMETHODIMP
CBaseFilter::GetState(DWORD dwMSecs, __out FILTER_STATE *State)
{
UNREFERENCED_PARAMETER(dwMSecs);
- CheckPointer(State,E_POINTER);
- ValidateReadWritePtr(State,sizeof(FILTER_STATE));
+ CheckPointer(State, E_POINTER);
+ ValidateReadWritePtr(State, sizeof(FILTER_STATE));
*State = m_State;
return S_OK;
@@ -472,12 +499,14 @@ CBaseFilter::SetSyncSource(__in_opt IReferenceClock *pClock)
CAutoLock cObjectLock(m_pLock);
// Ensure the new one does not go away - even if the same as the old
- if (pClock) {
+ if(pClock)
+ {
pClock->AddRef();
}
// if we have a clock, release it
- if (m_pClock) {
+ if(m_pClock)
+ {
m_pClock->Release();
}
@@ -492,11 +521,12 @@ CBaseFilter::SetSyncSource(__in_opt IReferenceClock *pClock)
STDMETHODIMP
CBaseFilter::GetSyncSource(__deref_out_opt IReferenceClock **pClock)
{
- CheckPointer(pClock,E_POINTER);
- ValidateReadWritePtr(pClock,sizeof(IReferenceClock *));
+ CheckPointer(pClock, E_POINTER);
+ ValidateReadWritePtr(pClock, sizeof(IReferenceClock *));
CAutoLock cObjectLock(m_pLock);
- if (m_pClock) {
+ if(m_pClock)
+ {
// returning an interface... addref it...
m_pClock->AddRef();
}
@@ -515,12 +545,15 @@ CBaseFilter::Stop()
HRESULT hr = NOERROR;
// notify all pins of the state change
- if (m_State != State_Stopped) {
+ if(m_State != State_Stopped)
+ {
int cPins = GetPinCount();
- for (int c = 0; c < cPins; c++) {
+ for(int c = 0; c < cPins; c++)
+ {
CBasePin *pPin = GetPin(c);
- if (NULL == pPin) {
+ if(NULL == pPin)
+ {
break;
}
@@ -530,9 +563,11 @@ CBaseFilter::Stop()
// class can return an error if it has no allocator but Stop can
// be used to resync the graph state after something has gone bad
- if (pPin->IsConnected()) {
+ if(pPin->IsConnected())
+ {
HRESULT hrTmp = pPin->Inactive();
- if (FAILED(hrTmp) && SUCCEEDED(hr)) {
+ if(FAILED(hrTmp) && SUCCEEDED(hr))
+ {
hr = hrTmp;
}
}
@@ -540,7 +575,7 @@ CBaseFilter::Stop()
}
#ifdef DXMPERF
- PERFLOG_STOP( m_pName ? m_pName : L"CBaseFilter", (IBaseFilter *) this, m_State );
+ PERFLOG_STOP(m_pName ? m_pName : L"CBaseFilter", (IBaseFilter *) this, m_State);
#endif // DXMPERF
m_State = State_Stopped;
@@ -557,21 +592,26 @@ CBaseFilter::Pause()
CAutoLock cObjectLock(m_pLock);
// notify all pins of the change to active state
- if (m_State == State_Stopped) {
+ if(m_State == State_Stopped)
+ {
int cPins = GetPinCount();
- for (int c = 0; c < cPins; c++) {
+ for(int c = 0; c < cPins; c++)
+ {
CBasePin *pPin = GetPin(c);
- if (NULL == pPin) {
+ if(NULL == pPin)
+ {
break;
}
// Disconnected pins are not activated - this saves pins
// worrying about this state themselves
- if (pPin->IsConnected()) {
+ if(pPin->IsConnected())
+ {
HRESULT hr = pPin->Active();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
}
@@ -580,7 +620,7 @@ CBaseFilter::Pause()
#ifdef DXMPERF
- PERFLOG_PAUSE( m_pName ? m_pName : L"CBaseFilter", (IBaseFilter *) this, m_State );
+ PERFLOG_PAUSE(m_pName ? m_pName : L"CBaseFilter", (IBaseFilter *) this, m_State);
#endif // DXMPERF
m_State = State_Paused;
@@ -604,29 +644,36 @@ CBaseFilter::Run(REFERENCE_TIME tStart)
// remember the stream time offset
m_tStart = tStart;
- if (m_State == State_Stopped){
- HRESULT hr = Pause();
+ if(m_State == State_Stopped)
+ {
+ HRESULT hr = Pause();
- if (FAILED(hr)) {
- return hr;
- }
+ if(FAILED(hr))
+ {
+ return hr;
+ }
}
// notify all pins of the change to active state
- if (m_State != State_Running) {
+ if(m_State != State_Running)
+ {
int cPins = GetPinCount();
- for (int c = 0; c < cPins; c++) {
+ for(int c = 0; c < cPins; c++)
+ {
CBasePin *pPin = GetPin(c);
- if (NULL == pPin) {
+ if(NULL == pPin)
+ {
break;
}
// Disconnected pins are not activated - this saves pins
// worrying about this state themselves
- if (pPin->IsConnected()) {
+ if(pPin->IsConnected())
+ {
HRESULT hr = pPin->Run(tStart);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
}
@@ -634,7 +681,7 @@ CBaseFilter::Run(REFERENCE_TIME tStart)
}
#ifdef DXMPERF
- PERFLOG_RUN( m_pName ? m_pName : L"CBaseFilter", (IBaseFilter *) this, tStart, m_State );
+ PERFLOG_RUN(m_pName ? m_pName : L"CBaseFilter", (IBaseFilter *) this, tStart, m_State);
#endif // DXMPERF
m_State = State_Running;
@@ -651,13 +698,15 @@ CBaseFilter::StreamTime(CRefTime& rtStream)
// We can't grab the filter lock because we want to be able to call
// this from worker threads without deadlocking
- if (m_pClock == NULL) {
+ if(m_pClock == NULL)
+ {
return VFW_E_NO_CLOCK;
}
// get the current reference time
HRESULT hr = m_pClock->GetTime((REFERENCE_TIME*)&rtStream);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -673,13 +722,13 @@ CBaseFilter::StreamTime(CRefTime& rtStream)
STDMETHODIMP
CBaseFilter::EnumPins(__deref_out IEnumPins **ppEnum)
{
- CheckPointer(ppEnum,E_POINTER);
- ValidateReadWritePtr(ppEnum,sizeof(IEnumPins *));
+ CheckPointer(ppEnum, E_POINTER);
+ ValidateReadWritePtr(ppEnum, sizeof(IEnumPins *));
/* Create a new ref counted enumerator */
*ppEnum = new CEnumPins(this,
- NULL);
+ NULL);
return *ppEnum == NULL ? E_OUTOFMEMORY : NOERROR;
}
@@ -693,19 +742,22 @@ CBaseFilter::FindPin(
__deref_out IPin ** ppPin
)
{
- CheckPointer(ppPin,E_POINTER);
- ValidateReadWritePtr(ppPin,sizeof(IPin *));
+ CheckPointer(ppPin, E_POINTER);
+ ValidateReadWritePtr(ppPin, sizeof(IPin *));
// We're going to search the pin list so maintain integrity
CAutoLock lck(m_pLock);
int iCount = GetPinCount();
- for (int i = 0; i < iCount; i++) {
+ for(int i = 0; i < iCount; i++)
+ {
CBasePin *pPin = GetPin(i);
- if (NULL == pPin) {
+ if(NULL == pPin)
+ {
break;
}
- if (0 == lstrcmpW(pPin->Name(), Id)) {
+ if(0 == lstrcmpW(pPin->Name(), Id))
+ {
// Found one that matches
//
// AddRef() and return it
@@ -723,16 +775,19 @@ CBaseFilter::FindPin(
STDMETHODIMP
CBaseFilter::QueryFilterInfo(__out FILTER_INFO * pInfo)
{
- CheckPointer(pInfo,E_POINTER);
- ValidateReadWritePtr(pInfo,sizeof(FILTER_INFO));
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- if (m_pName) {
+ if(m_pName)
+ {
(void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
+ }
+ else
+ {
pInfo->achName[0] = L'\0';
}
pInfo->pGraph = m_pGraph;
- if (m_pGraph)
+ if(m_pGraph)
m_pGraph->AddRef();
return NOERROR;
}
@@ -750,14 +805,18 @@ CBaseFilter::JoinFilterGraph(
// NOTE: we no longer hold references on the graph (m_pGraph, m_pSink)
m_pGraph = pGraph;
- if (m_pGraph) {
+ if(m_pGraph)
+ {
HRESULT hr = m_pGraph->QueryInterface(IID_IMediaEventSink,
- (void**) &m_pSink);
- if (FAILED(hr)) {
+ (void**) &m_pSink);
+ if(FAILED(hr))
+ {
ASSERT(m_pSink == NULL);
}
else m_pSink->Release(); // we do NOT keep a reference on it.
- } else {
+ }
+ else
+ {
// if graph pointer is null, then we should
// also release the IMediaEventSink on the same object - we don't
// refcount it, so just set it to null
@@ -765,27 +824,33 @@ CBaseFilter::JoinFilterGraph(
}
- if (m_pName) {
+ if(m_pName)
+ {
delete[] m_pName;
m_pName = NULL;
}
- if (pName) {
+ if(pName)
+ {
size_t namelen;
HRESULT hr = StringCchLengthW(pName, STRSAFE_MAX_CCH, &namelen);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
m_pName = new WCHAR[namelen + 1];
- if (m_pName) {
+ if(m_pName)
+ {
(void)StringCchCopyW(m_pName, namelen + 1, pName);
- } else {
+ }
+ else
+ {
return E_OUTOFMEMORY;
}
}
#ifdef DXMPERF
- PERFLOG_JOINGRAPH( m_pName ? m_pName : L"CBaseFilter",(IBaseFilter *) this, pGraph );
+ PERFLOG_JOINGRAPH(m_pName ? m_pName : L"CBaseFilter", (IBaseFilter *) this, pGraph);
#endif // DXMPERF
return NOERROR;
@@ -815,13 +880,17 @@ CBaseFilter::NotifyEvent(
{
// Snapshot so we don't have to lock up
IMediaEventSink *pSink = m_pSink;
- if (pSink) {
- if (EC_COMPLETE == EventCode) {
+ if(pSink)
+ {
+ if(EC_COMPLETE == EventCode)
+ {
EventParam2 = (LONG_PTR)(IBaseFilter*)this;
}
return pSink->Notify(EventCode, EventParam1, EventParam2);
- } else {
+ }
+ else
+ {
return E_NOTIMPL;
}
}
@@ -837,16 +906,22 @@ CBaseFilter::ReconnectPin(
)
{
IFilterGraph2 *pGraph2;
- if (m_pGraph != NULL) {
+ if(m_pGraph != NULL)
+ {
HRESULT hr = m_pGraph->QueryInterface(IID_IFilterGraph2, (void **)&pGraph2);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
hr = pGraph2->ReconnectEx(pPin, pmt);
pGraph2->Release();
return hr;
- } else {
+ }
+ else
+ {
return m_pGraph->Reconnect(pPin);
}
- } else {
+ }
+ else
+ {
return E_NOINTERFACE;
}
}
@@ -881,25 +956,25 @@ STDMETHODIMP CBaseFilter::Register()
// check we've got data
//
- if( NULL == psetupdata ) return S_FALSE;
+ if(NULL == psetupdata) return S_FALSE;
// init is ref counted so call just in case
// we're being called cold.
//
- HRESULT hr = CoInitialize( (LPVOID)NULL );
- ASSERT( SUCCEEDED(hr) );
+ HRESULT hr = CoInitialize((LPVOID)NULL);
+ ASSERT(SUCCEEDED(hr));
// get hold of IFilterMapper
//
IFilterMapper *pIFM;
- hr = CoCreateInstance( CLSID_FilterMapper
- , NULL
- , CLSCTX_INPROC_SERVER
- , IID_IFilterMapper
- , (void **)&pIFM );
- if( SUCCEEDED(hr) )
- {
- hr = AMovieSetupRegisterFilter( psetupdata, pIFM, TRUE );
+ hr = CoCreateInstance(CLSID_FilterMapper
+ , NULL
+ , CLSCTX_INPROC_SERVER
+ , IID_IFilterMapper
+ , (void **)&pIFM);
+ if(SUCCEEDED(hr))
+ {
+ hr = AMovieSetupRegisterFilter(psetupdata, pIFM, TRUE);
pIFM->Release();
}
@@ -922,25 +997,25 @@ STDMETHODIMP CBaseFilter::Unregister()
// check we've got data
//
- if( NULL == psetupdata ) return S_FALSE;
+ if(NULL == psetupdata) return S_FALSE;
// OLE init is ref counted so call
// just in case we're being called cold.
//
- HRESULT hr = CoInitialize( (LPVOID)NULL );
- ASSERT( SUCCEEDED(hr) );
+ HRESULT hr = CoInitialize((LPVOID)NULL);
+ ASSERT(SUCCEEDED(hr));
// get hold of IFilterMapper
//
IFilterMapper *pIFM;
- hr = CoCreateInstance( CLSID_FilterMapper
- , NULL
- , CLSCTX_INPROC_SERVER
- , IID_IFilterMapper
- , (void **)&pIFM );
- if( SUCCEEDED(hr) )
+ hr = CoCreateInstance(CLSID_FilterMapper
+ , NULL
+ , CLSCTX_INPROC_SERVER
+ , IID_IFilterMapper
+ , (void **)&pIFM);
+ if(SUCCEEDED(hr))
{
- hr = AMovieSetupRegisterFilter( psetupdata, pIFM, FALSE );
+ hr = AMovieSetupRegisterFilter(psetupdata, pIFM, FALSE);
// release interface
//
@@ -957,10 +1032,10 @@ STDMETHODIMP CBaseFilter::Unregister()
// (couldn't find a suitable #define'd
// name for the error!)
//
- if( 0x80070002 == hr)
- return NOERROR;
+ if(0x80070002 == hr)
+ return NOERROR;
else
- return hr;
+ return hr;
}
@@ -993,10 +1068,13 @@ CEnumPins::CEnumPins(__in CBaseFilter *pFilter,
/* Are we creating a new enumerator */
- if (pEnumPins == NULL) {
+ if(pEnumPins == NULL)
+ {
m_Version = m_pFilter->GetPinVersion();
m_PinCount = m_pFilter->GetPinCount();
- } else {
+ }
+ else
+ {
ASSERT(m_Position <= m_PinCount);
m_Position = pEnumPins->m_Position;
m_PinCount = pEnumPins->m_PinCount;
@@ -1030,9 +1108,12 @@ CEnumPins::QueryInterface(REFIID riid, __deref_out void **ppv)
/* Do we have this interface */
- if (riid == IID_IEnumPins || riid == IID_IUnknown) {
+ if(riid == IID_IEnumPins || riid == IID_IUnknown)
+ {
return GetInterface((IEnumPins *) this, ppv);
- } else {
+ }
+ else
+ {
*ppv = NULL;
return E_NOINTERFACE;
}
@@ -1048,7 +1129,8 @@ STDMETHODIMP_(ULONG)
CEnumPins::Release()
{
ULONG cRef = InterlockedDecrement(&m_cRef);
- if (cRef == 0) {
+ if(cRef == 0)
+ {
delete this;
}
return cRef;
@@ -1058,21 +1140,25 @@ CEnumPins::Release()
interface that initially has the same state. Since we are taking a snapshot
of an object (current position and all) we must lock access at the start */
-STDMETHODIMP
+STDMETHODIMP
CEnumPins::Clone(__deref_out IEnumPins **ppEnum)
{
- CheckPointer(ppEnum,E_POINTER);
- ValidateReadWritePtr(ppEnum,sizeof(IEnumPins *));
+ CheckPointer(ppEnum, E_POINTER);
+ ValidateReadWritePtr(ppEnum, sizeof(IEnumPins *));
HRESULT hr = NOERROR;
/* Check we are still in sync with the filter */
- if (AreWeOutOfSync() == TRUE) {
+ if(AreWeOutOfSync() == TRUE)
+ {
*ppEnum = NULL;
hr = VFW_E_ENUM_OUT_OF_SYNC;
- } else {
- *ppEnum = new CEnumPins(m_pFilter,
+ }
+ else
+ {
+ *ppEnum = new CEnumPins(m_pFilter,
this);
- if (*ppEnum == NULL) {
+ if(*ppEnum == NULL)
+ {
hr = E_OUTOFMEMORY;
}
}
@@ -1084,26 +1170,29 @@ CEnumPins::Clone(__deref_out IEnumPins **ppEnum)
STDMETHODIMP
CEnumPins::Next(ULONG cPins, // place this many pins...
- __out_ecount(cPins) IPin **ppPins, // ...in this array
- __out_opt ULONG *pcFetched) // actual count passed returned here
+ __out_ecount(cPins) IPin **ppPins, // ...in this array
+ __out_opt ULONG *pcFetched) // actual count passed returned here
{
- CheckPointer(ppPins,E_POINTER);
- ValidateReadWritePtr(ppPins,cPins * sizeof(IPin *));
+ CheckPointer(ppPins, E_POINTER);
+ ValidateReadWritePtr(ppPins, cPins * sizeof(IPin *));
ASSERT(ppPins);
- if (pcFetched!=NULL) {
+ if(pcFetched != NULL)
+ {
ValidateWritePtr(pcFetched, sizeof(ULONG));
*pcFetched = 0; // default unless we succeed
}
// now check that the parameter is valid
- else if (cPins>1) { // pcFetched == NULL
+ else if(cPins > 1) // pcFetched == NULL
+ {
return E_INVALIDARG;
}
ULONG cFetched = 0; // increment as we get each one.
/* Check we are still in sync with the filter */
- if (AreWeOutOfSync() == TRUE) {
+ if(AreWeOutOfSync() == TRUE)
+ {
// If we are out of sync, we should refresh the enumerator.
// This will reset the position and update the other members, but
// will not clear cache of pins we have already returned.
@@ -1117,21 +1206,23 @@ CEnumPins::Next(ULONG cPins, // place this many pins...
(for example someone has deleted a pin) so we
return VFW_E_ENUM_OUT_OF_SYNC */
- while (cFetched < cPins && m_PinCount > m_Position) {
+ while(cFetched < cPins && m_PinCount > m_Position)
+ {
/* Get the next pin object from the filter */
CBasePin *pPin = m_pFilter->GetPin(m_Position++);
- if (pPin == NULL) {
+ if(pPin == NULL)
+ {
// If this happend, and it's not the first time through, then we've got a problem,
// since we should really go back and release the iPins, which we have previously
// AddRef'ed.
- ASSERT( cFetched==0 );
+ ASSERT(cFetched == 0);
return VFW_E_ENUM_OUT_OF_SYNC;
}
/* We only want to return this pin, if it is not in our cache */
- if (0 == m_PinCache.Find(pPin))
+ if(0 == m_PinCache.Find(pPin))
{
/* From the object get an IPin interface */
@@ -1145,11 +1236,12 @@ CEnumPins::Next(ULONG cPins, // place this many pins...
}
}
- if (pcFetched!=NULL) {
+ if(pcFetched != NULL)
+ {
*pcFetched = cFetched;
}
- return (cPins==cFetched ? NOERROR : S_FALSE);
+ return (cPins == cFetched ? NOERROR : S_FALSE);
}
@@ -1159,7 +1251,8 @@ STDMETHODIMP
CEnumPins::Skip(ULONG cPins)
{
/* Check we are still in sync with the filter */
- if (AreWeOutOfSync() == TRUE) {
+ if(AreWeOutOfSync() == TRUE)
+ {
return VFW_E_ENUM_OUT_OF_SYNC;
}
@@ -1168,7 +1261,8 @@ CEnumPins::Skip(ULONG cPins)
/* ..which would match the base implementation for CEnumMediaTypes::Skip */
ULONG PinsLeft = m_PinCount - m_Position;
- if (cPins > PinsLeft) {
+ if(cPins > PinsLeft)
+ {
return S_FALSE;
}
m_Position += cPins;
@@ -1246,7 +1340,8 @@ CEnumMediaTypes::CEnumMediaTypes(__in CBasePin *pPin,
/* Are we creating a new enumerator */
- if (pEnumMediaTypes == NULL) {
+ if(pEnumMediaTypes == NULL)
+ {
m_Version = m_pPin->GetMediaTypeVersion();
return;
}
@@ -1279,9 +1374,12 @@ CEnumMediaTypes::QueryInterface(REFIID riid, __deref_out void **ppv)
/* Do we have this interface */
- if (riid == IID_IEnumMediaTypes || riid == IID_IUnknown) {
+ if(riid == IID_IEnumMediaTypes || riid == IID_IUnknown)
+ {
return GetInterface((IEnumMediaTypes *) this, ppv);
- } else {
+ }
+ else
+ {
*ppv = NULL;
return E_NOINTERFACE;
}
@@ -1297,7 +1395,8 @@ STDMETHODIMP_(ULONG)
CEnumMediaTypes::Release()
{
ULONG cRef = InterlockedDecrement(&m_cRef);
- if (cRef == 0) {
+ if(cRef == 0)
+ {
delete this;
}
return cRef;
@@ -1310,20 +1409,24 @@ CEnumMediaTypes::Release()
STDMETHODIMP
CEnumMediaTypes::Clone(__deref_out IEnumMediaTypes **ppEnum)
{
- CheckPointer(ppEnum,E_POINTER);
- ValidateReadWritePtr(ppEnum,sizeof(IEnumMediaTypes *));
+ CheckPointer(ppEnum, E_POINTER);
+ ValidateReadWritePtr(ppEnum, sizeof(IEnumMediaTypes *));
HRESULT hr = NOERROR;
/* Check we are still in sync with the pin */
- if (AreWeOutOfSync() == TRUE) {
+ if(AreWeOutOfSync() == TRUE)
+ {
*ppEnum = NULL;
hr = VFW_E_ENUM_OUT_OF_SYNC;
- } else {
+ }
+ else
+ {
*ppEnum = new CEnumMediaTypes(m_pPin,
this);
- if (*ppEnum == NULL) {
+ if(*ppEnum == NULL)
+ {
hr = E_OUTOFMEMORY;
}
}
@@ -1346,19 +1449,22 @@ CEnumMediaTypes::Next(ULONG cMediaTypes, // place this many types...
__out_ecount(cMediaTypes) AM_MEDIA_TYPE **ppMediaTypes, // ...in this array
__out ULONG *pcFetched) // actual count passed
{
- CheckPointer(ppMediaTypes,E_POINTER);
- ValidateReadWritePtr(ppMediaTypes,cMediaTypes * sizeof(AM_MEDIA_TYPE *));
+ CheckPointer(ppMediaTypes, E_POINTER);
+ ValidateReadWritePtr(ppMediaTypes, cMediaTypes * sizeof(AM_MEDIA_TYPE *));
/* Check we are still in sync with the pin */
- if (AreWeOutOfSync() == TRUE) {
+ if(AreWeOutOfSync() == TRUE)
+ {
return VFW_E_ENUM_OUT_OF_SYNC;
}
- if (pcFetched!=NULL) {
+ if(pcFetched != NULL)
+ {
ValidateWritePtr(pcFetched, sizeof(ULONG));
*pcFetched = 0; // default unless we succeed
}
// now check that the parameter is valid
- else if (cMediaTypes>1) { // pcFetched == NULL
+ else if(cMediaTypes > 1) // pcFetched == NULL
+ {
return E_INVALIDARG;
}
ULONG cFetched = 0; // increment as we get each one.
@@ -1369,12 +1475,14 @@ CEnumMediaTypes::Next(ULONG cMediaTypes, // place this many types...
(for example the window size changing) so we return
VFW_E_ENUM_OUT_OF_SYNC */
- while (cMediaTypes) {
+ while(cMediaTypes)
+ {
CMediaType cmt;
HRESULT hr = m_pPin->GetMediaType(m_Position++, &cmt);
- if (S_OK != hr) {
+ if(S_OK != hr)
+ {
break;
}
@@ -1388,7 +1496,8 @@ CEnumMediaTypes::Next(ULONG cMediaTypes, // place this many types...
and free on the format block and generally go faster */
*ppMediaTypes = (AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- if (*ppMediaTypes == NULL) {
+ if(*ppMediaTypes == NULL)
+ {
break;
}
@@ -1406,11 +1515,12 @@ CEnumMediaTypes::Next(ULONG cMediaTypes, // place this many types...
cMediaTypes--;
}
- if (pcFetched!=NULL) {
+ if(pcFetched != NULL)
+ {
*pcFetched = cFetched;
}
- return ( cMediaTypes==0 ? NOERROR : S_FALSE );
+ return (cMediaTypes == 0 ? NOERROR : S_FALSE);
}
@@ -1421,12 +1531,14 @@ CEnumMediaTypes::Skip(ULONG cMediaTypes)
{
// If we're skipping 0 elements we're guaranteed to skip the
// correct number of elements
- if (cMediaTypes == 0) {
+ if(cMediaTypes == 0)
+ {
return S_OK;
}
/* Check we are still in sync with the pin */
- if (AreWeOutOfSync() == TRUE) {
+ if(AreWeOutOfSync() == TRUE)
+ {
return VFW_E_ENUM_OUT_OF_SYNC;
}
@@ -1479,12 +1591,12 @@ CEnumMediaTypes::Reset()
/* Constructor */
CBasePin::CBasePin(__in_opt LPCTSTR pObjectName,
- __in CBaseFilter *pFilter,
- __in CCritSec *pLock,
- __inout HRESULT *phr,
- __in_opt LPCWSTR pName,
- PIN_DIRECTION dir) :
- CUnknown( pObjectName, NULL ),
+ __in CBaseFilter *pFilter,
+ __in CCritSec *pLock,
+ __inout HRESULT *phr,
+ __in_opt LPCWSTR pName,
+ PIN_DIRECTION dir) :
+ CUnknown(pObjectName, NULL),
m_pFilter(pFilter),
m_pLock(pLock),
m_pName(NULL),
@@ -1507,18 +1619,21 @@ CBasePin::CBasePin(__in_opt LPCTSTR pObjectName,
called
*/
#ifdef DXMPERF
- PERFLOG_CTOR( pName ? pName : L"CBasePin", (IPin *) this );
+ PERFLOG_CTOR(pName ? pName : L"CBasePin", (IPin *) this);
#endif // DXMPERF
ASSERT(pFilter != NULL);
ASSERT(pLock != NULL);
- if (pName) {
+ if(pName)
+ {
size_t cchName;
HRESULT hr = StringCchLengthW(pName, STRSAFE_MAX_CCH, &cchName);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
m_pName = new WCHAR[cchName + 1];
- if (m_pName) {
+ if(m_pName)
+ {
(void)StringCchCopyW(m_pName, cchName + 1, pName);
}
}
@@ -1531,12 +1646,12 @@ CBasePin::CBasePin(__in_opt LPCTSTR pObjectName,
#ifdef UNICODE
CBasePin::CBasePin(__in_opt LPCSTR pObjectName,
- __in CBaseFilter *pFilter,
- __in CCritSec *pLock,
- __inout HRESULT *phr,
- __in_opt LPCWSTR pName,
- PIN_DIRECTION dir) :
- CUnknown( pObjectName, NULL ),
+ __in CBaseFilter *pFilter,
+ __in CCritSec *pLock,
+ __inout HRESULT *phr,
+ __in_opt LPCWSTR pName,
+ PIN_DIRECTION dir) :
+ CUnknown(pObjectName, NULL),
m_pFilter(pFilter),
m_pLock(pLock),
m_pName(NULL),
@@ -1559,18 +1674,21 @@ CBasePin::CBasePin(__in_opt LPCSTR pObjectName,
called
*/
#ifdef DXMPERF
- PERFLOG_CTOR( pName ? pName : L"CBasePin", (IPin *) this );
+ PERFLOG_CTOR(pName ? pName : L"CBasePin", (IPin *) this);
#endif // DXMPERF
ASSERT(pFilter != NULL);
ASSERT(pLock != NULL);
- if (pName) {
+ if(pName)
+ {
size_t cchName;
HRESULT hr = StringCchLengthW(pName, STRSAFE_MAX_CCH, &cchName);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
m_pName = new WCHAR[cchName + 1];
- if (m_pName) {
+ if(m_pName)
+ {
(void)StringCchCopyW(m_pName, cchName + 1, pName);
}
}
@@ -1589,7 +1707,7 @@ CBasePin::CBasePin(__in_opt LPCSTR pObjectName,
CBasePin::~CBasePin()
{
#ifdef DXMPERF
- PERFLOG_DTOR( m_pName ? m_pName : L"CBasePin", (IPin *) this );
+ PERFLOG_DTOR(m_pName ? m_pName : L"CBasePin", (IPin *) this);
#endif // DXMPERF
// We don't call disconnect because if the filter is going away
@@ -1611,11 +1729,16 @@ CBasePin::NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv)
{
/* Do we have this interface */
- if (riid == IID_IPin) {
+ if(riid == IID_IPin)
+ {
return GetInterface((IPin *) this, ppv);
- } else if (riid == IID_IQualityControl) {
+ }
+ else if(riid == IID_IQualityControl)
+ {
return GetInterface((IQualityControl *) this, ppv);
- } else {
+ }
+ else
+ {
return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -1648,19 +1771,26 @@ void
CBasePin::DisplayPinInfo(IPin *pReceivePin)
{
- if (DbgCheckModuleLevel(LOG_TRACE, CONNECT_TRACE_LEVEL)) {
+ if(DbgCheckModuleLevel(LOG_TRACE, CONNECT_TRACE_LEVEL))
+ {
PIN_INFO ConnectPinInfo;
PIN_INFO ReceivePinInfo;
- if (FAILED(QueryPinInfo(&ConnectPinInfo))) {
- StringCchCopyW(ConnectPinInfo.achName, sizeof(ConnectPinInfo.achName)/sizeof(WCHAR), L"Bad Pin");
- } else {
+ if(FAILED(QueryPinInfo(&ConnectPinInfo)))
+ {
+ StringCchCopyW(ConnectPinInfo.achName, sizeof(ConnectPinInfo.achName) / sizeof(WCHAR), L"Bad Pin");
+ }
+ else
+ {
QueryPinInfoReleaseFilter(ConnectPinInfo);
}
- if (FAILED(pReceivePin->QueryPinInfo(&ReceivePinInfo))) {
- StringCchCopyW(ReceivePinInfo.achName, sizeof(ReceivePinInfo.achName)/sizeof(WCHAR), L"Bad Pin");
- } else {
+ if(FAILED(pReceivePin->QueryPinInfo(&ReceivePinInfo)))
+ {
+ StringCchCopyW(ReceivePinInfo.achName, sizeof(ReceivePinInfo.achName) / sizeof(WCHAR), L"Bad Pin");
+ }
+ else
+ {
QueryPinInfoReleaseFilter(ReceivePinInfo);
}
@@ -1678,12 +1808,13 @@ CBasePin::DisplayPinInfo(IPin *pReceivePin)
void CBasePin::DisplayTypeInfo(IPin *pPin, const CMediaType *pmt)
{
UNREFERENCED_PARAMETER(pPin);
- if (DbgCheckModuleLevel(LOG_TRACE, CONNECT_TRACE_LEVEL)) {
+ if(DbgCheckModuleLevel(LOG_TRACE, CONNECT_TRACE_LEVEL))
+ {
DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT("Trying media type:")));
DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(" major type: %hs"),
- GuidNames[*pmt->Type()]));
+ GuidNames[*pmt->Type()]));
DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(" sub type : %hs"),
- GuidNames[*pmt->Subtype()]));
+ GuidNames[*pmt->Subtype()]));
}
}
#endif
@@ -1700,20 +1831,22 @@ CBasePin::Connect(
__in_opt const AM_MEDIA_TYPE *pmt // optional media type
)
{
- CheckPointer(pReceivePin,E_POINTER);
- ValidateReadPtr(pReceivePin,sizeof(IPin));
+ CheckPointer(pReceivePin, E_POINTER);
+ ValidateReadPtr(pReceivePin, sizeof(IPin));
CAutoLock cObjectLock(m_pLock);
DisplayPinInfo(pReceivePin);
/* See if we are already connected */
- if (m_Connected) {
+ if(m_Connected)
+ {
DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT("Already connected")));
return VFW_E_ALREADY_CONNECTED;
}
/* See if the filter is active */
- if (!IsStopped() && !m_bCanReconnectWhenActive) {
+ if(!IsStopped() && !m_bCanReconnectWhenActive)
+ {
return VFW_E_NOT_STOPPED;
}
@@ -1726,15 +1859,16 @@ CBasePin::Connect(
const CMediaType * ptype = (CMediaType*)pmt;
HRESULT hr = AgreeMediaType(pReceivePin, ptype);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT("Failed to agree type")));
// Since the procedure is already returning an error code, there
// is nothing else this function can do to report the error.
- EXECUTE_ASSERT( SUCCEEDED( BreakConnect() ) );
+ EXECUTE_ASSERT(SUCCEEDED(BreakConnect()));
#ifdef DXMPERF
- PERFLOG_CONNECT( (IPin *) this, pReceivePin, hr, pmt );
+ PERFLOG_CONNECT((IPin *) this, pReceivePin, hr, pmt);
#endif // DXMPERF
return hr;
@@ -1743,7 +1877,7 @@ CBasePin::Connect(
DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT("Connection succeeded")));
#ifdef DXMPERF
- PERFLOG_CONNECT( (IPin *) this, pReceivePin, NOERROR, pmt );
+ PERFLOG_CONNECT((IPin *) this, pReceivePin, NOERROR, pmt);
#endif // DXMPERF
return NOERROR;
@@ -1766,12 +1900,13 @@ CBasePin::AttemptConnection(
// Check that the connection is valid -- need to do this for every
// connect attempt since BreakConnect will undo it.
HRESULT hr = CheckConnect(pReceivePin);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT("CheckConnect failed")));
// Since the procedure is already returning an error code, there
// is nothing else this function can do to report the error.
- EXECUTE_ASSERT( SUCCEEDED( BreakConnect() ) );
+ EXECUTE_ASSERT(SUCCEEDED(BreakConnect()));
return hr;
}
@@ -1781,7 +1916,8 @@ CBasePin::AttemptConnection(
/* Check we will accept this media type */
hr = CheckMediaType(pmt);
- if (hr == NOERROR) {
+ if(hr == NOERROR)
+ {
/* Make ourselves look connected otherwise ReceiveConnection
may not be able to complete the connection
@@ -1789,17 +1925,22 @@ CBasePin::AttemptConnection(
m_Connected = pReceivePin;
m_Connected->AddRef();
hr = SetMediaType(pmt);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
/* See if the other pin will accept this type */
hr = pReceivePin->ReceiveConnection((IPin *)this, pmt);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
/* Complete the connection */
hr = CompleteConnect(pReceivePin);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
return hr;
- } else {
+ }
+ else
+ {
DbgLog((LOG_TRACE,
CONNECT_TRACE_LEVEL,
TEXT("Failed to complete connection")));
@@ -1807,15 +1948,18 @@ CBasePin::AttemptConnection(
}
}
}
- } else {
+ }
+ else
+ {
// we cannot use this media type
// return a specific media type error if there is one
// or map a general failure code to something more helpful
// (in particular S_FALSE gets changed to an error code)
- if (SUCCEEDED(hr) ||
- (hr == E_FAIL) ||
- (hr == E_INVALIDARG)) {
+ if(SUCCEEDED(hr) ||
+ (hr == E_FAIL) ||
+ (hr == E_INVALIDARG))
+ {
hr = VFW_E_TYPE_NOT_ACCEPTED;
}
}
@@ -1826,10 +1970,11 @@ CBasePin::AttemptConnection(
// Since the procedure is already returning an error code, there
// is nothing else this function can do to report the error.
- EXECUTE_ASSERT( SUCCEEDED( BreakConnect() ) );
+ EXECUTE_ASSERT(SUCCEEDED(BreakConnect()));
/* If failed then undo our state */
- if (m_Connected) {
+ if(m_Connected)
+ {
m_Connected->Release();
m_Connected = NULL;
}
@@ -1852,7 +1997,8 @@ HRESULT CBasePin::TryMediaTypes(
/* Reset the current enumerator position */
HRESULT hr = pEnum->Reset();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -1862,16 +2008,19 @@ HRESULT CBasePin::TryMediaTypes(
// attempt to remember a specific error code if there is one
HRESULT hrFailure = S_OK;
- for (;;) {
+ for(;;)
+ {
/* Retrieve the next media type NOTE each time round the loop the
enumerator interface will allocate another AM_MEDIA_TYPE structure
If we are successful then we copy it into our output object, if
not then we must delete the memory allocated before returning */
- hr = pEnum->Next(1, (AM_MEDIA_TYPE**)&pMediaType,&ulMediaCount);
- if (hr != S_OK) {
- if (S_OK == hrFailure) {
+ hr = pEnum->Next(1, (AM_MEDIA_TYPE**)&pMediaType, &ulMediaCount);
+ if(hr != S_OK)
+ {
+ if(S_OK == hrFailure)
+ {
hrFailure = VFW_E_NO_ACCEPTABLE_TYPES;
}
return hrFailure;
@@ -1883,30 +2032,36 @@ HRESULT CBasePin::TryMediaTypes(
// check that this matches the partial type (if any)
- if (pMediaType &&
- ((pmt == NULL) ||
- pMediaType->MatchesPartial(pmt))) {
+ if(pMediaType &&
+ ((pmt == NULL) ||
+ pMediaType->MatchesPartial(pmt)))
+ {
hr = AttemptConnection(pReceivePin, pMediaType);
// attempt to remember a specific error code
- if (FAILED(hr) &&
- SUCCEEDED(hrFailure) &&
- (hr != E_FAIL) &&
- (hr != E_INVALIDARG) &&
- (hr != VFW_E_TYPE_NOT_ACCEPTED)) {
+ if(FAILED(hr) &&
+ SUCCEEDED(hrFailure) &&
+ (hr != E_FAIL) &&
+ (hr != E_INVALIDARG) &&
+ (hr != VFW_E_TYPE_NOT_ACCEPTED))
+ {
hrFailure = hr;
}
- } else {
+ }
+ else
+ {
hr = VFW_E_NO_ACCEPTABLE_TYPES;
}
- if(pMediaType) {
+ if(pMediaType)
+ {
DeleteMediaType(pMediaType);
pMediaType = NULL;
}
- if (S_OK == hr) {
+ if(S_OK == hr)
+ {
return hr;
}
}
@@ -1930,7 +2085,8 @@ HRESULT CBasePin::AgreeMediaType(
IEnumMediaTypes *pEnumMediaTypes = NULL;
// if the media type is fully specified then use that
- if ( (pmt != NULL) && (!pmt->IsPartiallySpecified())) {
+ if((pmt != NULL) && (!pmt->IsPartiallySpecified()))
+ {
// if this media type fails, then we must fail the connection
// since if pmt is nonnull we are only allowed to connect
@@ -1944,24 +2100,33 @@ HRESULT CBasePin::AgreeMediaType(
HRESULT hrFailure = VFW_E_NO_ACCEPTABLE_TYPES;
- for (int i = 0; i < 2; i++) {
+ for(int i = 0; i < 2; i++)
+ {
HRESULT hr;
- if (i == (int)m_bTryMyTypesFirst) {
+ if(i == (int)m_bTryMyTypesFirst)
+ {
hr = pReceivePin->EnumMediaTypes(&pEnumMediaTypes);
- } else {
+ }
+ else
+ {
hr = EnumMediaTypes(&pEnumMediaTypes);
}
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
ASSERT(pEnumMediaTypes);
- hr = TryMediaTypes(pReceivePin,pmt,pEnumMediaTypes);
+ hr = TryMediaTypes(pReceivePin, pmt, pEnumMediaTypes);
pEnumMediaTypes->Release();
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
return NOERROR;
- } else {
+ }
+ else
+ {
// try to remember specific error codes if there are any
- if ((hr != E_FAIL) &&
- (hr != E_INVALIDARG) &&
- (hr != VFW_E_TYPE_NOT_ACCEPTED)) {
+ if((hr != E_FAIL) &&
+ (hr != E_INVALIDARG) &&
+ (hr != VFW_E_TYPE_NOT_ACCEPTED))
+ {
hrFailure = hr;
}
}
@@ -1991,7 +2156,8 @@ HRESULT
CBasePin::SetMediaType(const CMediaType *pmt)
{
HRESULT hr = m_mt.Set(*pmt);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -2015,7 +2181,8 @@ CBasePin::CheckConnect(IPin * pPin)
ASSERT((m_dir == PINDIR_OUTPUT) || (m_dir == PINDIR_INPUT));
// we should allow for non-input and non-output connections?
- if (pd == m_dir) {
+ if(pd == m_dir)
+ {
return VFW_E_INVALID_DIRECTION;
}
return NOERROR;
@@ -2042,30 +2209,33 @@ CBasePin::ReceiveConnection(
const AM_MEDIA_TYPE *pmt // this is the media type we will exchange
)
{
- CheckPointer(pConnector,E_POINTER);
- CheckPointer(pmt,E_POINTER);
- ValidateReadPtr(pConnector,sizeof(IPin));
- ValidateReadPtr(pmt,sizeof(AM_MEDIA_TYPE));
+ CheckPointer(pConnector, E_POINTER);
+ CheckPointer(pmt, E_POINTER);
+ ValidateReadPtr(pConnector, sizeof(IPin));
+ ValidateReadPtr(pmt, sizeof(AM_MEDIA_TYPE));
CAutoLock cObjectLock(m_pLock);
/* Are we already connected */
- if (m_Connected) {
+ if(m_Connected)
+ {
return VFW_E_ALREADY_CONNECTED;
}
/* See if the filter is active */
- if (!IsStopped() && !m_bCanReconnectWhenActive) {
+ if(!IsStopped() && !m_bCanReconnectWhenActive)
+ {
return VFW_E_NOT_STOPPED;
}
HRESULT hr = CheckConnect(pConnector);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
// Since the procedure is already returning an error code, there
// is nothing else this function can do to report the error.
- EXECUTE_ASSERT( SUCCEEDED( BreakConnect() ) );
+ EXECUTE_ASSERT(SUCCEEDED(BreakConnect()));
#ifdef DXMPERF
- PERFLOG_RXCONNECT( pConnector, (IPin *) this, hr, pmt );
+ PERFLOG_RXCONNECT(pConnector, (IPin *) this, hr, pmt);
#endif // DXMPERF
return hr;
@@ -2075,24 +2245,26 @@ CBasePin::ReceiveConnection(
CMediaType * pcmt = (CMediaType*) pmt;
hr = CheckMediaType(pcmt);
- if (hr != NOERROR) {
+ if(hr != NOERROR)
+ {
// no -we don't support this media type
// Since the procedure is already returning an error code, there
// is nothing else this function can do to report the error.
- EXECUTE_ASSERT( SUCCEEDED( BreakConnect() ) );
+ EXECUTE_ASSERT(SUCCEEDED(BreakConnect()));
// return a specific media type error if there is one
// or map a general failure code to something more helpful
// (in particular S_FALSE gets changed to an error code)
- if (SUCCEEDED(hr) ||
- (hr == E_FAIL) ||
- (hr == E_INVALIDARG)) {
+ if(SUCCEEDED(hr) ||
+ (hr == E_FAIL) ||
+ (hr == E_INVALIDARG))
+ {
hr = VFW_E_TYPE_NOT_ACCEPTED;
}
#ifdef DXMPERF
- PERFLOG_RXCONNECT( pConnector, (IPin *) this, hr, pmt );
+ PERFLOG_RXCONNECT(pConnector, (IPin *) this, hr, pmt);
#endif // DXMPERF
return hr;
@@ -2103,12 +2275,14 @@ CBasePin::ReceiveConnection(
m_Connected = pConnector;
m_Connected->AddRef();
hr = SetMediaType(pcmt);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
hr = CompleteConnect(pConnector);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
#ifdef DXMPERF
- PERFLOG_RXCONNECT( pConnector, (IPin *) this, NOERROR, pmt );
+ PERFLOG_RXCONNECT(pConnector, (IPin *) this, NOERROR, pmt);
#endif // DXMPERF
return NOERROR;
@@ -2121,10 +2295,10 @@ CBasePin::ReceiveConnection(
// Since the procedure is already returning an error code, there
// is nothing else this function can do to report the error.
- EXECUTE_ASSERT( SUCCEEDED( BreakConnect() ) );
+ EXECUTE_ASSERT(SUCCEEDED(BreakConnect()));
#ifdef DXMPERF
- PERFLOG_RXCONNECT( pConnector, (IPin *) this, hr, pmt );
+ PERFLOG_RXCONNECT(pConnector, (IPin *) this, hr, pmt);
#endif // DXMPERF
return hr;
@@ -2139,7 +2313,8 @@ CBasePin::Disconnect()
CAutoLock cObjectLock(m_pLock);
/* See if the filter is active */
- if (!IsStopped()) {
+ if(!IsStopped())
+ {
return VFW_E_NOT_STOPPED;
}
@@ -2151,16 +2326,18 @@ CBasePin::DisconnectInternal()
{
ASSERT(CritCheckIn(m_pLock));
- if (m_Connected) {
+ if(m_Connected)
+ {
HRESULT hr = BreakConnect();
- if( FAILED( hr ) ) {
+ if(FAILED(hr))
+ {
#ifdef DXMPERF
- PERFLOG_DISCONNECT( (IPin *) this, m_Connected, hr );
+ PERFLOG_DISCONNECT((IPin *) this, m_Connected, hr);
#endif // DXMPERF
// There is usually a bug in the program if BreakConnect() fails.
- DbgBreak( "WARNING: BreakConnect() failed in CBasePin::Disconnect()." );
+ DbgBreak("WARNING: BreakConnect() failed in CBasePin::Disconnect().");
return hr;
}
@@ -2168,15 +2345,17 @@ CBasePin::DisconnectInternal()
m_Connected = NULL;
#ifdef DXMPERF
- PERFLOG_DISCONNECT( (IPin *) this, m_Connected, S_OK );
+ PERFLOG_DISCONNECT((IPin *) this, m_Connected, S_OK);
#endif // DXMPERF
return S_OK;
- } else {
+ }
+ else
+ {
// no connection - not an error
#ifdef DXMPERF
- PERFLOG_DISCONNECT( (IPin *) this, m_Connected, S_FALSE );
+ PERFLOG_DISCONNECT((IPin *) this, m_Connected, S_FALSE);
#endif // DXMPERF
return S_FALSE;
@@ -2190,8 +2369,8 @@ CBasePin::ConnectedTo(
__deref_out IPin **ppPin
)
{
- CheckPointer(ppPin,E_POINTER);
- ValidateReadWritePtr(ppPin,sizeof(IPin *));
+ CheckPointer(ppPin, E_POINTER);
+ ValidateReadWritePtr(ppPin, sizeof(IPin *));
//
// It's pointless to lock here.
// The caller should ensure integrity.
@@ -2199,10 +2378,13 @@ CBasePin::ConnectedTo(
IPin *pPin = m_Connected;
*ppPin = pPin;
- if (pPin != NULL) {
+ if(pPin != NULL)
+ {
pPin->AddRef();
return S_OK;
- } else {
+ }
+ else
+ {
ASSERT(*ppPin == NULL);
return VFW_E_NOT_CONNECTED;
}
@@ -2214,15 +2396,18 @@ CBasePin::ConnectionMediaType(
__out AM_MEDIA_TYPE *pmt
)
{
- CheckPointer(pmt,E_POINTER);
- ValidateReadWritePtr(pmt,sizeof(AM_MEDIA_TYPE));
+ CheckPointer(pmt, E_POINTER);
+ ValidateReadWritePtr(pmt, sizeof(AM_MEDIA_TYPE));
CAutoLock cObjectLock(m_pLock);
/* Copy constructor of m_mt allocates the memory */
- if (IsConnected()) {
- CopyMediaType( pmt, &m_mt );
+ if(IsConnected())
+ {
+ CopyMediaType(pmt, &m_mt);
return S_OK;
- } else {
+ }
+ else
+ {
((CMediaType *)pmt)->InitMediaType();
return VFW_E_NOT_CONNECTED;
}
@@ -2235,17 +2420,21 @@ CBasePin::QueryPinInfo(
__out PIN_INFO * pInfo
)
{
- CheckPointer(pInfo,E_POINTER);
- ValidateReadWritePtr(pInfo,sizeof(PIN_INFO));
+ CheckPointer(pInfo, E_POINTER);
+ ValidateReadWritePtr(pInfo, sizeof(PIN_INFO));
pInfo->pFilter = m_pFilter;
- if (m_pFilter) {
+ if(m_pFilter)
+ {
m_pFilter->AddRef();
}
- if (m_pName) {
+ if(m_pName)
+ {
(void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
+ }
+ else
+ {
pInfo->achName[0] = L'\0';
}
@@ -2259,8 +2448,8 @@ CBasePin::QueryDirection(
__out PIN_DIRECTION * pPinDir
)
{
- CheckPointer(pPinDir,E_POINTER);
- ValidateReadWritePtr(pPinDir,sizeof(PIN_DIRECTION));
+ CheckPointer(pPinDir, E_POINTER);
+ ValidateReadWritePtr(pPinDir, sizeof(PIN_DIRECTION));
*pPinDir = m_dir;
return NOERROR;
@@ -2288,15 +2477,16 @@ CBasePin::QueryAccept(
const AM_MEDIA_TYPE *pmt
)
{
- CheckPointer(pmt,E_POINTER);
- ValidateReadPtr(pmt,sizeof(AM_MEDIA_TYPE));
+ CheckPointer(pmt, E_POINTER);
+ ValidateReadPtr(pmt, sizeof(AM_MEDIA_TYPE));
/* The CheckMediaType method is valid to return error codes if the media
type is horrible, an example might be E_INVALIDARG. What we do here
is map all the error codes into either S_OK or S_FALSE regardless */
HRESULT hr = CheckMediaType((CMediaType*)pmt);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return S_FALSE;
}
// note that the only defined success codes should be S_OK and S_FALSE...
@@ -2316,15 +2506,16 @@ CBasePin::EnumMediaTypes(
__deref_out IEnumMediaTypes **ppEnum
)
{
- CheckPointer(ppEnum,E_POINTER);
- ValidateReadWritePtr(ppEnum,sizeof(IEnumMediaTypes *));
+ CheckPointer(ppEnum, E_POINTER);
+ ValidateReadWritePtr(ppEnum, sizeof(IEnumMediaTypes *));
/* Create a new ref counted enumerator */
*ppEnum = new CEnumMediaTypes(this,
- NULL);
+ NULL);
- if (*ppEnum == NULL) {
+ if(*ppEnum == NULL)
+ {
return E_OUTOFMEMORY;
}
@@ -2413,7 +2604,7 @@ STDMETHODIMP
CBasePin::SetSink(IQualityControl * piqc)
{
CAutoLock cObjectLock(m_pLock);
- if (piqc) ValidateReadPtr(piqc,sizeof(IQualityControl));
+ if(piqc) ValidateReadPtr(piqc, sizeof(IQualityControl));
m_pQSink = piqc;
return NOERROR;
} // SetSink
@@ -2435,9 +2626,9 @@ CBasePin::Notify(IBaseFilter * pSender, Quality q)
// Override this to pass downstream.
STDMETHODIMP
CBasePin::NewSegment(
- REFERENCE_TIME tStart,
- REFERENCE_TIME tStop,
- double dRate)
+ REFERENCE_TIME tStart,
+ REFERENCE_TIME tStop,
+ double dRate)
{
m_tStart = tStart;
m_tStop = tStop;
@@ -2455,10 +2646,10 @@ CBasePin::NewSegment(
CBaseOutputPin::CBaseOutputPin(__in_opt LPCTSTR pObjectName,
- __in CBaseFilter *pFilter,
- __in CCritSec *pLock,
- __inout HRESULT *phr,
- __in_opt LPCWSTR pName) :
+ __in CBaseFilter *pFilter,
+ __in CCritSec *pLock,
+ __inout HRESULT *phr,
+ __in_opt LPCWSTR pName) :
CBasePin(pObjectName, pFilter, pLock, phr, pName, PINDIR_OUTPUT),
m_pAllocator(NULL),
m_pInputPin(NULL)
@@ -2468,10 +2659,10 @@ CBaseOutputPin::CBaseOutputPin(__in_opt LPCTSTR pObjectName,
#ifdef UNICODE
CBaseOutputPin::CBaseOutputPin(__in_opt LPCSTR pObjectName,
- __in CBaseFilter *pFilter,
- __in CCritSec *pLock,
- __inout HRESULT *phr,
- __in_opt LPCWSTR pName) :
+ __in CBaseFilter *pFilter,
+ __in CCritSec *pLock,
+ __inout HRESULT *phr,
+ __in_opt LPCWSTR pName) :
CBasePin(pObjectName, pFilter, pLock, phr, pName, PINDIR_OUTPUT),
m_pAllocator(NULL),
m_pInputPin(NULL)
@@ -2506,13 +2697,15 @@ HRESULT
CBaseOutputPin::CheckConnect(IPin * pPin)
{
HRESULT hr = CBasePin::CheckConnect(pPin);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
// get an input pin and an allocator interface
hr = pPin->QueryInterface(IID_IMemInputPin, (void **) &m_pInputPin);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return NOERROR;
@@ -2526,12 +2719,14 @@ CBaseOutputPin::BreakConnect()
{
/* Release any allocator we hold */
- if (m_pAllocator) {
+ if(m_pAllocator)
+ {
// Always decommit the allocator because a downstream filter may or
// may not decommit the connection's allocator. A memory leak could
// occur if the allocator is not decommited when a connection is broken.
HRESULT hr = m_pAllocator->Decommit();
- if( FAILED( hr ) ) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -2541,7 +2736,8 @@ CBaseOutputPin::BreakConnect()
/* Release any input pin interface we hold */
- if (m_pInputPin) {
+ if(m_pInputPin)
+ {
m_pInputPin->Release();
m_pInputPin = NULL;
}
@@ -2589,19 +2785,23 @@ CBaseOutputPin::DecideAllocator(IMemInputPin *pPin, __deref_out IMemAllocator **
pPin->GetAllocatorRequirements(&prop);
// if he doesn't care about alignment, then set it to 1
- if (prop.cbAlign == 0) {
+ if(prop.cbAlign == 0)
+ {
prop.cbAlign = 1;
}
/* Try the allocator provided by the input pin */
hr = pPin->GetAllocator(ppAlloc);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
hr = DecideBufferSize(*ppAlloc, &prop);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
hr = pPin->NotifyAllocator(*ppAlloc, FALSE);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
return NOERROR;
}
}
@@ -2609,7 +2809,8 @@ CBaseOutputPin::DecideAllocator(IMemInputPin *pPin, __deref_out IMemAllocator **
/* If the GetAllocator failed we may not have an interface */
- if (*ppAlloc) {
+ if(*ppAlloc)
+ {
(*ppAlloc)->Release();
*ppAlloc = NULL;
}
@@ -2617,15 +2818,18 @@ CBaseOutputPin::DecideAllocator(IMemInputPin *pPin, __deref_out IMemAllocator **
/* Try the output pin's allocator by the same method */
hr = InitAllocator(ppAlloc);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
// note - the properties passed here are in the same
// structure as above and may have been modified by
// the previous call to DecideBufferSize
hr = DecideBufferSize(*ppAlloc, &prop);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
hr = pPin->NotifyAllocator(*ppAlloc, FALSE);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
return NOERROR;
}
}
@@ -2633,7 +2837,8 @@ CBaseOutputPin::DecideAllocator(IMemInputPin *pPin, __deref_out IMemAllocator **
/* Likewise we may not have an interface to release */
- if (*ppAlloc) {
+ if(*ppAlloc)
+ {
(*ppAlloc)->Release();
*ppAlloc = NULL;
}
@@ -2650,9 +2855,12 @@ CBaseOutputPin::GetDeliveryBuffer(__deref_out IMediaSample ** ppSample,
__in_opt REFERENCE_TIME * pEndTime,
DWORD dwFlags)
{
- if (m_pAllocator != NULL) {
- return m_pAllocator->GetBuffer(ppSample,pStartTime,pEndTime,dwFlags);
- } else {
+ if(m_pAllocator != NULL)
+ {
+ return m_pAllocator->GetBuffer(ppSample, pStartTime, pEndTime, dwFlags);
+ }
+ else
+ {
return E_NOINTERFACE;
}
}
@@ -2684,12 +2892,13 @@ CBaseOutputPin::GetDeliveryBuffer(__deref_out IMediaSample ** ppSample,
HRESULT
CBaseOutputPin::Deliver(IMediaSample * pSample)
{
- if (m_pInputPin == NULL) {
+ if(m_pInputPin == NULL)
+ {
return VFW_E_NOT_CONNECTED;
}
#ifdef DXMPERF
- PERFLOG_DELIVER( m_pName ? m_pName : L"CBaseOutputPin", (IPin *) this, (IPin *) m_pInputPin, pSample, &m_mt );
+ PERFLOG_DELIVER(m_pName ? m_pName : L"CBaseOutputPin", (IPin *) this, (IPin *) m_pInputPin, pSample, &m_mt);
#endif // DXMPERF
return m_pInputPin->Receive(pSample);
@@ -2702,7 +2911,8 @@ HRESULT
CBaseOutputPin::DeliverEndOfStream(void)
{
// remember this is on IPin not IMemInputPin
- if (m_Connected == NULL) {
+ if(m_Connected == NULL)
+ {
return VFW_E_NOT_CONNECTED;
}
return m_Connected->EndOfStream();
@@ -2715,7 +2925,8 @@ CBaseOutputPin::DeliverEndOfStream(void)
HRESULT
CBaseOutputPin::Active(void)
{
- if (m_pAllocator == NULL) {
+ if(m_pAllocator == NULL)
+ {
return VFW_E_NO_ALLOCATOR;
}
return m_pAllocator->Commit();
@@ -2729,7 +2940,8 @@ HRESULT
CBaseOutputPin::Inactive(void)
{
m_bRunTimeError = FALSE;
- if (m_pAllocator == NULL) {
+ if(m_pAllocator == NULL)
+ {
return VFW_E_NO_ALLOCATOR;
}
return m_pAllocator->Decommit();
@@ -2763,7 +2975,8 @@ HRESULT
CBaseOutputPin::DeliverBeginFlush(void)
{
// remember this is on IPin not IMemInputPin
- if (m_Connected == NULL) {
+ if(m_Connected == NULL)
+ {
return VFW_E_NOT_CONNECTED;
}
return m_Connected->BeginFlush();
@@ -2774,7 +2987,8 @@ HRESULT
CBaseOutputPin::DeliverEndFlush(void)
{
// remember this is on IPin not IMemInputPin
- if (m_Connected == NULL) {
+ if(m_Connected == NULL)
+ {
return VFW_E_NOT_CONNECTED;
}
return m_Connected->EndFlush();
@@ -2786,7 +3000,8 @@ CBaseOutputPin::DeliverNewSegment(
REFERENCE_TIME tStop,
double dRate)
{
- if (m_Connected == NULL) {
+ if(m_Connected == NULL)
+ {
return VFW_E_NOT_CONNECTED;
}
return m_Connected->NewSegment(tStart, tStop, dRate);
@@ -2803,10 +3018,10 @@ CBaseOutputPin::DeliverNewSegment(
/* Constructor creates a default allocator object */
CBaseInputPin::CBaseInputPin(__in_opt LPCTSTR pObjectName,
- __in CBaseFilter *pFilter,
- __in CCritSec *pLock,
- __inout HRESULT *phr,
- __in_opt LPCWSTR pPinName) :
+ __in CBaseFilter *pFilter,
+ __in CCritSec *pLock,
+ __inout HRESULT *phr,
+ __in_opt LPCWSTR pPinName) :
CBasePin(pObjectName, pFilter, pLock, phr, pPinName, PINDIR_INPUT),
m_pAllocator(NULL),
m_bReadOnly(FALSE),
@@ -2817,10 +3032,10 @@ CBaseInputPin::CBaseInputPin(__in_opt LPCTSTR pObjectName,
#ifdef UNICODE
CBaseInputPin::CBaseInputPin(__in LPCSTR pObjectName,
- __in CBaseFilter *pFilter,
- __in CCritSec *pLock,
- __inout HRESULT *phr,
- __in_opt LPCWSTR pPinName) :
+ __in CBaseFilter *pFilter,
+ __in CCritSec *pLock,
+ __inout HRESULT *phr,
+ __in_opt LPCWSTR pPinName) :
CBasePin(pObjectName, pFilter, pLock, phr, pPinName, PINDIR_INPUT),
m_pAllocator(NULL),
m_bReadOnly(FALSE),
@@ -2834,9 +3049,10 @@ CBaseInputPin::CBaseInputPin(__in LPCSTR pObjectName,
CBaseInputPin::~CBaseInputPin()
{
- if (m_pAllocator != NULL) {
- m_pAllocator->Release();
- m_pAllocator = NULL;
+ if(m_pAllocator != NULL)
+ {
+ m_pAllocator->Release();
+ m_pAllocator = NULL;
}
}
@@ -2847,9 +3063,12 @@ CBaseInputPin::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
/* Do we know about this interface */
- if (riid == IID_IMemInputPin) {
+ if(riid == IID_IMemInputPin)
+ {
return GetInterface((IMemInputPin *) this, ppv);
- } else {
+ }
+ else
+ {
return CBasePin::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -2870,13 +3089,15 @@ STDMETHODIMP
CBaseInputPin::GetAllocator(
__deref_out IMemAllocator **ppAllocator)
{
- CheckPointer(ppAllocator,E_POINTER);
- ValidateReadWritePtr(ppAllocator,sizeof(IMemAllocator *));
+ CheckPointer(ppAllocator, E_POINTER);
+ ValidateReadWritePtr(ppAllocator, sizeof(IMemAllocator *));
CAutoLock cObjectLock(m_pLock);
- if (m_pAllocator == NULL) {
+ if(m_pAllocator == NULL)
+ {
HRESULT hr = CreateMemoryAllocator(&m_pAllocator);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
}
@@ -2897,15 +3118,16 @@ CBaseInputPin::NotifyAllocator(
IMemAllocator * pAllocator,
BOOL bReadOnly)
{
- CheckPointer(pAllocator,E_POINTER);
- ValidateReadPtr(pAllocator,sizeof(IMemAllocator));
+ CheckPointer(pAllocator, E_POINTER);
+ ValidateReadPtr(pAllocator, sizeof(IMemAllocator));
CAutoLock cObjectLock(m_pLock);
IMemAllocator *pOldAllocator = m_pAllocator;
pAllocator->AddRef();
m_pAllocator = pAllocator;
- if (pOldAllocator != NULL) {
+ if(pOldAllocator != NULL)
+ {
pOldAllocator->Release();
}
@@ -2921,12 +3143,14 @@ HRESULT
CBaseInputPin::BreakConnect()
{
/* We don't need our allocator any more */
- if (m_pAllocator) {
+ if(m_pAllocator)
+ {
// Always decommit the allocator because a downstream filter may or
// may not decommit the connection's allocator. A memory leak could
// occur if the allocator is not decommited when a pin is disconnected.
HRESULT hr = m_pAllocator->Decommit();
- if( FAILED( hr ) ) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -2951,49 +3175,59 @@ CBaseInputPin::BreakConnect()
STDMETHODIMP
CBaseInputPin::Receive(IMediaSample *pSample)
{
- CheckPointer(pSample,E_POINTER);
- ValidateReadPtr(pSample,sizeof(IMediaSample));
+ CheckPointer(pSample, E_POINTER);
+ ValidateReadPtr(pSample, sizeof(IMediaSample));
ASSERT(pSample);
HRESULT hr = CheckStreaming();
- if (S_OK != hr) {
+ if(S_OK != hr)
+ {
return hr;
}
#ifdef DXMPERF
- PERFLOG_RECEIVE( m_pName ? m_pName : L"CBaseInputPin", (IPin *) m_Connected, (IPin *) this, pSample, &m_mt );
+ PERFLOG_RECEIVE(m_pName ? m_pName : L"CBaseInputPin", (IPin *) m_Connected, (IPin *) this, pSample, &m_mt);
#endif // DXMPERF
/* Check for IMediaSample2 */
IMediaSample2 *pSample2;
- if (SUCCEEDED(pSample->QueryInterface(IID_IMediaSample2, (void **)&pSample2))) {
+ if(SUCCEEDED(pSample->QueryInterface(IID_IMediaSample2, (void **)&pSample2)))
+ {
hr = pSample2->GetProperties(sizeof(m_SampleProps), (PBYTE)&m_SampleProps);
pSample2->Release();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
- } else {
+ }
+ else
+ {
/* Get the properties the hard way */
m_SampleProps.cbData = sizeof(m_SampleProps);
m_SampleProps.dwTypeSpecificFlags = 0;
m_SampleProps.dwStreamId = AM_STREAM_MEDIA;
m_SampleProps.dwSampleFlags = 0;
- if (S_OK == pSample->IsDiscontinuity()) {
+ if(S_OK == pSample->IsDiscontinuity())
+ {
m_SampleProps.dwSampleFlags |= AM_SAMPLE_DATADISCONTINUITY;
}
- if (S_OK == pSample->IsPreroll()) {
+ if(S_OK == pSample->IsPreroll())
+ {
m_SampleProps.dwSampleFlags |= AM_SAMPLE_PREROLL;
}
- if (S_OK == pSample->IsSyncPoint()) {
+ if(S_OK == pSample->IsSyncPoint())
+ {
m_SampleProps.dwSampleFlags |= AM_SAMPLE_SPLICEPOINT;
}
- if (SUCCEEDED(pSample->GetTime(&m_SampleProps.tStart,
- &m_SampleProps.tStop))) {
+ if(SUCCEEDED(pSample->GetTime(&m_SampleProps.tStart,
+ &m_SampleProps.tStop)))
+ {
m_SampleProps.dwSampleFlags |= AM_SAMPLE_TIMEVALID |
AM_SAMPLE_STOPVALID;
}
- if (S_OK == pSample->GetMediaType(&m_SampleProps.pMediaType)) {
+ if(S_OK == pSample->GetMediaType(&m_SampleProps.pMediaType))
+ {
m_SampleProps.dwSampleFlags |= AM_SAMPLE_TYPECHANGED;
}
pSample->GetPointer(&m_SampleProps.pbBuffer);
@@ -3003,7 +3237,8 @@ CBaseInputPin::Receive(IMediaSample *pSample)
/* Has the format changed in this sample */
- if (!(m_SampleProps.dwSampleFlags & AM_SAMPLE_TYPECHANGED)) {
+ if(!(m_SampleProps.dwSampleFlags & AM_SAMPLE_TYPECHANGED))
+ {
return NOERROR;
}
@@ -3012,7 +3247,8 @@ CBaseInputPin::Receive(IMediaSample *pSample)
hr = CheckMediaType((CMediaType *)m_SampleProps.pMediaType);
- if (hr == NOERROR) {
+ if(hr == NOERROR)
+ {
return NOERROR;
}
@@ -3020,31 +3256,33 @@ CBaseInputPin::Receive(IMediaSample *pSample)
m_bRunTimeError = TRUE;
EndOfStream();
- m_pFilter->NotifyEvent(EC_ERRORABORT,VFW_E_TYPE_NOT_ACCEPTED,0);
+ m_pFilter->NotifyEvent(EC_ERRORABORT, VFW_E_TYPE_NOT_ACCEPTED, 0);
return VFW_E_INVALIDMEDIATYPE;
}
/* Receive multiple samples */
STDMETHODIMP
-CBaseInputPin::ReceiveMultiple (
+CBaseInputPin::ReceiveMultiple(
__in_ecount(nSamples) IMediaSample **pSamples,
long nSamples,
__out long *nSamplesProcessed)
{
- CheckPointer(pSamples,E_POINTER);
- ValidateReadPtr(pSamples,nSamples * sizeof(IMediaSample *));
+ CheckPointer(pSamples, E_POINTER);
+ ValidateReadPtr(pSamples, nSamples * sizeof(IMediaSample *));
HRESULT hr = S_OK;
*nSamplesProcessed = 0;
- while (nSamples-- > 0) {
- hr = Receive(pSamples[*nSamplesProcessed]);
+ while(nSamples-- > 0)
+ {
+ hr = Receive(pSamples[*nSamplesProcessed]);
- /* S_FALSE means don't send any more */
- if (hr != S_OK) {
- break;
- }
- (*nSamplesProcessed)++;
+ /* S_FALSE means don't send any more */
+ if(hr != S_OK)
+ {
+ break;
+ }
+ (*nSamplesProcessed)++;
}
return hr;
}
@@ -3058,36 +3296,45 @@ CBaseInputPin::ReceiveCanBlock()
*/
int cPins = m_pFilter->GetPinCount();
int cOutputPins = 0;
- for (int c = 0; c < cPins; c++) {
+ for(int c = 0; c < cPins; c++)
+ {
CBasePin *pPin = m_pFilter->GetPin(c);
- if (NULL == pPin) {
+ if(NULL == pPin)
+ {
break;
}
PIN_DIRECTION pd;
HRESULT hr = pPin->QueryDirection(&pd);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
- if (pd == PINDIR_OUTPUT) {
+ if(pd == PINDIR_OUTPUT)
+ {
IPin *pConnected;
hr = pPin->ConnectedTo(&pConnected);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
ASSERT(pConnected != NULL);
cOutputPins++;
IMemInputPin *pInputPin;
hr = pConnected->QueryInterface(
- IID_IMemInputPin,
- (void **)&pInputPin);
+ IID_IMemInputPin,
+ (void **)&pInputPin);
pConnected->Release();
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
hr = pInputPin->ReceiveCanBlock();
pInputPin->Release();
- if (hr != S_FALSE) {
+ if(hr != S_FALSE)
+ {
return S_OK;
}
- } else {
+ }
+ else
+ {
/* There's a transport we don't understand here */
return S_OK;
}
@@ -3153,8 +3400,8 @@ STDMETHODIMP
CBaseInputPin::Notify(IBaseFilter * pSender, Quality q)
{
UNREFERENCED_PARAMETER(q);
- CheckPointer(pSender,E_POINTER);
- ValidateReadPtr(pSender,sizeof(IBaseFilter));
+ CheckPointer(pSender, E_POINTER);
+ ValidateReadPtr(pSender, sizeof(IBaseFilter));
DbgBreak("IQuality::Notify called on an input pin");
return NOERROR;
} // Notify
@@ -3166,7 +3413,8 @@ HRESULT
CBaseInputPin::Inactive(void)
{
m_bRunTimeError = FALSE;
- if (m_pAllocator == NULL) {
+ if(m_pAllocator == NULL)
+ {
return VFW_E_NO_ALLOCATOR;
}
@@ -3194,13 +3442,16 @@ CBaseInputPin::CheckStreaming()
ASSERT(IsConnected());
// Don't process stuff in Stopped state
- if (IsStopped()) {
+ if(IsStopped())
+ {
return VFW_E_WRONG_STATE;
}
- if (m_bFlushing) {
+ if(m_bFlushing)
+ {
return S_FALSE;
}
- if (m_bRunTimeError) {
+ if(m_bRunTimeError)
+ {
return VFW_E_RUNTIME_ERROR;
}
return S_OK;
@@ -3216,19 +3467,24 @@ CBaseInputPin::PassNotify(Quality& q)
// We pass the message on, which means that we find the quality sink
// for our input pin and send it there
- DbgLog((LOG_TRACE,3,TEXT("Passing Quality notification through transform")));
- if (m_pQSink!=NULL) {
+ DbgLog((LOG_TRACE, 3, TEXT("Passing Quality notification through transform")));
+ if(m_pQSink != NULL)
+ {
return m_pQSink->Notify(m_pFilter, q);
- } else {
+ }
+ else
+ {
// no sink set, so pass it upstream
HRESULT hr;
IQualityControl * pIQC;
hr = VFW_E_NOT_FOUND; // default
- if (m_Connected) {
+ if(m_Connected)
+ {
m_Connected->QueryInterface(IID_IQualityControl, (void**)&pIQC);
- if (pIQC!=NULL) {
+ if(pIQC != NULL)
+ {
hr = pIQC->Notify(m_pFilter, q);
pIQC->Release();
}
@@ -3257,10 +3513,10 @@ CBaseInputPin::PassNotify(Quality& q)
/* The last two parameters have default values of NULL and zero */
CMediaSample::CMediaSample(__in_opt LPCTSTR pName,
- __in_opt CBaseAllocator *pAllocator,
- __inout_opt HRESULT *phr,
- __in_bcount_opt(length) LPBYTE pBuffer,
- LONG length) :
+ __in_opt CBaseAllocator *pAllocator,
+ __inout_opt HRESULT *phr,
+ __in_bcount_opt(length) LPBYTE pBuffer,
+ LONG length) :
m_pBuffer(pBuffer), // Initialise the buffer
m_cbBuffer(length), // And it's length
m_lActual(length), // By default, actual = length
@@ -3272,7 +3528,7 @@ CMediaSample::CMediaSample(__in_opt LPCTSTR pName,
m_pAllocator(pAllocator) // Allocator
{
#ifdef DXMPERF
- PERFLOG_CTOR( pName ? pName : L"CMediaSample", (IMediaSample *) this );
+ PERFLOG_CTOR(pName ? pName : L"CMediaSample", (IMediaSample *) this);
#endif // DXMPERF
/* We must have an owner and it must also be derived from class
@@ -3280,7 +3536,8 @@ CMediaSample::CMediaSample(__in_opt LPCTSTR pName,
ASSERT(pAllocator);
- if (length < 0) {
+ if(length < 0)
+ {
*phr = VFW_E_BUFFER_OVERFLOW;
m_cbBuffer = 0;
}
@@ -3288,10 +3545,10 @@ CMediaSample::CMediaSample(__in_opt LPCTSTR pName,
#ifdef UNICODE
CMediaSample::CMediaSample(__in_opt LPCSTR pName,
- __in_opt CBaseAllocator *pAllocator,
- __inout_opt HRESULT *phr,
- __in_bcount_opt(length) LPBYTE pBuffer,
- LONG length) :
+ __in_opt CBaseAllocator *pAllocator,
+ __inout_opt HRESULT *phr,
+ __in_bcount_opt(length) LPBYTE pBuffer,
+ LONG length) :
m_pBuffer(pBuffer), // Initialise the buffer
m_cbBuffer(length), // And it's length
m_lActual(length), // By default, actual = length
@@ -3303,7 +3560,7 @@ CMediaSample::CMediaSample(__in_opt LPCSTR pName,
m_pAllocator(pAllocator) // Allocator
{
#ifdef DXMPERF
- PERFLOG_CTOR( L"CMediaSample", (IMediaSample *) this );
+ PERFLOG_CTOR(L"CMediaSample", (IMediaSample *) this);
#endif // DXMPERF
/* We must have an owner and it must also be derived from class
@@ -3318,11 +3575,12 @@ CMediaSample::CMediaSample(__in_opt LPCSTR pName,
CMediaSample::~CMediaSample()
{
#ifdef DXMPERF
- PERFLOG_DTOR( L"CMediaSample", (IMediaSample *) this );
+ PERFLOG_DTOR(L"CMediaSample", (IMediaSample *) this);
#endif // DXMPERF
- if (m_pMediaType) {
- DeleteMediaType(m_pMediaType);
+ if(m_pMediaType)
+ {
+ DeleteMediaType(m_pMediaType);
}
}
@@ -3331,11 +3589,14 @@ CMediaSample::~CMediaSample()
STDMETHODIMP
CMediaSample::QueryInterface(REFIID riid, __deref_out void **ppv)
{
- if (riid == IID_IMediaSample ||
- riid == IID_IMediaSample2 ||
- riid == IID_IUnknown) {
+ if(riid == IID_IMediaSample ||
+ riid == IID_IMediaSample2 ||
+ riid == IID_IUnknown)
+ {
return GetInterface((IMediaSample *) this, ppv);
- } else {
+ }
+ else
+ {
*ppv = NULL;
return E_NOINTERFACE;
}
@@ -3370,21 +3631,26 @@ CMediaSample::Release()
{
/* Decrement our own private reference count */
LONG lRef;
- if (m_cRef == 1) {
+ if(m_cRef == 1)
+ {
lRef = 0;
m_cRef = 0;
- } else {
+ }
+ else
+ {
lRef = InterlockedDecrement(&m_cRef);
}
ASSERT(lRef >= 0);
- DbgLog((LOG_MEMORY,3,TEXT(" Unknown %X ref-- = %d"),
- this, m_cRef));
+ DbgLog((LOG_MEMORY, 3, TEXT(" Unknown %X ref-- = %d"),
+ this, m_cRef));
/* Did we release our final reference count */
- if (lRef == 0) {
+ if(lRef == 0)
+ {
/* Free all resources */
- if (m_dwFlags & Sample_TypeChanged) {
+ if(m_dwFlags & Sample_TypeChanged)
+ {
SetMediaType(NULL);
}
ASSERT(m_pMediaType == NULL);
@@ -3407,7 +3673,8 @@ CMediaSample::Release()
HRESULT
CMediaSample::SetPointer(__in_bcount(cBytes) BYTE * ptr, LONG cBytes)
{
- if (cBytes < 0) {
+ if(cBytes < 0)
+ {
return VFW_E_BUFFER_OVERFLOW;
}
m_pBuffer = ptr; // new buffer area (could be null)
@@ -3423,7 +3690,7 @@ CMediaSample::SetPointer(__in_bcount(cBytes) BYTE * ptr, LONG cBytes)
STDMETHODIMP
CMediaSample::GetPointer(__deref_out BYTE ** ppBuffer)
{
- ValidateReadWritePtr(ppBuffer,sizeof(BYTE *));
+ ValidateReadWritePtr(ppBuffer, sizeof(BYTE *));
// creator must have set pointer either during
// constructor or by SetPointer
@@ -3449,13 +3716,17 @@ CMediaSample::GetTime(
__out REFERENCE_TIME * pTimeEnd
)
{
- ValidateReadWritePtr(pTimeStart,sizeof(REFERENCE_TIME));
- ValidateReadWritePtr(pTimeEnd,sizeof(REFERENCE_TIME));
+ ValidateReadWritePtr(pTimeStart, sizeof(REFERENCE_TIME));
+ ValidateReadWritePtr(pTimeEnd, sizeof(REFERENCE_TIME));
- if (!(m_dwFlags & Sample_StopValid)) {
- if (!(m_dwFlags & Sample_TimeValid)) {
+ if(!(m_dwFlags & Sample_StopValid))
+ {
+ if(!(m_dwFlags & Sample_TimeValid))
+ {
return VFW_E_SAMPLE_TIME_NOT_SET;
- } else {
+ }
+ else
+ {
*pTimeStart = m_Start;
// Make sure old stuff works
@@ -3478,17 +3749,23 @@ CMediaSample::SetTime(
__in_opt REFERENCE_TIME * pTimeEnd
)
{
- if (pTimeStart == NULL) {
+ if(pTimeStart == NULL)
+ {
ASSERT(pTimeEnd == NULL);
m_dwFlags &= ~(Sample_TimeValid | Sample_StopValid);
- } else {
- if (pTimeEnd == NULL) {
+ }
+ else
+ {
+ if(pTimeEnd == NULL)
+ {
m_Start = *pTimeStart;
m_dwFlags |= Sample_TimeValid;
m_dwFlags &= ~Sample_StopValid;
- } else {
- ValidateReadPtr(pTimeStart,sizeof(REFERENCE_TIME));
- ValidateReadPtr(pTimeEnd,sizeof(REFERENCE_TIME));
+ }
+ else
+ {
+ ValidateReadPtr(pTimeStart, sizeof(REFERENCE_TIME));
+ ValidateReadPtr(pTimeEnd, sizeof(REFERENCE_TIME));
ASSERT(*pTimeEnd >= *pTimeStart);
m_Start = *pTimeStart;
@@ -3507,10 +3784,11 @@ CMediaSample::GetMediaTime(
__out LONGLONG * pTimeEnd
)
{
- ValidateReadWritePtr(pTimeStart,sizeof(LONGLONG));
- ValidateReadWritePtr(pTimeEnd,sizeof(LONGLONG));
+ ValidateReadWritePtr(pTimeStart, sizeof(LONGLONG));
+ ValidateReadWritePtr(pTimeEnd, sizeof(LONGLONG));
- if (!(m_dwFlags & Sample_MediaTimeValid)) {
+ if(!(m_dwFlags & Sample_MediaTimeValid))
+ {
return VFW_E_MEDIA_TIME_NOT_SET;
}
@@ -3527,15 +3805,19 @@ CMediaSample::SetMediaTime(
__in_opt LONGLONG * pTimeEnd
)
{
- if (pTimeStart == NULL) {
+ if(pTimeStart == NULL)
+ {
ASSERT(pTimeEnd == NULL);
m_dwFlags &= ~Sample_MediaTimeValid;
- } else {
- if (NULL == pTimeEnd) {
+ }
+ else
+ {
+ if(NULL == pTimeEnd)
+ {
return E_POINTER;
}
- ValidateReadPtr(pTimeStart,sizeof(LONGLONG));
- ValidateReadPtr(pTimeEnd,sizeof(LONGLONG));
+ ValidateReadPtr(pTimeStart, sizeof(LONGLONG));
+ ValidateReadPtr(pTimeEnd, sizeof(LONGLONG));
ASSERT(*pTimeEnd >= *pTimeStart);
m_MediaStart = *pTimeStart;
@@ -3549,9 +3831,12 @@ CMediaSample::SetMediaTime(
STDMETHODIMP
CMediaSample::IsSyncPoint(void)
{
- if (m_dwFlags & Sample_SyncPoint) {
+ if(m_dwFlags & Sample_SyncPoint)
+ {
return S_OK;
- } else {
+ }
+ else
+ {
return S_FALSE;
}
}
@@ -3560,9 +3845,12 @@ CMediaSample::IsSyncPoint(void)
STDMETHODIMP
CMediaSample::SetSyncPoint(BOOL bIsSyncPoint)
{
- if (bIsSyncPoint) {
+ if(bIsSyncPoint)
+ {
m_dwFlags |= Sample_SyncPoint;
- } else {
+ }
+ else
+ {
m_dwFlags &= ~Sample_SyncPoint;
}
return NOERROR;
@@ -3574,9 +3862,12 @@ CMediaSample::SetSyncPoint(BOOL bIsSyncPoint)
STDMETHODIMP
CMediaSample::IsDiscontinuity(void)
{
- if (m_dwFlags & Sample_Discontinuity) {
+ if(m_dwFlags & Sample_Discontinuity)
+ {
return S_OK;
- } else {
+ }
+ else
+ {
return S_FALSE;
}
}
@@ -3587,9 +3878,12 @@ STDMETHODIMP
CMediaSample::SetDiscontinuity(BOOL bDiscont)
{
// should be TRUE or FALSE
- if (bDiscont) {
+ if(bDiscont)
+ {
m_dwFlags |= Sample_Discontinuity;
- } else {
+ }
+ else
+ {
m_dwFlags &= ~Sample_Discontinuity;
}
return S_OK;
@@ -3598,9 +3892,12 @@ CMediaSample::SetDiscontinuity(BOOL bDiscont)
STDMETHODIMP
CMediaSample::IsPreroll(void)
{
- if (m_dwFlags & Sample_Preroll) {
+ if(m_dwFlags & Sample_Preroll)
+ {
return S_OK;
- } else {
+ }
+ else
+ {
return S_FALSE;
}
}
@@ -3609,9 +3906,12 @@ CMediaSample::IsPreroll(void)
STDMETHODIMP
CMediaSample::SetPreroll(BOOL bIsPreroll)
{
- if (bIsPreroll) {
+ if(bIsPreroll)
+ {
m_dwFlags |= Sample_Preroll;
- } else {
+ }
+ else
+ {
m_dwFlags &= ~Sample_Preroll;
}
return NOERROR;
@@ -3627,7 +3927,8 @@ CMediaSample::GetActualDataLength(void)
STDMETHODIMP
CMediaSample::SetActualDataLength(LONG lActual)
{
- if (lActual > m_cbBuffer || lActual < 0) {
+ if(lActual > m_cbBuffer || lActual < 0)
+ {
ASSERT(lActual <= GetSize());
return VFW_E_BUFFER_OVERFLOW;
}
@@ -3641,12 +3942,13 @@ CMediaSample::SetActualDataLength(LONG lActual)
STDMETHODIMP
CMediaSample::GetMediaType(__deref_out AM_MEDIA_TYPE **ppMediaType)
{
- ValidateReadWritePtr(ppMediaType,sizeof(AM_MEDIA_TYPE *));
+ ValidateReadWritePtr(ppMediaType, sizeof(AM_MEDIA_TYPE *));
ASSERT(ppMediaType);
/* Do we have a new media type for them */
- if (!(m_dwFlags & Sample_TypeChanged)) {
+ if(!(m_dwFlags & Sample_TypeChanged))
+ {
ASSERT(m_pMediaType == NULL);
*ppMediaType = NULL;
return S_FALSE;
@@ -3657,7 +3959,8 @@ CMediaSample::GetMediaType(__deref_out AM_MEDIA_TYPE **ppMediaType)
/* Create a copy of our media type */
*ppMediaType = CreateMediaType(m_pMediaType);
- if (*ppMediaType == NULL) {
+ if(*ppMediaType == NULL)
+ {
return E_OUTOFMEMORY;
}
return NOERROR;
@@ -3671,25 +3974,28 @@ CMediaSample::SetMediaType(__in_opt AM_MEDIA_TYPE *pMediaType)
{
/* Delete the current media type */
- if (m_pMediaType) {
+ if(m_pMediaType)
+ {
DeleteMediaType(m_pMediaType);
m_pMediaType = NULL;
}
/* Mechanism for resetting the format type */
- if (pMediaType == NULL) {
+ if(pMediaType == NULL)
+ {
m_dwFlags &= ~Sample_TypeChanged;
return NOERROR;
}
ASSERT(pMediaType);
- ValidateReadPtr(pMediaType,sizeof(AM_MEDIA_TYPE));
+ ValidateReadPtr(pMediaType, sizeof(AM_MEDIA_TYPE));
/* Take a copy of the media type */
m_pMediaType = CreateMediaType(pMediaType);
- if (m_pMediaType == NULL) {
+ if(m_pMediaType == NULL)
+ {
m_dwFlags &= ~Sample_TypeChanged;
return E_OUTOFMEMORY;
}
@@ -3704,7 +4010,8 @@ STDMETHODIMP CMediaSample::GetProperties(
__out_bcount(cbProperties) BYTE * pbProperties
)
{
- if (0 != cbProperties) {
+ if(0 != cbProperties)
+ {
CheckPointer(pbProperties, E_POINTER);
// Return generic stuff up to the length
AM_SAMPLE2_PROPERTIES Props;
@@ -3717,9 +4024,12 @@ STDMETHODIMP CMediaSample::GetProperties(
Props.tStart = m_Start;
Props.tStop = m_End;
Props.dwStreamId = m_dwStreamId;
- if (m_dwFlags & AM_SAMPLE_TYPECHANGED) {
+ if(m_dwFlags & AM_SAMPLE_TYPECHANGED)
+ {
Props.pMediaType = m_pMediaType;
- } else {
+ }
+ else
+ {
Props.pMediaType = NULL;
}
CopyMemory(pbProperties, &Props, Props.cbData);
@@ -3739,107 +4049,133 @@ HRESULT CMediaSample::SetProperties(
/* Generic properties */
AM_MEDIA_TYPE *pMediaType = NULL;
- if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, cbData, cbProperties)) {
+ if(CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, cbData, cbProperties))
+ {
CheckPointer(pbProperties, E_POINTER);
AM_SAMPLE2_PROPERTIES *pProps =
(AM_SAMPLE2_PROPERTIES *)pbProperties;
/* Don't use more data than is actually there */
- if (pProps->cbData < cbProperties) {
+ if(pProps->cbData < cbProperties)
+ {
cbProperties = pProps->cbData;
}
/* We only handle IMediaSample2 */
- if (cbProperties > sizeof(*pProps) ||
- pProps->cbData > sizeof(*pProps)) {
+ if(cbProperties > sizeof(*pProps) ||
+ pProps->cbData > sizeof(*pProps))
+ {
return E_INVALIDARG;
}
/* Do checks first, the assignments (for backout) */
- if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwSampleFlags, cbProperties)) {
+ if(CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwSampleFlags, cbProperties))
+ {
/* Check the flags */
- if (pProps->dwSampleFlags &
- (~Sample_ValidFlags | Sample_MediaTimeValid)) {
+ if(pProps->dwSampleFlags &
+ (~Sample_ValidFlags | Sample_MediaTimeValid))
+ {
return E_INVALIDARG;
}
/* Check a flag isn't being set for a property
not being provided
*/
- if ((pProps->dwSampleFlags & AM_SAMPLE_TIMEVALID) &&
- !(m_dwFlags & AM_SAMPLE_TIMEVALID) &&
- !CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, tStop, cbProperties)) {
- return E_INVALIDARG;
+ if((pProps->dwSampleFlags & AM_SAMPLE_TIMEVALID) &&
+ !(m_dwFlags & AM_SAMPLE_TIMEVALID) &&
+ !CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, tStop, cbProperties))
+ {
+ return E_INVALIDARG;
}
}
/* NB - can't SET the pointer or size */
- if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, pbBuffer, cbProperties)) {
+ if(CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, pbBuffer, cbProperties))
+ {
/* Check pbBuffer */
- if (pProps->pbBuffer != 0 && pProps->pbBuffer != m_pBuffer) {
+ if(pProps->pbBuffer != 0 && pProps->pbBuffer != m_pBuffer)
+ {
return E_INVALIDARG;
}
}
- if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, cbBuffer, cbProperties)) {
+ if(CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, cbBuffer, cbProperties))
+ {
/* Check cbBuffer */
- if (pProps->cbBuffer != 0 && pProps->cbBuffer != m_cbBuffer) {
+ if(pProps->cbBuffer != 0 && pProps->cbBuffer != m_cbBuffer)
+ {
return E_INVALIDARG;
}
}
- if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, cbBuffer, cbProperties) &&
- CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, lActual, cbProperties)) {
+ if(CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, cbBuffer, cbProperties) &&
+ CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, lActual, cbProperties))
+ {
/* Check lActual */
- if (pProps->cbBuffer < pProps->lActual) {
+ if(pProps->cbBuffer < pProps->lActual)
+ {
return E_INVALIDARG;
}
}
- if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, pMediaType, cbProperties)) {
+ if(CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, pMediaType, cbProperties))
+ {
/* Check pMediaType */
- if (pProps->dwSampleFlags & AM_SAMPLE_TYPECHANGED) {
+ if(pProps->dwSampleFlags & AM_SAMPLE_TYPECHANGED)
+ {
CheckPointer(pProps->pMediaType, E_POINTER);
pMediaType = CreateMediaType(pProps->pMediaType);
- if (pMediaType == NULL) {
+ if(pMediaType == NULL)
+ {
return E_OUTOFMEMORY;
}
}
}
/* Now do the assignments */
- if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwStreamId, cbProperties)) {
+ if(CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwStreamId, cbProperties))
+ {
m_dwStreamId = pProps->dwStreamId;
}
- if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwSampleFlags, cbProperties)) {
+ if(CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwSampleFlags, cbProperties))
+ {
/* Set the flags */
m_dwFlags = pProps->dwSampleFlags |
- (m_dwFlags & Sample_MediaTimeValid);
+ (m_dwFlags & Sample_MediaTimeValid);
m_dwTypeSpecificFlags = pProps->dwTypeSpecificFlags;
- } else {
- if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwTypeSpecificFlags, cbProperties)) {
+ }
+ else
+ {
+ if(CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwTypeSpecificFlags, cbProperties))
+ {
m_dwTypeSpecificFlags = pProps->dwTypeSpecificFlags;
}
}
- if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, lActual, cbProperties)) {
+ if(CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, lActual, cbProperties))
+ {
/* Set lActual */
m_lActual = pProps->lActual;
}
- if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, tStop, cbProperties)) {
+ if(CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, tStop, cbProperties))
+ {
/* Set the times */
m_End = pProps->tStop;
}
- if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, tStart, cbProperties)) {
+ if(CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, tStart, cbProperties))
+ {
/* Set the times */
m_Start = pProps->tStart;
}
- if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, pMediaType, cbProperties)) {
+ if(CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, pMediaType, cbProperties))
+ {
/* Set pMediaType */
- if (pProps->dwSampleFlags & AM_SAMPLE_TYPECHANGED) {
- if (m_pMediaType != NULL) {
+ if(pProps->dwSampleFlags & AM_SAMPLE_TYPECHANGED)
+ {
+ if(m_pMediaType != NULL)
+ {
DeleteMediaType(m_pMediaType);
}
m_pMediaType = pMediaType;
@@ -3851,9 +4187,12 @@ HRESULT CMediaSample::SetProperties(
output does then if we don't do this we'd lose the
output media type.
*/
- if (m_pMediaType) {
+ if(m_pMediaType)
+ {
m_dwFlags |= Sample_TypeChanged;
- } else {
+ }
+ else
+ {
m_dwFlags &= ~Sample_TypeChanged;
}
}
@@ -3889,18 +4228,19 @@ CDynamicOutputPin::CDynamicOutputPin(
__in CCritSec *pLock,
__inout HRESULT *phr,
__in_opt LPCWSTR pName) :
- CBaseOutputPin(pObjectName, pFilter, pLock, phr, pName),
- m_hStopEvent(NULL),
- m_pGraphConfig(NULL),
- m_bPinUsesReadOnlyAllocator(FALSE),
- m_BlockState(NOT_BLOCKED),
- m_hUnblockOutputPinEvent(NULL),
- m_hNotifyCallerPinBlockedEvent(NULL),
- m_dwBlockCallerThreadID(0),
- m_dwNumOutstandingOutputPinUsers(0)
+ CBaseOutputPin(pObjectName, pFilter, pLock, phr, pName),
+ m_hStopEvent(NULL),
+ m_pGraphConfig(NULL),
+ m_bPinUsesReadOnlyAllocator(FALSE),
+ m_BlockState(NOT_BLOCKED),
+ m_hUnblockOutputPinEvent(NULL),
+ m_hNotifyCallerPinBlockedEvent(NULL),
+ m_dwBlockCallerThreadID(0),
+ m_dwNumOutstandingOutputPinUsers(0)
{
HRESULT hr = Initialize();
- if( FAILED( hr ) ) {
+ if(FAILED(hr))
+ {
*phr = hr;
return;
}
@@ -3913,18 +4253,19 @@ CDynamicOutputPin::CDynamicOutputPin(
__in CCritSec *pLock,
__inout HRESULT *phr,
__in_opt LPCWSTR pName) :
- CBaseOutputPin(pObjectName, pFilter, pLock, phr, pName),
- m_hStopEvent(NULL),
- m_pGraphConfig(NULL),
- m_bPinUsesReadOnlyAllocator(FALSE),
- m_BlockState(NOT_BLOCKED),
- m_hUnblockOutputPinEvent(NULL),
- m_hNotifyCallerPinBlockedEvent(NULL),
- m_dwBlockCallerThreadID(0),
- m_dwNumOutstandingOutputPinUsers(0)
+ CBaseOutputPin(pObjectName, pFilter, pLock, phr, pName),
+ m_hStopEvent(NULL),
+ m_pGraphConfig(NULL),
+ m_bPinUsesReadOnlyAllocator(FALSE),
+ m_BlockState(NOT_BLOCKED),
+ m_hUnblockOutputPinEvent(NULL),
+ m_hNotifyCallerPinBlockedEvent(NULL),
+ m_dwBlockCallerThreadID(0),
+ m_dwNumOutstandingOutputPinUsers(0)
{
HRESULT hr = Initialize();
- if( FAILED( hr ) ) {
+ if(FAILED(hr))
+ {
*phr = hr;
return;
}
@@ -3933,13 +4274,15 @@ CDynamicOutputPin::CDynamicOutputPin(
CDynamicOutputPin::~CDynamicOutputPin()
{
- if(NULL != m_hUnblockOutputPinEvent) {
+ if(NULL != m_hUnblockOutputPinEvent)
+ {
// This call should not fail because we have access to m_hUnblockOutputPinEvent
// and m_hUnblockOutputPinEvent is a valid event.
EXECUTE_ASSERT(::CloseHandle(m_hUnblockOutputPinEvent));
}
- if(NULL != m_hNotifyCallerPinBlockedEvent) {
+ if(NULL != m_hNotifyCallerPinBlockedEvent)
+ {
// This call should not fail because we have access to m_hNotifyCallerPinBlockedEvent
// and m_hNotifyCallerPinBlockedEvent is a valid event.
EXECUTE_ASSERT(::CloseHandle(m_hNotifyCallerPinBlockedEvent));
@@ -3948,13 +4291,14 @@ CDynamicOutputPin::~CDynamicOutputPin()
HRESULT CDynamicOutputPin::Initialize(void)
{
- m_hUnblockOutputPinEvent = ::CreateEvent( NULL, // The event will have the default security descriptor.
- TRUE, // This is a manual reset event.
- TRUE, // The event is initially signaled.
- NULL ); // The event is not named.
+ m_hUnblockOutputPinEvent = ::CreateEvent(NULL, // The event will have the default security descriptor.
+ TRUE, // This is a manual reset event.
+ TRUE, // The event is initially signaled.
+ NULL); // The event is not named.
// CreateEvent() returns NULL if an error occurs.
- if(NULL == m_hUnblockOutputPinEvent) {
+ if(NULL == m_hUnblockOutputPinEvent)
+ {
return AmGetLastErrorToHResult();
}
@@ -3966,9 +4310,12 @@ HRESULT CDynamicOutputPin::Initialize(void)
STDMETHODIMP CDynamicOutputPin::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
- if(riid == IID_IPinFlowControl) {
+ if(riid == IID_IPinFlowControl)
+ {
return GetInterface(static_cast<IPinFlowControl*>(this), ppv);
- } else {
+ }
+ else
+ {
return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -3984,50 +4331,62 @@ STDMETHODIMP CDynamicOutputPin::Block(DWORD dwBlockFlags, HANDLE hEvent)
const DWORD VALID_FLAGS = AM_PIN_FLOW_CONTROL_BLOCK;
// Check for illegal flags.
- if(dwBlockFlags & ~VALID_FLAGS) {
+ if(dwBlockFlags & ~VALID_FLAGS)
+ {
return E_INVALIDARG;
}
// Make sure the event is unsignaled.
- if((dwBlockFlags & AM_PIN_FLOW_CONTROL_BLOCK) && (NULL != hEvent)) {
- if( !::ResetEvent( hEvent ) ) {
+ if((dwBlockFlags & AM_PIN_FLOW_CONTROL_BLOCK) && (NULL != hEvent))
+ {
+ if(!::ResetEvent(hEvent))
+ {
return AmGetLastErrorToHResult();
}
}
// No flags are set if we are unblocking the output pin.
- if(0 == dwBlockFlags) {
+ if(0 == dwBlockFlags)
+ {
// This parameter should be NULL because unblock operations are always synchronous.
// There is no need to notify the caller when the event is done.
- if(NULL != hEvent) {
+ if(NULL != hEvent)
+ {
return E_INVALIDARG;
}
}
- #ifdef _DEBUG
+#ifdef _DEBUG
AssertValid();
- #endif // DEBUG
+#endif // DEBUG
HRESULT hr;
- if(dwBlockFlags & AM_PIN_FLOW_CONTROL_BLOCK) {
+ if(dwBlockFlags & AM_PIN_FLOW_CONTROL_BLOCK)
+ {
// IPinFlowControl::Block()'s hEvent parameter is NULL if the block is synchronous.
// If hEvent is not NULL, the block is asynchronous.
- if(NULL == hEvent) {
+ if(NULL == hEvent)
+ {
hr = SynchronousBlockOutputPin();
- } else {
+ }
+ else
+ {
hr = AsynchronousBlockOutputPin(hEvent);
}
- } else {
+ }
+ else
+ {
hr = UnblockOutputPin();
}
- #ifdef _DEBUG
+#ifdef _DEBUG
AssertValid();
- #endif // DEBUG
+#endif // DEBUG
- if(FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -4036,18 +4395,20 @@ STDMETHODIMP CDynamicOutputPin::Block(DWORD dwBlockFlags, HANDLE hEvent)
HRESULT CDynamicOutputPin::SynchronousBlockOutputPin(void)
{
- HANDLE hNotifyCallerPinBlockedEvent = :: CreateEvent( NULL, // The event will have the default security attributes.
- FALSE, // This is an automatic reset event.
- FALSE, // The event is initially unsignaled.
- NULL ); // The event is not named.
+ HANDLE hNotifyCallerPinBlockedEvent = :: CreateEvent(NULL, // The event will have the default security attributes.
+ FALSE, // This is an automatic reset event.
+ FALSE, // The event is initially unsignaled.
+ NULL); // The event is not named.
// CreateEvent() returns NULL if an error occurs.
- if(NULL == hNotifyCallerPinBlockedEvent) {
+ if(NULL == hNotifyCallerPinBlockedEvent)
+ {
return AmGetLastErrorToHResult();
}
HRESULT hr = AsynchronousBlockOutputPin(hNotifyCallerPinBlockedEvent);
- if(FAILED(hr)) {
+ if(FAILED(hr))
+ {
// This call should not fail because we have access to hNotifyCallerPinBlockedEvent
// and hNotifyCallerPinBlockedEvent is a valid event.
EXECUTE_ASSERT(::CloseHandle(hNotifyCallerPinBlockedEvent));
@@ -4061,7 +4422,8 @@ HRESULT CDynamicOutputPin::SynchronousBlockOutputPin(void)
// and hNotifyCallerPinBlockedEvent is a valid event.
EXECUTE_ASSERT(::CloseHandle(hNotifyCallerPinBlockedEvent));
- if(FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -4075,22 +4437,27 @@ HRESULT CDynamicOutputPin::AsynchronousBlockOutputPin(HANDLE hNotifyCallerPinBlo
// m_hNotifyCallerPinBlockedEvent.
CAutoLock alBlockStateLock(&m_BlockStateLock);
- if(NOT_BLOCKED != m_BlockState) {
- if(m_dwBlockCallerThreadID == ::GetCurrentThreadId()) {
+ if(NOT_BLOCKED != m_BlockState)
+ {
+ if(m_dwBlockCallerThreadID == ::GetCurrentThreadId())
+ {
return VFW_E_PIN_ALREADY_BLOCKED_ON_THIS_THREAD;
- } else {
+ }
+ else
+ {
return VFW_E_PIN_ALREADY_BLOCKED;
}
}
- BOOL fSuccess = ::DuplicateHandle( ::GetCurrentProcess(),
- hNotifyCallerPinBlockedEvent,
- ::GetCurrentProcess(),
- &m_hNotifyCallerPinBlockedEvent,
- EVENT_MODIFY_STATE,
- FALSE,
- 0 );
- if( !fSuccess ) {
+ BOOL fSuccess = ::DuplicateHandle(::GetCurrentProcess(),
+ hNotifyCallerPinBlockedEvent,
+ ::GetCurrentProcess(),
+ &m_hNotifyCallerPinBlockedEvent,
+ EVENT_MODIFY_STATE,
+ FALSE,
+ 0);
+ if(!fSuccess)
+ {
return AmGetLastErrorToHResult();
}
@@ -4102,7 +4469,8 @@ HRESULT CDynamicOutputPin::AsynchronousBlockOutputPin(HANDLE hNotifyCallerPinBlo
// or IMemInputPin::ReceiveMultiple() on the connected input pin. Also, it
// cannot be blocked if the streaming thread is calling DynamicReconnect(),
// ChangeMediaType() or ChangeOutputFormat().
- if(!StreamingThreadUsingOutputPin()) {
+ if(!StreamingThreadUsingOutputPin())
+ {
// The output pin can be immediately blocked.
BlockOutputPin();
@@ -4141,7 +4509,8 @@ HRESULT CDynamicOutputPin::UnblockOutputPin(void)
// m_hNotifyCallerPinBlockedEvent.
CAutoLock alBlockStateLock(&m_BlockStateLock);
- if(NOT_BLOCKED == m_BlockState) {
+ if(NOT_BLOCKED == m_BlockState)
+ {
return S_FALSE;
}
@@ -4150,7 +4519,8 @@ HRESULT CDynamicOutputPin::UnblockOutputPin(void)
EXECUTE_ASSERT(::SetEvent(m_hUnblockOutputPinEvent));
// Cancel the block operation if it's still pending.
- if(NULL != m_hNotifyCallerPinBlockedEvent) {
+ if(NULL != m_hNotifyCallerPinBlockedEvent)
+ {
// This event should not fail because AsynchronousBlockOutputPin() successfully
// duplicated this handle and we have the appropriate security permissions.
EXECUTE_ASSERT(::SetEvent(m_hNotifyCallerPinBlockedEvent));
@@ -4172,17 +4542,18 @@ HRESULT CDynamicOutputPin::StartUsingOutputPin(void)
CAutoLock alBlockStateLock(&m_BlockStateLock);
- #ifdef _DEBUG
+#ifdef _DEBUG
AssertValid();
- #endif // DEBUG
+#endif // DEBUG
// Are we in the middle of a block operation?
- while(BLOCKED == m_BlockState) {
+ while(BLOCKED == m_BlockState)
+ {
m_BlockStateLock.Unlock();
// If this ASSERT fires, a deadlock could occur. The caller should make sure
// that this thread never acquires the Block State lock more than once.
- ASSERT(CritCheckOut( &m_BlockStateLock ));
+ ASSERT(CritCheckOut(&m_BlockStateLock));
// WaitForMultipleObjects() returns WAIT_OBJECT_0 if the unblock event
// is fired. It returns WAIT_OBJECT_0 + 1 if the stop event if fired.
@@ -4192,17 +4563,18 @@ HRESULT CDynamicOutputPin::StartUsingOutputPin(void)
const DWORD STOP = WAIT_OBJECT_0 + 1;
HANDLE ahWaitEvents[] = { m_hUnblockOutputPinEvent, m_hStopEvent };
- DWORD dwNumWaitEvents = sizeof(ahWaitEvents)/sizeof(HANDLE);
+ DWORD dwNumWaitEvents = sizeof(ahWaitEvents) / sizeof(HANDLE);
- DWORD dwReturnValue = ::WaitForMultipleObjects( dwNumWaitEvents, ahWaitEvents, FALSE, INFINITE );
+ DWORD dwReturnValue = ::WaitForMultipleObjects(dwNumWaitEvents, ahWaitEvents, FALSE, INFINITE);
m_BlockStateLock.Lock();
- #ifdef _DEBUG
+#ifdef _DEBUG
AssertValid();
- #endif // DEBUG
+#endif // DEBUG
- switch( dwReturnValue ) {
+ switch(dwReturnValue)
+ {
case UNBLOCK:
break;
@@ -4213,16 +4585,16 @@ HRESULT CDynamicOutputPin::StartUsingOutputPin(void)
return AmGetLastErrorToHResult();
default:
- DbgBreak( "An Unexpected case occured in CDynamicOutputPin::StartUsingOutputPin()." );
+ DbgBreak("An Unexpected case occured in CDynamicOutputPin::StartUsingOutputPin().");
return E_UNEXPECTED;
}
}
m_dwNumOutstandingOutputPinUsers++;
- #ifdef _DEBUG
+#ifdef _DEBUG
AssertValid();
- #endif // DEBUG
+#endif // DEBUG
return S_OK;
}
@@ -4231,19 +4603,20 @@ void CDynamicOutputPin::StopUsingOutputPin(void)
{
CAutoLock alBlockStateLock(&m_BlockStateLock);
- #ifdef _DEBUG
+#ifdef _DEBUG
AssertValid();
- #endif // DEBUG
+#endif // DEBUG
m_dwNumOutstandingOutputPinUsers--;
- if((m_dwNumOutstandingOutputPinUsers == 0) && (NOT_BLOCKED != m_BlockState)) {
+ if((m_dwNumOutstandingOutputPinUsers == 0) && (NOT_BLOCKED != m_BlockState))
+ {
BlockOutputPin();
}
- #ifdef _DEBUG
+#ifdef _DEBUG
AssertValid();
- #endif // DEBUG
+#endif // DEBUG
}
bool CDynamicOutputPin::StreamingThreadUsingOutputPin(void)
@@ -4266,8 +4639,9 @@ void CDynamicOutputPin::SetConfigInfo(IGraphConfig *pGraphConfig, HANDLE hStopEv
HRESULT CDynamicOutputPin::Active(void)
{
// Make sure the user initialized the object by calling SetConfigInfo().
- if((NULL == m_hStopEvent) || (NULL == m_pGraphConfig)) {
- DbgBreak( ERROR: CDynamicOutputPin::Active() failed because m_pGraphConfig and m_hStopEvent were not initialized. Call SetConfigInfo() to initialize them. );
+ if((NULL == m_hStopEvent) || (NULL == m_pGraphConfig))
+ {
+DbgBreak(ERROR: CDynamicOutputPin::Active() failed because m_pGraphConfig and m_hStopEvent were not initialized. Call SetConfigInfo() to initialize them.);
return E_FAIL;
}
@@ -4317,12 +4691,12 @@ HRESULT CDynamicOutputPin::DeliverEndFlush(void)
// ChangeOutputFormat() either dynamicly changes the connection's format type or it dynamicly
// reconnects the output pin.
HRESULT CDynamicOutputPin::ChangeOutputFormat
- (
+(
const AM_MEDIA_TYPE *pmt,
REFERENCE_TIME tSegmentStart,
REFERENCE_TIME tSegmentStop,
double dSegmentRate
- )
+)
{
// The caller should call StartUsingOutputPin() before calling this
// method.
@@ -4333,12 +4707,14 @@ HRESULT CDynamicOutputPin::ChangeOutputFormat
CMediaType cmt(*pmt);
HRESULT hr = ChangeMediaType(&cmt);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
hr = DeliverNewSegment(tSegmentStart, tSegmentStop, dSegmentRate);
- if( FAILED( hr ) ) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -4354,7 +4730,8 @@ HRESULT CDynamicOutputPin::ChangeMediaType(const CMediaType *pmt)
// This function assumes the filter graph is running.
ASSERT(!IsStopped());
- if(!IsConnected()) {
+ if(!IsConnected())
+ {
return VFW_E_NOT_CONNECTED;
}
@@ -4364,12 +4741,15 @@ HRESULT CDynamicOutputPin::ChangeMediaType(const CMediaType *pmt)
QzCComPtr<IPinConnection> pConnection;
m_Connected->QueryInterface(IID_IPinConnection, (void **)&pConnection);
- if(pConnection != NULL) {
+ if(pConnection != NULL)
+ {
- if(S_OK == pConnection->DynamicQueryAccept(pmt)) {
+ if(S_OK == pConnection->DynamicQueryAccept(pmt))
+ {
HRESULT hr = ChangeMediaTypeHelper(pmt);
- if(FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -4388,17 +4768,20 @@ HRESULT CDynamicOutputPin::ChangeMediaTypeHelper(const CMediaType *pmt)
ASSERT(StreamingThreadUsingOutputPin());
HRESULT hr = m_Connected->ReceiveConnection(this, pmt);
- if(FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
hr = SetMediaType(pmt);
- if(FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
// Does this pin use the local memory transport?
- if(NULL != m_pInputPin) {
+ if(NULL != m_pInputPin)
+ {
// This function assumes that m_pInputPin and m_Connected are
// two different interfaces to the same object.
ASSERT(::IsEqualObject(m_Connected, m_pInputPin));
@@ -4412,27 +4795,32 @@ HRESULT CDynamicOutputPin::ChangeMediaTypeHelper(const CMediaType *pmt)
m_pInputPin->GetAllocatorRequirements(&apInputPinRequirements);
// A zero allignment does not make any sense.
- if(0 == apInputPinRequirements.cbAlign) {
+ if(0 == apInputPinRequirements.cbAlign)
+ {
apInputPinRequirements.cbAlign = 1;
}
hr = m_pAllocator->Decommit();
- if(FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
hr = DecideBufferSize(m_pAllocator, &apInputPinRequirements);
- if(FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
hr = m_pAllocator->Commit();
- if(FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
hr = m_pInputPin->NotifyAllocator(m_pAllocator, m_bPinUsesReadOnlyAllocator);
- if(FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
}
@@ -4445,23 +4833,24 @@ HRESULT CDynamicOutputPin::ChangeMediaTypeHelper(const CMediaType *pmt)
// has no outstand samples because they cannot be delivered after a
// reconnect
//
-HRESULT CDynamicOutputPin::DynamicReconnect( const CMediaType* pmt )
+HRESULT CDynamicOutputPin::DynamicReconnect(const CMediaType* pmt)
{
// The caller should call StartUsingOutputPin() before calling this
// method.
ASSERT(StreamingThreadUsingOutputPin());
- if((m_pGraphConfig == NULL) || (NULL == m_hStopEvent)) {
+ if((m_pGraphConfig == NULL) || (NULL == m_hStopEvent))
+ {
return E_FAIL;
}
HRESULT hr = m_pGraphConfig->Reconnect(
- this,
- NULL,
- pmt,
- NULL,
- m_hStopEvent,
- AM_GRAPH_CONFIG_RECONNECT_CACHE_REMOVED_FILTERS );
+ this,
+ NULL,
+ pmt,
+ NULL,
+ m_hStopEvent,
+ AM_GRAPH_CONFIG_RECONNECT_CACHE_REMOVED_FILTERS);
return hr;
}
@@ -4469,8 +4858,10 @@ HRESULT CDynamicOutputPin::DynamicReconnect( const CMediaType* pmt )
HRESULT CDynamicOutputPin::CompleteConnect(IPin *pReceivePin)
{
HRESULT hr = CBaseOutputPin::CompleteConnect(pReceivePin);
- if(SUCCEEDED(hr)) {
- if(!IsStopped() && m_pAllocator) {
+ if(SUCCEEDED(hr))
+ {
+ if(!IsStopped() && m_pAllocator)
+ {
hr = m_pAllocator->Commit();
ASSERT(hr != VFW_E_ALREADY_COMMITTED);
}
@@ -4503,7 +4894,7 @@ void CDynamicOutputPin::AssertValid(void)
// m_hNotifyCallerPinBlockedEvent is only needed when a block operation cannot complete
// immediately.
ASSERT(((NULL == m_hNotifyCallerPinBlockedEvent) && (PENDING != m_BlockState)) ||
- ((NULL != m_hNotifyCallerPinBlockedEvent) && (PENDING == m_BlockState)) );
+ ((NULL != m_hNotifyCallerPinBlockedEvent) && (PENDING == m_BlockState)));
// m_dwBlockCallerThreadID should always be 0 if the pin is not blocked and
// the user is not trying to block the pin.
@@ -4513,7 +4904,7 @@ void CDynamicOutputPin::AssertValid(void)
// output pin is blocked.
ASSERT(((0 != m_dwNumOutstandingOutputPinUsers) && (BLOCKED != m_BlockState)) ||
((0 == m_dwNumOutstandingOutputPinUsers) && (NOT_BLOCKED != m_BlockState)) ||
- ((0 == m_dwNumOutstandingOutputPinUsers) && (NOT_BLOCKED == m_BlockState)) );
+ ((0 == m_dwNumOutstandingOutputPinUsers) && (NOT_BLOCKED == m_BlockState)));
}
#endif // DEBUG
@@ -4523,7 +4914,8 @@ HRESULT CDynamicOutputPin::WaitEvent(HANDLE hEvent)
DWORD dwReturnValue = ::WaitForSingleObject(hEvent, INFINITE);
- switch( dwReturnValue ) {
+ switch(dwReturnValue)
+ {
case EVENT_SIGNALED:
return S_OK;
@@ -4531,7 +4923,7 @@ HRESULT CDynamicOutputPin::WaitEvent(HANDLE hEvent)
return AmGetLastErrorToHResult();
default:
- DbgBreak( "An Unexpected case occured in CDynamicOutputPin::WaitEvent()." );
+ DbgBreak("An Unexpected case occured in CDynamicOutputPin::WaitEvent().");
return E_UNEXPECTED;
}
}
@@ -4554,7 +4946,7 @@ CBaseAllocator::CBaseAllocator(__in_opt LPCTSTR pName,
__inout HRESULT *phr,
BOOL bEvent,
BOOL fEnableReleaseCallback
- ) :
+ ) :
CUnknown(pName, pUnk),
m_lAllocated(0),
m_bChanged(FALSE),
@@ -4570,12 +4962,14 @@ CBaseAllocator::CBaseAllocator(__in_opt LPCTSTR pName,
m_pNotify(NULL)
{
#ifdef DXMPERF
- PERFLOG_CTOR( pName ? pName : L"CBaseAllocator", (IMemAllocator *) this );
+ PERFLOG_CTOR(pName ? pName : L"CBaseAllocator", (IMemAllocator *) this);
#endif // DXMPERF
- if (bEvent) {
+ if(bEvent)
+ {
m_hSem = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL);
- if (m_hSem == NULL) {
+ if(m_hSem == NULL)
+ {
*phr = E_OUTOFMEMORY;
return;
}
@@ -4603,12 +4997,14 @@ CBaseAllocator::CBaseAllocator(__in_opt LPCSTR pName,
m_pNotify(NULL)
{
#ifdef DXMPERF
- PERFLOG_CTOR( L"CBaseAllocator", (IMemAllocator *) this );
+ PERFLOG_CTOR(L"CBaseAllocator", (IMemAllocator *) this);
#endif // DXMPERF
- if (bEvent) {
+ if(bEvent)
+ {
m_hSem = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL);
- if (m_hSem == NULL) {
+ if(m_hSem == NULL)
+ {
*phr = E_OUTOFMEMORY;
return;
}
@@ -4625,14 +5021,16 @@ CBaseAllocator::~CBaseAllocator()
// We must assume that the derived class has gone into decommit state in
// its destructor.
#ifdef DXMPERF
- PERFLOG_DTOR( L"CBaseAllocator", (IMemAllocator *) this );
+ PERFLOG_DTOR(L"CBaseAllocator", (IMemAllocator *) this);
#endif // DXMPERF
ASSERT(!m_bCommitted);
- if (m_hSem != NULL) {
+ if(m_hSem != NULL)
+ {
EXECUTE_ASSERT(CloseHandle(m_hSem));
}
- if (m_pNotify) {
+ if(m_pNotify)
+ {
m_pNotify->Release();
}
}
@@ -4645,10 +5043,13 @@ CBaseAllocator::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
/* Do we know about this interface */
- if (riid == IID_IMemAllocator ||
- riid == IID_IMemAllocatorCallbackTemp && m_fEnableReleaseCallback) {
+ if(riid == IID_IMemAllocator ||
+ riid == IID_IMemAllocatorCallbackTemp && m_fEnableReleaseCallback)
+ {
return GetInterface((IMemAllocatorCallbackTemp *) this, ppv);
- } else {
+ }
+ else
+ {
return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -4661,8 +5062,8 @@ CBaseAllocator::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
STDMETHODIMP
CBaseAllocator::SetProperties(
- __in ALLOCATOR_PROPERTIES* pRequest,
- __out ALLOCATOR_PROPERTIES* pActual)
+ __in ALLOCATOR_PROPERTIES* pRequest,
+ __out ALLOCATOR_PROPERTIES* pActual)
{
CheckPointer(pRequest, E_POINTER);
CheckPointer(pActual, E_POINTER);
@@ -4674,9 +5075,10 @@ CBaseAllocator::SetProperties(
ASSERT(pRequest->cbBuffer > 0);
/* Check the alignment requested */
- if (pRequest->cbAlign != 1) {
+ if(pRequest->cbAlign != 1)
+ {
DbgLog((LOG_ERROR, 2, TEXT("Alignment requested was 0x%x, not 1"),
- pRequest->cbAlign));
+ pRequest->cbAlign));
return VFW_E_BADALIGN;
}
@@ -4686,13 +5088,15 @@ CBaseAllocator::SetProperties(
person who is holding the samples. Therefore it is not unreasonable
for them to free all their samples before changing the requirements */
- if (m_bCommitted) {
+ if(m_bCommitted)
+ {
return VFW_E_ALREADY_COMMITTED;
}
/* Must be no outstanding buffers */
- if (m_lAllocated != m_lFree.GetCount()) {
+ if(m_lAllocated != m_lFree.GetCount())
+ {
return VFW_E_BUFFERS_OUTSTANDING;
}
@@ -4712,8 +5116,8 @@ STDMETHODIMP
CBaseAllocator::GetProperties(
__out ALLOCATOR_PROPERTIES * pActual)
{
- CheckPointer(pActual,E_POINTER);
- ValidateReadWritePtr(pActual,sizeof(ALLOCATOR_PROPERTIES));
+ CheckPointer(pActual, E_POINTER);
+ ValidateReadWritePtr(pActual, sizeof(ALLOCATOR_PROPERTIES));
CAutoLock cObjectLock(this);
pActual->cbBuffer = m_lSize;
@@ -4732,7 +5136,7 @@ HRESULT CBaseAllocator::GetBuffer(__deref_out IMediaSample **ppBuffer,
__in_opt REFERENCE_TIME *pStartTime,
__in_opt REFERENCE_TIME *pEndTime,
DWORD dwFlags
- )
+ )
{
UNREFERENCED_PARAMETER(pStartTime);
UNREFERENCED_PARAMETER(pEndTime);
@@ -4740,27 +5144,32 @@ HRESULT CBaseAllocator::GetBuffer(__deref_out IMediaSample **ppBuffer,
CMediaSample *pSample;
*ppBuffer = NULL;
- for (;;)
+ for(;;)
{
- { // scope for lock
+ {
+ // scope for lock
CAutoLock cObjectLock(this);
/* Check we are committed */
- if (!m_bCommitted) {
+ if(!m_bCommitted)
+ {
return VFW_E_NOT_COMMITTED;
}
pSample = (CMediaSample *) m_lFree.RemoveHead();
- if (pSample == NULL) {
+ if(pSample == NULL)
+ {
SetWaiting();
}
}
/* If we didn't get a sample then wait for the list to signal */
- if (pSample) {
+ if(pSample)
+ {
break;
}
- if (dwFlags & AM_GBF_NOWAIT) {
+ if(dwFlags & AM_GBF_NOWAIT)
+ {
return VFW_E_TIMEOUT;
}
ASSERT(m_hSem != NULL);
@@ -4778,7 +5187,7 @@ HRESULT CBaseAllocator::GetBuffer(__deref_out IMediaSample **ppBuffer,
*ppBuffer = pSample;
#ifdef DXMPERF
- PERFLOG_GETBUFFER( (IMemAllocator *) this, pSample );
+ PERFLOG_GETBUFFER((IMemAllocator *) this, pSample);
#endif // DXMPERF
return NOERROR;
@@ -4790,11 +5199,11 @@ HRESULT CBaseAllocator::GetBuffer(__deref_out IMediaSample **ppBuffer,
STDMETHODIMP
CBaseAllocator::ReleaseBuffer(IMediaSample * pSample)
{
- CheckPointer(pSample,E_POINTER);
- ValidateReadPtr(pSample,sizeof(IMediaSample));
+ CheckPointer(pSample, E_POINTER);
+ ValidateReadPtr(pSample, sizeof(IMediaSample));
#ifdef DXMPERF
- PERFLOG_RELBUFFER( (IMemAllocator *) this, pSample );
+ PERFLOG_RELBUFFER((IMemAllocator *) this, pSample);
#endif // DXMPERF
@@ -4805,7 +5214,8 @@ CBaseAllocator::ReleaseBuffer(IMediaSample * pSample)
/* Put back on the free list */
m_lFree.Add((CMediaSample *)pSample);
- if (m_lWaiting != 0) {
+ if(m_lWaiting != 0)
+ {
NotifySample();
}
@@ -4813,14 +5223,16 @@ CBaseAllocator::ReleaseBuffer(IMediaSample * pSample)
// calling Free() when the last buffer is placed on the free list
LONG l1 = m_lFree.GetCount();
- if (m_bDecommitInProgress && (l1 == m_lAllocated)) {
+ if(m_bDecommitInProgress && (l1 == m_lAllocated))
+ {
Free();
m_bDecommitInProgress = FALSE;
bRelease = TRUE;
}
}
- if (m_pNotify) {
+ if(m_pNotify)
+ {
ASSERT(m_fEnableReleaseCallback);
@@ -4834,7 +5246,8 @@ CBaseAllocator::ReleaseBuffer(IMediaSample * pSample)
/* For each buffer there is one AddRef, made in GetBuffer and released
here. This may cause the allocator and all samples to be deleted */
- if (bRelease) {
+ if(bRelease)
+ {
Release();
}
return NOERROR;
@@ -4843,14 +5256,16 @@ CBaseAllocator::ReleaseBuffer(IMediaSample * pSample)
STDMETHODIMP
CBaseAllocator::SetNotify(
IMemAllocatorNotifyCallbackTemp* pNotify
- )
+)
{
ASSERT(m_fEnableReleaseCallback);
CAutoLock lck(this);
- if (pNotify) {
+ if(pNotify)
+ {
pNotify->AddRef();
}
- if (m_pNotify) {
+ if(m_pNotify)
+ {
m_pNotify->Release();
}
m_pNotify = pNotify;
@@ -4860,7 +5275,7 @@ CBaseAllocator::SetNotify(
STDMETHODIMP
CBaseAllocator::GetFreeCount(
__out LONG* plBuffersFree
- )
+)
{
ASSERT(m_fEnableReleaseCallback);
CAutoLock cObjectLock(this);
@@ -4871,7 +5286,8 @@ CBaseAllocator::GetFreeCount(
void
CBaseAllocator::NotifySample()
{
- if (m_lWaiting != 0) {
+ if(m_lWaiting != 0)
+ {
ASSERT(m_hSem != NULL);
ReleaseSemaphore(m_hSem, m_lWaiting, 0);
m_lWaiting = 0;
@@ -4885,7 +5301,8 @@ CBaseAllocator::Commit()
CAutoLock cObjectLock(this);
// cannot need to alloc or re-alloc if we are committed
- if (m_bCommitted) {
+ if(m_bCommitted)
+ {
return NOERROR;
}
@@ -4894,7 +5311,8 @@ CBaseAllocator::Commit()
m_bCommitted = TRUE;
// is there a pending decommit ? if so, just cancel it
- if (m_bDecommitInProgress) {
+ if(m_bDecommitInProgress)
+ {
m_bDecommitInProgress = FALSE;
// don't call Alloc at this point. He cannot allow SetProperties
@@ -4908,7 +5326,8 @@ CBaseAllocator::Commit()
// actually need to allocate the samples
HRESULT hr = Alloc();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
m_bCommitted = FALSE;
return hr;
}
@@ -4924,8 +5343,10 @@ CBaseAllocator::Decommit()
{
/* Check we are not already decommitted */
CAutoLock cObjectLock(this);
- if (m_bCommitted == FALSE) {
- if (m_bDecommitInProgress == FALSE) {
+ if(m_bCommitted == FALSE)
+ {
+ if(m_bDecommitInProgress == FALSE)
+ {
return NOERROR;
}
}
@@ -4934,10 +5355,13 @@ CBaseAllocator::Decommit()
m_bCommitted = FALSE;
// are any buffers outstanding?
- if (m_lFree.GetCount() < m_lAllocated) {
+ if(m_lFree.GetCount() < m_lAllocated)
+ {
// please complete the decommit when last buffer is freed
m_bDecommitInProgress = TRUE;
- } else {
+ }
+ else
+ {
m_bDecommitInProgress = FALSE;
// need to complete the decommit here as there are no
@@ -4959,7 +5383,8 @@ CBaseAllocator::Decommit()
#pragma warning(pop)
}
- if (bRelease) {
+ if(bRelease)
+ {
Release();
}
return NOERROR;
@@ -4973,7 +5398,8 @@ HRESULT
CBaseAllocator::Alloc(void)
{
/* Error if he hasn't set the size yet */
- if (m_lCount <= 0 || m_lSize <= 0 || m_lAlignment <= 0) {
+ if(m_lCount <= 0 || m_lSize <= 0 || m_lAlignment <= 0)
+ {
return VFW_E_SIZENOTSET;
}
@@ -4981,7 +5407,8 @@ CBaseAllocator::Alloc(void)
ASSERT(m_lFree.GetCount() == m_lAllocated);
/* If the requirements haven't changed then don't reallocate */
- if (m_bChanged == FALSE) {
+ if(m_bChanged == FALSE)
+ {
return S_FALSE;
}
@@ -4995,15 +5422,17 @@ void
CBaseAllocator::CSampleList::Remove(__inout CMediaSample * pSample)
{
CMediaSample **pSearch;
- for (pSearch = &m_List;
- *pSearch != NULL;
- pSearch = &(CBaseAllocator::NextSample(*pSearch))) {
- if (*pSearch == pSample) {
- *pSearch = CBaseAllocator::NextSample(pSample);
- CBaseAllocator::NextSample(pSample) = NULL;
- m_nOnList--;
- return;
- }
+ for(pSearch = &m_List;
+ *pSearch != NULL;
+ pSearch = &(CBaseAllocator::NextSample(*pSearch)))
+ {
+ if(*pSearch == pSample)
+ {
+ *pSearch = CBaseAllocator::NextSample(pSample);
+ CBaseAllocator::NextSample(pSample) = NULL;
+ m_nOnList--;
+ return;
+ }
}
DbgBreak("Couldn't find sample in list");
}
@@ -5027,7 +5456,7 @@ CMemAllocator::CMemAllocator(
__inout_opt LPUNKNOWN pUnk,
__inout HRESULT *phr)
: CBaseAllocator(pName, pUnk, phr, TRUE, TRUE),
- m_pBuffer(NULL)
+ m_pBuffer(NULL)
{
}
@@ -5037,7 +5466,7 @@ CMemAllocator::CMemAllocator(
__inout_opt LPUNKNOWN pUnk,
__inout HRESULT *phr)
: CBaseAllocator(pName, pUnk, phr, TRUE, TRUE),
- m_pBuffer(NULL)
+ m_pBuffer(NULL)
{
}
#endif
@@ -5048,11 +5477,11 @@ CMemAllocator::CMemAllocator(
to change the buffering, the memory will be released in Commit() */
STDMETHODIMP
CMemAllocator::SetProperties(
- __in ALLOCATOR_PROPERTIES* pRequest,
- __out ALLOCATOR_PROPERTIES* pActual)
+ __in ALLOCATOR_PROPERTIES* pRequest,
+ __out ALLOCATOR_PROPERTIES* pActual)
{
- CheckPointer(pActual,E_POINTER);
- ValidateReadWritePtr(pActual,sizeof(ALLOCATOR_PROPERTIES));
+ CheckPointer(pActual, E_POINTER);
+ ValidateReadWritePtr(pActual, sizeof(ALLOCATOR_PROPERTIES));
CAutoLock cObjectLock(this);
ZeroMemory(pActual, sizeof(ALLOCATOR_PROPERTIES));
@@ -5063,15 +5492,17 @@ CMemAllocator::SetProperties(
GetSystemInfo(&SysInfo);
/* Check the alignment request is a power of 2 */
- if ((-pRequest->cbAlign & pRequest->cbAlign) != pRequest->cbAlign) {
+ if((-pRequest->cbAlign & pRequest->cbAlign) != pRequest->cbAlign)
+ {
DbgLog((LOG_ERROR, 1, TEXT("Alignment requested 0x%x not a power of 2!"),
- pRequest->cbAlign));
+ pRequest->cbAlign));
}
/* Check the alignment requested */
- if (pRequest->cbAlign == 0 ||
- (SysInfo.dwAllocationGranularity & (pRequest->cbAlign - 1)) != 0) {
+ if(pRequest->cbAlign == 0 ||
+ (SysInfo.dwAllocationGranularity & (pRequest->cbAlign - 1)) != 0)
+ {
DbgLog((LOG_ERROR, 1, TEXT("Invalid alignment 0x%x requested - granularity = 0x%x"),
- pRequest->cbAlign, SysInfo.dwAllocationGranularity));
+ pRequest->cbAlign, SysInfo.dwAllocationGranularity));
return VFW_E_BADALIGN;
}
@@ -5081,13 +5512,15 @@ CMemAllocator::SetProperties(
person who is holding the samples. Therefore it is not unreasonable
for them to free all their samples before changing the requirements */
- if (m_bCommitted == TRUE) {
+ if(m_bCommitted == TRUE)
+ {
return VFW_E_ALREADY_COMMITTED;
}
/* Must be no outstanding buffers */
- if (m_lFree.GetCount() < m_lAllocated) {
+ if(m_lFree.GetCount() < m_lAllocated)
+ {
return VFW_E_BUFFERS_OUTSTANDING;
}
@@ -5098,7 +5531,8 @@ CMemAllocator::SetProperties(
// the alignment
LONG lSize = pRequest->cbBuffer + pRequest->cbPrefix;
LONG lRemainder = lSize % pRequest->cbAlign;
- if (lRemainder != 0) {
+ if(lRemainder != 0)
+ {
lSize = lSize - lRemainder + pRequest->cbAlign;
}
pActual->cbBuffer = m_lSize = (lSize - pRequest->cbPrefix);
@@ -5125,24 +5559,28 @@ CMemAllocator::Alloc(void)
/* Check he has called SetProperties */
HRESULT hr = CBaseAllocator::Alloc();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
/* If the requirements haven't changed then don't reallocate */
- if (hr == S_FALSE) {
+ if(hr == S_FALSE)
+ {
ASSERT(m_pBuffer);
return NOERROR;
}
ASSERT(hr == S_OK); // we use this fact in the loop below
/* Free the old resources */
- if (m_pBuffer) {
+ if(m_pBuffer)
+ {
ReallyFree();
}
/* Make sure we've got reasonable values */
- if ( m_lSize < 0 || m_lPrefix < 0 || m_lCount < 0 ) {
+ if(m_lSize < 0 || m_lPrefix < 0 || m_lCount < 0)
+ {
return E_OUTOFMEMORY;
}
@@ -5150,15 +5588,19 @@ CMemAllocator::Alloc(void)
LONG lAlignedSize = m_lSize + m_lPrefix;
/* Check overflow */
- if (lAlignedSize < m_lSize) {
+ if(lAlignedSize < m_lSize)
+ {
return E_OUTOFMEMORY;
}
- if (m_lAlignment > 1) {
+ if(m_lAlignment > 1)
+ {
LONG lRemainder = lAlignedSize % m_lAlignment;
- if (lRemainder != 0) {
+ if(lRemainder != 0)
+ {
LONG lNewSize = lAlignedSize + m_lAlignment - lRemainder;
- if (lNewSize < lAlignedSize) {
+ if(lNewSize < lAlignedSize)
+ {
return E_OUTOFMEMORY;
}
lAlignedSize = lNewSize;
@@ -5173,16 +5615,18 @@ CMemAllocator::Alloc(void)
LONGLONG lToAllocate = m_lCount * (LONGLONG)lAlignedSize;
/* Check overflow */
- if (lToAllocate > MAXLONG) {
+ if(lToAllocate > MAXLONG)
+ {
return E_OUTOFMEMORY;
}
m_pBuffer = (PBYTE)VirtualAlloc(NULL,
- (LONG)lToAllocate,
- MEM_COMMIT,
- PAGE_READWRITE);
+ (LONG)lToAllocate,
+ MEM_COMMIT,
+ PAGE_READWRITE);
- if (m_pBuffer == NULL) {
+ if(m_pBuffer == NULL)
+ {
return E_OUTOFMEMORY;
}
@@ -5195,18 +5639,20 @@ CMemAllocator::Alloc(void)
// plus m_lPrefix bytes per sample as a prefix. We set the pointer to
// the memory after the prefix - so that GetPointer() will return a pointer
// to m_lSize bytes.
- for (; m_lAllocated < m_lCount; m_lAllocated++, pNext += lAlignedSize) {
+ for(; m_lAllocated < m_lCount; m_lAllocated++, pNext += lAlignedSize)
+ {
pSample = new CMediaSample(
- NAME("Default memory media sample"),
- this,
- &hr,
- pNext + m_lPrefix, // GetPointer() value
- m_lSize); // not including prefix
-
- ASSERT(SUCCEEDED(hr));
- if (pSample == NULL) {
+ NAME("Default memory media sample"),
+ this,
+ &hr,
+ pNext + m_lPrefix, // GetPointer() value
+ m_lSize); // not including prefix
+
+ ASSERT(SUCCEEDED(hr));
+ if(pSample == NULL)
+ {
return E_OUTOFMEMORY;
}
@@ -5247,11 +5693,15 @@ CMemAllocator::ReallyFree(void)
/* Free up all the CMediaSamples */
CMediaSample *pSample;
- for (;;) {
+ for(;;)
+ {
pSample = m_lFree.RemoveHead();
- if (pSample != NULL) {
+ if(pSample != NULL)
+ {
delete pSample;
- } else {
+ }
+ else
+ {
break;
}
}
@@ -5259,7 +5709,8 @@ CMemAllocator::ReallyFree(void)
m_lAllocated = 0;
// free the block of buffer memory
- if (m_pBuffer) {
+ if(m_pBuffer)
+ {
EXECUTE_ASSERT(VirtualFree(m_pBuffer, 0, MEM_RELEASE));
m_pBuffer = NULL;
}
@@ -5279,78 +5730,78 @@ CMemAllocator::~CMemAllocator()
// not found (Quartz 1.0 install)
STDAPI
-AMovieSetupRegisterFilter( const AMOVIESETUP_FILTER * const psetupdata
- , IFilterMapper * pIFM
- , BOOL bRegister )
+AMovieSetupRegisterFilter(const AMOVIESETUP_FILTER * const psetupdata
+ , IFilterMapper * pIFM
+ , BOOL bRegister)
{
- DbgLog((LOG_TRACE, 3, TEXT("= AMovieSetupRegisterFilter")));
+ DbgLog((LOG_TRACE, 3, TEXT("= AMovieSetupRegisterFilter")));
- // check we've got data
- //
- if( NULL == psetupdata ) return S_FALSE;
+ // check we've got data
+ //
+ if(NULL == psetupdata) return S_FALSE;
- // unregister filter
- // (as pins are subkeys of filter's CLSID key
- // they do not need to be removed separately).
- //
- DbgLog((LOG_TRACE, 3, TEXT("= = unregister filter")));
- HRESULT hr = pIFM->UnregisterFilter( *(psetupdata->clsID) );
+ // unregister filter
+ // (as pins are subkeys of filter's CLSID key
+ // they do not need to be removed separately).
+ //
+ DbgLog((LOG_TRACE, 3, TEXT("= = unregister filter")));
+ HRESULT hr = pIFM->UnregisterFilter(*(psetupdata->clsID));
- if( bRegister )
- {
- // register filter
- //
- DbgLog((LOG_TRACE, 3, TEXT("= = register filter")));
- hr = pIFM->RegisterFilter( *(psetupdata->clsID)
- , psetupdata->strName
- , psetupdata->dwMerit );
- if( SUCCEEDED(hr) )
- {
- // all its pins
- //
- DbgLog((LOG_TRACE, 3, TEXT("= = register filter pins")));
- for( UINT m1=0; m1 < psetupdata->nPins; m1++ )
- {
- hr = pIFM->RegisterPin( *(psetupdata->clsID)
- , psetupdata->lpPin[m1].strName
- , psetupdata->lpPin[m1].bRendered
- , psetupdata->lpPin[m1].bOutput
- , psetupdata->lpPin[m1].bZero
- , psetupdata->lpPin[m1].bMany
- , *(psetupdata->lpPin[m1].clsConnectsToFilter)
- , psetupdata->lpPin[m1].strConnectsToPin );
-
- if( SUCCEEDED(hr) )
+ if(bRegister)
+ {
+ // register filter
+ //
+ DbgLog((LOG_TRACE, 3, TEXT("= = register filter")));
+ hr = pIFM->RegisterFilter(*(psetupdata->clsID)
+ , psetupdata->strName
+ , psetupdata->dwMerit);
+ if(SUCCEEDED(hr))
{
- // and each pin's media types
- //
- DbgLog((LOG_TRACE, 3, TEXT("= = register filter pin types")));
- for( UINT m2=0; m2 < psetupdata->lpPin[m1].nMediaTypes; m2++ )
- {
- hr = pIFM->RegisterPinType( *(psetupdata->clsID)
- , psetupdata->lpPin[m1].strName
- , *(psetupdata->lpPin[m1].lpMediaType[m2].clsMajorType)
- , *(psetupdata->lpPin[m1].lpMediaType[m2].clsMinorType) );
- if( FAILED(hr) ) break;
- }
- if( FAILED(hr) ) break;
+ // all its pins
+ //
+ DbgLog((LOG_TRACE, 3, TEXT("= = register filter pins")));
+ for(UINT m1 = 0; m1 < psetupdata->nPins; m1++)
+ {
+ hr = pIFM->RegisterPin(*(psetupdata->clsID)
+ , psetupdata->lpPin[m1].strName
+ , psetupdata->lpPin[m1].bRendered
+ , psetupdata->lpPin[m1].bOutput
+ , psetupdata->lpPin[m1].bZero
+ , psetupdata->lpPin[m1].bMany
+ , *(psetupdata->lpPin[m1].clsConnectsToFilter)
+ , psetupdata->lpPin[m1].strConnectsToPin);
+
+ if(SUCCEEDED(hr))
+ {
+ // and each pin's media types
+ //
+ DbgLog((LOG_TRACE, 3, TEXT("= = register filter pin types")));
+ for(UINT m2 = 0; m2 < psetupdata->lpPin[m1].nMediaTypes; m2++)
+ {
+ hr = pIFM->RegisterPinType(*(psetupdata->clsID)
+ , psetupdata->lpPin[m1].strName
+ , *(psetupdata->lpPin[m1].lpMediaType[m2].clsMajorType)
+ , *(psetupdata->lpPin[m1].lpMediaType[m2].clsMinorType));
+ if(FAILED(hr)) break;
+ }
+ if(FAILED(hr)) break;
+ }
+ if(FAILED(hr)) break;
+ }
}
- if( FAILED(hr) ) break;
- }
}
- }
- // handle one acceptable "error" - that
- // of filter not being registered!
- // (couldn't find a suitable #define'd
- // name for the error!)
- //
- if( 0x80070002 == hr)
- return NOERROR;
- else
- return hr;
+ // handle one acceptable "error" - that
+ // of filter not being registered!
+ // (couldn't find a suitable #define'd
+ // name for the error!)
+ //
+ if(0x80070002 == hr)
+ return NOERROR;
+ else
+ return hr;
}
// Remove warnings about unreferenced inline functions
diff --git a/src/filters/BaseClasses/amfilter.h b/src/filters/BaseClasses/amfilter.h
index 82e0268f4..4005f1698 100644
--- a/src/filters/BaseClasses/amfilter.h
+++ b/src/filters/BaseClasses/amfilter.h
@@ -54,7 +54,7 @@ class CMemAllocator; // Implements memory buffer allocation
//=====================================================================
class AM_NOVTABLE CBaseMediaFilter : public CUnknown,
- public IMediaFilter
+ public IMediaFilter
{
protected:
@@ -67,7 +67,7 @@ protected:
CRefTime m_tStart;
CLSID m_clsid; // This filters clsid
- // used for serialization
+ // used for serialization
CCritSec *m_pLock; // Object we use for locking
public:
@@ -76,7 +76,7 @@ public:
__in_opt LPCTSTR pName,
__inout_opt LPUNKNOWN pUnk,
__in CCritSec *pLock,
- REFCLSID clsid);
+ REFCLSID clsid);
virtual ~CBaseMediaFilter();
@@ -120,7 +120,8 @@ public:
virtual HRESULT StreamTime(CRefTime& rtStream);
// Is the filter currently active? (running or paused)
- BOOL IsActive() {
+ BOOL IsActive()
+ {
CAutoLock cObjectLock(m_pLock);
return ((m_State == State_Paused) || (m_State == State_Running));
};
@@ -146,18 +147,18 @@ public:
class AM_NOVTABLE CBaseFilter : public CUnknown, // Handles an IUnknown
- public IBaseFilter, // The Filter Interface
- public IAMovieSetup // For un/registration
+ public IBaseFilter, // The Filter Interface
+ public IAMovieSetup // For un/registration
{
-friend class CBasePin;
+ friend class CBasePin;
protected:
FILTER_STATE m_State; // current state: running, paused
IReferenceClock *m_pClock; // this graph's ref clock
CRefTime m_tStart; // offset from stream time to reference time
CLSID m_clsid; // This filters clsid
- // used for serialization
+ // used for serialization
CCritSec *m_pLock; // Object we use for locking
WCHAR *m_pName; // Full filter name
@@ -171,26 +172,26 @@ public:
__in_opt LPCTSTR pName, // Object description
__inout_opt LPUNKNOWN pUnk, // IUnknown of delegating object
__in CCritSec *pLock, // Object who maintains lock
- REFCLSID clsid); // The clsid to be used to serialize this filter
+ REFCLSID clsid); // The clsid to be used to serialize this filter
CBaseFilter(
__in_opt LPCTSTR pName, // Object description
__in_opt LPUNKNOWN pUnk, // IUnknown of delegating object
__in CCritSec *pLock, // Object who maintains lock
- REFCLSID clsid, // The clsid to be used to serialize this filter
+ REFCLSID clsid, // The clsid to be used to serialize this filter
__inout HRESULT *phr); // General OLE return code
#ifdef UNICODE
CBaseFilter(
__in_opt LPCSTR pName, // Object description
__in_opt LPUNKNOWN pUnk, // IUnknown of delegating object
__in CCritSec *pLock, // Object who maintains lock
- REFCLSID clsid); // The clsid to be used to serialize this filter
+ REFCLSID clsid); // The clsid to be used to serialize this filter
CBaseFilter(
__in_opt LPCSTR pName, // Object description
__in_opt LPUNKNOWN pUnk, // IUnknown of delegating object
__in CCritSec *pLock, // Object who maintains lock
- REFCLSID clsid, // The clsid to be used to serialize this filter
+ REFCLSID clsid, // The clsid to be used to serialize this filter
__inout HRESULT *phr); // General OLE return code
#endif
~CBaseFilter();
@@ -237,13 +238,15 @@ public:
virtual HRESULT StreamTime(CRefTime& rtStream);
// Is the filter currently active?
- BOOL IsActive() {
+ BOOL IsActive()
+ {
CAutoLock cObjectLock(m_pLock);
return ((m_State == State_Paused) || (m_State == State_Running));
};
// Is this filter stopped (without locking)
- BOOL IsStopped() {
+ BOOL IsStopped()
+ {
return (m_State == State_Stopped);
};
@@ -253,7 +256,7 @@ public:
// pin enumerator
STDMETHODIMP EnumPins(
- __deref_out IEnumPins ** ppEnum);
+ __deref_out IEnumPins ** ppEnum);
// default behaviour of FindPin assumes pin ids are their names
@@ -263,18 +266,18 @@ public:
);
STDMETHODIMP QueryFilterInfo(
- __out FILTER_INFO * pInfo);
+ __out FILTER_INFO * pInfo);
STDMETHODIMP JoinFilterGraph(
- __inout_opt IFilterGraph * pGraph,
- __in_opt LPCWSTR pName);
+ __inout_opt IFilterGraph * pGraph,
+ __in_opt LPCWSTR pName);
// return a Vendor information string. Optional - may return E_NOTIMPL.
// memory returned should be freed using CoTaskMemFree
// default implementation returns E_NOTIMPL
STDMETHODIMP QueryVendorInfo(
- __deref_out LPWSTR* pVendorInfo
- );
+ __deref_out LPWSTR* pVendorInfo
+ );
// --- helper methods ---
@@ -287,7 +290,8 @@ public:
LONG_PTR EventParam2);
// return the filter graph we belong to
- __out_opt IFilterGraph *GetFilterGraph() {
+ __out_opt IFilterGraph *GetFilterGraph()
+ {
return m_pGraph;
}
@@ -314,7 +318,10 @@ public:
// --- setup helper methods ---
// (override to return filters setup data)
- virtual __out_opt LPAMOVIESETUP_FILTER GetSetupData(){ return NULL; }
+ virtual __out_opt LPAMOVIESETUP_FILTER GetSetupData()
+ {
+ return NULL;
+ }
};
@@ -339,7 +346,7 @@ protected:
bool m_bRunTimeError; // Run time error generated
bool m_bCanReconnectWhenActive; // OK to reconnect when active
bool m_bTryMyTypesFirst; // When connecting enumerate
- // this pin's types first
+ // this pin's types first
CBaseFilter *m_pFilter; // Filter we were created by
IQualityControl *m_pQSink; // Target for Quality messages
LONG m_TypeVersion; // Holds current type version
@@ -376,17 +383,17 @@ protected:
// try all the media types in this enumerator - for each that
// we accept, try to connect using ReceiveConnection.
HRESULT TryMediaTypes(
- IPin *pReceivePin, // connect to this pin
- __in_opt const CMediaType *pmt, // proposed type from Connect
- IEnumMediaTypes *pEnum); // try this enumerator
+ IPin *pReceivePin, // connect to this pin
+ __in_opt const CMediaType *pmt, // proposed type from Connect
+ IEnumMediaTypes *pEnum); // try this enumerator
// establish a connection with a suitable mediatype. Needs to
// propose a media type if the pmt pointer is null or partially
// specified - use TryMediaTypes on both our and then the other pin's
// enumerator until we find one that works.
HRESULT AgreeMediaType(
- IPin *pReceivePin, // connect to this pin
- const CMediaType *pmt); // proposed type from Connect
+ IPin *pReceivePin, // connect to this pin
+ const CMediaType *pmt); // proposed type from Connect
public:
@@ -441,7 +448,7 @@ public:
);
STDMETHODIMP QueryDirection(
- __out PIN_DIRECTION * pPinDir
+ __out PIN_DIRECTION * pPinDir
);
STDMETHODIMP QueryId(
@@ -466,10 +473,13 @@ public:
// all visible output pins and vice versa.
// apPin can be NULL if nPin==0 (not otherwise).
STDMETHODIMP QueryInternalConnections(
- __out_ecount_part(*nPin,*nPin) IPin* *apPin, // array of IPin*
+ __out_ecount_part(*nPin, *nPin) IPin* *apPin, // array of IPin*
__inout ULONG *nPin // on input, the number of slots
- // on output the number of pins
- ) { return E_NOTIMPL; }
+ // on output the number of pins
+ )
+ {
+ return E_NOTIMPL;
+ }
// Called when no more data will be sent
STDMETHODIMP EndOfStream(void);
@@ -481,9 +491,9 @@ public:
// returns S_OK.
// Override this to pass downstream.
STDMETHODIMP NewSegment(
- REFERENCE_TIME tStart,
- REFERENCE_TIME tStop,
- double dRate);
+ REFERENCE_TIME tStart,
+ REFERENCE_TIME tStop,
+ double dRate);
//================================================================================
// IQualityControl methods
@@ -496,12 +506,19 @@ public:
// --- helper methods ---
// Returns true if the pin is connected. false otherwise.
- BOOL IsConnected(void) {return (m_Connected != NULL); };
+ BOOL IsConnected(void)
+ {
+ return (m_Connected != NULL);
+ };
// Return the pin this is connected to (if any)
- IPin * GetConnected() { return m_Connected; };
+ IPin * GetConnected()
+ {
+ return m_Connected;
+ };
// Check if our filter is currently stopped
- BOOL IsStopped() {
+ BOOL IsStopped()
+ {
return (m_pFilter->m_State == State_Stopped);
};
@@ -537,18 +554,24 @@ public:
virtual HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType);
// access to NewSegment values
- REFERENCE_TIME CurrentStopTime() {
+ REFERENCE_TIME CurrentStopTime()
+ {
return m_tStop;
}
- REFERENCE_TIME CurrentStartTime() {
+ REFERENCE_TIME CurrentStartTime()
+ {
return m_tStart;
}
- double CurrentRate() {
+ double CurrentRate()
+ {
return m_dRate;
}
// Access name
- LPWSTR Name() { return m_pName; };
+ LPWSTR Name()
+ {
+ return m_pName;
+ };
// Can reconnectwhen active?
void SetReconnectWhenActive(bool bCanReconnect)
@@ -590,8 +613,8 @@ class CEnumPins : public IEnumPins // The interface we support
typedef CGenericList<CBasePin> CPinList;
CPinList m_PinCache; // These pointers have not been AddRef'ed and
- // so they should not be dereferenced. They are
- // merely kept to ID which pins have been enumerated.
+ // so they should not be dereferenced. They are
+ // merely kept to ID which pins have been enumerated.
#ifdef _DEBUG
DWORD m_dwCookie;
@@ -604,7 +627,8 @@ class CEnumPins : public IEnumPins // The interface we support
filter what it's current version number is. If the filter has not
overriden the GetPinVersion method then this will always match */
- BOOL AreWeOutOfSync() {
+ BOOL AreWeOutOfSync()
+ {
return (m_pFilter->GetPinVersion() == m_Version ? FALSE : TRUE);
};
@@ -665,7 +689,8 @@ class CEnumMediaTypes : public IEnumMediaTypes // The interface we support
Reset method is called after the state changes all further calls to
the enumerator (except Reset) will return E_UNEXPECTED error code */
- BOOL AreWeOutOfSync() {
+ BOOL AreWeOutOfSync()
+ {
return (m_pPin->GetMediaTypeVersion() == m_Version ? FALSE : TRUE);
};
@@ -716,7 +741,7 @@ protected:
IMemAllocator *m_pAllocator;
IMemInputPin *m_pInputPin; // interface on the downstreaminput pin
- // set up in CheckConnect when we connect.
+ // set up in CheckConnect when we connect.
public:
@@ -791,9 +816,9 @@ public:
// deliver NewSegment to connected pin - you will need to
// override this if you queue any data in your output pin.
virtual HRESULT DeliverNewSegment(
- REFERENCE_TIME tStart,
- REFERENCE_TIME tStop,
- double dRate);
+ REFERENCE_TIME tStart,
+ REFERENCE_TIME tStop,
+ double dRate);
//================================================================================
// IQualityControl methods
@@ -817,7 +842,7 @@ public:
//=====================================================================
class AM_NOVTABLE CBaseInputPin : public CBasePin,
- public IMemInputPin
+ public IMemInputPin
{
protected:
@@ -866,14 +891,14 @@ public:
// tell the input pin which allocator the output pin is actually
// going to use.
STDMETHODIMP NotifyAllocator(
- IMemAllocator * pAllocator,
- BOOL bReadOnly);
+ IMemAllocator * pAllocator,
+ BOOL bReadOnly);
// do something with this media sample
STDMETHODIMP Receive(IMediaSample *pSample);
// do something with these media samples
- STDMETHODIMP ReceiveMultiple (
+ STDMETHODIMP ReceiveMultiple(
__in_ecount(nSamples) IMediaSample **pSamples,
long nSamples,
__out long *nSamplesProcessed);
@@ -904,12 +929,14 @@ public:
HRESULT BreakConnect();
// helper method to check the read-only flag
- BOOL IsReadOnly() {
+ BOOL IsReadOnly()
+ {
return m_bReadOnly;
};
// helper method to see if we are flushing
- BOOL IsFlushing() {
+ BOOL IsFlushing()
+ {
return m_bFlushing;
};
@@ -935,7 +962,8 @@ public:
virtual HRESULT Inactive(void);
// Return sample properties pointer
- AM_SAMPLE2_PROPERTIES * SampleProps() {
+ AM_SAMPLE2_PROPERTIES * SampleProps()
+ {
ASSERT(m_SampleProps.cbData != 0);
return &m_SampleProps;
}
@@ -947,7 +975,7 @@ public:
//
class CDynamicOutputPin : public CBaseOutputPin,
- public IPinFlowControl
+ public IPinFlowControl
{
public:
#ifdef UNICODE
@@ -981,11 +1009,11 @@ public:
// Set graph config info
void SetConfigInfo(IGraphConfig *pGraphConfig, HANDLE hStopEvent);
- #ifdef _DEBUG
+#ifdef _DEBUG
virtual HRESULT Deliver(IMediaSample *pSample);
virtual HRESULT DeliverEndOfStream(void);
virtual HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- #endif // DEBUG
+#endif // DEBUG
HRESULT DeliverBeginFlush(void);
HRESULT DeliverEndFlush(void);
@@ -999,12 +1027,12 @@ public:
virtual bool StreamingThreadUsingOutputPin(void);
HRESULT ChangeOutputFormat
- (
+ (
const AM_MEDIA_TYPE *pmt,
REFERENCE_TIME tSegmentStart,
REFERENCE_TIME tSegmentStop,
double dSegmentRate
- );
+ );
HRESULT ChangeMediaType(const CMediaType *pmt);
HRESULT DynamicReconnect(const CMediaType *pmt);
@@ -1075,33 +1103,33 @@ private:
HRESULT Initialize(void);
HRESULT ChangeMediaTypeHelper(const CMediaType *pmt);
- #ifdef _DEBUG
+#ifdef _DEBUG
void AssertValid(void);
- #endif // DEBUG
+#endif // DEBUG
};
class CAutoUsingOutputPin
{
public:
- CAutoUsingOutputPin( __in CDynamicOutputPin* pOutputPin, __inout HRESULT* phr );
+ CAutoUsingOutputPin(__in CDynamicOutputPin* pOutputPin, __inout HRESULT* phr);
~CAutoUsingOutputPin();
private:
CDynamicOutputPin* m_pOutputPin;
};
-inline CAutoUsingOutputPin::CAutoUsingOutputPin( __in CDynamicOutputPin* pOutputPin, __inout HRESULT* phr ) :
+inline CAutoUsingOutputPin::CAutoUsingOutputPin(__in CDynamicOutputPin* pOutputPin, __inout HRESULT* phr) :
m_pOutputPin(NULL)
{
// The caller should always pass in valid pointers.
- ASSERT( NULL != pOutputPin );
- ASSERT( NULL != phr );
+ ASSERT(NULL != pOutputPin);
+ ASSERT(NULL != phr);
// Make sure the user initialized phr.
- ASSERT( S_OK == *phr );
+ ASSERT(S_OK == *phr);
HRESULT hr = pOutputPin->StartUsingOutputPin();
- if( FAILED( hr ) )
+ if(FAILED(hr))
{
*phr = hr;
return;
@@ -1112,7 +1140,7 @@ inline CAutoUsingOutputPin::CAutoUsingOutputPin( __in CDynamicOutputPin* pOutput
inline CAutoUsingOutputPin::~CAutoUsingOutputPin()
{
- if( NULL != m_pOutputPin )
+ if(NULL != m_pOutputPin)
{
m_pOutputPin->StopUsingOutputPin();
}
@@ -1133,7 +1161,7 @@ inline HRESULT CDynamicOutputPin::DeliverEndOfStream(void)
{
// The caller should call StartUsingOutputPin() before calling this
// method.
- ASSERT( StreamingThreadUsingOutputPin() );
+ ASSERT(StreamingThreadUsingOutputPin());
return CBaseOutputPin::DeliverEndOfStream();
}
@@ -1209,9 +1237,9 @@ protected:
we do no internal processing on it we leave it as a pointer */
DWORD m_dwFlags; /* Flags for this sample */
- /* Type specific flags are packed
- into the top word
- */
+ /* Type specific flags are packed
+ into the top word
+ */
DWORD m_dwTypeSpecificFlags; /* Media type specific flags */
__field_ecount_opt(m_cbBuffer) LPBYTE m_pBuffer; /* Pointer to the complete buffer */
LONG m_lActual; /* Length of data in this sample */
@@ -1298,14 +1326,14 @@ public:
// get the media times for this sample
STDMETHODIMP GetMediaTime(
- __out LONGLONG * pTimeStart,
- __out LONGLONG * pTimeEnd
+ __out LONGLONG * pTimeStart,
+ __out LONGLONG * pTimeEnd
);
// Set the media times for this sample
STDMETHODIMP SetMediaTime(
- __in_opt LONGLONG * pTimeStart,
- __in_opt LONGLONG * pTimeEnd
+ __in_opt LONGLONG * pTimeStart,
+ __in_opt LONGLONG * pTimeEnd
);
// Set and get properties (IMediaSample2)
@@ -1337,8 +1365,8 @@ public:
//=====================================================================
class AM_NOVTABLE CBaseAllocator : public CUnknown,// A non delegating IUnknown
- public IMemAllocatorCallbackTemp, // The interface we support
- public CCritSec // Provides object locking
+ public IMemAllocatorCallbackTemp, // The interface we support
+ public CCritSec // Provides object locking
{
class CSampleList;
friend class CSampleList;
@@ -1360,9 +1388,18 @@ class AM_NOVTABLE CBaseAllocator : public CUnknown,// A non delegating IUnknown
ASSERT(m_nOnList == 0);
};
#endif
- CMediaSample *Head() const { return m_List; };
- CMediaSample *Next(__in CMediaSample *pSample) const { return CBaseAllocator::NextSample(pSample); };
- int GetCount() const { return m_nOnList; };
+ CMediaSample *Head() const
+ {
+ return m_List;
+ };
+ CMediaSample *Next(__in CMediaSample *pSample) const
+ {
+ return CBaseAllocator::NextSample(pSample);
+ };
+ int GetCount() const
+ {
+ return m_nOnList;
+ };
void Add(__inout CMediaSample *pSample)
{
ASSERT(pSample != NULL);
@@ -1373,7 +1410,8 @@ class AM_NOVTABLE CBaseAllocator : public CUnknown,// A non delegating IUnknown
CMediaSample *RemoveHead()
{
CMediaSample *pSample = m_List;
- if (pSample != NULL) {
+ if(pSample != NULL)
+ {
m_List = CBaseAllocator::NextSample(m_List);
m_nOnList--;
}
@@ -1470,12 +1508,12 @@ public:
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
STDMETHODIMP SetProperties(
- __in ALLOCATOR_PROPERTIES* pRequest,
- __out ALLOCATOR_PROPERTIES* pActual);
+ __in ALLOCATOR_PROPERTIES* pRequest,
+ __out ALLOCATOR_PROPERTIES* pActual);
// return the properties actually being used on this allocator
STDMETHODIMP GetProperties(
- __out ALLOCATOR_PROPERTIES* pProps);
+ __out ALLOCATOR_PROPERTIES* pProps);
// override Commit to allocate memory. We handle the GetBuffer
//state changes
@@ -1511,7 +1549,10 @@ public:
void NotifySample();
// Notify that we're waiting for a sample
- void SetWaiting() { m_lWaiting++; };
+ void SetWaiting()
+ {
+ m_lWaiting++;
+ };
};
@@ -1557,8 +1598,8 @@ public:
static CUnknown *CreateInstance(__inout_opt LPUNKNOWN, __inout HRESULT *);
STDMETHODIMP SetProperties(
- __in ALLOCATOR_PROPERTIES* pRequest,
- __out ALLOCATOR_PROPERTIES* pActual);
+ __in ALLOCATOR_PROPERTIES* pRequest,
+ __out ALLOCATOR_PROPERTIES* pActual);
CMemAllocator(__in_opt LPCTSTR , __inout_opt LPUNKNOWN, __inout HRESULT *);
#ifdef UNICODE
@@ -1569,9 +1610,9 @@ public:
// helper used by IAMovieSetup implementation
STDAPI
-AMovieSetupRegisterFilter( const AMOVIESETUP_FILTER * const psetupdata
- , IFilterMapper * pIFM
- , BOOL bRegister );
+AMovieSetupRegisterFilter(const AMOVIESETUP_FILTER * const psetupdata
+ , IFilterMapper * pIFM
+ , BOOL bRegister);
///////////////////////////////////////////////////////////////////////////
diff --git a/src/filters/BaseClasses/amvideo.cpp b/src/filters/BaseClasses/amvideo.cpp
index 42fe446de..75c3d8e83 100644
--- a/src/filters/BaseClasses/amvideo.cpp
+++ b/src/filters/BaseClasses/amvideo.cpp
@@ -13,29 +13,30 @@
// These are bit field masks for true colour devices
-const DWORD bits555[] = {0x007C00,0x0003E0,0x00001F};
-const DWORD bits565[] = {0x00F800,0x0007E0,0x00001F};
-const DWORD bits888[] = {0xFF0000,0x00FF00,0x0000FF};
+const DWORD bits555[] = {0x007C00, 0x0003E0, 0x00001F};
+const DWORD bits565[] = {0x00F800, 0x0007E0, 0x00001F};
+const DWORD bits888[] = {0xFF0000, 0x00FF00, 0x0000FF};
// This maps bitmap subtypes into a bits per pixel value and also a
// name. unicode and ansi versions are stored because we have to
// return a pointer to a static string.
-const struct {
+const struct
+{
const GUID *pSubtype;
WORD BitCount;
CHAR *pName;
WCHAR *wszName;
-} BitCountMap[] = { &MEDIASUBTYPE_RGB1, 1, "RGB Monochrome", L"RGB Monochrome",
- &MEDIASUBTYPE_RGB4, 4, "RGB VGA", L"RGB VGA",
- &MEDIASUBTYPE_RGB8, 8, "RGB 8", L"RGB 8",
- &MEDIASUBTYPE_RGB565, 16, "RGB 565 (16 bit)", L"RGB 565 (16 bit)",
- &MEDIASUBTYPE_RGB555, 16, "RGB 555 (16 bit)", L"RGB 555 (16 bit)",
- &MEDIASUBTYPE_RGB24, 24, "RGB 24", L"RGB 24",
+} BitCountMap[] = { &MEDIASUBTYPE_RGB1, 1, "RGB Monochrome", L"RGB Monochrome",
+ &MEDIASUBTYPE_RGB4, 4, "RGB VGA", L"RGB VGA",
+ &MEDIASUBTYPE_RGB8, 8, "RGB 8", L"RGB 8",
+ &MEDIASUBTYPE_RGB565, 16, "RGB 565 (16 bit)", L"RGB 565 (16 bit)",
+ &MEDIASUBTYPE_RGB555, 16, "RGB 555 (16 bit)", L"RGB 555 (16 bit)",
+ &MEDIASUBTYPE_RGB24, 24, "RGB 24", L"RGB 24",
&MEDIASUBTYPE_RGB32, 32, "RGB 32", L"RGB 32",
&MEDIASUBTYPE_ARGB32, 32, "ARGB 32", L"ARGB 32",
- &MEDIASUBTYPE_Overlay, 0, "Overlay", L"Overlay",
- &GUID_NULL, 0, "UNKNOWN", L"UNKNOWN"
-};
+ &MEDIASUBTYPE_Overlay, 0, "Overlay", L"Overlay",
+ &GUID_NULL, 0, "UNKNOWN", L"UNKNOWN"
+ };
// Return the size of the bitmap as defined by this header
@@ -55,16 +56,20 @@ STDAPI_(const GUID) GetTrueColorType(const BITMAPINFOHEADER *pbmiHeader)
// If its BI_RGB then it's RGB 555 by default
- if (pbmiHeader->biCompression == BI_RGB) {
+ if(pbmiHeader->biCompression == BI_RGB)
+ {
return MEDIASUBTYPE_RGB555;
}
// Compare the bit fields with RGB 555
DWORD *pMask = (DWORD *) pbmInfo->bmiColors;
- if (pMask[0] == bits555[0]) {
- if (pMask[1] == bits555[1]) {
- if (pMask[2] == bits555[2]) {
+ if(pMask[0] == bits555[0])
+ {
+ if(pMask[1] == bits555[1])
+ {
+ if(pMask[2] == bits555[2])
+ {
return MEDIASUBTYPE_RGB555;
}
}
@@ -73,9 +78,12 @@ STDAPI_(const GUID) GetTrueColorType(const BITMAPINFOHEADER *pbmiHeader)
// Compare the bit fields with RGB 565
pMask = (DWORD *) pbmInfo->bmiColors;
- if (pMask[0] == bits565[0]) {
- if (pMask[1] == bits565[1]) {
- if (pMask[2] == bits565[2]) {
+ if(pMask[0] == bits565[0])
+ {
+ if(pMask[1] == bits565[1])
+ {
+ if(pMask[2] == bits565[2])
+ {
return MEDIASUBTYPE_RGB565;
}
}
@@ -96,8 +104,10 @@ STDAPI_(const GUID) GetBitmapSubtype(const BITMAPINFOHEADER *pbmiHeader)
// If it's not RGB then create a GUID from the compression type
- if (pbmiHeader->biCompression != BI_RGB) {
- if (pbmiHeader->biCompression != BI_BITFIELDS) {
+ if(pbmiHeader->biCompression != BI_RGB)
+ {
+ if(pbmiHeader->biCompression != BI_BITFIELDS)
+ {
FOURCCMap FourCCMap(pbmiHeader->biCompression);
return (const GUID) FourCCMap;
}
@@ -105,13 +115,20 @@ STDAPI_(const GUID) GetBitmapSubtype(const BITMAPINFOHEADER *pbmiHeader)
// Map the RGB DIB bit depth to a image GUID
- switch(pbmiHeader->biBitCount) {
- case 1 : return MEDIASUBTYPE_RGB1;
- case 4 : return MEDIASUBTYPE_RGB4;
- case 8 : return MEDIASUBTYPE_RGB8;
- case 16 : return GetTrueColorType(pbmiHeader);
- case 24 : return MEDIASUBTYPE_RGB24;
- case 32 : return MEDIASUBTYPE_RGB32;
+ switch(pbmiHeader->biBitCount)
+ {
+ case 1 :
+ return MEDIASUBTYPE_RGB1;
+ case 4 :
+ return MEDIASUBTYPE_RGB4;
+ case 8 :
+ return MEDIASUBTYPE_RGB8;
+ case 16 :
+ return GetTrueColorType(pbmiHeader);
+ case 24 :
+ return MEDIASUBTYPE_RGB24;
+ case 32 :
+ return MEDIASUBTYPE_RGB32;
}
return GUID_NULL;
}
@@ -130,12 +147,15 @@ STDAPI_(WORD) GetBitCount(const GUID *pSubtype)
// Scan the mapping list seeing if the source GUID matches any known
// bitmap subtypes, the list is terminated by a GUID_NULL entry
- while (TRUE) {
+ while(TRUE)
+ {
pMediaSubtype = BitCountMap[iPosition].pSubtype;
- if (IsEqualGUID(*pMediaSubtype,GUID_NULL)) {
+ if(IsEqualGUID(*pMediaSubtype, GUID_NULL))
+ {
return USHRT_MAX;
}
- if (IsEqualGUID(*pMediaSubtype,*pSubtype)) {
+ if(IsEqualGUID(*pMediaSubtype, *pSubtype))
+ {
return BitCountMap[iPosition].BitCount;
}
iPosition++;
@@ -156,15 +176,16 @@ int LocateSubtype(const GUID *pSubtype)
// Scan the mapping list seeing if the source GUID matches any known
// bitmap subtypes, the list is terminated by a GUID_NULL entry
- while (TRUE) {
+ while(TRUE)
+ {
pMediaSubtype = BitCountMap[iPosition].pSubtype;
- if (IsEqualGUID(*pMediaSubtype,*pSubtype) ||
- IsEqualGUID(*pMediaSubtype,GUID_NULL)
- )
+ if(IsEqualGUID(*pMediaSubtype, *pSubtype) ||
+ IsEqualGUID(*pMediaSubtype, GUID_NULL)
+ )
{
break;
}
-
+
iPosition++;
}
@@ -212,11 +233,11 @@ STDAPI_(CHAR *) GetSubtypeName(const GUID *pSubtype)
STDAPI_(LONG) GetBitmapFormatSize(const BITMAPINFOHEADER *pHeader)
{
- // Everyone has this to start with this
+ // Everyone has this to start with this
LONG Size = SIZE_PREHEADER + pHeader->biSize;
ASSERT(pHeader->biSize >= sizeof(BITMAPINFOHEADER));
-
+
// Does this format use a palette, if the number of colours actually used
// is zero then it is set to the maximum that are allowed for that colour
// depth (an example is 256 for eight bits). Truecolour formats may also
@@ -225,9 +246,11 @@ STDAPI_(LONG) GetBitmapFormatSize(const BITMAPINFOHEADER *pHeader)
// This would scare me.
ASSERT(pHeader->biBitCount <= iPALETTE || pHeader->biClrUsed == 0);
- if (pHeader->biBitCount <= iPALETTE || pHeader->biClrUsed) {
+ if(pHeader->biBitCount <= iPALETTE || pHeader->biClrUsed)
+ {
LONG Entries = (DWORD) 1 << pHeader->biBitCount;
- if (pHeader->biClrUsed) {
+ if(pHeader->biClrUsed)
+ {
Entries = pHeader->biClrUsed;
}
Size += Entries * sizeof(RGBQUAD);
@@ -237,7 +260,8 @@ STDAPI_(LONG) GetBitmapFormatSize(const BITMAPINFOHEADER *pHeader)
// type which means that room for three DWORDs should be allocated that
// specify where in each pixel the RGB colour components may be found
- if (pHeader->biCompression == BI_BITFIELDS) {
+ if(pHeader->biCompression == BI_BITFIELDS)
+ {
Size += SIZE_MASKS;
}
@@ -255,8 +279,10 @@ STDAPI_(LONG) GetBitmapFormatSize(const BITMAPINFOHEADER *pHeader)
STDAPI_(BOOL) ContainsPalette(const VIDEOINFOHEADER *pVideoInfo)
{
- if (PALETTISED(pVideoInfo) == FALSE) {
- if (pVideoInfo->bmiHeader.biClrUsed == 0) {
+ if(PALETTISED(pVideoInfo) == FALSE)
+ {
+ if(pVideoInfo->bmiHeader.biClrUsed == 0)
+ {
return FALSE;
}
}
@@ -268,7 +294,8 @@ STDAPI_(BOOL) ContainsPalette(const VIDEOINFOHEADER *pVideoInfo)
STDAPI_(const RGBQUAD *) GetBitmapPalette(const VIDEOINFOHEADER *pVideoInfo)
{
- if (pVideoInfo->bmiHeader.biCompression == BI_BITFIELDS) {
+ if(pVideoInfo->bmiHeader.biCompression == BI_BITFIELDS)
+ {
return TRUECOLOR(pVideoInfo)->bmiColors;
}
return COLORS(pVideoInfo);
diff --git a/src/filters/BaseClasses/arithutil.cpp b/src/filters/BaseClasses/arithutil.cpp
index cd0d1271f..c1592e566 100644
--- a/src/filters/BaseClasses/arithutil.cpp
+++ b/src/filters/BaseClasses/arithutil.cpp
@@ -24,39 +24,40 @@
__inline
ULONG
WINAPI
-EnlargedUnsignedDivide (
+EnlargedUnsignedDivide(
IN ULARGE_INTEGER Dividend,
IN ULONG Divisor,
IN PULONG Remainder
- )
+)
{
- // return remainder if necessary
- if (Remainder != NULL)
- *Remainder = (ULONG)(LLtoU64(Dividend) % Divisor);
- return (ULONG)(LLtoU64(Dividend) / Divisor);
+ // return remainder if necessary
+ if(Remainder != NULL)
+ *Remainder = (ULONG)(LLtoU64(Dividend) % Divisor);
+ return (ULONG)(LLtoU64(Dividend) / Divisor);
}
#else
__inline
ULONG
WINAPI
-EnlargedUnsignedDivide (
+EnlargedUnsignedDivide(
IN ULARGE_INTEGER Dividend,
IN ULONG Divisor,
IN PULONG Remainder
- )
+)
{
ULONG ulResult;
- _asm {
- mov eax,Dividend.LowPart
- mov edx,Dividend.HighPart
- mov ecx,Remainder
+ _asm
+ {
+ mov eax, Dividend.LowPart
+ mov edx, Dividend.HighPart
+ mov ecx, Remainder
div Divisor
- or ecx,ecx
+ or ecx, ecx
jz short label
- mov [ecx],edx
-label:
- mov ulResult,eax
+ mov [ecx], edx
+ label:
+ mov ulResult, eax
}
return ulResult;
}
@@ -83,7 +84,7 @@ LONGLONG WINAPI llMulDiv(LONGLONG a, LONGLONG b, LONGLONG c, LONGLONG d)
ua.QuadPart = (DWORDLONG)(a >= 0 ? a : -a);
ub.QuadPart = (DWORDLONG)(b >= 0 ? b : -b);
uc = (DWORDLONG)(c >= 0 ? c : -c);
- BOOL bSign = (a < 0) ^ (b < 0);
+ BOOL bSign = (a < 0) ^(b < 0);
/* Do long multiplication */
ULARGE_INTEGER p[2];
@@ -107,21 +108,31 @@ LONGLONG WINAPI llMulDiv(LONGLONG a, LONGLONG b, LONGLONG c, LONGLONG d)
p[0].HighPart = x.LowPart;
p[1].QuadPart = UInt32x32To64(ua.HighPart, ub.HighPart) + x.HighPart;
- if (d != 0) {
+ if(d != 0)
+ {
ULARGE_INTEGER ud[2];
- if (bSign) {
+ if(bSign)
+ {
ud[0].QuadPart = (DWORDLONG)(-d);
- if (d > 0) {
+ if(d > 0)
+ {
/* -d < 0 */
- ud[1].QuadPart = (DWORDLONG)(LONGLONG)-1;
- } else {
+ ud[1].QuadPart = (DWORDLONG)(LONGLONG) - 1;
+ }
+ else
+ {
ud[1].QuadPart = (DWORDLONG)0;
}
- } else {
+ }
+ else
+ {
ud[0].QuadPart = (DWORDLONG)d;
- if (d < 0) {
- ud[1].QuadPart = (DWORDLONG)(LONGLONG)-1;
- } else {
+ if(d < 0)
+ {
+ ud[1].QuadPart = (DWORDLONG)(LONGLONG) - 1;
+ }
+ else
+ {
ud[1].QuadPart = (DWORDLONG)0;
}
}
@@ -148,7 +159,8 @@ LONGLONG WINAPI llMulDiv(LONGLONG a, LONGLONG b, LONGLONG c, LONGLONG d)
p[1].QuadPart += ud[1].QuadPart + uliTotal.QuadPart;
/* Now see if we got a sign change from the addition */
- if ((LONG)p[1].HighPart < 0) {
+ if((LONG)p[1].HighPart < 0)
+ {
bSign = !bSign;
/* Negate the current value (ugh!) */
@@ -160,22 +172,25 @@ LONGLONG WINAPI llMulDiv(LONGLONG a, LONGLONG b, LONGLONG c, LONGLONG d)
}
/* Now for the division */
- if (c < 0) {
+ if(c < 0)
+ {
bSign = !bSign;
}
/* This will catch c == 0 and overflow */
- if (uc <= p[1].QuadPart) {
+ if(uc <= p[1].QuadPart)
+ {
return bSign ? (LONGLONG)0x8000000000000000 :
- (LONGLONG)0x7FFFFFFFFFFFFFFF;
+ (LONGLONG)0x7FFFFFFFFFFFFFFF;
}
DWORDLONG ullResult;
/* Do the division */
/* If the dividend is a DWORD_LONG use the compiler */
- if (p[1].QuadPart == 0) {
+ if(p[1].QuadPart == 0)
+ {
ullResult = p[0].QuadPart / uc;
return bSign ? -(LONGLONG)ullResult : (LONGLONG)ullResult;
}
@@ -183,7 +198,8 @@ LONGLONG WINAPI llMulDiv(LONGLONG a, LONGLONG b, LONGLONG c, LONGLONG d)
/* If the divisor is a DWORD then its simpler */
ULARGE_INTEGER ulic;
ulic.QuadPart = uc;
- if (ulic.HighPart == 0) {
+ if(ulic.HighPart == 0)
+ {
ULARGE_INTEGER uliDividend;
ULARGE_INTEGER uliResult;
DWORD dwDivisor = (DWORD)uc;
@@ -199,39 +215,45 @@ LONGLONG WINAPI llMulDiv(LONGLONG a, LONGLONG b, LONGLONG c, LONGLONG d)
/* NOTE - this routine will take exceptions if
the result does not fit in a DWORD
*/
- if (uliDividend.QuadPart >= (DWORDLONG)dwDivisor) {
+ if(uliDividend.QuadPart >= (DWORDLONG)dwDivisor)
+ {
uliResult.HighPart = EnlargedUnsignedDivide(
uliDividend,
dwDivisor,
&p[0].HighPart);
- } else {
+ }
+ else
+ {
uliResult.HighPart = 0;
}
uliResult.LowPart = EnlargedUnsignedDivide(
- p[0],
- dwDivisor,
- NULL);
+ p[0],
+ dwDivisor,
+ NULL);
#endif
return bSign ? -(LONGLONG)uliResult.QuadPart :
- (LONGLONG)uliResult.QuadPart;
+ (LONGLONG)uliResult.QuadPart;
}
ullResult = 0;
/* OK - do long division */
- for (int i = 0; i < 64; i++) {
+ for(int i = 0; i < 64; i++)
+ {
ullResult <<= 1;
/* Shift 128 bit p left 1 */
p[1].QuadPart <<= 1;
- if ((p[0].HighPart & 0x80000000) != 0) {
+ if((p[0].HighPart & 0x80000000) != 0)
+ {
p[1].LowPart++;
}
p[0].QuadPart <<= 1;
/* Compare */
- if (uc <= p[1].QuadPart) {
+ if(uc <= p[1].QuadPart)
+ {
p[1].QuadPart -= uc;
ullResult += 1;
}
@@ -250,43 +272,56 @@ LONGLONG WINAPI Int64x32Div32(LONGLONG a, LONG b, LONG c, LONG d)
ua.QuadPart = (DWORDLONG)(a >= 0 ? a : -a);
ub = (DWORD)(b >= 0 ? b : -b);
uc = (DWORD)(c >= 0 ? c : -c);
- BOOL bSign = (a < 0) ^ (b < 0);
+ BOOL bSign = (a < 0) ^(b < 0);
/* Do long multiplication */
ULARGE_INTEGER p0;
DWORD p1;
p0.QuadPart = UInt32x32To64(ua.LowPart, ub);
- if (ua.HighPart != 0) {
+ if(ua.HighPart != 0)
+ {
ULARGE_INTEGER x;
x.QuadPart = UInt32x32To64(ua.HighPart, ub) + p0.HighPart;
p0.HighPart = x.LowPart;
p1 = x.HighPart;
- } else {
+ }
+ else
+ {
p1 = 0;
}
- if (d != 0) {
+ if(d != 0)
+ {
ULARGE_INTEGER ud0;
DWORD ud1;
- if (bSign) {
+ if(bSign)
+ {
//
// Cast d to LONGLONG first otherwise -0x80000000 sign extends
// incorrectly
//
ud0.QuadPart = (DWORDLONG)(-(LONGLONG)d);
- if (d > 0) {
+ if(d > 0)
+ {
/* -d < 0 */
- ud1 = (DWORD)-1;
- } else {
+ ud1 = (DWORD) - 1;
+ }
+ else
+ {
ud1 = (DWORD)0;
}
- } else {
+ }
+ else
+ {
ud0.QuadPart = (DWORDLONG)d;
- if (d < 0) {
- ud1 = (DWORD)-1;
- } else {
+ if(d < 0)
+ {
+ ud1 = (DWORD) - 1;
+ }
+ else
+ {
ud1 = (DWORD)0;
}
}
@@ -309,7 +344,8 @@ LONGLONG WINAPI Int64x32Div32(LONGLONG a, LONG b, LONG c, LONG d)
p1 += ud1 + uliTotal.HighPart;
/* Now see if we got a sign change from the addition */
- if ((LONG)p1 < 0) {
+ if((LONG)p1 < 0)
+ {
bSign = !bSign;
/* Negate the current value (ugh!) */
@@ -321,15 +357,17 @@ LONGLONG WINAPI Int64x32Div32(LONGLONG a, LONG b, LONG c, LONG d)
}
/* Now for the division */
- if (c < 0) {
+ if(c < 0)
+ {
bSign = !bSign;
}
/* This will catch c == 0 and overflow */
- if (uc <= p1) {
+ if(uc <= p1)
+ {
return bSign ? (LONGLONG)0x8000000000000000 :
- (LONGLONG)0x7FFFFFFFFFFFFFFF;
+ (LONGLONG)0x7FFFFFFFFFFFFFFF;
}
/* Do the division */
@@ -343,18 +381,21 @@ LONGLONG WINAPI Int64x32Div32(LONGLONG a, LONG b, LONG c, LONG d)
/* NOTE - this routine will take exceptions if
the result does not fit in a DWORD
*/
- if (uliDividend.QuadPart >= (DWORDLONG)dwDivisor) {
+ if(uliDividend.QuadPart >= (DWORDLONG)dwDivisor)
+ {
uliResult.HighPart = EnlargedUnsignedDivide(
uliDividend,
dwDivisor,
&p0.HighPart);
- } else {
+ }
+ else
+ {
uliResult.HighPart = 0;
}
uliResult.LowPart = EnlargedUnsignedDivide(
- p0,
- dwDivisor,
- NULL);
+ p0,
+ dwDivisor,
+ NULL);
return bSign ? -(LONGLONG)uliResult.QuadPart :
- (LONGLONG)uliResult.QuadPart;
+ (LONGLONG)uliResult.QuadPart;
}
diff --git a/src/filters/BaseClasses/cache.h b/src/filters/BaseClasses/cache.h
index 0a807c27e..e8f488fb7 100644
--- a/src/filters/BaseClasses/cache.h
+++ b/src/filters/BaseClasses/cache.h
@@ -31,7 +31,8 @@
#define __CACHE__
-class CCache : CBaseObject {
+class CCache : CBaseObject
+{
/* Make copy constructor and assignment operator inaccessible */
@@ -54,7 +55,7 @@ private:
public:
- CCache(__in_opt LPCTSTR pName,INT iItems);
+ CCache(__in_opt LPCTSTR pName, INT iItems);
virtual ~CCache();
/* Add an item to the cache */
@@ -67,7 +68,10 @@ public:
void RemoveAll(void);
/* Return the cache size which is set during construction */
- INT GetCacheSize(void) const {return m_iCacheSize;};
+ INT GetCacheSize(void) const
+ {
+ return m_iCacheSize;
+ };
};
#endif /* __CACHE__ */
diff --git a/src/filters/BaseClasses/checkbmi.h b/src/filters/BaseClasses/checkbmi.h
index 72879679c..24fda7c7a 100644
--- a/src/filters/BaseClasses/checkbmi.h
+++ b/src/filters/BaseClasses/checkbmi.h
@@ -8,13 +8,15 @@ extern "C" {
#endif
// Helper
-__inline BOOL MultiplyCheckOverflow(DWORD a, DWORD b, __deref_out_range(==, a * b) DWORD *pab) {
- *pab = a * b;
- if ((a == 0) || (((*pab) / a) == b)) {
- return TRUE;
+ __inline BOOL MultiplyCheckOverflow(DWORD a, DWORD b, __deref_out_range( == , a * b) DWORD *pab)
+ {
+ *pab = a * b;
+ if((a == 0) || (((*pab) / a) == b))
+ {
+ return TRUE;
+ }
+ return FALSE;
}
- return FALSE;
-}
// Checks if the fields in a BITMAPINFOHEADER won't generate
@@ -29,89 +31,103 @@ __inline BOOL MultiplyCheckOverflow(DWORD a, DWORD b, __deref_out_range(==, a *
// 5. Total structure size exceeding know size of data
//
-__success(return != 0) __inline BOOL ValidateBitmapInfoHeader(
- const BITMAPINFOHEADER *pbmi, // pointer to structure to check
- __out_range(>=, sizeof(BITMAPINFOHEADER)) DWORD cbSize // size of memory block containing structure
-)
-{
- DWORD dwWidthInBytes;
- DWORD dwBpp;
- DWORD dwWidthInBits;
- DWORD dwHeight;
- DWORD dwSizeImage;
- DWORD dwClrUsed;
-
- // Reject bad parameters - do the size check first to avoid reading bad memory
- if (cbSize < sizeof(BITMAPINFOHEADER) ||
- pbmi->biSize < sizeof(BITMAPINFOHEADER) ||
- pbmi->biSize > 4096) {
- return FALSE;
- }
+ __success(return != 0) __inline BOOL ValidateBitmapInfoHeader(
+ const BITMAPINFOHEADER *pbmi, // pointer to structure to check
+ __out_range( >= , sizeof(BITMAPINFOHEADER)) DWORD cbSize // size of memory block containing structure
+ )
+ {
+ DWORD dwWidthInBytes;
+ DWORD dwBpp;
+ DWORD dwWidthInBits;
+ DWORD dwHeight;
+ DWORD dwSizeImage;
+ DWORD dwClrUsed;
+
+ // Reject bad parameters - do the size check first to avoid reading bad memory
+ if(cbSize < sizeof(BITMAPINFOHEADER) ||
+ pbmi->biSize < sizeof(BITMAPINFOHEADER) ||
+ pbmi->biSize > 4096)
+ {
+ return FALSE;
+ }
- // Reject 0 size
- if (pbmi->biWidth == 0 || pbmi->biHeight == 0) {
- return FALSE;
- }
+ // Reject 0 size
+ if(pbmi->biWidth == 0 || pbmi->biHeight == 0)
+ {
+ return FALSE;
+ }
- // Use bpp of 200 for validating against further overflows if not set for compressed format
- dwBpp = 200;
+ // Use bpp of 200 for validating against further overflows if not set for compressed format
+ dwBpp = 200;
- if (pbmi->biBitCount > dwBpp) {
- return FALSE;
- }
+ if(pbmi->biBitCount > dwBpp)
+ {
+ return FALSE;
+ }
- // Strictly speaking abs can overflow so cast explicitly to DWORD
- dwHeight = (DWORD)abs(pbmi->biHeight);
+ // Strictly speaking abs can overflow so cast explicitly to DWORD
+ dwHeight = (DWORD)abs(pbmi->biHeight);
- if (!MultiplyCheckOverflow(dwBpp, (DWORD)pbmi->biWidth, &dwWidthInBits)) {
- return FALSE;
- }
+ if(!MultiplyCheckOverflow(dwBpp, (DWORD)pbmi->biWidth, &dwWidthInBits))
+ {
+ return FALSE;
+ }
- // Compute correct width in bytes - rounding up to 4 bytes
- dwWidthInBytes = (dwWidthInBits / 8 + 3) & ~3;
+ // Compute correct width in bytes - rounding up to 4 bytes
+ dwWidthInBytes = (dwWidthInBits / 8 + 3) & ~3;
- if (!MultiplyCheckOverflow(dwWidthInBytes, dwHeight, &dwSizeImage)) {
- return FALSE;
- }
+ if(!MultiplyCheckOverflow(dwWidthInBytes, dwHeight, &dwSizeImage))
+ {
+ return FALSE;
+ }
- // Fail if total size is 0 - this catches indivual quantities being 0
- // Also don't allow huge values > 1GB which might cause arithmetic
- // errors for users
- if (dwSizeImage > 0x40000000 ||
- pbmi->biSizeImage > 0x40000000) {
- return FALSE;
- }
+ // Fail if total size is 0 - this catches indivual quantities being 0
+ // Also don't allow huge values > 1GB which might cause arithmetic
+ // errors for users
+ if(dwSizeImage > 0x40000000 ||
+ pbmi->biSizeImage > 0x40000000)
+ {
+ return FALSE;
+ }
- // Fail if biClrUsed looks bad
- if (pbmi->biClrUsed > 256) {
- return FALSE;
- }
+ // Fail if biClrUsed looks bad
+ if(pbmi->biClrUsed > 256)
+ {
+ return FALSE;
+ }
- if (pbmi->biClrUsed == 0 && pbmi->biBitCount <= 8 && pbmi->biBitCount > 0) {
- dwClrUsed = (1 << pbmi->biBitCount);
- } else {
- dwClrUsed = pbmi->biClrUsed;
- }
+ if(pbmi->biClrUsed == 0 && pbmi->biBitCount <= 8 && pbmi->biBitCount > 0)
+ {
+ dwClrUsed = (1 << pbmi->biBitCount);
+ }
+ else
+ {
+ dwClrUsed = pbmi->biClrUsed;
+ }
- // Check total size
- if (cbSize < pbmi->biSize + dwClrUsed * sizeof(RGBQUAD) +
- (pbmi->biCompression == BI_BITFIELDS ? 3 * sizeof(DWORD) : 0)) {
- return FALSE;
- }
+ // Check total size
+ if(cbSize < pbmi->biSize + dwClrUsed * sizeof(RGBQUAD) +
+ (pbmi->biCompression == BI_BITFIELDS ? 3 * sizeof(DWORD) : 0))
+ {
+ return FALSE;
+ }
- // If it is RGB validate biSizeImage - lots of code assumes the size is correct
- if (pbmi->biCompression == BI_RGB || pbmi->biCompression == BI_BITFIELDS) {
- if (pbmi->biSizeImage != 0) {
- DWORD dwBits = (DWORD)pbmi->biWidth * (DWORD)pbmi->biBitCount;
- DWORD dwWidthInBytes = ((DWORD)((dwBits+31) & (~31)) / 8);
- DWORD dwTotalSize = (DWORD)abs(pbmi->biHeight) * dwWidthInBytes;
- if (dwTotalSize > pbmi->biSizeImage) {
- return FALSE;
+ // If it is RGB validate biSizeImage - lots of code assumes the size is correct
+ if(pbmi->biCompression == BI_RGB || pbmi->biCompression == BI_BITFIELDS)
+ {
+ if(pbmi->biSizeImage != 0)
+ {
+ DWORD dwBits = (DWORD)pbmi->biWidth * (DWORD)pbmi->biBitCount;
+ DWORD dwWidthInBytes = ((DWORD)((dwBits + 31) & (~31)) / 8);
+ DWORD dwTotalSize = (DWORD)abs(pbmi->biHeight) * dwWidthInBytes;
+ if(dwTotalSize > pbmi->biSizeImage)
+ {
+ return FALSE;
+ }
}
}
+ return TRUE;
}
- return TRUE;
-}
#ifdef __cplusplus
}
diff --git a/src/filters/BaseClasses/combase.cpp b/src/filters/BaseClasses/combase.cpp
index 25ed0c65d..1bff6b761 100644
--- a/src/filters/BaseClasses/combase.cpp
+++ b/src/filters/BaseClasses/combase.cpp
@@ -54,12 +54,14 @@ HINSTANCE hlibOLEAut32;
CBaseObject::~CBaseObject()
{
/* Decrement the number of objects active */
- if (InterlockedDecrement(&m_cObjects) == 0) {
- if (hlibOLEAut32) {
- FreeLibrary(hlibOLEAut32);
-
- hlibOLEAut32 = 0;
- }
+ if(InterlockedDecrement(&m_cObjects) == 0)
+ {
+ if(hlibOLEAut32)
+ {
+ FreeLibrary(hlibOLEAut32);
+
+ hlibOLEAut32 = 0;
+ }
};
@@ -72,9 +74,10 @@ static const TCHAR szOle32Aut[] = TEXT("OleAut32.dll");
HINSTANCE LoadOLEAut32()
{
- if (hlibOLEAut32 == 0) {
+ if(hlibOLEAut32 == 0)
+ {
- hlibOLEAut32 = LoadLibrary(szOle32Aut);
+ hlibOLEAut32 = LoadLibrary(szOle32Aut);
}
return hlibOLEAut32;
@@ -86,21 +89,21 @@ HINSTANCE LoadOLEAut32()
// We know we use "this" in the initialization list, we also know we don't modify *phr.
#pragma warning( disable : 4355 4100 )
CUnknown::CUnknown(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk)
-: CBaseObject(pName)
+ : CBaseObject(pName)
/* Start the object with a reference count of zero - when the */
/* object is queried for it's first interface this may be */
/* incremented depending on whether or not this object is */
/* currently being aggregated upon */
-, m_cRef(0)
+ , m_cRef(0)
/* Set our pointer to our IUnknown interface. */
/* If we have an outer, use its, otherwise use ours. */
/* This pointer effectivly points to the owner of */
/* this object and can be accessed by the GetOwner() method. */
-, m_pUnknown( pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>( static_cast<PNDUNKNOWN>(this) ) )
- /* Why the double cast? Well, the inner cast is a type-safe cast */
- /* to pointer to a type from which we inherit. The second is */
- /* type-unsafe but works because INonDelegatingUnknown "behaves */
- /* like" IUnknown. (Only the names on the methods change.) */
+ , m_pUnknown(pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>(static_cast<PNDUNKNOWN>(this)))
+/* Why the double cast? Well, the inner cast is a type-safe cast */
+/* to pointer to a type from which we inherit. The second is */
+/* type-unsafe but works because INonDelegatingUnknown "behaves */
+/* like" IUnknown. (Only the names on the methods change.) */
{
// Everything we need to do has been done in the initializer list
}
@@ -110,19 +113,19 @@ CUnknown::CUnknown(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk)
CUnknown::CUnknown(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr) :
CBaseObject(pName),
m_cRef(0),
- m_pUnknown( pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>( static_cast<PNDUNKNOWN>(this) ) )
+ m_pUnknown(pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>(static_cast<PNDUNKNOWN>(this)))
{
}
#ifdef UNICODE
CUnknown::CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk)
-: CBaseObject(pName), m_cRef(0),
- m_pUnknown( pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>( static_cast<PNDUNKNOWN>(this) ) )
+ : CBaseObject(pName), m_cRef(0),
+ m_pUnknown(pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>(static_cast<PNDUNKNOWN>(this)))
{ }
CUnknown::CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr) :
CBaseObject(pName), m_cRef(0),
- m_pUnknown( pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>( static_cast<PNDUNKNOWN>(this) ) )
+ m_pUnknown(pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>(static_cast<PNDUNKNOWN>(this)))
{ }
#endif
@@ -134,15 +137,18 @@ CUnknown::CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk, __inout_opt H
STDMETHODIMP CUnknown::NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv)
{
- CheckPointer(ppv,E_POINTER);
- ValidateReadWritePtr(ppv,sizeof(PVOID));
+ CheckPointer(ppv, E_POINTER);
+ ValidateReadWritePtr(ppv, sizeof(PVOID));
/* We know only about IUnknown */
- if (riid == IID_IUnknown) {
- GetInterface((LPUNKNOWN) (PNDUNKNOWN) this, ppv);
+ if(riid == IID_IUnknown)
+ {
+ GetInterface((LPUNKNOWN)(PNDUNKNOWN) this, ppv);
return NOERROR;
- } else {
+ }
+ else
+ {
*ppv = NULL;
return E_NOINTERFACE;
}
@@ -153,7 +159,7 @@ STDMETHODIMP CUnknown::NonDelegatingQueryInterface(REFIID riid, __deref_out void
/* about concurrency, we can't afford to access the m_cRef twice since we can't */
/* afford to run the risk that its value having changed between accesses. */
-template<class T> inline static T ourmax( const T & a, const T & b )
+template<class T> inline static T ourmax(const T & a, const T & b)
{
return a > b ? a : b;
}
@@ -162,10 +168,10 @@ template<class T> inline static T ourmax( const T & a, const T & b )
STDMETHODIMP_(ULONG) CUnknown::NonDelegatingAddRef()
{
- LONG lRef = InterlockedIncrement( &m_cRef );
+ LONG lRef = InterlockedIncrement(&m_cRef);
ASSERT(lRef > 0);
- DbgLog((LOG_MEMORY,3,TEXT(" Obj %d ref++ = %d"),
- m_dwCookie, m_cRef));
+ DbgLog((LOG_MEMORY, 3, TEXT(" Obj %d ref++ = %d"),
+ m_dwCookie, m_cRef));
return ourmax(ULONG(m_cRef), 1ul);
}
@@ -176,12 +182,13 @@ STDMETHODIMP_(ULONG) CUnknown::NonDelegatingRelease()
{
/* If the reference count drops to zero delete ourselves */
- LONG lRef = InterlockedDecrement( &m_cRef );
+ LONG lRef = InterlockedDecrement(&m_cRef);
ASSERT(lRef >= 0);
- DbgLog((LOG_MEMORY,3,TEXT(" Object %d ref-- = %d"),
- m_dwCookie, m_cRef));
- if (lRef == 0) {
+ DbgLog((LOG_MEMORY, 3, TEXT(" Object %d ref-- = %d"),
+ m_dwCookie, m_cRef));
+ if(lRef == 0)
+ {
// COM rules say we must protect against re-entrancy.
// If we are an aggregator and we hold our own interfaces
@@ -199,7 +206,9 @@ STDMETHODIMP_(ULONG) CUnknown::NonDelegatingRelease()
delete this;
return ULONG(0);
- } else {
+ }
+ else
+ {
// Don't touch m_cRef again even in this leg as the object
// may have just been released on another thread too
return ourmax(ULONG(lRef), 1ul);
@@ -226,7 +235,8 @@ BOOL WINAPI IsEqualObject(IUnknown *pFirst, IUnknown *pSecond)
/* Different objects can't have the same interface pointer for
any interface
*/
- if (pFirst == pSecond) {
+ if(pFirst == pSecond)
+ {
return TRUE;
}
/* OK - do it the hard way - check if they have the same
@@ -241,8 +251,9 @@ BOOL WINAPI IsEqualObject(IUnknown *pFirst, IUnknown *pSecond)
/* See if the IUnknown pointers match */
- hr = pFirst->QueryInterface(IID_IUnknown,(void **) &pUnknown1);
- if (FAILED(hr)) {
+ hr = pFirst->QueryInterface(IID_IUnknown, (void **) &pUnknown1);
+ if(FAILED(hr))
+ {
return FALSE;
}
ASSERT(pUnknown1);
@@ -251,8 +262,9 @@ BOOL WINAPI IsEqualObject(IUnknown *pFirst, IUnknown *pSecond)
pUnknown1->Release();
- hr = pSecond->QueryInterface(IID_IUnknown,(void **) &pUnknown2);
- if (FAILED(hr)) {
+ hr = pSecond->QueryInterface(IID_IUnknown, (void **) &pUnknown2);
+ if(FAILED(hr))
+ {
return FALSE;
}
ASSERT(pUnknown2);
diff --git a/src/filters/BaseClasses/combase.h b/src/filters/BaseClasses/combase.h
index 7b0d1edae..32ac70305 100644
--- a/src/filters/BaseClasses/combase.h
+++ b/src/filters/BaseClasses/combase.h
@@ -115,12 +115,12 @@ AMOVIESETUP_PIN, * PAMOVIESETUP_PIN, * FAR LPAMOVIESETUP_PIN;
typedef struct _AMOVIESETUP_FILTER
{
- const CLSID * clsID;
- const WCHAR * strName;
- DWORD dwMerit;
- UINT nPins;
- const AMOVIESETUP_PIN * lpPin;
- const CLSID filterCategory;
+ const CLSID * clsID;
+ const WCHAR * strName;
+ DWORD dwMerit;
+ UINT nPins;
+ const AMOVIESETUP_PIN * lpPin;
+ const CLSID filterCategory;
}
AMOVIESETUP_FILTER, * PAMOVIESETUP_FILTER, * FAR LPAMOVIESETUP_FILTER;
@@ -139,7 +139,7 @@ extern OSVERSIONINFO g_osInfo; // Filled in by GetVersionEx
#ifndef INONDELEGATINGUNKNOWN_DEFINED
DECLARE_INTERFACE(INonDelegatingUnknown)
{
- STDMETHOD(NonDelegatingQueryInterface) (THIS_ REFIID, LPVOID *) PURE;
+ STDMETHOD(NonDelegatingQueryInterface)(THIS_ REFIID, LPVOID *) PURE;
STDMETHOD_(ULONG, NonDelegatingAddRef)(THIS) PURE;
STDMETHOD_(ULONG, NonDelegatingRelease)(THIS) PURE;
};
@@ -188,7 +188,8 @@ public:
/* Call this to find if there are any CUnknown derived objects active */
- static LONG ObjectsActive() {
+ static LONG ObjectsActive()
+ {
return m_cObjects;
};
};
@@ -199,7 +200,7 @@ public:
support, and an implementation of the core non delegating IUnknown */
class AM_NOVTABLE CUnknown : public INonDelegatingUnknown,
- public CBaseObject
+ public CBaseObject
{
private:
const LPUNKNOWN m_pUnknown; /* Owner of this object */
@@ -217,12 +218,13 @@ public:
CUnknown(__in_opt LPCTSTR Name, __in_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr);
#ifdef UNICODE
CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk);
- CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk,__inout_opt HRESULT *phr);
+ CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr);
#endif
/* Return the owner of this object */
- LPUNKNOWN GetOwner() const {
+ LPUNKNOWN GetOwner() const
+ {
return m_pUnknown;
};
@@ -258,7 +260,8 @@ typedef void (CALLBACK *LPFNInitRoutine)(BOOL bLoading, const CLSID *rclsid);
/* Create one of these per object class in an array so that
the default class factory code can create new instances */
-class CFactoryTemplate {
+class CFactoryTemplate
+{
public:
@@ -268,12 +271,14 @@ public:
LPFNInitRoutine m_lpfnInit;
const AMOVIESETUP_FILTER * m_pAMovieSetup_Filter;
- BOOL IsClassID(REFCLSID rclsid) const {
- return (IsEqualCLSID(*m_ClsID,rclsid));
+ BOOL IsClassID(REFCLSID rclsid) const
+ {
+ return (IsEqualCLSID(*m_ClsID, rclsid));
};
- CUnknown *CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr) const {
- CheckPointer(phr,NULL);
+ CUnknown *CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr) const
+ {
+ CheckPointer(phr, NULL);
return m_lpfnNew(pUnk, phr);
};
};
diff --git a/src/filters/BaseClasses/cprop.cpp b/src/filters/BaseClasses/cprop.cpp
index 7bd76b4e3..41c40e0a9 100644
--- a/src/filters/BaseClasses/cprop.cpp
+++ b/src/filters/BaseClasses/cprop.cpp
@@ -20,7 +20,7 @@ CBasePropertyPage::CBasePropertyPage(__in_opt LPCTSTR pName, // Debug only nam
__inout_opt LPUNKNOWN pUnk, // COM Delegator
int DialogId, // Resource ID
int TitleId) : // To get tital
- CUnknown(pName,pUnk),
+ CUnknown(pName, pUnk),
m_DialogId(DialogId),
m_TitleId(TitleId),
m_hwnd(NULL),
@@ -36,7 +36,7 @@ CBasePropertyPage::CBasePropertyPage(__in_opt LPCSTR pName, // Debug only na
__inout_opt LPUNKNOWN pUnk, // COM Delegator
int DialogId, // Resource ID
int TitleId) : // To get tital
- CUnknown(pName,pUnk),
+ CUnknown(pName, pUnk),
m_DialogId(DialogId),
m_TitleId(TitleId),
m_hwnd(NULL),
@@ -54,7 +54,7 @@ STDMETHODIMP_(ULONG) CBasePropertyPage::NonDelegatingAddRef()
{
LONG lRef = InterlockedIncrement(&m_cRef);
ASSERT(lRef > 0);
- return max(ULONG(m_cRef),1ul);
+ return max(ULONG(m_cRef), 1ul);
}
@@ -65,15 +65,18 @@ STDMETHODIMP_(ULONG) CBasePropertyPage::NonDelegatingRelease()
// If the reference count drops to zero delete ourselves
LONG lRef = InterlockedDecrement(&m_cRef);
- if (lRef == 0) {
+ if(lRef == 0)
+ {
m_cRef++;
SetPageSite(NULL);
- SetObjects(0,NULL);
+ SetObjects(0, NULL);
delete this;
return ULONG(0);
- } else {
+ }
+ else
+ {
// Don't touch m_cRef again here!
- return max(ULONG(lRef),1ul);
+ return max(ULONG(lRef), 1ul);
}
}
@@ -81,12 +84,15 @@ STDMETHODIMP_(ULONG) CBasePropertyPage::NonDelegatingRelease()
// Expose our IPropertyPage interface
STDMETHODIMP
-CBasePropertyPage::NonDelegatingQueryInterface(REFIID riid,__deref_out void **ppv)
+CBasePropertyPage::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
- if (riid == IID_IPropertyPage) {
- return GetInterface((IPropertyPage *)this,ppv);
- } else {
- return CUnknown::NonDelegatingQueryInterface(riid,ppv);
+ if(riid == IID_IPropertyPage)
+ {
+ return GetInterface((IPropertyPage *)this, ppv);
+ }
+ else
+ {
+ return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -95,15 +101,16 @@ CBasePropertyPage::NonDelegatingQueryInterface(REFIID riid,__deref_out void **pp
STDMETHODIMP CBasePropertyPage::GetPageInfo(__out LPPROPPAGEINFO pPageInfo)
{
- CheckPointer(pPageInfo,E_POINTER);
+ CheckPointer(pPageInfo, E_POINTER);
WCHAR wszTitle[STR_MAX_LENGTH];
- WideStringFromResource(wszTitle,m_TitleId);
+ WideStringFromResource(wszTitle, m_TitleId);
// Allocate dynamic memory for the property page title
LPOLESTR pszTitle;
HRESULT hr = AMGetWideString(wszTitle, &pszTitle);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
NOTE("No caption memory");
return hr;
}
@@ -118,7 +125,7 @@ STDMETHODIMP CBasePropertyPage::GetPageInfo(__out LPPROPPAGEINFO pPageInfo)
pPageInfo->size.cx = 340;
pPageInfo->size.cy = 150;
- GetDialogSize(m_DialogId, DialogProc,0L,&pPageInfo->size);
+ GetDialogSize(m_DialogId, DialogProc, 0L, &pPageInfo->size);
return NOERROR;
}
@@ -126,44 +133,49 @@ STDMETHODIMP CBasePropertyPage::GetPageInfo(__out LPPROPPAGEINFO pPageInfo)
// Handles the messages for our property window
INT_PTR CALLBACK CBasePropertyPage::DialogProc(HWND hwnd,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
{
CBasePropertyPage *pPropertyPage;
- switch (uMsg) {
+ switch(uMsg)
+ {
- case WM_INITDIALOG:
+ case WM_INITDIALOG:
- _SetWindowLongPtr(hwnd, DWLP_USER, lParam);
+ _SetWindowLongPtr(hwnd, DWLP_USER, lParam);
- // This pointer may be NULL when calculating size
+ // This pointer may be NULL when calculating size
- pPropertyPage = (CBasePropertyPage *) lParam;
- if (pPropertyPage == NULL) {
- return (LRESULT) 1;
- }
- pPropertyPage->m_Dlg = hwnd;
+ pPropertyPage = (CBasePropertyPage *) lParam;
+ if(pPropertyPage == NULL)
+ {
+ return (LRESULT) 1;
+ }
+ pPropertyPage->m_Dlg = hwnd;
}
// This pointer may be NULL when calculating size
pPropertyPage = _GetWindowLongPtr<CBasePropertyPage*>(hwnd, DWLP_USER);
- if (pPropertyPage == NULL) {
+ if(pPropertyPage == NULL)
+ {
return (LRESULT) 1;
}
- return pPropertyPage->OnReceiveMessage(hwnd,uMsg,wParam,lParam);
+ return pPropertyPage->OnReceiveMessage(hwnd, uMsg, wParam, lParam);
}
// Tells us the object that should be informed of the property changes
-STDMETHODIMP CBasePropertyPage::SetObjects(ULONG cObjects,__in_ecount_opt(cObjects) LPUNKNOWN *ppUnk)
+STDMETHODIMP CBasePropertyPage::SetObjects(ULONG cObjects, __in_ecount_opt(cObjects) LPUNKNOWN *ppUnk)
{
- if (cObjects == 1) {
+ if(cObjects == 1)
+ {
- if ((ppUnk == NULL) || (*ppUnk == NULL)) {
+ if((ppUnk == NULL) || (*ppUnk == NULL))
+ {
return E_POINTER;
}
@@ -171,7 +183,9 @@ STDMETHODIMP CBasePropertyPage::SetObjects(ULONG cObjects,__in_ecount_opt(cObjec
m_bObjectSet = TRUE ;
return OnConnect(*ppUnk);
- } else if (cObjects == 0) {
+ }
+ else if(cObjects == 0)
+ {
// Set a flag to say that we have not set the Object for the page
m_bObjectSet = FALSE ;
@@ -186,17 +200,19 @@ STDMETHODIMP CBasePropertyPage::SetObjects(ULONG cObjects,__in_ecount_opt(cObjec
// Create the window we will use to edit properties
STDMETHODIMP CBasePropertyPage::Activate(HWND hwndParent,
- LPCRECT pRect,
- BOOL fModal)
+ LPCRECT pRect,
+ BOOL fModal)
{
- CheckPointer(pRect,E_POINTER);
+ CheckPointer(pRect, E_POINTER);
// Return failure if SetObject has not been called.
- if (m_bObjectSet == FALSE) {
+ if(m_bObjectSet == FALSE)
+ {
return E_UNEXPECTED;
}
- if (m_hwnd) {
+ if(m_hwnd)
+ {
return E_UNEXPECTED;
}
@@ -205,7 +221,8 @@ STDMETHODIMP CBasePropertyPage::Activate(HWND hwndParent,
hwndParent,
DialogProc,
(LPARAM) this);
- if (m_hwnd == NULL) {
+ if(m_hwnd == NULL)
+ {
return E_OUTOFMEMORY;
}
@@ -219,9 +236,10 @@ STDMETHODIMP CBasePropertyPage::Activate(HWND hwndParent,
STDMETHODIMP CBasePropertyPage::Move(LPCRECT pRect)
{
- CheckPointer(pRect,E_POINTER);
+ CheckPointer(pRect, E_POINTER);
- if (m_hwnd == NULL) {
+ if(m_hwnd == NULL)
+ {
return E_UNEXPECTED;
}
@@ -240,20 +258,22 @@ STDMETHODIMP CBasePropertyPage::Move(LPCRECT pRect)
STDMETHODIMP CBasePropertyPage::Show(UINT nCmdShow)
{
- // Have we been activated yet
+ // Have we been activated yet
- if (m_hwnd == NULL) {
+ if(m_hwnd == NULL)
+ {
return E_UNEXPECTED;
}
// Ignore wrong show flags
- if ((nCmdShow != SW_SHOW) && (nCmdShow != SW_SHOWNORMAL) && (nCmdShow != SW_HIDE)) {
+ if((nCmdShow != SW_SHOW) && (nCmdShow != SW_SHOWNORMAL) && (nCmdShow != SW_HIDE))
+ {
return E_INVALIDARG;
}
- ShowWindow(m_hwnd,nCmdShow);
- InvalidateRect(m_hwnd,NULL,TRUE);
+ ShowWindow(m_hwnd, nCmdShow);
+ InvalidateRect(m_hwnd, NULL, TRUE);
return NOERROR;
}
@@ -262,7 +282,8 @@ STDMETHODIMP CBasePropertyPage::Show(UINT nCmdShow)
STDMETHODIMP CBasePropertyPage::Deactivate(void)
{
- if (m_hwnd == NULL) {
+ if(m_hwnd == NULL)
+ {
return E_UNEXPECTED;
}
@@ -293,18 +314,23 @@ STDMETHODIMP CBasePropertyPage::Deactivate(void)
STDMETHODIMP CBasePropertyPage::SetPageSite(__in_opt LPPROPERTYPAGESITE pPageSite)
{
- if (pPageSite) {
+ if(pPageSite)
+ {
- if (m_pPageSite) {
+ if(m_pPageSite)
+ {
return E_UNEXPECTED;
}
m_pPageSite = pPageSite;
m_pPageSite->AddRef();
- } else {
+ }
+ else
+ {
- if (m_pPageSite == NULL) {
+ if(m_pPageSite == NULL)
+ {
return E_UNEXPECTED;
}
@@ -325,26 +351,30 @@ STDMETHODIMP CBasePropertyPage::Apply()
// see if we have been activated (ie., m_hWnd != NULL), but instead
// make sure that m_bObjectSet is TRUE (ie., SetObject has been called).
- if (m_bObjectSet == FALSE) {
+ if(m_bObjectSet == FALSE)
+ {
return E_UNEXPECTED;
}
// Must have had a site set
- if (m_pPageSite == NULL) {
+ if(m_pPageSite == NULL)
+ {
return E_UNEXPECTED;
}
// Has anything changed
- if (m_bDirty == FALSE) {
+ if(m_bDirty == FALSE)
+ {
return NOERROR;
}
// Commit derived class changes
HRESULT hr = OnApplyChanges();
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
m_bDirty = FALSE;
}
return hr;
@@ -353,7 +383,7 @@ STDMETHODIMP CBasePropertyPage::Apply()
// Base class definition for message handling
-INT_PTR CBasePropertyPage::OnReceiveMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
+INT_PTR CBasePropertyPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
// we would like the TAB key to move around the tab stops in our property
// page, but for some reason OleCreatePropertyFrame clears the CONTROLPARENT
@@ -365,19 +395,22 @@ INT_PTR CBasePropertyPage::OnReceiveMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LP
{
pPropertyPage = _GetWindowLongPtr<CBasePropertyPage*>(hwnd, DWLP_USER);
- if (pPropertyPage->m_hwnd == NULL) {
+ if(pPropertyPage->m_hwnd == NULL)
+ {
return 0;
}
- switch (uMsg) {
- case WM_STYLECHANGING:
- if (wParam == GWL_EXSTYLE) {
- LPSTYLESTRUCT lpss = (LPSTYLESTRUCT)lParam;
- lpss->styleNew |= WS_EX_CONTROLPARENT;
- return 0;
- }
+ switch(uMsg)
+ {
+ case WM_STYLECHANGING:
+ if(wParam == GWL_EXSTYLE)
+ {
+ LPSTYLESTRUCT lpss = (LPSTYLESTRUCT)lParam;
+ lpss->styleNew |= WS_EX_CONTROLPARENT;
+ return 0;
+ }
}
}
-
- return DefWindowProc(hwnd,uMsg,wParam,lParam);
+
+ return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
diff --git a/src/filters/BaseClasses/cprop.h b/src/filters/BaseClasses/cprop.h
index db4494067..af217aff0 100644
--- a/src/filters/BaseClasses/cprop.h
+++ b/src/filters/BaseClasses/cprop.h
@@ -58,7 +58,7 @@ public:
#ifdef UNICODE
CBasePropertyPage(__in_opt LPCSTR pName,
__inout_opt LPUNKNOWN pUnk,
- int DialogId,
+ int DialogId,
int TitleId);
#endif
virtual ~CBasePropertyPage() { };
@@ -66,12 +66,27 @@ public:
// Override these virtual methods
- virtual HRESULT OnConnect(IUnknown *pUnknown) { return NOERROR; };
- virtual HRESULT OnDisconnect() { return NOERROR; };
- virtual HRESULT OnActivate() { return NOERROR; };
- virtual HRESULT OnDeactivate() { return NOERROR; };
- virtual HRESULT OnApplyChanges() { return NOERROR; };
- virtual INT_PTR OnReceiveMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
+ virtual HRESULT OnConnect(IUnknown *pUnknown)
+ {
+ return NOERROR;
+ };
+ virtual HRESULT OnDisconnect()
+ {
+ return NOERROR;
+ };
+ virtual HRESULT OnActivate()
+ {
+ return NOERROR;
+ };
+ virtual HRESULT OnDeactivate()
+ {
+ return NOERROR;
+ };
+ virtual HRESULT OnApplyChanges()
+ {
+ return NOERROR;
+ };
+ virtual INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
// These implement an IPropertyPage interface
@@ -79,16 +94,25 @@ public:
STDMETHODIMP_(ULONG) NonDelegatingRelease();
STDMETHODIMP_(ULONG) NonDelegatingAddRef();
STDMETHODIMP SetPageSite(__in_opt LPPROPERTYPAGESITE pPageSite);
- STDMETHODIMP Activate(HWND hwndParent, LPCRECT prect,BOOL fModal);
+ STDMETHODIMP Activate(HWND hwndParent, LPCRECT prect, BOOL fModal);
STDMETHODIMP Deactivate(void);
STDMETHODIMP GetPageInfo(__out LPPROPPAGEINFO pPageInfo);
STDMETHODIMP SetObjects(ULONG cObjects, __in_ecount_opt(cObjects) LPUNKNOWN *ppUnk);
STDMETHODIMP Show(UINT nCmdShow);
STDMETHODIMP Move(LPCRECT prect);
- STDMETHODIMP IsPageDirty(void) { return m_bDirty ? S_OK : S_FALSE; }
+ STDMETHODIMP IsPageDirty(void)
+ {
+ return m_bDirty ? S_OK : S_FALSE;
+ }
STDMETHODIMP Apply(void);
- STDMETHODIMP Help(LPCWSTR lpszHelpDir) { return E_NOTIMPL; }
- STDMETHODIMP TranslateAccelerator(__inout LPMSG lpMsg) { return E_NOTIMPL; }
+ STDMETHODIMP Help(LPCWSTR lpszHelpDir)
+ {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP TranslateAccelerator(__inout LPMSG lpMsg)
+ {
+ return E_NOTIMPL;
+ }
};
#endif // __CPROP__
diff --git a/src/filters/BaseClasses/ctlutil.cpp b/src/filters/BaseClasses/ctlutil.cpp
index 8ccb9dc3c..b9adb300a 100644
--- a/src/filters/BaseClasses/ctlutil.cpp
+++ b/src/filters/BaseClasses/ctlutil.cpp
@@ -24,8 +24,9 @@
// --- CBaseDispatch implementation ----------
CBaseDispatch::~CBaseDispatch()
{
- if (m_pti) {
- m_pti->Release();
+ if(m_pti)
+ {
+ m_pti->Release();
}
}
@@ -35,104 +36,113 @@ CBaseDispatch::~CBaseDispatch()
STDMETHODIMP
CBaseDispatch::GetTypeInfoCount(__out UINT * pctinfo)
{
- CheckPointer(pctinfo,E_POINTER);
- ValidateReadWritePtr(pctinfo,sizeof(UINT *));
+ CheckPointer(pctinfo, E_POINTER);
+ ValidateReadWritePtr(pctinfo, sizeof(UINT *));
*pctinfo = 1;
return S_OK;
}
-typedef HRESULT (STDAPICALLTYPE *LPLOADTYPELIB)(
- const OLECHAR FAR *szFile,
- __deref_out ITypeLib FAR* FAR* pptlib);
+typedef HRESULT(STDAPICALLTYPE *LPLOADTYPELIB)(
+ const OLECHAR FAR *szFile,
+ __deref_out ITypeLib FAR* FAR* pptlib);
-typedef HRESULT (STDAPICALLTYPE *LPLOADREGTYPELIB)(REFGUID rguid,
- WORD wVerMajor,
- WORD wVerMinor,
- LCID lcid,
- __deref_out ITypeLib FAR* FAR* pptlib);
+typedef HRESULT(STDAPICALLTYPE *LPLOADREGTYPELIB)(REFGUID rguid,
+ WORD wVerMajor,
+ WORD wVerMinor,
+ LCID lcid,
+ __deref_out ITypeLib FAR* FAR* pptlib);
// attempt to find our type library
STDMETHODIMP
CBaseDispatch::GetTypeInfo(
- REFIID riid,
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo)
+ REFIID riid,
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo)
{
- CheckPointer(pptinfo,E_POINTER);
- ValidateReadWritePtr(pptinfo,sizeof(ITypeInfo *));
+ CheckPointer(pptinfo, E_POINTER);
+ ValidateReadWritePtr(pptinfo, sizeof(ITypeInfo *));
HRESULT hr;
*pptinfo = NULL;
// we only support one type element
- if (0 != itinfo) {
- return TYPE_E_ELEMENTNOTFOUND;
+ if(0 != itinfo)
+ {
+ return TYPE_E_ELEMENTNOTFOUND;
}
- if (NULL == pptinfo) {
- return E_POINTER;
+ if(NULL == pptinfo)
+ {
+ return E_POINTER;
}
// always look for neutral
- if (NULL == m_pti) {
+ if(NULL == m_pti)
+ {
- LPLOADTYPELIB lpfnLoadTypeLib;
- LPLOADREGTYPELIB lpfnLoadRegTypeLib;
- ITypeLib *ptlib;
- HINSTANCE hInst;
+ LPLOADTYPELIB lpfnLoadTypeLib;
+ LPLOADREGTYPELIB lpfnLoadRegTypeLib;
+ ITypeLib *ptlib;
+ HINSTANCE hInst;
- static const char szTypeLib[] = "LoadTypeLib";
- static const char szRegTypeLib[] = "LoadRegTypeLib";
- static const WCHAR szControl[] = L"control.tlb";
+ static const char szTypeLib[] = "LoadTypeLib";
+ static const char szRegTypeLib[] = "LoadRegTypeLib";
+ static const WCHAR szControl[] = L"control.tlb";
- //
- // Try to get the Ole32Aut.dll module handle.
- //
+ //
+ // Try to get the Ole32Aut.dll module handle.
+ //
- hInst = LoadOLEAut32();
- if (hInst == NULL) {
- DWORD dwError = GetLastError();
- return AmHresultFromWin32(dwError);
- }
- lpfnLoadRegTypeLib = (LPLOADREGTYPELIB)GetProcAddress(hInst,
- szRegTypeLib);
- if (lpfnLoadRegTypeLib == NULL) {
- DWORD dwError = GetLastError();
- return AmHresultFromWin32(dwError);
- }
+ hInst = LoadOLEAut32();
+ if(hInst == NULL)
+ {
+ DWORD dwError = GetLastError();
+ return AmHresultFromWin32(dwError);
+ }
+ lpfnLoadRegTypeLib = (LPLOADREGTYPELIB)GetProcAddress(hInst,
+ szRegTypeLib);
+ if(lpfnLoadRegTypeLib == NULL)
+ {
+ DWORD dwError = GetLastError();
+ return AmHresultFromWin32(dwError);
+ }
- hr = (*lpfnLoadRegTypeLib)(LIBID_QuartzTypeLib, 1, 0, // version 1.0
- lcid, &ptlib);
+ hr = (*lpfnLoadRegTypeLib)(LIBID_QuartzTypeLib, 1, 0, // version 1.0
+ lcid, &ptlib);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
- // attempt to load directly - this will fill the
- // registry in if it finds it
+ // attempt to load directly - this will fill the
+ // registry in if it finds it
- lpfnLoadTypeLib = (LPLOADTYPELIB)GetProcAddress(hInst, szTypeLib);
- if (lpfnLoadTypeLib == NULL) {
- DWORD dwError = GetLastError();
- return AmHresultFromWin32(dwError);
- }
+ lpfnLoadTypeLib = (LPLOADTYPELIB)GetProcAddress(hInst, szTypeLib);
+ if(lpfnLoadTypeLib == NULL)
+ {
+ DWORD dwError = GetLastError();
+ return AmHresultFromWin32(dwError);
+ }
- hr = (*lpfnLoadTypeLib)(szControl, &ptlib);
- if (FAILED(hr)) {
- return hr;
- }
- }
+ hr = (*lpfnLoadTypeLib)(szControl, &ptlib);
+ if(FAILED(hr))
+ {
+ return hr;
+ }
+ }
- hr = ptlib->GetTypeInfoOfGuid(
- riid,
- &m_pti);
+ hr = ptlib->GetTypeInfoOfGuid(
+ riid,
+ &m_pti);
- ptlib->Release();
+ ptlib->Release();
- if (FAILED(hr)) {
- return hr;
- }
+ if(FAILED(hr))
+ {
+ return hr;
+ }
}
*pptinfo = m_pti;
@@ -143,11 +153,11 @@ CBaseDispatch::GetTypeInfo(
STDMETHODIMP
CBaseDispatch::GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid)
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid)
{
// although the IDispatch riid is dead, we use this to pass from
// the interface implementation class to us the iid we are talking about.
@@ -155,10 +165,11 @@ CBaseDispatch::GetIDsOfNames(
ITypeInfo * pti;
HRESULT hr = GetTypeInfo(riid, 0, lcid, &pti);
- if (SUCCEEDED(hr)) {
- hr = pti->GetIDsOfNames(rgszNames, cNames, rgdispid);
+ if(SUCCEEDED(hr))
+ {
+ hr = pti->GetIDsOfNames(rgszNames, cNames, rgdispid);
- pti->Release();
+ pti->Release();
}
return hr;
}
@@ -166,7 +177,7 @@ CBaseDispatch::GetIDsOfNames(
// --- CMediaControl implementation ---------
-CMediaControl::CMediaControl(const TCHAR * name,LPUNKNOWN pUnk) :
+CMediaControl::CMediaControl(const TCHAR * name, LPUNKNOWN pUnk) :
CUnknown(name, pUnk)
{
}
@@ -176,11 +187,14 @@ CMediaControl::CMediaControl(const TCHAR * name,LPUNKNOWN pUnk) :
STDMETHODIMP
CMediaControl::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
- ValidateReadWritePtr(ppv,sizeof(PVOID));
- if (riid == IID_IMediaControl) {
- return GetInterface( (IMediaControl *) this, ppv);
- } else {
- return CUnknown::NonDelegatingQueryInterface(riid, ppv);
+ ValidateReadWritePtr(ppv, sizeof(PVOID));
+ if(riid == IID_IMediaControl)
+ {
+ return GetInterface((IMediaControl *) this, ppv);
+ }
+ else
+ {
+ return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -198,66 +212,68 @@ CMediaControl::GetTypeInfoCount(__out UINT * pctinfo)
STDMETHODIMP
CMediaControl::GetTypeInfo(
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo)
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo)
{
return m_basedisp.GetTypeInfo(
- IID_IMediaControl,
- itinfo,
- lcid,
- pptinfo);
+ IID_IMediaControl,
+ itinfo,
+ lcid,
+ pptinfo);
}
STDMETHODIMP
CMediaControl::GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid)
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid)
{
return m_basedisp.GetIDsOfNames(
- IID_IMediaControl,
- rgszNames,
- cNames,
- lcid,
- rgdispid);
+ IID_IMediaControl,
+ rgszNames,
+ cNames,
+ lcid,
+ rgdispid);
}
STDMETHODIMP
CMediaControl::Invoke(
- DISPID dispidMember,
- REFIID riid,
- LCID lcid,
- WORD wFlags,
- __in DISPPARAMS * pdispparams,
- __out_opt VARIANT * pvarResult,
- __out_opt EXCEPINFO * pexcepinfo,
- __out_opt UINT * puArgErr)
+ DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ __in DISPPARAMS * pdispparams,
+ __out_opt VARIANT * pvarResult,
+ __out_opt EXCEPINFO * pexcepinfo,
+ __out_opt UINT * puArgErr)
{
// this parameter is a dead leftover from an earlier interface
- if (IID_NULL != riid) {
- return DISP_E_UNKNOWNINTERFACE;
+ if(IID_NULL != riid)
+ {
+ return DISP_E_UNKNOWNINTERFACE;
}
ITypeInfo * pti;
HRESULT hr = GetTypeInfo(0, lcid, &pti);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pti->Invoke(
- (IMediaControl *)this,
- dispidMember,
- wFlags,
- pdispparams,
- pvarResult,
- pexcepinfo,
- puArgErr);
+ (IMediaControl *)this,
+ dispidMember,
+ wFlags,
+ pdispparams,
+ pvarResult,
+ pexcepinfo,
+ puArgErr);
pti->Release();
return hr;
@@ -267,7 +283,7 @@ CMediaControl::Invoke(
// --- CMediaEvent implementation ----------
-CMediaEvent::CMediaEvent(__in_opt LPCTSTR name,__in_opt LPUNKNOWN pUnk) :
+CMediaEvent::CMediaEvent(__in_opt LPCTSTR name, __in_opt LPUNKNOWN pUnk) :
CUnknown(name, pUnk)
{
}
@@ -278,11 +294,14 @@ CMediaEvent::CMediaEvent(__in_opt LPCTSTR name,__in_opt LPUNKNOWN pUnk) :
STDMETHODIMP
CMediaEvent::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
- ValidateReadWritePtr(ppv,sizeof(PVOID));
- if (riid == IID_IMediaEvent || riid == IID_IMediaEventEx) {
- return GetInterface( (IMediaEventEx *) this, ppv);
- } else {
- return CUnknown::NonDelegatingQueryInterface(riid, ppv);
+ ValidateReadWritePtr(ppv, sizeof(PVOID));
+ if(riid == IID_IMediaEvent || riid == IID_IMediaEventEx)
+ {
+ return GetInterface((IMediaEventEx *) this, ppv);
+ }
+ else
+ {
+ return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -300,66 +319,68 @@ CMediaEvent::GetTypeInfoCount(__out UINT * pctinfo)
STDMETHODIMP
CMediaEvent::GetTypeInfo(
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo)
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo)
{
return m_basedisp.GetTypeInfo(
- IID_IMediaEvent,
- itinfo,
- lcid,
- pptinfo);
+ IID_IMediaEvent,
+ itinfo,
+ lcid,
+ pptinfo);
}
STDMETHODIMP
CMediaEvent::GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid)
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid)
{
return m_basedisp.GetIDsOfNames(
- IID_IMediaEvent,
- rgszNames,
- cNames,
- lcid,
- rgdispid);
+ IID_IMediaEvent,
+ rgszNames,
+ cNames,
+ lcid,
+ rgdispid);
}
STDMETHODIMP
CMediaEvent::Invoke(
- DISPID dispidMember,
- REFIID riid,
- LCID lcid,
- WORD wFlags,
- __in DISPPARAMS * pdispparams,
- __out_opt VARIANT * pvarResult,
- __out_opt EXCEPINFO * pexcepinfo,
- __out_opt UINT * puArgErr)
+ DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ __in DISPPARAMS * pdispparams,
+ __out_opt VARIANT * pvarResult,
+ __out_opt EXCEPINFO * pexcepinfo,
+ __out_opt UINT * puArgErr)
{
// this parameter is a dead leftover from an earlier interface
- if (IID_NULL != riid) {
- return DISP_E_UNKNOWNINTERFACE;
+ if(IID_NULL != riid)
+ {
+ return DISP_E_UNKNOWNINTERFACE;
}
ITypeInfo * pti;
HRESULT hr = GetTypeInfo(0, lcid, &pti);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pti->Invoke(
- (IMediaEvent *)this,
- dispidMember,
- wFlags,
- pdispparams,
- pvarResult,
- pexcepinfo,
- puArgErr);
+ (IMediaEvent *)this,
+ dispidMember,
+ wFlags,
+ pdispparams,
+ pvarResult,
+ pexcepinfo,
+ puArgErr);
pti->Release();
return hr;
@@ -369,7 +390,7 @@ CMediaEvent::Invoke(
// --- CMediaPosition implementation ----------
-CMediaPosition::CMediaPosition(__in_opt LPCTSTR name,__in_opt LPUNKNOWN pUnk) :
+CMediaPosition::CMediaPosition(__in_opt LPCTSTR name, __in_opt LPUNKNOWN pUnk) :
CUnknown(name, pUnk)
{
}
@@ -388,11 +409,14 @@ CMediaPosition::CMediaPosition(__in_opt LPCTSTR name,
STDMETHODIMP
CMediaPosition::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
- ValidateReadWritePtr(ppv,sizeof(PVOID));
- if (riid == IID_IMediaPosition) {
- return GetInterface( (IMediaPosition *) this, ppv);
- } else {
- return CUnknown::NonDelegatingQueryInterface(riid, ppv);
+ ValidateReadWritePtr(ppv, sizeof(PVOID));
+ if(riid == IID_IMediaPosition)
+ {
+ return GetInterface((IMediaPosition *) this, ppv);
+ }
+ else
+ {
+ return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -410,66 +434,68 @@ CMediaPosition::GetTypeInfoCount(__out UINT * pctinfo)
STDMETHODIMP
CMediaPosition::GetTypeInfo(
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo)
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo)
{
return m_basedisp.GetTypeInfo(
- IID_IMediaPosition,
- itinfo,
- lcid,
- pptinfo);
+ IID_IMediaPosition,
+ itinfo,
+ lcid,
+ pptinfo);
}
STDMETHODIMP
CMediaPosition::GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid)
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid)
{
return m_basedisp.GetIDsOfNames(
- IID_IMediaPosition,
- rgszNames,
- cNames,
- lcid,
- rgdispid);
+ IID_IMediaPosition,
+ rgszNames,
+ cNames,
+ lcid,
+ rgdispid);
}
STDMETHODIMP
CMediaPosition::Invoke(
- DISPID dispidMember,
- REFIID riid,
- LCID lcid,
- WORD wFlags,
- __in DISPPARAMS * pdispparams,
- __out_opt VARIANT * pvarResult,
- __out_opt EXCEPINFO * pexcepinfo,
- __out_opt UINT * puArgErr)
+ DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ __in DISPPARAMS * pdispparams,
+ __out_opt VARIANT * pvarResult,
+ __out_opt EXCEPINFO * pexcepinfo,
+ __out_opt UINT * puArgErr)
{
// this parameter is a dead leftover from an earlier interface
- if (IID_NULL != riid) {
- return DISP_E_UNKNOWNINTERFACE;
+ if(IID_NULL != riid)
+ {
+ return DISP_E_UNKNOWNINTERFACE;
}
ITypeInfo * pti;
HRESULT hr = GetTypeInfo(0, lcid, &pti);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pti->Invoke(
- (IMediaPosition *)this,
- dispidMember,
- wFlags,
- pdispparams,
- pvarResult,
- pexcepinfo,
- puArgErr);
+ (IMediaPosition *)this,
+ dispidMember,
+ wFlags,
+ pdispparams,
+ pvarResult,
+ pexcepinfo,
+ puArgErr);
pti->Release();
return hr;
@@ -480,15 +506,16 @@ CMediaPosition::Invoke(
CPosPassThru::CPosPassThru(__in_opt LPCTSTR pName,
- __in_opt LPUNKNOWN pUnk,
- __inout HRESULT *phr,
- IPin *pPin) :
- CMediaPosition(pName,pUnk),
+ __in_opt LPUNKNOWN pUnk,
+ __inout HRESULT *phr,
+ IPin *pPin) :
+ CMediaPosition(pName, pUnk),
m_pPin(pPin)
{
- if (pPin == NULL) {
- *phr = E_POINTER;
- return;
+ if(pPin == NULL)
+ {
+ *phr = E_POINTER;
+ return;
}
}
@@ -496,15 +523,16 @@ CPosPassThru::CPosPassThru(__in_opt LPCTSTR pName,
// Expose our IMediaSeeking and IMediaPosition interfaces
STDMETHODIMP
-CPosPassThru::NonDelegatingQueryInterface(REFIID riid,__deref_out void **ppv)
+CPosPassThru::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
- CheckPointer(ppv,E_POINTER);
+ CheckPointer(ppv, E_POINTER);
*ppv = NULL;
- if (riid == IID_IMediaSeeking) {
- return GetInterface( static_cast<IMediaSeeking *>(this), ppv);
+ if(riid == IID_IMediaSeeking)
+ {
+ return GetInterface(static_cast<IMediaSeeking *>(this), ppv);
}
- return CMediaPosition::NonDelegatingQueryInterface(riid,ppv);
+ return CMediaPosition::NonDelegatingQueryInterface(riid, ppv);
}
@@ -517,14 +545,16 @@ CPosPassThru::GetPeer(IMediaPosition ** ppMP)
IPin *pConnected;
HRESULT hr = m_pPin->ConnectedTo(&pConnected);
- if (FAILED(hr)) {
- return E_NOTIMPL;
+ if(FAILED(hr))
+ {
+ return E_NOTIMPL;
}
IMediaPosition * pMP;
hr = pConnected->QueryInterface(IID_IMediaPosition, (void **) &pMP);
pConnected->Release();
- if (FAILED(hr)) {
- return E_NOTIMPL;
+ if(FAILED(hr))
+ {
+ return E_NOTIMPL;
}
*ppMP = pMP;
@@ -541,14 +571,16 @@ CPosPassThru::GetPeerSeeking(__deref_out IMediaSeeking ** ppMS)
IPin *pConnected;
HRESULT hr = m_pPin->ConnectedTo(&pConnected);
- if (FAILED(hr)) {
- return E_NOTIMPL;
+ if(FAILED(hr))
+ {
+ return E_NOTIMPL;
}
IMediaSeeking * pMS;
hr = pConnected->QueryInterface(IID_IMediaSeeking, (void **) &pMS);
pConnected->Release();
- if (FAILED(hr)) {
- return E_NOTIMPL;
+ if(FAILED(hr))
+ {
+ return E_NOTIMPL;
}
*ppMS = pMS;
@@ -564,8 +596,9 @@ CPosPassThru::GetCapabilities(__out DWORD * pCaps)
{
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMS->GetCapabilities(pCaps);
@@ -578,8 +611,9 @@ CPosPassThru::CheckCapabilities(__inout DWORD * pCaps)
{
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMS->CheckCapabilities(pCaps);
@@ -592,8 +626,9 @@ CPosPassThru::IsFormatSupported(const GUID * pFormat)
{
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMS->IsFormatSupported(pFormat);
@@ -607,8 +642,9 @@ CPosPassThru::QueryPreferredFormat(__out GUID *pFormat)
{
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMS->QueryPreferredFormat(pFormat);
@@ -622,8 +658,9 @@ CPosPassThru::SetTimeFormat(const GUID * pFormat)
{
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMS->SetTimeFormat(pFormat);
@@ -637,8 +674,9 @@ CPosPassThru::GetTimeFormat(__out GUID *pFormat)
{
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMS->GetTimeFormat(pFormat);
@@ -652,8 +690,9 @@ CPosPassThru::IsUsingTimeFormat(const GUID * pFormat)
{
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMS->IsUsingTimeFormat(pFormat);
@@ -663,36 +702,38 @@ CPosPassThru::IsUsingTimeFormat(const GUID * pFormat)
STDMETHODIMP
-CPosPassThru::ConvertTimeFormat(__out LONGLONG * pTarget,
+CPosPassThru::ConvertTimeFormat(__out LONGLONG * pTarget,
__in_opt const GUID * pTargetFormat,
- LONGLONG Source,
- __in_opt const GUID * pSourceFormat )
+ LONGLONG Source,
+ __in_opt const GUID * pSourceFormat)
{
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
- hr = pMS->ConvertTimeFormat(pTarget, pTargetFormat, Source, pSourceFormat );
+ hr = pMS->ConvertTimeFormat(pTarget, pTargetFormat, Source, pSourceFormat);
pMS->Release();
return hr;
}
STDMETHODIMP
-CPosPassThru::SetPositions( __inout_opt LONGLONG * pCurrent,
- DWORD CurrentFlags,
- __inout_opt LONGLONG * pStop,
- DWORD StopFlags )
+CPosPassThru::SetPositions(__inout_opt LONGLONG * pCurrent,
+ DWORD CurrentFlags,
+ __inout_opt LONGLONG * pStop,
+ DWORD StopFlags)
{
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
- hr = pMS->SetPositions(pCurrent, CurrentFlags, pStop, StopFlags );
+ hr = pMS->SetPositions(pCurrent, CurrentFlags, pStop, StopFlags);
pMS->Release();
return hr;
}
@@ -702,27 +743,28 @@ CPosPassThru::GetPositions(__out_opt LONGLONG *pCurrent, __out_opt LONGLONG * pS
{
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
- hr = pMS->GetPositions(pCurrent,pStop);
+ hr = pMS->GetPositions(pCurrent, pStop);
pMS->Release();
return hr;
}
HRESULT
CPosPassThru::GetSeekingLongLong
-( HRESULT (__stdcall IMediaSeeking::*pMethod)( __out LONGLONG * )
-, LONGLONG * pll
+(HRESULT(__stdcall IMediaSeeking::*pMethod)(__out LONGLONG *)
+ , LONGLONG * pll
)
{
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (SUCCEEDED(hr))
+ if(SUCCEEDED(hr))
{
- hr = (pMS->*pMethod)(pll);
- pMS->Release();
+ hr = (pMS->*pMethod)(pll);
+ pMS->Release();
}
return hr;
}
@@ -733,9 +775,9 @@ STDMETHODIMP
CPosPassThru::GetCurrentPosition(__out LONGLONG *pCurrent)
{
// Can we report the current position
- HRESULT hr = GetMediaTime(pCurrent,NULL);
- if (SUCCEEDED(hr)) hr = NOERROR;
- else hr = GetSeekingLongLong( &IMediaSeeking::GetCurrentPosition, pCurrent );
+ HRESULT hr = GetMediaTime(pCurrent, NULL);
+ if(SUCCEEDED(hr)) hr = NOERROR;
+ else hr = GetSeekingLongLong(&IMediaSeeking::GetCurrentPosition, pCurrent);
return hr;
}
@@ -743,33 +785,34 @@ CPosPassThru::GetCurrentPosition(__out LONGLONG *pCurrent)
STDMETHODIMP
CPosPassThru::GetStopPosition(__out LONGLONG *pStop)
{
- return GetSeekingLongLong( &IMediaSeeking::GetStopPosition, pStop );;
+ return GetSeekingLongLong(&IMediaSeeking::GetStopPosition, pStop);;
}
STDMETHODIMP
CPosPassThru::GetDuration(__out LONGLONG *pDuration)
{
- return GetSeekingLongLong( &IMediaSeeking::GetDuration, pDuration );;
+ return GetSeekingLongLong(&IMediaSeeking::GetDuration, pDuration);;
}
STDMETHODIMP
CPosPassThru::GetPreroll(__out LONGLONG *pllPreroll)
{
- return GetSeekingLongLong( &IMediaSeeking::GetPreroll, pllPreroll );;
+ return GetSeekingLongLong(&IMediaSeeking::GetPreroll, pllPreroll);;
}
STDMETHODIMP
-CPosPassThru::GetAvailable( __out_opt LONGLONG *pEarliest, __out_opt LONGLONG *pLatest )
+CPosPassThru::GetAvailable(__out_opt LONGLONG *pEarliest, __out_opt LONGLONG *pLatest)
{
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
- hr = pMS->GetAvailable( pEarliest, pLatest );
+ hr = pMS->GetAvailable(pEarliest, pLatest);
pMS->Release();
return hr;
}
@@ -780,8 +823,9 @@ CPosPassThru::GetRate(__out double * pdRate)
{
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMS->GetRate(pdRate);
pMS->Release();
@@ -792,14 +836,16 @@ CPosPassThru::GetRate(__out double * pdRate)
STDMETHODIMP
CPosPassThru::SetRate(double dRate)
{
- if (0.0 == dRate) {
- return E_INVALIDARG;
+ if(0.0 == dRate)
+ {
+ return E_INVALIDARG;
}
IMediaSeeking* pMS;
HRESULT hr = GetPeerSeeking(&pMS);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMS->SetRate(dRate);
pMS->Release();
@@ -817,8 +863,9 @@ CPosPassThru::get_Duration(__out REFTIME * plength)
{
IMediaPosition* pMP;
HRESULT hr = GetPeer(&pMP);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMP->get_Duration(plength);
@@ -832,8 +879,9 @@ CPosPassThru::get_CurrentPosition(__out REFTIME * pllTime)
{
IMediaPosition* pMP;
HRESULT hr = GetPeer(&pMP);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMP->get_CurrentPosition(pllTime);
pMP->Release();
@@ -846,8 +894,9 @@ CPosPassThru::put_CurrentPosition(REFTIME llTime)
{
IMediaPosition* pMP;
HRESULT hr = GetPeer(&pMP);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMP->put_CurrentPosition(llTime);
pMP->Release();
@@ -860,8 +909,9 @@ CPosPassThru::get_StopTime(__out REFTIME * pllTime)
{
IMediaPosition* pMP;
HRESULT hr = GetPeer(&pMP);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMP->get_StopTime(pllTime);
pMP->Release();
@@ -874,8 +924,9 @@ CPosPassThru::put_StopTime(REFTIME llTime)
{
IMediaPosition* pMP;
HRESULT hr = GetPeer(&pMP);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMP->put_StopTime(llTime);
pMP->Release();
@@ -888,8 +939,9 @@ CPosPassThru::get_PrerollTime(__out REFTIME * pllTime)
{
IMediaPosition* pMP;
HRESULT hr = GetPeer(&pMP);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMP->get_PrerollTime(pllTime);
pMP->Release();
@@ -902,8 +954,9 @@ CPosPassThru::put_PrerollTime(REFTIME llTime)
{
IMediaPosition* pMP;
HRESULT hr = GetPeer(&pMP);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMP->put_PrerollTime(llTime);
pMP->Release();
@@ -916,8 +969,9 @@ CPosPassThru::get_Rate(__out double * pdRate)
{
IMediaPosition* pMP;
HRESULT hr = GetPeer(&pMP);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMP->get_Rate(pdRate);
pMP->Release();
@@ -928,14 +982,16 @@ CPosPassThru::get_Rate(__out double * pdRate)
STDMETHODIMP
CPosPassThru::put_Rate(double dRate)
{
- if (0.0 == dRate) {
- return E_INVALIDARG;
+ if(0.0 == dRate)
+ {
+ return E_INVALIDARG;
}
IMediaPosition* pMP;
HRESULT hr = GetPeer(&pMP);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMP->put_Rate(dRate);
pMP->Release();
@@ -948,8 +1004,9 @@ CPosPassThru::CanSeekForward(__out LONG *pCanSeekForward)
{
IMediaPosition* pMP;
HRESULT hr = GetPeer(&pMP);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMP->CanSeekForward(pCanSeekForward);
pMP->Release();
@@ -962,8 +1019,9 @@ CPosPassThru::CanSeekBackward(__out LONG *pCanSeekBackward)
{
IMediaPosition* pMP;
HRESULT hr = GetPeer(&pMP);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pMP->CanSeekBackward(pCanSeekBackward);
pMP->Release();
@@ -981,10 +1039,10 @@ CPosPassThru::CanSeekBackward(__out LONG *pCanSeekBackward)
// store the media times internally and return them in GetCurrentPosition.
CRendererPosPassThru::CRendererPosPassThru(__in_opt LPCTSTR pName,
- __in_opt LPUNKNOWN pUnk,
- __inout HRESULT *phr,
- IPin *pPin) :
- CPosPassThru(pName,pUnk,phr,pPin),
+ __in_opt LPUNKNOWN pUnk,
+ __inout HRESULT *phr,
+ IPin *pPin) :
+ CPosPassThru(pName, pUnk, phr, pPin),
m_StartMedia(0),
m_EndMedia(0),
m_bReset(TRUE)
@@ -1005,11 +1063,11 @@ CRendererPosPassThru::RegisterMediaTime(IMediaSample *pMediaSample)
// Get the media times from the sample
- HRESULT hr = pMediaSample->GetTime(&StartMedia,&EndMedia);
- if (FAILED(hr))
+ HRESULT hr = pMediaSample->GetTime(&StartMedia, &EndMedia);
+ if(FAILED(hr))
{
- ASSERT(hr == VFW_E_SAMPLE_TIME_NOT_SET);
- return hr;
+ ASSERT(hr == VFW_E_SAMPLE_TIME_NOT_SET);
+ return hr;
}
m_StartMedia = StartMedia;
@@ -1022,7 +1080,7 @@ CRendererPosPassThru::RegisterMediaTime(IMediaSample *pMediaSample)
// Sets the media times the object should report
HRESULT
-CRendererPosPassThru::RegisterMediaTime(LONGLONG StartTime,LONGLONG EndTime)
+CRendererPosPassThru::RegisterMediaTime(LONGLONG StartTime, LONGLONG EndTime)
{
CAutoLock cAutoLock(&m_PositionLock);
m_StartMedia = StartTime;
@@ -1040,15 +1098,17 @@ CRendererPosPassThru::GetMediaTime(__out LONGLONG *pStartTime, __out_opt LONGLON
ASSERT(pStartTime);
CAutoLock cAutoLock(&m_PositionLock);
- if (m_bReset == TRUE) {
- return E_FAIL;
+ if(m_bReset == TRUE)
+ {
+ return E_FAIL;
}
// We don't have to return the end time
- HRESULT hr = ConvertTimeFormat( pStartTime, 0, m_StartMedia, &TIME_FORMAT_MEDIA_TIME );
- if (pEndTime && SUCCEEDED(hr)) {
- hr = ConvertTimeFormat( pEndTime, 0, m_EndMedia, &TIME_FORMAT_MEDIA_TIME );
+ HRESULT hr = ConvertTimeFormat(pStartTime, 0, m_StartMedia, &TIME_FORMAT_MEDIA_TIME);
+ if(pEndTime && SUCCEEDED(hr))
+ {
+ hr = ConvertTimeFormat(pEndTime, 0, m_EndMedia, &TIME_FORMAT_MEDIA_TIME);
}
return hr;
}
@@ -1074,16 +1134,16 @@ CRendererPosPassThru::EOS()
{
HRESULT hr;
- if ( m_bReset == TRUE ) hr = E_FAIL;
+ if(m_bReset == TRUE) hr = E_FAIL;
else
{
- LONGLONG llStop;
- if SUCCEEDED(hr=GetStopPosition(&llStop))
- {
- CAutoLock cAutoLock(&m_PositionLock);
- m_StartMedia =
- m_EndMedia = llStop;
- }
+ LONGLONG llStop;
+ if SUCCEEDED(hr = GetStopPosition(&llStop))
+ {
+ CAutoLock cAutoLock(&m_PositionLock);
+ m_StartMedia =
+ m_EndMedia = llStop;
+ }
}
return hr;
}
@@ -1095,28 +1155,30 @@ CSourceSeeking::CSourceSeeking(
__in_opt LPUNKNOWN pUnk,
__inout HRESULT* phr,
__in CCritSec * pLock) :
- CUnknown(pName, pUnk),
- m_pLock(pLock),
- m_rtStart((long)0)
+ CUnknown(pName, pUnk),
+ m_pLock(pLock),
+ m_rtStart((long)0)
{
m_rtStop = _I64_MAX / 2;
m_rtDuration = m_rtStop;
m_dRateSeeking = 1.0;
m_dwSeekingCaps = AM_SEEKING_CanSeekForwards
- | AM_SEEKING_CanSeekBackwards
- | AM_SEEKING_CanSeekAbsolute
- | AM_SEEKING_CanGetStopPos
- | AM_SEEKING_CanGetDuration;
+ | AM_SEEKING_CanSeekBackwards
+ | AM_SEEKING_CanSeekAbsolute
+ | AM_SEEKING_CanGetStopPos
+ | AM_SEEKING_CanGetDuration;
}
HRESULT CSourceSeeking::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
- if(riid == IID_IMediaSeeking) {
+ if(riid == IID_IMediaSeeking)
+ {
CheckPointer(ppv, E_POINTER);
return GetInterface(static_cast<IMediaSeeking *>(this), ppv);
}
- else {
+ else
+ {
return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -1180,14 +1242,14 @@ HRESULT CSourceSeeking::GetCurrentPosition(__out LONGLONG *pCurrent)
return E_NOTIMPL;
}
-HRESULT CSourceSeeking::GetCapabilities( __out DWORD * pCapabilities )
+HRESULT CSourceSeeking::GetCapabilities(__out DWORD * pCapabilities)
{
CheckPointer(pCapabilities, E_POINTER);
*pCapabilities = m_dwSeekingCaps;
return S_OK;
}
-HRESULT CSourceSeeking::CheckCapabilities( __inout DWORD * pCapabilities )
+HRESULT CSourceSeeking::CheckCapabilities(__inout DWORD * pCapabilities)
{
CheckPointer(pCapabilities, E_POINTER);
@@ -1195,10 +1257,10 @@ HRESULT CSourceSeeking::CheckCapabilities( __inout DWORD * pCapabilities )
return (~m_dwSeekingCaps & *pCapabilities) ? S_FALSE : S_OK;
}
-HRESULT CSourceSeeking::ConvertTimeFormat( __out LONGLONG * pTarget,
- __in_opt const GUID * pTargetFormat,
- LONGLONG Source,
- __in_opt const GUID * pSourceFormat )
+HRESULT CSourceSeeking::ConvertTimeFormat(__out LONGLONG * pTarget,
+ __in_opt const GUID * pTargetFormat,
+ LONGLONG Source,
+ __in_opt const GUID * pSourceFormat)
{
CheckPointer(pTarget, E_POINTER);
// format guids can be null to indicate current format
@@ -1218,27 +1280,31 @@ HRESULT CSourceSeeking::ConvertTimeFormat( __out LONGLONG * pTarget,
}
-HRESULT CSourceSeeking::SetPositions( __inout_opt LONGLONG * pCurrent,
- DWORD CurrentFlags,
- __inout_opt LONGLONG * pStop,
- DWORD StopFlags )
+HRESULT CSourceSeeking::SetPositions(__inout_opt LONGLONG * pCurrent,
+ DWORD CurrentFlags,
+ __inout_opt LONGLONG * pStop,
+ DWORD StopFlags)
{
DWORD StopPosBits = StopFlags & AM_SEEKING_PositioningBitsMask;
DWORD StartPosBits = CurrentFlags & AM_SEEKING_PositioningBitsMask;
- if(StopFlags) {
+ if(StopFlags)
+ {
CheckPointer(pStop, E_POINTER);
// accept only relative, incremental, or absolute positioning
- if(StopPosBits != StopFlags) {
+ if(StopPosBits != StopFlags)
+ {
return E_INVALIDARG;
}
}
- if(CurrentFlags) {
+ if(CurrentFlags)
+ {
CheckPointer(pCurrent, E_POINTER);
if(StartPosBits != AM_SEEKING_AbsolutePositioning &&
- StartPosBits != AM_SEEKING_RelativePositioning) {
+ StartPosBits != AM_SEEKING_RelativePositioning)
+ {
return E_INVALIDARG;
}
}
@@ -1275,10 +1341,12 @@ HRESULT CSourceSeeking::SetPositions( __inout_opt LONGLONG * pCurrent,
HRESULT hr = S_OK;
- if(SUCCEEDED(hr) && StopPosBits) {
+ if(SUCCEEDED(hr) && StopPosBits)
+ {
hr = ChangeStop();
}
- if(StartPosBits) {
+ if(StartPosBits)
+ {
hr = ChangeStart();
}
@@ -1286,12 +1354,14 @@ HRESULT CSourceSeeking::SetPositions( __inout_opt LONGLONG * pCurrent,
}
-HRESULT CSourceSeeking::GetPositions( __out_opt LONGLONG * pCurrent, __out_opt LONGLONG * pStop )
+HRESULT CSourceSeeking::GetPositions(__out_opt LONGLONG * pCurrent, __out_opt LONGLONG * pStop)
{
- if(pCurrent) {
+ if(pCurrent)
+ {
*pCurrent = m_rtStart;
}
- if(pStop) {
+ if(pStop)
+ {
*pStop = m_rtStop;
}
@@ -1299,19 +1369,21 @@ HRESULT CSourceSeeking::GetPositions( __out_opt LONGLONG * pCurrent, __out_opt L
}
-HRESULT CSourceSeeking::GetAvailable( __out_opt LONGLONG * pEarliest, __out_opt LONGLONG * pLatest )
+HRESULT CSourceSeeking::GetAvailable(__out_opt LONGLONG * pEarliest, __out_opt LONGLONG * pLatest)
{
- if(pEarliest) {
+ if(pEarliest)
+ {
*pEarliest = 0;
}
- if(pLatest) {
+ if(pLatest)
+ {
CAutoLock lock(m_pLock);
*pLatest = m_rtDuration;
}
return S_OK;
}
-HRESULT CSourceSeeking::SetRate( double dRate)
+HRESULT CSourceSeeking::SetRate(double dRate)
{
{
CAutoLock lock(m_pLock);
@@ -1320,7 +1392,7 @@ HRESULT CSourceSeeking::SetRate( double dRate)
return ChangeRate();
}
-HRESULT CSourceSeeking::GetRate( __out double * pdRate)
+HRESULT CSourceSeeking::GetRate(__out double * pdRate)
{
CheckPointer(pdRate, E_POINTER);
CAutoLock lock(m_pLock);
@@ -1343,9 +1415,9 @@ HRESULT CSourceSeeking::GetPreroll(__out LONGLONG *pPreroll)
CSourcePosition::CSourcePosition(__in_opt LPCTSTR pName,
- __in_opt LPUNKNOWN pUnk,
- __inout HRESULT* phr,
- __in CCritSec * pLock) :
+ __in_opt LPUNKNOWN pUnk,
+ __inout HRESULT* phr,
+ __in CCritSec * pLock) :
CMediaPosition(pName, pUnk),
m_pLock(pLock),
m_Start(CRefTime((LONGLONG)0))
@@ -1358,8 +1430,8 @@ CSourcePosition::CSourcePosition(__in_opt LPCTSTR pName,
STDMETHODIMP
CSourcePosition::get_Duration(__out REFTIME * plength)
{
- CheckPointer(plength,E_POINTER);
- ValidateReadWritePtr(plength,sizeof(REFTIME));
+ CheckPointer(plength, E_POINTER);
+ ValidateReadWritePtr(plength, sizeof(REFTIME));
CAutoLock lock(m_pLock);
*plength = m_Duration;
@@ -1381,8 +1453,8 @@ CSourcePosition::put_CurrentPosition(REFTIME llTime)
STDMETHODIMP
CSourcePosition::get_StopTime(__out REFTIME * pllTime)
{
- CheckPointer(pllTime,E_POINTER);
- ValidateReadWritePtr(pllTime,sizeof(REFTIME));
+ CheckPointer(pllTime, E_POINTER);
+ ValidateReadWritePtr(pllTime, sizeof(REFTIME));
CAutoLock lock(m_pLock);
*pllTime = m_Stop;
@@ -1404,8 +1476,8 @@ CSourcePosition::put_StopTime(REFTIME llTime)
STDMETHODIMP
CSourcePosition::get_PrerollTime(__out REFTIME * pllTime)
{
- CheckPointer(pllTime,E_POINTER);
- ValidateReadWritePtr(pllTime,sizeof(REFTIME));
+ CheckPointer(pllTime, E_POINTER);
+ ValidateReadWritePtr(pllTime, sizeof(REFTIME));
return E_NOTIMPL;
}
@@ -1420,8 +1492,8 @@ CSourcePosition::put_PrerollTime(REFTIME llTime)
STDMETHODIMP
CSourcePosition::get_Rate(__out double * pdRate)
{
- CheckPointer(pdRate,E_POINTER);
- ValidateReadWritePtr(pdRate,sizeof(double));
+ CheckPointer(pdRate, E_POINTER);
+ ValidateReadWritePtr(pdRate, sizeof(double));
CAutoLock lock(m_pLock);
*pdRate = m_Rate;
@@ -1445,7 +1517,7 @@ CSourcePosition::put_Rate(double dRate)
STDMETHODIMP
CSourcePosition::CanSeekForward(__out LONG *pCanSeekForward)
{
- CheckPointer(pCanSeekForward,E_POINTER);
+ CheckPointer(pCanSeekForward, E_POINTER);
*pCanSeekForward = OATRUE;
return S_OK;
}
@@ -1456,7 +1528,7 @@ CSourcePosition::CanSeekForward(__out LONG *pCanSeekForward)
STDMETHODIMP
CSourcePosition::CanSeekBackward(__out LONG *pCanSeekBackward)
{
- CheckPointer(pCanSeekBackward,E_POINTER);
+ CheckPointer(pCanSeekBackward, E_POINTER);
*pCanSeekBackward = OATRUE;
return S_OK;
}
@@ -1465,7 +1537,7 @@ CSourcePosition::CanSeekBackward(__out LONG *pCanSeekBackward)
// --- Implementation of CBasicAudio class ----------
-CBasicAudio::CBasicAudio(__in_opt LPCTSTR pName,__in_opt LPUNKNOWN punk) :
+CBasicAudio::CBasicAudio(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN punk) :
CUnknown(pName, punk)
{
}
@@ -1475,11 +1547,14 @@ CBasicAudio::CBasicAudio(__in_opt LPCTSTR pName,__in_opt LPUNKNOWN punk) :
STDMETHODIMP
CBasicAudio::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
- ValidateReadWritePtr(ppv,sizeof(PVOID));
- if (riid == IID_IBasicAudio) {
- return GetInterface( (IBasicAudio *) this, ppv);
- } else {
- return CUnknown::NonDelegatingQueryInterface(riid, ppv);
+ ValidateReadWritePtr(ppv, sizeof(PVOID));
+ if(riid == IID_IBasicAudio)
+ {
+ return GetInterface((IBasicAudio *) this, ppv);
+ }
+ else
+ {
+ return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -1493,66 +1568,68 @@ CBasicAudio::GetTypeInfoCount(__out UINT * pctinfo)
STDMETHODIMP
CBasicAudio::GetTypeInfo(
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo)
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo)
{
return m_basedisp.GetTypeInfo(
- IID_IBasicAudio,
- itinfo,
- lcid,
- pptinfo);
+ IID_IBasicAudio,
+ itinfo,
+ lcid,
+ pptinfo);
}
STDMETHODIMP
CBasicAudio::GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid)
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid)
{
return m_basedisp.GetIDsOfNames(
- IID_IBasicAudio,
- rgszNames,
- cNames,
- lcid,
- rgdispid);
+ IID_IBasicAudio,
+ rgszNames,
+ cNames,
+ lcid,
+ rgdispid);
}
STDMETHODIMP
CBasicAudio::Invoke(
- DISPID dispidMember,
- REFIID riid,
- LCID lcid,
- WORD wFlags,
- __in DISPPARAMS * pdispparams,
- __out_opt VARIANT * pvarResult,
- __out_opt EXCEPINFO * pexcepinfo,
- __out_opt UINT * puArgErr)
+ DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ __in DISPPARAMS * pdispparams,
+ __out_opt VARIANT * pvarResult,
+ __out_opt EXCEPINFO * pexcepinfo,
+ __out_opt UINT * puArgErr)
{
// this parameter is a dead leftover from an earlier interface
- if (IID_NULL != riid) {
- return DISP_E_UNKNOWNINTERFACE;
+ if(IID_NULL != riid)
+ {
+ return DISP_E_UNKNOWNINTERFACE;
}
ITypeInfo * pti;
HRESULT hr = GetTypeInfo(0, lcid, &pti);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pti->Invoke(
- (IBasicAudio *)this,
- dispidMember,
- wFlags,
- pdispparams,
- pvarResult,
- pexcepinfo,
- puArgErr);
+ (IBasicAudio *)this,
+ dispidMember,
+ wFlags,
+ pdispparams,
+ pvarResult,
+ pexcepinfo,
+ puArgErr);
pti->Release();
return hr;
@@ -1561,7 +1638,7 @@ CBasicAudio::Invoke(
// --- IVideoWindow implementation ----------
-CBaseVideoWindow::CBaseVideoWindow(__in_opt LPCTSTR pName,__in_opt LPUNKNOWN punk) :
+CBaseVideoWindow::CBaseVideoWindow(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN punk) :
CUnknown(pName, punk)
{
}
@@ -1572,11 +1649,14 @@ CBaseVideoWindow::CBaseVideoWindow(__in_opt LPCTSTR pName,__in_opt LPUNKNOWN pun
STDMETHODIMP
CBaseVideoWindow::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
- ValidateReadWritePtr(ppv,sizeof(PVOID));
- if (riid == IID_IVideoWindow) {
- return GetInterface( (IVideoWindow *) this, ppv);
- } else {
- return CUnknown::NonDelegatingQueryInterface(riid, ppv);
+ ValidateReadWritePtr(ppv, sizeof(PVOID));
+ if(riid == IID_IVideoWindow)
+ {
+ return GetInterface((IVideoWindow *) this, ppv);
+ }
+ else
+ {
+ return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -1590,66 +1670,68 @@ CBaseVideoWindow::GetTypeInfoCount(__out UINT * pctinfo)
STDMETHODIMP
CBaseVideoWindow::GetTypeInfo(
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo)
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo)
{
return m_basedisp.GetTypeInfo(
- IID_IVideoWindow,
- itinfo,
- lcid,
- pptinfo);
+ IID_IVideoWindow,
+ itinfo,
+ lcid,
+ pptinfo);
}
STDMETHODIMP
CBaseVideoWindow::GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid)
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid)
{
return m_basedisp.GetIDsOfNames(
- IID_IVideoWindow,
- rgszNames,
- cNames,
- lcid,
- rgdispid);
+ IID_IVideoWindow,
+ rgszNames,
+ cNames,
+ lcid,
+ rgdispid);
}
STDMETHODIMP
CBaseVideoWindow::Invoke(
- DISPID dispidMember,
- REFIID riid,
- LCID lcid,
- WORD wFlags,
- __in DISPPARAMS * pdispparams,
- __out_opt VARIANT * pvarResult,
- __out_opt EXCEPINFO * pexcepinfo,
- __out_opt UINT * puArgErr)
+ DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ __in DISPPARAMS * pdispparams,
+ __out_opt VARIANT * pvarResult,
+ __out_opt EXCEPINFO * pexcepinfo,
+ __out_opt UINT * puArgErr)
{
// this parameter is a dead leftover from an earlier interface
- if (IID_NULL != riid) {
- return DISP_E_UNKNOWNINTERFACE;
+ if(IID_NULL != riid)
+ {
+ return DISP_E_UNKNOWNINTERFACE;
}
ITypeInfo * pti;
HRESULT hr = GetTypeInfo(0, lcid, &pti);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pti->Invoke(
- (IVideoWindow *)this,
- dispidMember,
- wFlags,
- pdispparams,
- pvarResult,
- pexcepinfo,
- puArgErr);
+ (IVideoWindow *)this,
+ dispidMember,
+ wFlags,
+ pdispparams,
+ pvarResult,
+ pexcepinfo,
+ puArgErr);
pti->Release();
return hr;
@@ -1659,7 +1741,7 @@ CBaseVideoWindow::Invoke(
// --- IBasicVideo implementation ----------
-CBaseBasicVideo::CBaseBasicVideo(__in_opt LPCTSTR pName,__in_opt LPUNKNOWN punk) :
+CBaseBasicVideo::CBaseBasicVideo(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN punk) :
CUnknown(pName, punk)
{
}
@@ -1670,11 +1752,14 @@ CBaseBasicVideo::CBaseBasicVideo(__in_opt LPCTSTR pName,__in_opt LPUNKNOWN punk)
STDMETHODIMP
CBaseBasicVideo::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
- ValidateReadWritePtr(ppv,sizeof(PVOID));
- if (riid == IID_IBasicVideo || riid == IID_IBasicVideo2) {
- return GetInterface( static_cast<IBasicVideo2 *>(this), ppv);
- } else {
- return CUnknown::NonDelegatingQueryInterface(riid, ppv);
+ ValidateReadWritePtr(ppv, sizeof(PVOID));
+ if(riid == IID_IBasicVideo || riid == IID_IBasicVideo2)
+ {
+ return GetInterface(static_cast<IBasicVideo2 *>(this), ppv);
+ }
+ else
+ {
+ return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -1688,66 +1773,68 @@ CBaseBasicVideo::GetTypeInfoCount(__out UINT * pctinfo)
STDMETHODIMP
CBaseBasicVideo::GetTypeInfo(
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo)
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo)
{
return m_basedisp.GetTypeInfo(
- IID_IBasicVideo,
- itinfo,
- lcid,
- pptinfo);
+ IID_IBasicVideo,
+ itinfo,
+ lcid,
+ pptinfo);
}
STDMETHODIMP
CBaseBasicVideo::GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid)
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid)
{
return m_basedisp.GetIDsOfNames(
- IID_IBasicVideo,
- rgszNames,
- cNames,
- lcid,
- rgdispid);
+ IID_IBasicVideo,
+ rgszNames,
+ cNames,
+ lcid,
+ rgdispid);
}
STDMETHODIMP
CBaseBasicVideo::Invoke(
- DISPID dispidMember,
- REFIID riid,
- LCID lcid,
- WORD wFlags,
- __in DISPPARAMS * pdispparams,
- __out_opt VARIANT * pvarResult,
- __out_opt EXCEPINFO * pexcepinfo,
- __out_opt UINT * puArgErr)
+ DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ __in DISPPARAMS * pdispparams,
+ __out_opt VARIANT * pvarResult,
+ __out_opt EXCEPINFO * pexcepinfo,
+ __out_opt UINT * puArgErr)
{
// this parameter is a dead leftover from an earlier interface
- if (IID_NULL != riid) {
- return DISP_E_UNKNOWNINTERFACE;
+ if(IID_NULL != riid)
+ {
+ return DISP_E_UNKNOWNINTERFACE;
}
ITypeInfo * pti;
HRESULT hr = GetTypeInfo(0, lcid, &pti);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
hr = pti->Invoke(
- (IBasicVideo *)this,
- dispidMember,
- wFlags,
- pdispparams,
- pvarResult,
- pexcepinfo,
- puArgErr);
+ (IBasicVideo *)this,
+ dispidMember,
+ wFlags,
+ pdispparams,
+ pvarResult,
+ pexcepinfo,
+ puArgErr);
pti->Release();
return hr;
@@ -1759,109 +1846,123 @@ CBaseBasicVideo::Invoke(
CDispParams::CDispParams(UINT nArgs, __in_ecount(nArgs) VARIANT* pArgs, __inout_opt HRESULT *phr)
{
- cNamedArgs = 0;
- rgdispidNamedArgs = NULL;
- cArgs = nArgs;
+ cNamedArgs = 0;
+ rgdispidNamedArgs = NULL;
+ cArgs = nArgs;
- if (cArgs) {
- rgvarg = new VARIANT[cArgs];
- if (NULL == rgvarg) {
+ if(cArgs)
+ {
+ rgvarg = new VARIANT[cArgs];
+ if(NULL == rgvarg)
+ {
cArgs = 0;
- if (phr) {
+ if(phr)
+ {
*phr = E_OUTOFMEMORY;
}
return;
}
- for (UINT i = 0; i < cArgs; i++) {
+ for(UINT i = 0; i < cArgs; i++)
+ {
// Why aren't we using VariantCopy?
- VARIANT * pDest = &rgvarg[i];
- VARIANT * pSrc = &pArgs[i];
-
- pDest->vt = pSrc->vt;
- switch(pDest->vt) {
-
- case VT_I4:
- pDest->lVal = pSrc->lVal;
- break;
+ VARIANT * pDest = &rgvarg[i];
+ VARIANT * pSrc = &pArgs[i];
- case VT_UI1:
- pDest->bVal = pSrc->bVal;
- break;
+ pDest->vt = pSrc->vt;
+ switch(pDest->vt)
+ {
- case VT_I2:
- pDest->iVal = pSrc->iVal;
- break;
+ case VT_I4:
+ pDest->lVal = pSrc->lVal;
+ break;
- case VT_R4:
- pDest->fltVal = pSrc->fltVal;
- break;
+ case VT_UI1:
+ pDest->bVal = pSrc->bVal;
+ break;
- case VT_R8:
- pDest->dblVal = pSrc->dblVal;
- break;
+ case VT_I2:
+ pDest->iVal = pSrc->iVal;
+ break;
- case VT_BOOL:
- pDest->boolVal = pSrc->boolVal;
- break;
+ case VT_R4:
+ pDest->fltVal = pSrc->fltVal;
+ break;
- case VT_ERROR:
- pDest->scode = pSrc->scode;
- break;
+ case VT_R8:
+ pDest->dblVal = pSrc->dblVal;
+ break;
- case VT_CY:
- pDest->cyVal = pSrc->cyVal;
- break;
+ case VT_BOOL:
+ pDest->boolVal = pSrc->boolVal;
+ break;
- case VT_DATE:
- pDest->date = pSrc->date;
- break;
+ case VT_ERROR:
+ pDest->scode = pSrc->scode;
+ break;
- case VT_BSTR:
- if ((PVOID)pSrc->bstrVal == NULL) {
- pDest->bstrVal = NULL;
- } else {
+ case VT_CY:
+ pDest->cyVal = pSrc->cyVal;
+ break;
- // a BSTR is a WORD followed by a UNICODE string.
- // the pointer points just after the WORD
+ case VT_DATE:
+ pDest->date = pSrc->date;
+ break;
- WORD len = * (WORD*) (pSrc->bstrVal - (sizeof(WORD) / sizeof(OLECHAR)));
- OLECHAR* pch = new OLECHAR[len + (sizeof(WORD)/sizeof(OLECHAR))];
- if (pch) {
- WORD *pui = (WORD*)pch;
- *pui = len;
- pDest->bstrVal = pch + (sizeof(WORD)/sizeof(OLECHAR));
- CopyMemory(pDest->bstrVal, pSrc->bstrVal, len*sizeof(OLECHAR));
- } else {
+ case VT_BSTR:
+ if((PVOID)pSrc->bstrVal == NULL)
+ {
+ pDest->bstrVal = NULL;
+ }
+ else
+ {
+
+ // a BSTR is a WORD followed by a UNICODE string.
+ // the pointer points just after the WORD
+
+ WORD len = * (WORD*)(pSrc->bstrVal - (sizeof(WORD) / sizeof(OLECHAR)));
+ OLECHAR* pch = new OLECHAR[len + (sizeof(WORD)/sizeof(OLECHAR))];
+ if(pch)
+ {
+ WORD *pui = (WORD*)pch;
+ *pui = len;
+ pDest->bstrVal = pch + (sizeof(WORD) / sizeof(OLECHAR));
+ CopyMemory(pDest->bstrVal, pSrc->bstrVal, len * sizeof(OLECHAR));
+ }
+ else
+ {
cArgs = i;
- if (phr) {
+ if(phr)
+ {
*phr = E_OUTOFMEMORY;
}
}
- }
- break;
-
- case VT_UNKNOWN:
- pDest->punkVal = pSrc->punkVal;
- pDest->punkVal->AddRef();
- break;
-
- case VT_DISPATCH:
- pDest->pdispVal = pSrc->pdispVal;
- pDest->pdispVal->AddRef();
- break;
-
- default:
- // a type we haven't got round to adding yet!
- ASSERT(0);
- break;
- }
- }
+ }
+ break;
+
+ case VT_UNKNOWN:
+ pDest->punkVal = pSrc->punkVal;
+ pDest->punkVal->AddRef();
+ break;
+
+ case VT_DISPATCH:
+ pDest->pdispVal = pSrc->pdispVal;
+ pDest->pdispVal->AddRef();
+ break;
+
+ default:
+ // a type we haven't got round to adding yet!
+ ASSERT(0);
+ break;
+ }
+ }
- } else {
- rgvarg = NULL;
+ }
+ else
+ {
+ rgvarg = NULL;
}
}
@@ -1869,24 +1970,27 @@ CDispParams::CDispParams(UINT nArgs, __in_ecount(nArgs) VARIANT* pArgs, __inout_
CDispParams::~CDispParams()
{
- for (UINT i = 0; i < cArgs; i++) {
- switch(rgvarg[i].vt) {
+ for(UINT i = 0; i < cArgs; i++)
+ {
+ switch(rgvarg[i].vt)
+ {
case VT_BSTR:
// Explicitly cast BSTR to PVOID to tell code scanning tools we really mean to test the pointer
- if ((PVOID)rgvarg[i].bstrVal != NULL) {
- OLECHAR * pch = rgvarg[i].bstrVal - (sizeof(WORD)/sizeof(OLECHAR));
- delete pch;
- }
- break;
+ if((PVOID)rgvarg[i].bstrVal != NULL)
+ {
+ OLECHAR * pch = rgvarg[i].bstrVal - (sizeof(WORD) / sizeof(OLECHAR));
+ delete pch;
+ }
+ break;
- case VT_UNKNOWN:
- rgvarg[i].punkVal->Release();
- break;
+ case VT_UNKNOWN:
+ rgvarg[i].punkVal->Release();
+ break;
- case VT_DISPATCH:
- rgvarg[i].pdispVal->Release();
- break;
- }
+ case VT_DISPATCH:
+ rgvarg[i].pdispVal->Release();
+ break;
+ }
}
delete[] rgvarg;
}
@@ -1908,17 +2012,17 @@ CDeferredCommand::CDeferredCommand(
__out VARIANT* pvarResult,
__out short* puArgErr,
BOOL bStream
- ) :
- CUnknown(NAME("DeferredCommand"), pUnk),
- m_pQueue(pQ),
- m_pUnk(pUnkExecutor),
- m_iid(iid),
- m_dispidMethod(dispidMethod),
- m_wFlags(wFlags),
- m_DispParams(nArgs, pDispParams, phr),
- m_pvarResult(pvarResult),
- m_bStream(bStream),
- m_hrResult(E_ABORT)
+) :
+ CUnknown(NAME("DeferredCommand"), pUnk),
+ m_pQueue(pQ),
+ m_pUnk(pUnkExecutor),
+ m_iid(iid),
+ m_dispidMethod(dispidMethod),
+ m_wFlags(wFlags),
+ m_DispParams(nArgs, pDispParams, phr),
+ m_pvarResult(pvarResult),
+ m_bStream(bStream),
+ m_hrResult(E_ABORT)
{
// convert REFTIME to REFERENCE_TIME
@@ -1931,9 +2035,10 @@ CDeferredCommand::CDeferredCommand(
// check iid is supportable on pUnk by QueryInterface for it
IUnknown * pInterface;
HRESULT hr = m_pUnk->QueryInterface(GetIID(), (void**) &pInterface);
- if (FAILED(hr)) {
- *phr = hr;
- return;
+ if(FAILED(hr))
+ {
+ *phr = hr;
+ return;
}
pInterface->Release();
@@ -1941,16 +2046,18 @@ CDeferredCommand::CDeferredCommand(
// !!! check dispidMethod and param/return types using typelib
ITypeInfo *pti;
hr = m_Dispatch.GetTypeInfo(*iid, 0, 0, &pti);
- if (FAILED(hr)) {
- *phr = hr;
- return;
+ if(FAILED(hr))
+ {
+ *phr = hr;
+ return;
}
// !!! some sort of ITypeInfo validity check here
pti->Release();
// Fix up the dispid for put and get
- if (wFlags == DISPATCH_PROPERTYPUT) {
+ if(wFlags == DISPATCH_PROPERTYPUT)
+ {
m_DispParams.cNamedArgs = 1;
m_DispId = DISPID_PROPERTYPUT;
m_DispParams.rgdispidNamedArgs = &m_DispId;
@@ -1958,8 +2065,9 @@ CDeferredCommand::CDeferredCommand(
// all checks ok - add to queue
hr = pQ->Insert(this);
- if (FAILED(hr)) {
- *phr = hr;
+ if(FAILED(hr))
+ {
+ *phr = hr;
}
}
@@ -1993,11 +2101,14 @@ CDeferredCommand::~CDeferredCommand()
STDMETHODIMP
CDeferredCommand::NonDelegatingQueryInterface(REFIID riid, __out void **ppv)
{
- ValidateReadWritePtr(ppv,sizeof(PVOID));
- if (riid == IID_IDeferredCommand) {
- return GetInterface( (IDeferredCommand *) this, ppv);
- } else {
- return CUnknown::NonDelegatingQueryInterface(riid, ppv);
+ ValidateReadWritePtr(ppv, sizeof(PVOID));
+ if(riid == IID_IDeferredCommand)
+ {
+ return GetInterface((IDeferredCommand *) this, ppv);
+ }
+ else
+ {
+ return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -2009,13 +2120,15 @@ CDeferredCommand::NonDelegatingQueryInterface(REFIID riid, __out void **ppv)
STDMETHODIMP
CDeferredCommand::Cancel()
{
- if (m_pQueue == NULL) {
- return VFW_E_ALREADY_CANCELLED;
+ if(m_pQueue == NULL)
+ {
+ return VFW_E_ALREADY_CANCELLED;
}
HRESULT hr = m_pQueue->Remove(this);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
m_pQueue = NULL;
@@ -2033,11 +2146,12 @@ CDeferredCommand::Confidence(__out LONG* pConfidence)
STDMETHODIMP
CDeferredCommand::GetHResult(__out HRESULT * phrResult)
{
- CheckPointer(phrResult,E_POINTER);
- ValidateReadWritePtr(phrResult,sizeof(HRESULT));
+ CheckPointer(phrResult, E_POINTER);
+ ValidateReadWritePtr(phrResult, sizeof(HRESULT));
- if (m_pQueue != NULL) {
- return E_ABORT;
+ if(m_pQueue != NULL)
+ {
+ return E_ABORT;
}
*phrResult = m_hrResult;
return S_OK;
@@ -2056,14 +2170,16 @@ CDeferredCommand::Postpone(REFTIME newtime)
COARefTime convertor(newtime);
// check that the time has not passed
- if (m_pQueue->CheckTime(convertor, IsStreamTime())) {
- return VFW_E_TIME_ALREADY_PASSED;
+ if(m_pQueue->CheckTime(convertor, IsStreamTime()))
+ {
+ return VFW_E_TIME_ALREADY_PASSED;
}
// extract from list
HRESULT hr = m_pQueue->Remove(this);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
// change time
@@ -2080,15 +2196,17 @@ HRESULT
CDeferredCommand::Invoke()
{
// check that we are still outstanding
- if (m_pQueue == NULL) {
- return VFW_E_ALREADY_CANCELLED;
+ if(m_pQueue == NULL)
+ {
+ return VFW_E_ALREADY_CANCELLED;
}
// get the type info
ITypeInfo* pti;
HRESULT hr = m_Dispatch.GetTypeInfo(GetIID(), 0, 0, &pti);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
// qi for the expected interface and then invoke it. Note that we have to
@@ -2096,21 +2214,22 @@ CDeferredCommand::Invoke()
IUnknown* pInterface;
hr = m_pUnk->QueryInterface(GetIID(), (void**) &pInterface);
- if (FAILED(hr)) {
- pti->Release();
- return hr;
+ if(FAILED(hr))
+ {
+ pti->Release();
+ return hr;
}
EXCEPINFO expinfo;
UINT uArgErr;
m_hrResult = pti->Invoke(
- pInterface,
- GetMethod(),
- GetFlags(),
- GetParams(),
- GetResult(),
- &expinfo,
- &uArgErr);
+ pInterface,
+ GetMethod(),
+ GetFlags(),
+ GetParams(),
+ GetResult(),
+ &expinfo,
+ &uArgErr);
// release the interface we QI'd for
pInterface->Release();
@@ -2148,26 +2267,30 @@ CCmdQueue::~CCmdQueue()
// entry then RemoveAll to empty the list
POSITION pos = m_listPresentation.GetHeadPosition();
- while(pos) {
- CDeferredCommand* pCmd = m_listPresentation.GetNext(pos);
- pCmd->Release();
+ while(pos)
+ {
+ CDeferredCommand* pCmd = m_listPresentation.GetNext(pos);
+ pCmd->Release();
}
m_listPresentation.RemoveAll();
pos = m_listStream.GetHeadPosition();
- while(pos) {
- CDeferredCommand* pCmd = m_listStream.GetNext(pos);
- pCmd->Release();
+ while(pos)
+ {
+ CDeferredCommand* pCmd = m_listStream.GetNext(pos);
+ pCmd->Release();
}
m_listStream.RemoveAll();
- if (m_pClock) {
- if (m_dwAdvise) {
- m_pClock->Unadvise(m_dwAdvise);
- m_dwAdvise = 0;
- }
- m_pClock->Release();
+ if(m_pClock)
+ {
+ if(m_dwAdvise)
+ {
+ m_pClock->Unadvise(m_dwAdvise);
+ m_dwAdvise = 0;
+ }
+ m_pClock->Release();
}
}
@@ -2199,24 +2322,27 @@ CCmdQueue::New(
CDeferredCommand* pCmd;
pCmd = new CDeferredCommand(
- this,
- NULL, // not aggregated
- &hr,
- pUnk, // this guy will execute
- time,
- iid,
- dispidMethod,
- wFlags,
- cArgs,
- pDispParams,
- pvarResult,
- puArgErr,
- bStream);
-
- if (pCmd == NULL) {
- hr = E_OUTOFMEMORY;
- } else {
- *ppCmd = pCmd;
+ this,
+ NULL, // not aggregated
+ &hr,
+ pUnk, // this guy will execute
+ time,
+ iid,
+ dispidMethod,
+ wFlags,
+ cArgs,
+ pDispParams,
+ pvarResult,
+ puArgErr,
+ bStream);
+
+ if(pCmd == NULL)
+ {
+ hr = E_OUTOFMEMORY;
+ }
+ else
+ {
+ *ppCmd = pCmd;
}
return hr;
}
@@ -2231,25 +2357,32 @@ CCmdQueue::Insert(__in CDeferredCommand* pCmd)
pCmd->AddRef();
CGenericList<CDeferredCommand> * pList;
- if (pCmd->IsStreamTime()) {
- pList = &m_listStream;
- } else {
- pList = &m_listPresentation;
+ if(pCmd->IsStreamTime())
+ {
+ pList = &m_listStream;
+ }
+ else
+ {
+ pList = &m_listPresentation;
}
POSITION pos = pList->GetHeadPosition();
// seek past all items that are before us
- while (pos &&
- (pList->GetValid(pos)->GetTime() <= pCmd->GetTime())) {
+ while(pos &&
+ (pList->GetValid(pos)->GetTime() <= pCmd->GetTime()))
+ {
- pList->GetNext(pos);
+ pList->GetNext(pos);
}
// now at end of list or in front of items that come later
- if (!pos) {
- pList->AddTail(pCmd);
- } else {
- pList->AddBefore(pos, pCmd);
+ if(!pos)
+ {
+ pList->AddTail(pCmd);
+ }
+ else
+ {
+ pList->AddBefore(pos, pCmd);
}
SetTimeAdvise();
@@ -2264,31 +2397,38 @@ CCmdQueue::Remove(__in CDeferredCommand* pCmd)
HRESULT hr = S_OK;
CGenericList<CDeferredCommand> * pList;
- if (pCmd->IsStreamTime()) {
- pList = &m_listStream;
- } else {
- pList = &m_listPresentation;
+ if(pCmd->IsStreamTime())
+ {
+ pList = &m_listStream;
+ }
+ else
+ {
+ pList = &m_listPresentation;
}
POSITION pos = pList->GetHeadPosition();
// traverse the list
- while (pos && (pList->GetValid(pos) != pCmd)) {
- pList->GetNext(pos);
+ while(pos && (pList->GetValid(pos) != pCmd))
+ {
+ pList->GetNext(pos);
}
// did we drop off the end?
- if (!pos) {
- hr = VFW_E_NOT_FOUND;
- } else {
+ if(!pos)
+ {
+ hr = VFW_E_NOT_FOUND;
+ }
+ else
+ {
- // found it - now take off list
- pList->Remove(pos);
+ // found it - now take off list
+ pList->Remove(pos);
- // Insert did an AddRef, so release it
- pCmd->Release();
+ // Insert did an AddRef, so release it
+ pCmd->Release();
- // check that timer request is still for earliest time
- SetTimeAdvise();
+ // check that timer request is still for earliest time
+ SetTimeAdvise();
}
return hr;
}
@@ -2302,17 +2442,20 @@ CCmdQueue::SetSyncSource(__in_opt IReferenceClock* pClock)
CAutoLock lock(&m_Lock);
// addref the new clock first in case they are the same
- if (pClock) {
- pClock->AddRef();
+ if(pClock)
+ {
+ pClock->AddRef();
}
// kill any advise on the old clock
- if (m_pClock) {
- if (m_dwAdvise) {
- m_pClock->Unadvise(m_dwAdvise);
- m_dwAdvise = 0;
- }
- m_pClock->Release();
+ if(m_pClock)
+ {
+ if(m_dwAdvise)
+ {
+ m_pClock->Unadvise(m_dwAdvise);
+ m_dwAdvise = 0;
+ }
+ m_pClock->Release();
}
m_pClock = pClock;
@@ -2328,8 +2471,9 @@ void
CCmdQueue::SetTimeAdvise(void)
{
// make sure we have a clock to use
- if (!m_pClock) {
- return;
+ if(!m_pClock)
+ {
+ return;
}
// reset the event whenever we are requesting a new signal
@@ -2340,47 +2484,53 @@ CCmdQueue::SetTimeAdvise(void)
// find the earliest presentation time
POSITION pos = m_listPresentation.GetHeadPosition();
- if (pos != NULL) {
- current = m_listPresentation.GetValid(pos)->GetTime();
+ if(pos != NULL)
+ {
+ current = m_listPresentation.GetValid(pos)->GetTime();
}
// if we're running, check the stream times too
- if (m_bRunning) {
+ if(m_bRunning)
+ {
- CRefTime t;
+ CRefTime t;
pos = m_listStream.GetHeadPosition();
- if (NULL != pos) {
- t = m_listStream.GetValid(pos)->GetTime();
+ if(NULL != pos)
+ {
+ t = m_listStream.GetValid(pos)->GetTime();
- // add on stream time offset to get presentation time
- t += m_StreamTimeOffset;
+ // add on stream time offset to get presentation time
+ t += m_StreamTimeOffset;
- // is this earlier?
- if ((current == TimeZero) || (t < current)) {
- current = t;
- }
- }
+ // is this earlier?
+ if((current == TimeZero) || (t < current))
+ {
+ current = t;
+ }
+ }
}
// need to change?
- if ((current > TimeZero) && (current != m_tCurrentAdvise)) {
- if (m_dwAdvise) {
- m_pClock->Unadvise(m_dwAdvise);
- // reset the event whenever we are requesting a new signal
- m_evDue.Reset();
- }
+ if((current > TimeZero) && (current != m_tCurrentAdvise))
+ {
+ if(m_dwAdvise)
+ {
+ m_pClock->Unadvise(m_dwAdvise);
+ // reset the event whenever we are requesting a new signal
+ m_evDue.Reset();
+ }
- // ask for time advice - the first two params are either
- // stream time offset and stream time or
- // presentation time and 0. we always use the latter
- HRESULT hr = m_pClock->AdviseTime(
- (REFERENCE_TIME)current,
- TimeZero,
- (HEVENT) HANDLE(m_evDue),
- &m_dwAdvise);
+ // ask for time advice - the first two params are either
+ // stream time offset and stream time or
+ // presentation time and 0. we always use the latter
+ HRESULT hr = m_pClock->AdviseTime(
+ (REFERENCE_TIME)current,
+ TimeZero,
+ (HEVENT) HANDLE(m_evDue),
+ &m_dwAdvise);
- ASSERT(SUCCEEDED(hr));
- m_tCurrentAdvise = current;
+ ASSERT(SUCCEEDED(hr));
+ m_tCurrentAdvise = current;
}
}
@@ -2428,52 +2578,60 @@ HRESULT
CCmdQueue::GetDueCommand(__out CDeferredCommand ** ppCmd, long msTimeout)
{
// loop until we timeout or find a due command
- for (;;) {
+ for(;;)
+ {
- {
- CAutoLock lock(&m_Lock);
+ {
+ CAutoLock lock(&m_Lock);
- // find the earliest command
- CDeferredCommand * pCmd = NULL;
+ // find the earliest command
+ CDeferredCommand * pCmd = NULL;
- // check the presentation time and the
- // stream time list to find the earliest
+ // check the presentation time and the
+ // stream time list to find the earliest
POSITION pos = m_listPresentation.GetHeadPosition();
- if (NULL != pos) {
- pCmd = m_listPresentation.GetValid(pos);
- }
+ if(NULL != pos)
+ {
+ pCmd = m_listPresentation.GetValid(pos);
+ }
- if (m_bRunning) {
- pos = m_listStream.GetHeadPosition();
- if (NULL != pos) {
+ if(m_bRunning)
+ {
+ pos = m_listStream.GetHeadPosition();
+ if(NULL != pos)
+ {
CDeferredCommand* pStrm = m_listStream.GetValid(pos);
CRefTime t = pStrm->GetTime() + m_StreamTimeOffset;
- if (!pCmd || (t < pCmd->GetTime())) {
+ if(!pCmd || (t < pCmd->GetTime()))
+ {
pCmd = pStrm;
}
}
}
- // if we have found one, is it due?
- if (pCmd) {
- if (CheckTime(pCmd->GetTime(), pCmd->IsStreamTime())) {
+ // if we have found one, is it due?
+ if(pCmd)
+ {
+ if(CheckTime(pCmd->GetTime(), pCmd->IsStreamTime()))
+ {
- // yes it's due - addref it
- pCmd->AddRef();
- *ppCmd = pCmd;
- return S_OK;
- }
- }
- }
+ // yes it's due - addref it
+ pCmd->AddRef();
+ *ppCmd = pCmd;
+ return S_OK;
+ }
+ }
+ }
- // block until the advise is signalled
- if (WaitForSingleObject(m_evDue, msTimeout) != WAIT_OBJECT_0) {
- return E_ABORT;
- }
+ // block until the advise is signalled
+ if(WaitForSingleObject(m_evDue, msTimeout) != WAIT_OBJECT_0)
+ {
+ return E_ABORT;
+ }
}
}
@@ -2497,42 +2655,48 @@ CCmdQueue::GetCommandDueFor(REFERENCE_TIME rtStream, __out CDeferredCommand**ppC
// find the earliest stream and presentation time commands
CDeferredCommand* pStream = NULL;
POSITION pos = m_listStream.GetHeadPosition();
- if (NULL != pos) {
- pStream = m_listStream.GetValid(pos);
+ if(NULL != pos)
+ {
+ pStream = m_listStream.GetValid(pos);
}
CDeferredCommand* pPresent = NULL;
pos = m_listPresentation.GetHeadPosition();
- if (NULL != pos) {
- pPresent = m_listPresentation.GetValid(pos);
+ if(NULL != pos)
+ {
+ pPresent = m_listPresentation.GetValid(pos);
}
// is there a presentation time that has passed already
- if (pPresent && CheckTime(pPresent->GetTime(), FALSE)) {
- pPresent->AddRef();
- *ppCmd = pPresent;
- return S_OK;
+ if(pPresent && CheckTime(pPresent->GetTime(), FALSE))
+ {
+ pPresent->AddRef();
+ *ppCmd = pPresent;
+ return S_OK;
}
// is there a stream time command due before this stream time
- if (pStream && (pStream->GetTime() <= tStream)) {
- pStream->AddRef();
- *ppCmd = pStream;
- return S_OK;
+ if(pStream && (pStream->GetTime() <= tStream))
+ {
+ pStream->AddRef();
+ *ppCmd = pStream;
+ return S_OK;
}
// if we are running, we can map presentation times to
// stream time. In this case, is there a presentation time command
// that will be due before this stream time is presented?
- if (m_bRunning && pPresent) {
+ if(m_bRunning && pPresent)
+ {
- // this stream time will appear at...
- tStream += m_StreamTimeOffset;
+ // this stream time will appear at...
+ tStream += m_StreamTimeOffset;
- // due before that?
- if (pPresent->GetTime() <= tStream) {
- *ppCmd = pPresent;
- return S_OK;
- }
+ // due before that?
+ if(pPresent->GetTime() <= tStream)
+ {
+ *ppCmd = pPresent;
+ return S_OK;
+ }
}
// no commands due yet
diff --git a/src/filters/BaseClasses/ctlutil.h b/src/filters/BaseClasses/ctlutil.h
index 7e4719ce3..a335183f3 100644
--- a/src/filters/BaseClasses/ctlutil.h
+++ b/src/filters/BaseClasses/ctlutil.h
@@ -36,17 +36,17 @@ public:
STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo(
- REFIID riid,
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo);
+ REFIID riid,
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid);
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid);
};
@@ -69,26 +69,26 @@ public:
STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo(
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo);
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid);
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid);
STDMETHODIMP Invoke(
- DISPID dispidMember,
- REFIID riid,
- LCID lcid,
- WORD wFlags,
- __in DISPPARAMS * pdispparams,
- __out_opt VARIANT * pvarResult,
- __out_opt EXCEPINFO * pexcepinfo,
- __out_opt UINT * puArgErr);
+ DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ __in DISPPARAMS * pdispparams,
+ __out_opt VARIANT * pvarResult,
+ __out_opt EXCEPINFO * pexcepinfo,
+ __out_opt UINT * puArgErr);
};
@@ -111,26 +111,26 @@ public:
STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo(
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo);
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid);
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid);
STDMETHODIMP Invoke(
- DISPID dispidMember,
- REFIID riid,
- LCID lcid,
- WORD wFlags,
- __in DISPPARAMS * pdispparams,
- __out_opt VARIANT * pvarResult,
- __out_opt EXCEPINFO * pexcepinfo,
- __out_opt UINT * puArgErr);
+ DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ __in DISPPARAMS * pdispparams,
+ __out_opt VARIANT * pvarResult,
+ __out_opt EXCEPINFO * pexcepinfo,
+ __out_opt UINT * puArgErr);
};
@@ -155,26 +155,26 @@ public:
STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo(
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo);
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid);
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid);
STDMETHODIMP Invoke(
- DISPID dispidMember,
- REFIID riid,
- LCID lcid,
- WORD wFlags,
- __in DISPPARAMS * pdispparams,
- __out_opt VARIANT * pvarResult,
- __out_opt EXCEPINFO * pexcepinfo,
- __out_opt UINT * puArgErr);
+ DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ __in DISPPARAMS * pdispparams,
+ __out_opt VARIANT * pvarResult,
+ __out_opt EXCEPINFO * pexcepinfo,
+ __out_opt UINT * puArgErr);
};
@@ -183,10 +183,12 @@ public:
// and REFERENCE_TIME (essentially a LONGLONG) within filters.
// this class converts between the two
-class COARefTime : public CRefTime {
+class COARefTime : public CRefTime
+{
public:
- COARefTime() {
+ COARefTime()
+ {
};
COARefTime(CRefTime t)
@@ -199,24 +201,29 @@ public:
{
};
- COARefTime(double d) {
- m_time = (LONGLONG) (d * 10000000);
+ COARefTime(double d)
+ {
+ m_time = (LONGLONG)(d * 10000000);
};
- operator double() {
+ operator double()
+ {
return double(m_time) / 10000000;
};
- operator REFERENCE_TIME() {
+ operator REFERENCE_TIME()
+ {
return m_time;
};
- COARefTime& operator=(const double& rd) {
- m_time = (LONGLONG) (rd * 10000000);
+ COARefTime& operator=(const double& rd)
+ {
+ m_time = (LONGLONG)(rd * 10000000);
return *this;
}
- COARefTime& operator=(const REFERENCE_TIME& rt) {
+ COARefTime& operator=(const REFERENCE_TIME& rt)
+ {
m_time = rt;
return *this;
}
@@ -308,40 +315,42 @@ public:
CPosPassThru(__in_opt LPCTSTR, __in_opt LPUNKNOWN, __inout HRESULT*, IPin *);
DECLARE_IUNKNOWN
- HRESULT ForceRefresh() {
+ HRESULT ForceRefresh()
+ {
return S_OK;
};
// override to return an accurate current position
- virtual HRESULT GetMediaTime(__out LONGLONG *pStartTime, __out_opt LONGLONG *pEndTime) {
+ virtual HRESULT GetMediaTime(__out LONGLONG *pStartTime, __out_opt LONGLONG *pEndTime)
+ {
return E_FAIL;
}
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,__deref_out void **ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
// IMediaSeeking methods
- STDMETHODIMP GetCapabilities( __out DWORD * pCapabilities );
- STDMETHODIMP CheckCapabilities( __inout DWORD * pCapabilities );
+ STDMETHODIMP GetCapabilities(__out DWORD * pCapabilities);
+ STDMETHODIMP CheckCapabilities(__inout DWORD * pCapabilities);
STDMETHODIMP SetTimeFormat(const GUID * pFormat);
STDMETHODIMP GetTimeFormat(__out GUID *pFormat);
STDMETHODIMP IsUsingTimeFormat(const GUID * pFormat);
- STDMETHODIMP IsFormatSupported( const GUID * pFormat);
- STDMETHODIMP QueryPreferredFormat( __out GUID *pFormat);
- STDMETHODIMP ConvertTimeFormat(__out LONGLONG * pTarget,
+ STDMETHODIMP IsFormatSupported(const GUID * pFormat);
+ STDMETHODIMP QueryPreferredFormat(__out GUID *pFormat);
+ STDMETHODIMP ConvertTimeFormat(__out LONGLONG * pTarget,
__in_opt const GUID * pTargetFormat,
- LONGLONG Source,
- __in_opt const GUID * pSourceFormat );
- STDMETHODIMP SetPositions( __inout_opt LONGLONG * pCurrent, DWORD CurrentFlags
- , __inout_opt LONGLONG * pStop, DWORD StopFlags );
-
- STDMETHODIMP GetPositions( __out_opt LONGLONG * pCurrent, __out_opt LONGLONG * pStop );
- STDMETHODIMP GetCurrentPosition( __out LONGLONG * pCurrent );
- STDMETHODIMP GetStopPosition( __out LONGLONG * pStop );
- STDMETHODIMP SetRate( double dRate);
- STDMETHODIMP GetRate( __out double * pdRate);
- STDMETHODIMP GetDuration( __out LONGLONG *pDuration);
- STDMETHODIMP GetAvailable( __out_opt LONGLONG *pEarliest, __out_opt LONGLONG *pLatest );
- STDMETHODIMP GetPreroll( __out LONGLONG *pllPreroll );
+ LONGLONG Source,
+ __in_opt const GUID * pSourceFormat);
+ STDMETHODIMP SetPositions(__inout_opt LONGLONG * pCurrent, DWORD CurrentFlags
+ , __inout_opt LONGLONG * pStop, DWORD StopFlags);
+
+ STDMETHODIMP GetPositions(__out_opt LONGLONG * pCurrent, __out_opt LONGLONG * pStop);
+ STDMETHODIMP GetCurrentPosition(__out LONGLONG * pCurrent);
+ STDMETHODIMP GetStopPosition(__out LONGLONG * pStop);
+ STDMETHODIMP SetRate(double dRate);
+ STDMETHODIMP GetRate(__out double * pdRate);
+ STDMETHODIMP GetDuration(__out LONGLONG *pDuration);
+ STDMETHODIMP GetAvailable(__out_opt LONGLONG *pEarliest, __out_opt LONGLONG *pLatest);
+ STDMETHODIMP GetPreroll(__out LONGLONG *pllPreroll);
// IMediaPosition properties
STDMETHODIMP get_Duration(__out REFTIME * plength);
@@ -357,8 +366,8 @@ public:
STDMETHODIMP CanSeekBackward(__out LONG *pCanSeekBackward);
private:
- HRESULT GetSeekingLongLong( HRESULT (__stdcall IMediaSeeking::*pMethod)( LONGLONG * ),
- __out LONGLONG * pll );
+ HRESULT GetSeekingLongLong(HRESULT(__stdcall IMediaSeeking::*pMethod)(LONGLONG *),
+ __out LONGLONG * pll);
};
@@ -377,8 +386,8 @@ public:
CRendererPosPassThru(__in_opt LPCTSTR, __in_opt LPUNKNOWN, __inout HRESULT*, IPin *);
HRESULT RegisterMediaTime(IMediaSample *pMediaSample);
- HRESULT RegisterMediaTime(LONGLONG StartTime,LONGLONG EndTime);
- HRESULT GetMediaTime(__out LONGLONG *pStartTime,__out_opt LONGLONG *pEndTime);
+ HRESULT RegisterMediaTime(LONGLONG StartTime, LONGLONG EndTime);
+ HRESULT GetMediaTime(__out LONGLONG *pStartTime, __out_opt LONGLONG *pEndTime);
HRESULT ResetMediaTime();
HRESULT EOS();
};
@@ -410,26 +419,26 @@ public:
STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo(
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo);
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid);
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid);
STDMETHODIMP Invoke(
- DISPID dispidMember,
- REFIID riid,
- LCID lcid,
- WORD wFlags,
- __in DISPPARAMS * pdispparams,
- __out_opt VARIANT * pvarResult,
- __out_opt EXCEPINFO * pexcepinfo,
- __out_opt UINT * puArgErr);
+ DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ __in DISPPARAMS * pdispparams,
+ __out_opt VARIANT * pvarResult,
+ __out_opt EXCEPINFO * pexcepinfo,
+ __out_opt UINT * puArgErr);
};
@@ -453,30 +462,30 @@ public:
STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo(
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo);
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid);
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid);
STDMETHODIMP Invoke(
- DISPID dispidMember,
- REFIID riid,
- LCID lcid,
- WORD wFlags,
- __in DISPPARAMS * pdispparams,
- __out_opt VARIANT * pvarResult,
- __out_opt EXCEPINFO * pexcepinfo,
- __out_opt UINT * puArgErr);
+ DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ __in DISPPARAMS * pdispparams,
+ __out_opt VARIANT * pvarResult,
+ __out_opt EXCEPINFO * pexcepinfo,
+ __out_opt UINT * puArgErr);
STDMETHODIMP GetPreferredAspectRatio(
- __out long *plAspectX,
- __out long *plAspectY)
+ __out long *plAspectX,
+ __out long *plAspectY)
{
return E_NOTIMPL;
}
@@ -503,26 +512,26 @@ public:
STDMETHODIMP GetTypeInfoCount(__out UINT * pctinfo);
STDMETHODIMP GetTypeInfo(
- UINT itinfo,
- LCID lcid,
- __deref_out ITypeInfo ** pptinfo);
+ UINT itinfo,
+ LCID lcid,
+ __deref_out ITypeInfo ** pptinfo);
STDMETHODIMP GetIDsOfNames(
- REFIID riid,
- __in_ecount(cNames) LPOLESTR * rgszNames,
- UINT cNames,
- LCID lcid,
- __out_ecount(cNames) DISPID * rgdispid);
+ REFIID riid,
+ __in_ecount(cNames) LPOLESTR * rgszNames,
+ UINT cNames,
+ LCID lcid,
+ __out_ecount(cNames) DISPID * rgdispid);
STDMETHODIMP Invoke(
- DISPID dispidMember,
- REFIID riid,
- LCID lcid,
- WORD wFlags,
- __in DISPPARAMS * pdispparams,
- __out_opt VARIANT * pvarResult,
- __out_opt EXCEPINFO * pexcepinfo,
- __out_opt UINT * puArgErr);
+ DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ __in DISPPARAMS * pdispparams,
+ __out_opt VARIANT * pvarResult,
+ __out_opt EXCEPINFO * pexcepinfo,
+ __out_opt UINT * puArgErr);
};
@@ -550,7 +559,8 @@ public:
STDMETHODIMP CanSeekBackward(__out LONG *pCanSeekBackward);
// override if you can return the data you are actually working on
- STDMETHODIMP get_CurrentPosition(__out REFTIME * pllTime) {
+ STDMETHODIMP get_CurrentPosition(__out REFTIME * pllTime)
+ {
return E_NOTIMPL;
};
@@ -589,21 +599,21 @@ public:
STDMETHODIMP GetDuration(__out LONGLONG *pDuration);
STDMETHODIMP GetStopPosition(__out LONGLONG *pStop);
STDMETHODIMP GetCurrentPosition(__out LONGLONG *pCurrent);
- STDMETHODIMP GetCapabilities( __out DWORD * pCapabilities );
- STDMETHODIMP CheckCapabilities( __inout DWORD * pCapabilities );
- STDMETHODIMP ConvertTimeFormat( __out LONGLONG * pTarget,
- __in_opt const GUID * pTargetFormat,
- LONGLONG Source,
- __in_opt const GUID * pSourceFormat );
+ STDMETHODIMP GetCapabilities(__out DWORD * pCapabilities);
+ STDMETHODIMP CheckCapabilities(__inout DWORD * pCapabilities);
+ STDMETHODIMP ConvertTimeFormat(__out LONGLONG * pTarget,
+ __in_opt const GUID * pTargetFormat,
+ LONGLONG Source,
+ __in_opt const GUID * pSourceFormat);
- STDMETHODIMP SetPositions( __inout_opt LONGLONG * pCurrent, DWORD CurrentFlags
- , __inout_opt LONGLONG * pStop, DWORD StopFlags );
+ STDMETHODIMP SetPositions(__inout_opt LONGLONG * pCurrent, DWORD CurrentFlags
+ , __inout_opt LONGLONG * pStop, DWORD StopFlags);
- STDMETHODIMP GetPositions( __out_opt LONGLONG * pCurrent, __out_opt LONGLONG * pStop );
+ STDMETHODIMP GetPositions(__out_opt LONGLONG * pCurrent, __out_opt LONGLONG * pStop);
- STDMETHODIMP GetAvailable( __out_opt LONGLONG * pEarliest, __out_opt LONGLONG * pLatest );
- STDMETHODIMP SetRate( double dRate);
- STDMETHODIMP GetRate( __out double * pdRate);
+ STDMETHODIMP GetAvailable(__out_opt LONGLONG * pEarliest, __out_opt LONGLONG * pLatest);
+ STDMETHODIMP SetRate(double dRate);
+ STDMETHODIMP GetRate(__out double * pdRate);
STDMETHODIMP GetPreroll(__out LONGLONG *pPreroll);
@@ -667,7 +677,7 @@ public:
class CDeferredCommand
: public CUnknown,
- public IDeferredCommand
+ public IDeferredCommand
{
public:
@@ -685,7 +695,7 @@ public:
__out VARIANT* pvarResult,
__out short* puArgErr,
BOOL bStream
- );
+ );
DECLARE_IUNKNOWN
@@ -695,11 +705,11 @@ public:
// IDeferredCommand methods
STDMETHODIMP Cancel();
STDMETHODIMP Confidence(
- __out LONG* pConfidence);
+ __out LONG* pConfidence);
STDMETHODIMP Postpone(
- REFTIME newtime);
+ REFTIME newtime);
STDMETHODIMP GetHResult(
- __out HRESULT* phrResult);
+ __out HRESULT* phrResult);
// other public methods
@@ -708,31 +718,38 @@ public:
// access methods
// returns TRUE if streamtime, FALSE if presentation time
- BOOL IsStreamTime() {
- return m_bStream;
+ BOOL IsStreamTime()
+ {
+ return m_bStream;
};
- CRefTime GetTime() {
+ CRefTime GetTime()
+ {
return m_time;
};
- REFIID GetIID() {
+ REFIID GetIID()
+ {
return *m_iid;
};
- long GetMethod() {
+ long GetMethod()
+ {
return m_dispidMethod;
};
- short GetFlags() {
+ short GetFlags()
+ {
return m_wFlags;
};
- DISPPARAMS* GetParams() {
+ DISPPARAMS* GetParams()
+ {
return &m_DispParams;
};
- VARIANT* GetResult() {
+ VARIANT* GetResult()
+ {
return m_pvarResult;
};
@@ -850,7 +867,8 @@ public:
// return the event handle that will be signalled whenever
// there are deferred commands due for execution (when GetDueCommand
// will not block).
- HANDLE GetDueHandle() {
+ HANDLE GetDueHandle()
+ {
return HANDLE(m_evDue);
};
@@ -864,18 +882,22 @@ public:
virtual HRESULT GetCommandDueFor(REFERENCE_TIME tStream, __out CDeferredCommand**ppCmd);
// check if a given time is due (TRUE if it is due yet)
- BOOL CheckTime(CRefTime time, BOOL bStream) {
+ BOOL CheckTime(CRefTime time, BOOL bStream)
+ {
// if no clock, nothing is due!
- if (!m_pClock) {
+ if(!m_pClock)
+ {
return FALSE;
}
// stream time
- if (bStream) {
+ if(bStream)
+ {
// not valid if not running
- if (!m_bRunning) {
+ if(!m_bRunning)
+ {
return FALSE;
}
// add on known stream time offset to get presentation time
diff --git a/src/filters/BaseClasses/ddmm.cpp b/src/filters/BaseClasses/ddmm.cpp
index bfa700cb8..3165fb6f6 100644
--- a/src/filters/BaseClasses/ddmm.cpp
+++ b/src/filters/BaseClasses/ddmm.cpp
@@ -15,46 +15,55 @@
/*
* FindDeviceCallback
*/
-typedef struct {
- LPSTR szDevice;
- GUID* lpGUID;
- GUID GUID;
- BOOL fFound;
+typedef struct
+{
+ LPSTR szDevice;
+ GUID* lpGUID;
+ GUID GUID;
+ BOOL fFound;
} FindDeviceData;
BOOL CALLBACK FindDeviceCallback(__in_opt GUID* lpGUID, __in LPSTR szName, __in LPSTR szDevice, __in LPVOID lParam)
{
- FindDeviceData *p = (FindDeviceData*)lParam;
-
- if (lstrcmpiA(p->szDevice, szDevice) == 0) {
- if (lpGUID) {
- p->GUID = *lpGUID;
- p->lpGUID = &p->GUID;
- } else {
- p->lpGUID = NULL;
- }
- p->fFound = TRUE;
- return FALSE;
- }
- return TRUE;
+ FindDeviceData *p = (FindDeviceData*)lParam;
+
+ if(lstrcmpiA(p->szDevice, szDevice) == 0)
+ {
+ if(lpGUID)
+ {
+ p->GUID = *lpGUID;
+ p->lpGUID = &p->GUID;
+ }
+ else
+ {
+ p->lpGUID = NULL;
+ }
+ p->fFound = TRUE;
+ return FALSE;
+ }
+ return TRUE;
}
BOOL CALLBACK FindDeviceCallbackEx(__in_opt GUID* lpGUID, __in LPSTR szName, __in LPSTR szDevice, __in LPVOID lParam, HMONITOR hMonitor)
{
- FindDeviceData *p = (FindDeviceData*)lParam;
-
- if (lstrcmpiA(p->szDevice, szDevice) == 0) {
- if (lpGUID) {
- p->GUID = *lpGUID;
- p->lpGUID = &p->GUID;
- } else {
- p->lpGUID = NULL;
- }
- p->fFound = TRUE;
- return FALSE;
- }
- return TRUE;
+ FindDeviceData *p = (FindDeviceData*)lParam;
+
+ if(lstrcmpiA(p->szDevice, szDevice) == 0)
+ {
+ if(lpGUID)
+ {
+ p->GUID = *lpGUID;
+ p->lpGUID = &p->GUID;
+ }
+ else
+ {
+ p->lpGUID = NULL;
+ }
+ p->fFound = TRUE;
+ return FALSE;
+ }
+ return TRUE;
}
@@ -65,31 +74,32 @@ BOOL CALLBACK FindDeviceCallbackEx(__in_opt GUID* lpGUID, __in LPSTR szName, __i
*/
IDirectDraw * DirectDrawCreateFromDevice(__in_opt LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, PDRAWENUM DirectDrawEnumerateP)
{
- IDirectDraw* pdd = NULL;
- FindDeviceData find;
-
- if (szDevice == NULL) {
- DirectDrawCreateP(NULL, &pdd, NULL);
- return pdd;
- }
-
- find.szDevice = szDevice;
- find.fFound = FALSE;
- DirectDrawEnumerateP(FindDeviceCallback, (LPVOID)&find);
-
- if (find.fFound)
- {
- //
- // In 4bpp mode the following DDraw call causes a message box to be popped
- // up by DDraw (!?!). It's DDraw's fault, but we don't like it. So we
- // make sure it doesn't happen.
- //
- UINT ErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
- DirectDrawCreateP(find.lpGUID, &pdd, NULL);
- SetErrorMode(ErrorMode);
- }
-
- return pdd;
+ IDirectDraw* pdd = NULL;
+ FindDeviceData find;
+
+ if(szDevice == NULL)
+ {
+ DirectDrawCreateP(NULL, &pdd, NULL);
+ return pdd;
+ }
+
+ find.szDevice = szDevice;
+ find.fFound = FALSE;
+ DirectDrawEnumerateP(FindDeviceCallback, (LPVOID)&find);
+
+ if(find.fFound)
+ {
+ //
+ // In 4bpp mode the following DDraw call causes a message box to be popped
+ // up by DDraw (!?!). It's DDraw's fault, but we don't like it. So we
+ // make sure it doesn't happen.
+ //
+ UINT ErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
+ DirectDrawCreateP(find.lpGUID, &pdd, NULL);
+ SetErrorMode(ErrorMode);
+ }
+
+ return pdd;
}
@@ -100,30 +110,31 @@ IDirectDraw * DirectDrawCreateFromDevice(__in_opt LPSTR szDevice, PDRAWCREATE Di
*/
IDirectDraw * DirectDrawCreateFromDeviceEx(__in_opt LPSTR szDevice, PDRAWCREATE DirectDrawCreateP, LPDIRECTDRAWENUMERATEEXA DirectDrawEnumerateExP)
{
- IDirectDraw* pdd = NULL;
- FindDeviceData find;
-
- if (szDevice == NULL) {
- DirectDrawCreateP(NULL, &pdd, NULL);
- return pdd;
- }
-
- find.szDevice = szDevice;
- find.fFound = FALSE;
- DirectDrawEnumerateExP(FindDeviceCallbackEx, (LPVOID)&find,
- DDENUM_ATTACHEDSECONDARYDEVICES);
-
- if (find.fFound)
- {
- //
- // In 4bpp mode the following DDraw call causes a message box to be popped
- // up by DDraw (!?!). It's DDraw's fault, but we don't like it. So we
- // make sure it doesn't happen.
- //
- UINT ErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
- DirectDrawCreateP(find.lpGUID, &pdd, NULL);
- SetErrorMode(ErrorMode);
- }
-
- return pdd;
+ IDirectDraw* pdd = NULL;
+ FindDeviceData find;
+
+ if(szDevice == NULL)
+ {
+ DirectDrawCreateP(NULL, &pdd, NULL);
+ return pdd;
+ }
+
+ find.szDevice = szDevice;
+ find.fFound = FALSE;
+ DirectDrawEnumerateExP(FindDeviceCallbackEx, (LPVOID)&find,
+ DDENUM_ATTACHEDSECONDARYDEVICES);
+
+ if(find.fFound)
+ {
+ //
+ // In 4bpp mode the following DDraw call causes a message box to be popped
+ // up by DDraw (!?!). It's DDraw's fault, but we don't like it. So we
+ // make sure it doesn't happen.
+ //
+ UINT ErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
+ DirectDrawCreateP(find.lpGUID, &pdd, NULL);
+ SetErrorMode(ErrorMode);
+ }
+
+ return pdd;
}
diff --git a/src/filters/BaseClasses/ddmm.h b/src/filters/BaseClasses/ddmm.h
index 7b311bc10..67cb3ea7b 100644
--- a/src/filters/BaseClasses/ddmm.h
+++ b/src/filters/BaseClasses/ddmm.h
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// File: DDMM.h
//
-// Desc: DirectShow base classes - efines routines for using DirectDraw
+// Desc: DirectShow base classes - efines routines for using DirectDraw
// on a multimonitor system.
//
// Copyright (c) 1995-2001 Microsoft Corporation. All rights reserved.
@@ -17,11 +17,11 @@ extern "C" { /* Assume C declarations for C++ */
#define DDENUM_ATTACHEDSECONDARYDEVICES 0x00000001L
#endif
-typedef HRESULT (*PDRAWCREATE)(IID *,LPDIRECTDRAW *,LPUNKNOWN);
-typedef HRESULT (*PDRAWENUM)(LPDDENUMCALLBACKA, LPVOID);
+ typedef HRESULT(*PDRAWCREATE)(IID *, LPDIRECTDRAW *, LPUNKNOWN);
+ typedef HRESULT(*PDRAWENUM)(LPDDENUMCALLBACKA, LPVOID);
-IDirectDraw * DirectDrawCreateFromDevice(__in_opt LPSTR, PDRAWCREATE, PDRAWENUM);
-IDirectDraw * DirectDrawCreateFromDeviceEx(__in_opt LPSTR, PDRAWCREATE, LPDIRECTDRAWENUMERATEEXA);
+ IDirectDraw * DirectDrawCreateFromDevice(__in_opt LPSTR, PDRAWCREATE, PDRAWENUM);
+ IDirectDraw * DirectDrawCreateFromDeviceEx(__in_opt LPSTR, PDRAWCREATE, LPDIRECTDRAWENUMERATEEXA);
#ifdef __cplusplus
}
diff --git a/src/filters/BaseClasses/dllentry.cpp b/src/filters/BaseClasses/dllentry.cpp
index 81a8673a9..3b3eeb09e 100644
--- a/src/filters/BaseClasses/dllentry.cpp
+++ b/src/filters/BaseClasses/dllentry.cpp
@@ -56,7 +56,8 @@ public:
STDMETHODIMP LockServer(BOOL fLock);
// allow DLLGetClassObject to know about global server lock status
- static BOOL IsLocked() {
+ static BOOL IsLocked()
+ {
return (m_cLocked > 0);
};
};
@@ -65,24 +66,25 @@ public:
int CClassFactory::m_cLocked = 0;
CClassFactory::CClassFactory(const CFactoryTemplate *pTemplate)
-: CBaseObject(NAME("Class Factory"))
-, m_cRef(0)
-, m_pTemplate(pTemplate)
+ : CBaseObject(NAME("Class Factory"))
+ , m_cRef(0)
+ , m_pTemplate(pTemplate)
{
}
STDMETHODIMP
-CClassFactory::QueryInterface(REFIID riid,__deref_out void **ppv)
+CClassFactory::QueryInterface(REFIID riid, __deref_out void **ppv)
{
- CheckPointer(ppv,E_POINTER)
- ValidateReadWritePtr(ppv,sizeof(PVOID));
+ CheckPointer(ppv, E_POINTER)
+ ValidateReadWritePtr(ppv, sizeof(PVOID));
*ppv = NULL;
// any interface on this object is the object pointer.
- if ((riid == IID_IUnknown) || (riid == IID_IClassFactory)) {
+ if((riid == IID_IUnknown) || (riid == IID_IClassFactory))
+ {
*ppv = (LPVOID) this;
- // AddRef returned interface pointer
+ // AddRef returned interface pointer
((LPUNKNOWN) *ppv)->AddRef();
return NOERROR;
}
@@ -101,10 +103,13 @@ STDMETHODIMP_(ULONG)
CClassFactory::Release()
{
LONG lRef = InterlockedDecrement((volatile LONG *)&m_cRef);
- if (lRef == 0) {
+ if(lRef == 0)
+ {
delete this;
return 0;
- } else {
+ }
+ else
+ {
return lRef;
}
}
@@ -115,14 +120,16 @@ CClassFactory::CreateInstance(
REFIID riid,
__deref_out void **pv)
{
- CheckPointer(pv,E_POINTER)
- ValidateReadWritePtr(pv,sizeof(void *));
+ CheckPointer(pv, E_POINTER)
+ ValidateReadWritePtr(pv, sizeof(void *));
*pv = NULL;
/* Enforce the normal OLE rules regarding interfaces and delegation */
- if (pUnkOuter != NULL) {
- if (IsEqualIID(riid,IID_IUnknown) == FALSE) {
+ if(pUnkOuter != NULL)
+ {
+ if(IsEqualIID(riid, IID_IUnknown) == FALSE)
+ {
*pv = NULL;
return ResultFromScode(E_NOINTERFACE);
}
@@ -133,17 +140,20 @@ CClassFactory::CreateInstance(
HRESULT hr = NOERROR;
CUnknown *pObj = m_pTemplate->CreateInstance(pUnkOuter, &hr);
- if (pObj == NULL) {
+ if(pObj == NULL)
+ {
*pv = NULL;
- if (SUCCEEDED(hr)) {
- hr = E_OUTOFMEMORY;
- }
- return hr;
+ if(SUCCEEDED(hr))
+ {
+ hr = E_OUTOFMEMORY;
+ }
+ return hr;
}
/* Delete the object if we got a construction error */
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
delete pObj;
*pv = NULL;
return hr;
@@ -164,7 +174,8 @@ CClassFactory::CreateInstance(
/* destruct". Hence we don't need additional tidy-up code */
/* to cope with NonDelegatingQueryInterface failing. */
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
ASSERT(*pv);
}
@@ -174,9 +185,12 @@ CClassFactory::CreateInstance(
STDMETHODIMP
CClassFactory::LockServer(BOOL fLock)
{
- if (fLock) {
+ if(fLock)
+ {
m_cLocked++;
- } else {
+ }
+ else
+ {
m_cLocked--;
}
return NOERROR;
@@ -193,21 +207,25 @@ DllGetClassObject(
__deref_out void **pv)
{
*pv = NULL;
- if (!(riid == IID_IUnknown) && !(riid == IID_IClassFactory)) {
- return E_NOINTERFACE;
+ if(!(riid == IID_IUnknown) && !(riid == IID_IClassFactory))
+ {
+ return E_NOINTERFACE;
}
// traverse the array of templates looking for one with this
// class id
- for (int i = 0; i < g_cTemplates; i++) {
+ for(int i = 0; i < g_cTemplates; i++)
+ {
const CFactoryTemplate * pT = &g_Templates[i];
- if (pT->IsClassID(rClsID)) {
+ if(pT->IsClassID(rClsID))
+ {
// found a template - make a class factory based on this
// template
- *pv = (LPVOID) (LPUNKNOWN) new CClassFactory(pT);
- if (*pv == NULL) {
+ *pv = (LPVOID)(LPUNKNOWN) new CClassFactory(pT);
+ if(*pv == NULL)
+ {
return E_OUTOFMEMORY;
}
((LPUNKNOWN)*pv)->AddRef();
@@ -227,9 +245,11 @@ DllInitClasses(BOOL bLoading)
// traverse the array of templates calling the init routine
// if they have one
- for (i = 0; i < g_cTemplates; i++) {
+ for(i = 0; i < g_cTemplates; i++)
+ {
const CFactoryTemplate * pT = &g_Templates[i];
- if (pT->m_lpfnInit != NULL) {
+ if(pT->m_lpfnInit != NULL)
+ {
(*pT->m_lpfnInit)(bLoading, pT->m_ClsID);
}
}
@@ -246,41 +266,46 @@ DllInitClasses(BOOL bLoading)
STDAPI
DllCanUnloadNow()
{
- DbgLog((LOG_MEMORY,2,TEXT("DLLCanUnloadNow called - IsLocked = %d, Active objects = %d"),
- CClassFactory::IsLocked(),
- CBaseObject::ObjectsActive()));
+ DbgLog((LOG_MEMORY, 2, TEXT("DLLCanUnloadNow called - IsLocked = %d, Active objects = %d"),
+ CClassFactory::IsLocked(),
+ CBaseObject::ObjectsActive()));
- if (CClassFactory::IsLocked() || CBaseObject::ObjectsActive()) {
- return S_FALSE;
- } else {
+ if(CClassFactory::IsLocked() || CBaseObject::ObjectsActive())
+ {
+ return S_FALSE;
+ }
+ else
+ {
return S_OK;
}
}
// --- standard WIN32 entrypoints --------------------------------------
-BOOL SetHeapOptions() {
- HMODULE hLib = LoadLibrary(L"kernel32.dll");
- if (hLib == NULL) return FALSE;
-
- typedef BOOL (WINAPI *HSI)
- (HANDLE, HEAP_INFORMATION_CLASS ,PVOID, SIZE_T);
- HSI pHsi = (HSI)GetProcAddress(hLib,"HeapSetInformation");
- if (!pHsi) {
- FreeLibrary(hLib);
- return FALSE;
- }
+BOOL SetHeapOptions()
+{
+ HMODULE hLib = LoadLibrary(L"kernel32.dll");
+ if(hLib == NULL) return FALSE;
+
+ typedef BOOL (WINAPI * HSI)
+ (HANDLE, HEAP_INFORMATION_CLASS , PVOID, SIZE_T);
+ HSI pHsi = (HSI)GetProcAddress(hLib, "HeapSetInformation");
+ if(!pHsi)
+ {
+ FreeLibrary(hLib);
+ return FALSE;
+ }
#ifndef HeapEnableTerminationOnCorruption
# define HeapEnableTerminationOnCorruption (HEAP_INFORMATION_CLASS)1
#endif
- BOOL fRet = (pHsi)(NULL,HeapEnableTerminationOnCorruption,NULL,0)
- ? TRUE
- : FALSE;
- if (hLib) FreeLibrary(hLib);
+ BOOL fRet = (pHsi)(NULL, HeapEnableTerminationOnCorruption, NULL, 0)
+ ? TRUE
+ : FALSE;
+ if(hLib) FreeLibrary(hLib);
- return fRet;
+ return fRet;
}
extern "C" void __cdecl __security_init_cookie(void);
@@ -289,15 +314,16 @@ extern "C" BOOL WINAPI _DllEntryPoint(HINSTANCE, ULONG, __inout_opt LPVOID);
extern "C"
DECLSPEC_NOINLINE
-BOOL
+BOOL
WINAPI
DllEntryPoint(
- HINSTANCE hInstance,
- ULONG ulReason,
+ HINSTANCE hInstance,
+ ULONG ulReason,
__inout_opt LPVOID pv
- )
+)
{
- if ( ulReason == DLL_PROCESS_ATTACH ) {
+ if(ulReason == DLL_PROCESS_ATTACH)
+ {
// Must happen before any other code is executed. Thankfully - it's re-entrant
__security_init_cookie();
}
@@ -306,40 +332,43 @@ DllEntryPoint(
DECLSPEC_NOINLINE
-BOOL
+BOOL
WINAPI
_DllEntryPoint(
- HINSTANCE hInstance,
- ULONG ulReason,
+ HINSTANCE hInstance,
+ ULONG ulReason,
__inout_opt LPVOID pv
- )
+)
{
#ifdef _DEBUG
extern bool g_fDbgInDllEntryPoint;
g_fDbgInDllEntryPoint = true;
#endif
- switch (ulReason)
+ switch(ulReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstance);
DbgInitialise(hInstance);
- {
- SetHeapOptions();
- // The platform identifier is used to work out whether
- // full unicode support is available or not. Hence the
- // default will be the lowest common denominator - i.e. N/A
- g_amPlatform = VER_PLATFORM_WIN32_WINDOWS; // win95 assumed in case GetVersionEx fails
-
- g_osInfo.dwOSVersionInfoSize = sizeof(g_osInfo);
- if (GetVersionEx(&g_osInfo)) {
- g_amPlatform = g_osInfo.dwPlatformId;
- } else {
- DbgLog((LOG_ERROR, 1, TEXT("Failed to get the OS platform, assuming Win95")));
- }
- }
+ {
+ SetHeapOptions();
+ // The platform identifier is used to work out whether
+ // full unicode support is available or not. Hence the
+ // default will be the lowest common denominator - i.e. N/A
+ g_amPlatform = VER_PLATFORM_WIN32_WINDOWS; // win95 assumed in case GetVersionEx fails
+
+ g_osInfo.dwOSVersionInfoSize = sizeof(g_osInfo);
+ if(GetVersionEx(&g_osInfo))
+ {
+ g_amPlatform = g_osInfo.dwPlatformId;
+ }
+ else
+ {
+ DbgLog((LOG_ERROR, 1, TEXT("Failed to get the OS platform, assuming Win95")));
+ }
+ }
g_hInst = hInstance;
DllInitClasses(TRUE);
@@ -349,7 +378,8 @@ _DllEntryPoint(
DllInitClasses(FALSE);
#ifdef _DEBUG
- if (CBaseObject::ObjectsActive()) {
+ if(CBaseObject::ObjectsActive())
+ {
DbgSetModuleLevel(LOG_MEMORY, 2);
TCHAR szInfo[512];
extern TCHAR m_ModuleName[]; // Cut down module name
@@ -357,23 +387,26 @@ _DllEntryPoint(
TCHAR FullName[_MAX_PATH]; // Load the full path and module name
TCHAR *pName; // Searches from the end for a backslash
- GetModuleFileName(NULL,FullName,_MAX_PATH);
- pName = _tcsrchr(FullName,'\\');
- if (pName == NULL) {
+ GetModuleFileName(NULL, FullName, _MAX_PATH);
+ pName = _tcsrchr(FullName, '\\');
+ if(pName == NULL)
+ {
pName = FullName;
- } else {
+ }
+ else
+ {
pName++;
}
(void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("Executable: %s Pid %x Tid %x. "),
- pName, GetCurrentProcessId(), GetCurrentThreadId());
+ pName, GetCurrentProcessId(), GetCurrentThreadId());
- (void)StringCchPrintf(szInfo+lstrlen(szInfo), NUMELMS(szInfo) - lstrlen(szInfo), TEXT("Module %s, %d objects left active!"),
- m_ModuleName, CBaseObject::ObjectsActive());
- DbgAssert(szInfo, TEXT(__FILE__),__LINE__);
+ (void)StringCchPrintf(szInfo + lstrlen(szInfo), NUMELMS(szInfo) - lstrlen(szInfo), TEXT("Module %s, %d objects left active!"),
+ m_ModuleName, CBaseObject::ObjectsActive());
+ DbgAssert(szInfo, TEXT(__FILE__), __LINE__);
- // If running remotely wait for the Assert to be acknowledged
- // before dumping out the object register
+ // If running remotely wait for the Assert to be acknowledged
+ // before dumping out the object register
DbgDumpObjectRegister();
}
DbgTerminate();
diff --git a/src/filters/BaseClasses/dllsetup.cpp b/src/filters/BaseClasses/dllsetup.cpp
index c14c2f8e1..9b610df4b 100644
--- a/src/filters/BaseClasses/dllsetup.cpp
+++ b/src/filters/BaseClasses/dllsetup.cpp
@@ -37,62 +37,63 @@ extern CFactoryTemplate g_Templates[];
//---------------------------------------------------------------------------
STDAPI
-EliminateSubKey( HKEY hkey, LPCTSTR strSubKey )
+EliminateSubKey(HKEY hkey, LPCTSTR strSubKey)
{
- HKEY hk;
- if (0 == lstrlen(strSubKey) ) {
- // defensive approach
- return E_FAIL;
- }
-
- LONG lreturn = RegOpenKeyEx( hkey
- , strSubKey
- , 0
- , MAXIMUM_ALLOWED
- , &hk );
-
- ASSERT( lreturn == ERROR_SUCCESS
- || lreturn == ERROR_FILE_NOT_FOUND
- || lreturn == ERROR_INVALID_HANDLE );
-
- if( ERROR_SUCCESS == lreturn )
- {
- // Keep on enumerating the first (zero-th)
- // key and deleting that
-
- for( ; ; )
+ HKEY hk;
+ if(0 == lstrlen(strSubKey))
{
- TCHAR Buffer[MAX_KEY_LEN];
- DWORD dw = MAX_KEY_LEN;
- FILETIME ft;
-
- lreturn = RegEnumKeyEx( hk
- , 0
- , Buffer
- , &dw
- , NULL
- , NULL
- , NULL
- , &ft);
-
- ASSERT( lreturn == ERROR_SUCCESS
- || lreturn == ERROR_NO_MORE_ITEMS );
-
- if( ERROR_SUCCESS == lreturn )
- {
- EliminateSubKey(hk, Buffer);
- }
- else
- {
- break;
- }
+ // defensive approach
+ return E_FAIL;
}
- RegCloseKey(hk);
- RegDeleteKey(hkey, strSubKey);
- }
+ LONG lreturn = RegOpenKeyEx(hkey
+ , strSubKey
+ , 0
+ , MAXIMUM_ALLOWED
+ , &hk);
- return NOERROR;
+ ASSERT(lreturn == ERROR_SUCCESS
+ || lreturn == ERROR_FILE_NOT_FOUND
+ || lreturn == ERROR_INVALID_HANDLE);
+
+ if(ERROR_SUCCESS == lreturn)
+ {
+ // Keep on enumerating the first (zero-th)
+ // key and deleting that
+
+ for(; ;)
+ {
+ TCHAR Buffer[MAX_KEY_LEN];
+ DWORD dw = MAX_KEY_LEN;
+ FILETIME ft;
+
+ lreturn = RegEnumKeyEx(hk
+ , 0
+ , Buffer
+ , &dw
+ , NULL
+ , NULL
+ , NULL
+ , &ft);
+
+ ASSERT(lreturn == ERROR_SUCCESS
+ || lreturn == ERROR_NO_MORE_ITEMS);
+
+ if(ERROR_SUCCESS == lreturn)
+ {
+ EliminateSubKey(hk, Buffer);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ RegCloseKey(hk);
+ RegDeleteKey(hkey, strSubKey);
+ }
+
+ return NOERROR;
}
@@ -108,99 +109,99 @@ EliminateSubKey( HKEY hkey, LPCTSTR strSubKey )
//---------------------------------------------------------------------------
STDAPI
-AMovieSetupRegisterServer( CLSID clsServer
- , LPCWSTR szDescription
- , LPCWSTR szFileName
- , LPCWSTR szThreadingModel = L"Both"
- , LPCWSTR szServerType = L"InprocServer32" )
+AMovieSetupRegisterServer(CLSID clsServer
+ , LPCWSTR szDescription
+ , LPCWSTR szFileName
+ , LPCWSTR szThreadingModel = L"Both"
+ , LPCWSTR szServerType = L"InprocServer32")
{
- // temp buffer
- //
- TCHAR achTemp[_MAX_PATH];
-
- // convert CLSID uuid to string and write
- // out subkey as string - CLSID\{}
- //
- OLECHAR szCLSID[CHARS_IN_GUID];
- HRESULT hr = StringFromGUID2( clsServer
- , szCLSID
- , CHARS_IN_GUID );
- ASSERT( SUCCEEDED(hr) );
-
- // create key
- //
- HKEY hkey;
- (void)StringCchPrintf( achTemp, NUMELMS(achTemp), TEXT("CLSID\\%ls"), szCLSID );
- LONG lreturn = RegCreateKey( HKEY_CLASSES_ROOT
- , (LPCTSTR)achTemp
- , &hkey );
- if( ERROR_SUCCESS != lreturn )
- {
- return AmHresultFromWin32(lreturn);
- }
-
- // set description string
- //
-
- (void)StringCchPrintf( achTemp, NUMELMS(achTemp), TEXT("%ls"), szDescription );
- lreturn = RegSetValue( hkey
- , (LPCTSTR)NULL
- , REG_SZ
- , achTemp
- , sizeof(achTemp) );
- if( ERROR_SUCCESS != lreturn )
- {
- RegCloseKey( hkey );
- return AmHresultFromWin32(lreturn);
- }
-
- // create CLSID\\{"CLSID"}\\"ServerType" key,
- // using key to CLSID\\{"CLSID"} passed back by
- // last call to RegCreateKey().
- //
- HKEY hsubkey;
-
- (void)StringCchPrintf( achTemp, NUMELMS(achTemp), TEXT("%ls"), szServerType );
- lreturn = RegCreateKey( hkey
- , achTemp
- , &hsubkey );
- if( ERROR_SUCCESS != lreturn )
- {
- RegCloseKey( hkey );
- return AmHresultFromWin32(lreturn);
- }
-
- // set Server string
- //
- (void)StringCchPrintf( achTemp, NUMELMS(achTemp), TEXT("%ls"), szFileName );
- lreturn = RegSetValue( hsubkey
- , (LPCTSTR)NULL
- , REG_SZ
- , (LPCTSTR)achTemp
- , sizeof(TCHAR) * (lstrlen(achTemp)+1) );
- if( ERROR_SUCCESS != lreturn )
- {
- RegCloseKey( hkey );
- RegCloseKey( hsubkey );
- return AmHresultFromWin32(lreturn);
- }
-
- (void)StringCchPrintf( achTemp, NUMELMS(achTemp), TEXT("%ls"), szThreadingModel );
- lreturn = RegSetValueEx( hsubkey
- , TEXT("ThreadingModel")
- , 0L
- , REG_SZ
- , (CONST BYTE *)achTemp
- , sizeof(TCHAR) * (lstrlen(achTemp)+1) );
-
- // close hkeys
- //
- RegCloseKey( hkey );
- RegCloseKey( hsubkey );
-
- // and return
- //
- return HRESULT_FROM_WIN32(lreturn);
+ // temp buffer
+ //
+ TCHAR achTemp[_MAX_PATH];
+
+ // convert CLSID uuid to string and write
+ // out subkey as string - CLSID\{}
+ //
+ OLECHAR szCLSID[CHARS_IN_GUID];
+ HRESULT hr = StringFromGUID2(clsServer
+ , szCLSID
+ , CHARS_IN_GUID);
+ ASSERT(SUCCEEDED(hr));
+
+ // create key
+ //
+ HKEY hkey;
+ (void)StringCchPrintf(achTemp, NUMELMS(achTemp), TEXT("CLSID\\%ls"), szCLSID);
+ LONG lreturn = RegCreateKey(HKEY_CLASSES_ROOT
+ , (LPCTSTR)achTemp
+ , &hkey);
+ if(ERROR_SUCCESS != lreturn)
+ {
+ return AmHresultFromWin32(lreturn);
+ }
+
+ // set description string
+ //
+
+ (void)StringCchPrintf(achTemp, NUMELMS(achTemp), TEXT("%ls"), szDescription);
+ lreturn = RegSetValue(hkey
+ , (LPCTSTR)NULL
+ , REG_SZ
+ , achTemp
+ , sizeof(achTemp));
+ if(ERROR_SUCCESS != lreturn)
+ {
+ RegCloseKey(hkey);
+ return AmHresultFromWin32(lreturn);
+ }
+
+ // create CLSID\\{"CLSID"}\\"ServerType" key,
+ // using key to CLSID\\{"CLSID"} passed back by
+ // last call to RegCreateKey().
+ //
+ HKEY hsubkey;
+
+ (void)StringCchPrintf(achTemp, NUMELMS(achTemp), TEXT("%ls"), szServerType);
+ lreturn = RegCreateKey(hkey
+ , achTemp
+ , &hsubkey);
+ if(ERROR_SUCCESS != lreturn)
+ {
+ RegCloseKey(hkey);
+ return AmHresultFromWin32(lreturn);
+ }
+
+ // set Server string
+ //
+ (void)StringCchPrintf(achTemp, NUMELMS(achTemp), TEXT("%ls"), szFileName);
+ lreturn = RegSetValue(hsubkey
+ , (LPCTSTR)NULL
+ , REG_SZ
+ , (LPCTSTR)achTemp
+ , sizeof(TCHAR) * (lstrlen(achTemp) + 1));
+ if(ERROR_SUCCESS != lreturn)
+ {
+ RegCloseKey(hkey);
+ RegCloseKey(hsubkey);
+ return AmHresultFromWin32(lreturn);
+ }
+
+ (void)StringCchPrintf(achTemp, NUMELMS(achTemp), TEXT("%ls"), szThreadingModel);
+ lreturn = RegSetValueEx(hsubkey
+ , TEXT("ThreadingModel")
+ , 0L
+ , REG_SZ
+ , (CONST BYTE *)achTemp
+ , sizeof(TCHAR) * (lstrlen(achTemp) + 1));
+
+ // close hkeys
+ //
+ RegCloseKey(hkey);
+ RegCloseKey(hsubkey);
+
+ // and return
+ //
+ return HRESULT_FROM_WIN32(lreturn);
}
@@ -216,29 +217,29 @@ AMovieSetupRegisterServer( CLSID clsServer
//---------------------------------------------------------------------------
STDAPI
-AMovieSetupUnregisterServer( CLSID clsServer )
+AMovieSetupUnregisterServer(CLSID clsServer)
{
- // convert CLSID uuid to string and write
- // out subkey CLSID\{}
- //
- OLECHAR szCLSID[CHARS_IN_GUID];
- HRESULT hr = StringFromGUID2( clsServer
- , szCLSID
- , CHARS_IN_GUID );
- ASSERT( SUCCEEDED(hr) );
-
- TCHAR achBuffer[MAX_KEY_LEN];
- (void)StringCchPrintf( achBuffer, NUMELMS(achBuffer), TEXT("CLSID\\%ls"), szCLSID );
-
- // delete subkey
- //
-
- hr = EliminateSubKey( HKEY_CLASSES_ROOT, achBuffer );
- ASSERT( SUCCEEDED(hr) );
-
- // return
- //
- return NOERROR;
+ // convert CLSID uuid to string and write
+ // out subkey CLSID\{}
+ //
+ OLECHAR szCLSID[CHARS_IN_GUID];
+ HRESULT hr = StringFromGUID2(clsServer
+ , szCLSID
+ , CHARS_IN_GUID);
+ ASSERT(SUCCEEDED(hr));
+
+ TCHAR achBuffer[MAX_KEY_LEN];
+ (void)StringCchPrintf(achBuffer, NUMELMS(achBuffer), TEXT("CLSID\\%ls"), szCLSID);
+
+ // delete subkey
+ //
+
+ hr = EliminateSubKey(HKEY_CLASSES_ROOT, achBuffer);
+ ASSERT(SUCCEEDED(hr));
+
+ // return
+ //
+ return NOERROR;
}
@@ -249,58 +250,58 @@ AMovieSetupUnregisterServer( CLSID clsServer )
//---------------------------------------------------------------------------
STDAPI
-AMovieSetupRegisterFilter2( const AMOVIESETUP_FILTER * const psetupdata
- , IFilterMapper2 * pIFM2
- , BOOL bRegister )
+AMovieSetupRegisterFilter2(const AMOVIESETUP_FILTER * const psetupdata
+ , IFilterMapper2 * pIFM2
+ , BOOL bRegister)
{
- DbgLog((LOG_TRACE, 3, TEXT("= AMovieSetupRegisterFilter")));
-
- // check we've got data
- //
- if( NULL == psetupdata ) return S_FALSE;
-
-
- // unregister filter
- // (as pins are subkeys of filter's CLSID key
- // they do not need to be removed separately).
- //
- DbgLog((LOG_TRACE, 3, TEXT("= = unregister filter")));
- HRESULT hr = pIFM2->UnregisterFilter(
- 0, // default category
- 0, // default instance name
- *psetupdata->clsID );
-
-
- if( bRegister )
- {
- REGFILTER2 rf2;
- rf2.dwVersion = 1;
- rf2.dwMerit = psetupdata->dwMerit;
- rf2.cPins = psetupdata->nPins;
- rf2.rgPins = psetupdata->lpPin;
-
- const CLSID *filterCategory=&psetupdata->filterCategory;
-
- // register filter
+ DbgLog((LOG_TRACE, 3, TEXT("= AMovieSetupRegisterFilter")));
+
+ // check we've got data
//
- DbgLog((LOG_TRACE, 3, TEXT("= = register filter")));
- hr = pIFM2->RegisterFilter(*psetupdata->clsID
- , psetupdata->strName
- , 0 // moniker
- ,filterCategory // category
- , NULL // instance
- , &rf2);
- }
-
- // handle one acceptable "error" - that
- // of filter not being registered!
- // (couldn't find a suitable #define'd
- // name for the error!)
- //
- if( 0x80070002 == hr)
- return NOERROR;
- else
- return hr;
+ if(NULL == psetupdata) return S_FALSE;
+
+
+ // unregister filter
+ // (as pins are subkeys of filter's CLSID key
+ // they do not need to be removed separately).
+ //
+ DbgLog((LOG_TRACE, 3, TEXT("= = unregister filter")));
+ HRESULT hr = pIFM2->UnregisterFilter(
+ 0, // default category
+ 0, // default instance name
+ *psetupdata->clsID);
+
+
+ if(bRegister)
+ {
+ REGFILTER2 rf2;
+ rf2.dwVersion = 1;
+ rf2.dwMerit = psetupdata->dwMerit;
+ rf2.cPins = psetupdata->nPins;
+ rf2.rgPins = psetupdata->lpPin;
+
+ const CLSID *filterCategory = &psetupdata->filterCategory;
+
+ // register filter
+ //
+ DbgLog((LOG_TRACE, 3, TEXT("= = register filter")));
+ hr = pIFM2->RegisterFilter(*psetupdata->clsID
+ , psetupdata->strName
+ , 0 // moniker
+ , filterCategory // category
+ , NULL // instance
+ , &rf2);
+ }
+
+ // handle one acceptable "error" - that
+ // of filter not being registered!
+ // (couldn't find a suitable #define'd
+ // name for the error!)
+ //
+ if(0x80070002 == hr)
+ return NOERROR;
+ else
+ return hr;
}
@@ -311,40 +312,40 @@ AMovieSetupRegisterFilter2( const AMOVIESETUP_FILTER * const psetupdata
//---------------------------------------------------------------------------
STDAPI
-RegisterAllServers( LPCWSTR szFileName, BOOL bRegister )
+RegisterAllServers(LPCWSTR szFileName, BOOL bRegister)
{
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- for( int i = 0; i < g_cTemplates; i++ )
- {
- // get i'th template
- //
- const CFactoryTemplate *pT = &g_Templates[i];
+ for(int i = 0; i < g_cTemplates; i++)
+ {
+ // get i'th template
+ //
+ const CFactoryTemplate *pT = &g_Templates[i];
- DbgLog((LOG_TRACE, 2, TEXT("- - register %ls"),
- (LPCWSTR)pT->m_Name ));
+ DbgLog((LOG_TRACE, 2, TEXT("- - register %ls"),
+ (LPCWSTR)pT->m_Name));
- // register CLSID and InprocServer32
- //
- if( bRegister )
- {
- hr = AMovieSetupRegisterServer( *(pT->m_ClsID)
- , (LPCWSTR)pT->m_Name
- , szFileName );
- }
- else
- {
- hr = AMovieSetupUnregisterServer( *(pT->m_ClsID) );
- }
+ // register CLSID and InprocServer32
+ //
+ if(bRegister)
+ {
+ hr = AMovieSetupRegisterServer(*(pT->m_ClsID)
+ , (LPCWSTR)pT->m_Name
+ , szFileName);
+ }
+ else
+ {
+ hr = AMovieSetupUnregisterServer(*(pT->m_ClsID));
+ }
- // check final error for this pass
- // and break loop if we failed
- //
- if( FAILED(hr) )
- break;
- }
+ // check final error for this pass
+ // and break loop if we failed
+ //
+ if(FAILED(hr))
+ break;
+ }
- return hr;
+ return hr;
}
@@ -367,147 +368,147 @@ RegisterAllServers( LPCWSTR szFileName, BOOL bRegister )
//---------------------------------------------------------------------------
STDAPI
-AMovieDllRegisterServer2( BOOL bRegister )
+AMovieDllRegisterServer2(BOOL bRegister)
{
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- DbgLog((LOG_TRACE, 2, TEXT("AMovieDllRegisterServer2()")));
+ DbgLog((LOG_TRACE, 2, TEXT("AMovieDllRegisterServer2()")));
- // get file name (where g_hInst is the
- // instance handle of the filter dll)
- //
- WCHAR achFileName[_MAX_PATH];
+ // get file name (where g_hInst is the
+ // instance handle of the filter dll)
+ //
+ WCHAR achFileName[_MAX_PATH];
- // WIN95 doesn't support GetModuleFileNameW
- //
- {
- char achTemp[_MAX_PATH];
+ // WIN95 doesn't support GetModuleFileNameW
+ //
+ {
+ char achTemp[_MAX_PATH];
- DbgLog((LOG_TRACE, 2, TEXT("- get module file name")));
+ DbgLog((LOG_TRACE, 2, TEXT("- get module file name")));
- // g_hInst handle is set in our dll entry point. Make sure
- // DllEntryPoint in dllentry.cpp is called
- ASSERT(g_hInst != 0);
+ // g_hInst handle is set in our dll entry point. Make sure
+ // DllEntryPoint in dllentry.cpp is called
+ ASSERT(g_hInst != 0);
- if( 0 == GetModuleFileNameA( g_hInst
- , achTemp
- , sizeof(achTemp) ) )
- {
- // we've failed!
- DWORD dwerr = GetLastError();
- return AmHresultFromWin32(dwerr);
+ if(0 == GetModuleFileNameA(g_hInst
+ , achTemp
+ , sizeof(achTemp)))
+ {
+ // we've failed!
+ DWORD dwerr = GetLastError();
+ return AmHresultFromWin32(dwerr);
+ }
+
+ MultiByteToWideChar(CP_ACP
+ , 0L
+ , achTemp
+ , lstrlenA(achTemp) + 1
+ , achFileName
+ , NUMELMS(achFileName));
}
- MultiByteToWideChar( CP_ACP
- , 0L
- , achTemp
- , lstrlenA(achTemp) + 1
- , achFileName
- , NUMELMS(achFileName) );
- }
-
- //
- // first registering, register all OLE servers
- //
- if( bRegister )
- {
- DbgLog((LOG_TRACE, 2, TEXT("- register OLE Servers")));
- hr = RegisterAllServers( achFileName, TRUE );
- }
-
- //
- // next, register/unregister all filters
- //
-
- if( SUCCEEDED(hr) )
- {
- // init is ref counted so call just in case
- // we're being called cold.
//
- DbgLog((LOG_TRACE, 2, TEXT("- CoInitialize")));
- hr = CoInitialize( (LPVOID)NULL );
- ASSERT( SUCCEEDED(hr) );
-
- // get hold of IFilterMapper2
+ // first registering, register all OLE servers
//
- DbgLog((LOG_TRACE, 2, TEXT("- obtain IFilterMapper2")));
- IFilterMapper2 *pIFM2 = 0;
- IFilterMapper *pIFM = 0;
- hr = CoCreateInstance( CLSID_FilterMapper2
- , NULL
- , CLSCTX_INPROC_SERVER
- , IID_IFilterMapper2
- , (void **)&pIFM2 );
- if(FAILED(hr))
+ if(bRegister)
{
- DbgLog((LOG_TRACE, 2, TEXT("- trying IFilterMapper instead")));
-
- hr = CoCreateInstance(
- CLSID_FilterMapper,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IFilterMapper,
- (void **)&pIFM);
+ DbgLog((LOG_TRACE, 2, TEXT("- register OLE Servers")));
+ hr = RegisterAllServers(achFileName, TRUE);
}
- if( SUCCEEDED(hr) )
+
+ //
+ // next, register/unregister all filters
+ //
+
+ if(SUCCEEDED(hr))
{
- // scan through array of CFactoryTemplates
- // registering servers and filters.
- //
- DbgLog((LOG_TRACE, 2, TEXT("- register Filters")));
- for( int i = 0; i < g_cTemplates; i++ )
- {
- // get i'th template
+ // init is ref counted so call just in case
+ // we're being called cold.
//
- const CFactoryTemplate *pT = &g_Templates[i];
+ DbgLog((LOG_TRACE, 2, TEXT("- CoInitialize")));
+ hr = CoInitialize((LPVOID)NULL);
+ ASSERT(SUCCEEDED(hr));
- if( NULL != pT->m_pAMovieSetup_Filter )
+ // get hold of IFilterMapper2
+ //
+ DbgLog((LOG_TRACE, 2, TEXT("- obtain IFilterMapper2")));
+ IFilterMapper2 *pIFM2 = 0;
+ IFilterMapper *pIFM = 0;
+ hr = CoCreateInstance(CLSID_FilterMapper2
+ , NULL
+ , CLSCTX_INPROC_SERVER
+ , IID_IFilterMapper2
+ , (void **)&pIFM2);
+ if(FAILED(hr))
{
- DbgLog((LOG_TRACE, 2, TEXT("- - register %ls"), (LPCWSTR)pT->m_Name ));
-
- if(pIFM2)
- {
- hr = AMovieSetupRegisterFilter2( pT->m_pAMovieSetup_Filter, pIFM2, bRegister );
- }
- else
- {
- hr = AMovieSetupRegisterFilter( pT->m_pAMovieSetup_Filter, pIFM, bRegister );
- }
+ DbgLog((LOG_TRACE, 2, TEXT("- trying IFilterMapper instead")));
+
+ hr = CoCreateInstance(
+ CLSID_FilterMapper,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_IFilterMapper,
+ (void **)&pIFM);
}
+ if(SUCCEEDED(hr))
+ {
+ // scan through array of CFactoryTemplates
+ // registering servers and filters.
+ //
+ DbgLog((LOG_TRACE, 2, TEXT("- register Filters")));
+ for(int i = 0; i < g_cTemplates; i++)
+ {
+ // get i'th template
+ //
+ const CFactoryTemplate *pT = &g_Templates[i];
+
+ if(NULL != pT->m_pAMovieSetup_Filter)
+ {
+ DbgLog((LOG_TRACE, 2, TEXT("- - register %ls"), (LPCWSTR)pT->m_Name));
+
+ if(pIFM2)
+ {
+ hr = AMovieSetupRegisterFilter2(pT->m_pAMovieSetup_Filter, pIFM2, bRegister);
+ }
+ else
+ {
+ hr = AMovieSetupRegisterFilter(pT->m_pAMovieSetup_Filter, pIFM, bRegister);
+ }
+ }
+
+ // check final error for this pass
+ // and break loop if we failed
+ //
+ if(FAILED(hr))
+ break;
+ }
+
+ // release interface
+ //
+ if(pIFM2)
+ pIFM2->Release();
+ else
+ pIFM->Release();
- // check final error for this pass
- // and break loop if we failed
- //
- if( FAILED(hr) )
- break;
- }
-
- // release interface
- //
- if(pIFM2)
- pIFM2->Release();
- else
- pIFM->Release();
+ }
+ // and clear up
+ //
+ CoFreeUnusedLibraries();
+ CoUninitialize();
}
- // and clear up
//
- CoFreeUnusedLibraries();
- CoUninitialize();
- }
-
- //
- // if unregistering, unregister all OLE servers
- //
- if( SUCCEEDED(hr) && !bRegister )
- {
- DbgLog((LOG_TRACE, 2, TEXT("- register OLE Servers")));
- hr = RegisterAllServers( achFileName, FALSE );
- }
-
- DbgLog((LOG_TRACE, 2, TEXT("- return %0x"), hr));
- return hr;
+ // if unregistering, unregister all OLE servers
+ //
+ if(SUCCEEDED(hr) && !bRegister)
+ {
+ DbgLog((LOG_TRACE, 2, TEXT("- register OLE Servers")));
+ hr = RegisterAllServers(achFileName, FALSE);
+ }
+
+ DbgLog((LOG_TRACE, 2, TEXT("- return %0x"), hr));
+ return hr;
}
@@ -531,90 +532,90 @@ AMovieDllRegisterServer2( BOOL bRegister )
STDAPI
-AMovieDllRegisterServer( void )
+AMovieDllRegisterServer(void)
{
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
- // get file name (where g_hInst is the
- // instance handle of the filter dll)
- //
- WCHAR achFileName[_MAX_PATH];
-
- {
- // WIN95 doesn't support GetModuleFileNameW
+ // get file name (where g_hInst is the
+ // instance handle of the filter dll)
//
- char achTemp[_MAX_PATH];
+ WCHAR achFileName[_MAX_PATH];
- if( 0 == GetModuleFileNameA( g_hInst
- , achTemp
- , sizeof(achTemp) ) )
{
- // we've failed!
- DWORD dwerr = GetLastError();
- return AmHresultFromWin32(dwerr);
- }
+ // WIN95 doesn't support GetModuleFileNameW
+ //
+ char achTemp[_MAX_PATH];
- MultiByteToWideChar( CP_ACP
- , 0L
- , achTemp
- , lstrlenA(achTemp) + 1
- , achFileName
- , NUMELMS(achFileName) );
- }
-
- // scan through array of CFactoryTemplates
- // registering servers and filters.
- //
- for( int i = 0; i < g_cTemplates; i++ )
- {
- // get i'th template
- //
- const CFactoryTemplate *pT = &g_Templates[i];
+ if(0 == GetModuleFileNameA(g_hInst
+ , achTemp
+ , sizeof(achTemp)))
+ {
+ // we've failed!
+ DWORD dwerr = GetLastError();
+ return AmHresultFromWin32(dwerr);
+ }
- // register CLSID and InprocServer32
- //
- hr = AMovieSetupRegisterServer( *(pT->m_ClsID)
- , (LPCWSTR)pT->m_Name
- , achFileName );
+ MultiByteToWideChar(CP_ACP
+ , 0L
+ , achTemp
+ , lstrlenA(achTemp) + 1
+ , achFileName
+ , NUMELMS(achFileName));
+ }
- // instantiate all servers and get hold of
- // IAMovieSetup, if implemented, and call
- // IAMovieSetup.Register() method
+ // scan through array of CFactoryTemplates
+ // registering servers and filters.
//
- if( SUCCEEDED(hr) && (NULL != pT->m_lpfnNew) )
+ for(int i = 0; i < g_cTemplates; i++)
{
- // instantiate object
- //
- PAMOVIESETUP psetup;
- hr = CoCreateInstance( *(pT->m_ClsID)
- , 0
- , CLSCTX_INPROC_SERVER
- , IID_IAMovieSetup
- , reinterpret_cast<void**>(&psetup) );
- if( SUCCEEDED(hr) )
- {
- hr = psetup->Unregister();
- if( SUCCEEDED(hr) )
- hr = psetup->Register();
- psetup->Release();
- }
- else
- {
- if( (E_NOINTERFACE == hr )
- || (VFW_E_NEED_OWNER == hr ) )
- hr = NOERROR;
- }
- }
+ // get i'th template
+ //
+ const CFactoryTemplate *pT = &g_Templates[i];
- // check final error for this pass
- // and break loop if we failed
- //
- if( FAILED(hr) )
- break;
+ // register CLSID and InprocServer32
+ //
+ hr = AMovieSetupRegisterServer(*(pT->m_ClsID)
+ , (LPCWSTR)pT->m_Name
+ , achFileName);
- } // end-for
+ // instantiate all servers and get hold of
+ // IAMovieSetup, if implemented, and call
+ // IAMovieSetup.Register() method
+ //
+ if(SUCCEEDED(hr) && (NULL != pT->m_lpfnNew))
+ {
+ // instantiate object
+ //
+ PAMOVIESETUP psetup;
+ hr = CoCreateInstance(*(pT->m_ClsID)
+ , 0
+ , CLSCTX_INPROC_SERVER
+ , IID_IAMovieSetup
+ , reinterpret_cast<void**>(&psetup));
+ if(SUCCEEDED(hr))
+ {
+ hr = psetup->Unregister();
+ if(SUCCEEDED(hr))
+ hr = psetup->Register();
+ psetup->Release();
+ }
+ else
+ {
+ if((E_NOINTERFACE == hr)
+ || (VFW_E_NEED_OWNER == hr))
+ hr = NOERROR;
+ }
+ }
- return hr;
+ // check final error for this pass
+ // and break loop if we failed
+ //
+ if(FAILED(hr))
+ break;
+
+ } // end-for
+
+ return hr;
}
@@ -639,57 +640,57 @@ AMovieDllRegisterServer( void )
STDAPI
AMovieDllUnregisterServer()
{
- // initialize return code
- //
- HRESULT hr = NOERROR;
-
- // scan through CFactory template and unregister
- // all OLE servers and filters.
- //
- for( int i = g_cTemplates; i--; )
- {
- // get i'th template
+ // initialize return code
//
- const CFactoryTemplate *pT = &g_Templates[i];
+ HRESULT hr = NOERROR;
- // check method exists
+ // scan through CFactory template and unregister
+ // all OLE servers and filters.
//
- if( NULL != pT->m_lpfnNew )
+ for(int i = g_cTemplates; i--;)
{
- // instantiate object
- //
- PAMOVIESETUP psetup;
- hr = CoCreateInstance( *(pT->m_ClsID)
- , 0
- , CLSCTX_INPROC_SERVER
- , IID_IAMovieSetup
- , reinterpret_cast<void**>(&psetup) );
- if( SUCCEEDED(hr) )
- {
- hr = psetup->Unregister();
- psetup->Release();
- }
- else
- {
- if( (E_NOINTERFACE == hr )
- || (VFW_E_NEED_OWNER == hr ) )
- hr = NOERROR;
- }
- }
+ // get i'th template
+ //
+ const CFactoryTemplate *pT = &g_Templates[i];
- // unregister CLSID and InprocServer32
- //
- if( SUCCEEDED(hr) )
- {
- hr = AMovieSetupUnregisterServer( *(pT->m_ClsID) );
- }
+ // check method exists
+ //
+ if(NULL != pT->m_lpfnNew)
+ {
+ // instantiate object
+ //
+ PAMOVIESETUP psetup;
+ hr = CoCreateInstance(*(pT->m_ClsID)
+ , 0
+ , CLSCTX_INPROC_SERVER
+ , IID_IAMovieSetup
+ , reinterpret_cast<void**>(&psetup));
+ if(SUCCEEDED(hr))
+ {
+ hr = psetup->Unregister();
+ psetup->Release();
+ }
+ else
+ {
+ if((E_NOINTERFACE == hr)
+ || (VFW_E_NEED_OWNER == hr))
+ hr = NOERROR;
+ }
+ }
- // check final error for this pass
- // and break loop if we failed
- //
- if( FAILED(hr) )
- break;
- }
+ // unregister CLSID and InprocServer32
+ //
+ if(SUCCEEDED(hr))
+ {
+ hr = AMovieSetupUnregisterServer(*(pT->m_ClsID));
+ }
- return hr;
+ // check final error for this pass
+ // and break loop if we failed
+ //
+ if(FAILED(hr))
+ break;
+ }
+
+ return hr;
}
diff --git a/src/filters/BaseClasses/dllsetup.h b/src/filters/BaseClasses/dllsetup.h
index e363b8b6a..f532fa857 100644
--- a/src/filters/BaseClasses/dllsetup.h
+++ b/src/filters/BaseClasses/dllsetup.h
@@ -31,16 +31,16 @@
// AMovieDllRegisterServer calls IAMovieSetup.Register(), and
// AMovieDllUnregisterServer calls IAMovieSetup.Unregister().
-STDAPI AMovieDllRegisterServer2( BOOL );
+STDAPI AMovieDllRegisterServer2(BOOL);
STDAPI AMovieDllRegisterServer();
STDAPI AMovieDllUnregisterServer();
// helper functions
-STDAPI EliminateSubKey( HKEY, LPCTSTR );
+STDAPI EliminateSubKey(HKEY, LPCTSTR);
STDAPI
-AMovieSetupRegisterFilter2( const AMOVIESETUP_FILTER * const psetupdata
- , IFilterMapper2 * pIFM2
- , BOOL bRegister );
+AMovieSetupRegisterFilter2(const AMOVIESETUP_FILTER * const psetupdata
+ , IFilterMapper2 * pIFM2
+ , BOOL bRegister);
diff --git a/src/filters/BaseClasses/dxmperf.h b/src/filters/BaseClasses/dxmperf.h
index 54a21203b..f496a2f9e 100644
--- a/src/filters/BaseClasses/dxmperf.h
+++ b/src/filters/BaseClasses/dxmperf.h
@@ -14,19 +14,21 @@
#include "perflog.h"
#ifdef _IA64_
-extern "C" unsigned __int64 __getReg( int whichReg );
+extern "C" unsigned __int64 __getReg(int whichReg);
#pragma intrinsic(__getReg)
#endif // _IA64_
-inline ULONGLONG _RDTSC( void ) {
+inline ULONGLONG _RDTSC(void)
+{
#ifdef _X86_
LARGE_INTEGER li;
- __asm {
+ __asm
+ {
_emit 0x0F
_emit 0x31
- mov li.LowPart,eax
- mov li.HighPart,edx
+ mov li.LowPart, eax
+ mov li.HighPart, edx
}
return li.QuadPart;
@@ -35,7 +37,7 @@ inline ULONGLONG _RDTSC( void ) {
#elif defined (_IA64_)
#define INL_REGID_APITC 3116
- return __getReg( INL_REGID_APITC );
+ return __getReg(INL_REGID_APITC);
#endif // 0
@@ -216,7 +218,7 @@ inline ULONGLONG _RDTSC( void ) {
perfData.data.sampleDuration = (msecs); \
PerflogTraceEvent ((PEVENT_TRACE_HEADER) &perfData); \
} \
-
+
inline
VOID PERFLOG_STREAMTRACE(
@@ -227,13 +229,13 @@ VOID PERFLOG_STREAMTRACE(
ULONGLONG Data2,
ULONGLONG Data3,
ULONGLONG Data4
- )
+)
{
- if (Level <= PerflogModuleLevel)
+ if(Level <= PerflogModuleLevel)
{
PERFINFO_WMI_STREAMTRACE perfData;
- memset( &perfData, 0, sizeof( perfData ) );
- perfData.header.Size = sizeof( perfData );
+ memset(&perfData, 0, sizeof(perfData));
+ perfData.header.Size = sizeof(perfData);
perfData.header.Flags = WNODE_FLAG_TRACED_GUID;
perfData.header.Guid = GUID_STREAMTRACE;
perfData.data.dshowClock = DShowClock;
diff --git a/src/filters/BaseClasses/fourcc.h b/src/filters/BaseClasses/fourcc.h
index 19c0fcdbc..34e828c21 100644
--- a/src/filters/BaseClasses/fourcc.h
+++ b/src/filters/BaseClasses/fourcc.h
@@ -51,7 +51,8 @@ private:
#define GUID_Data4_2 0x719b3800
inline void
-FOURCCMap::InitGUID() {
+FOURCCMap::InitGUID()
+{
Data2 = GUID_Data2;
Data3 = GUID_Data3;
((DWORD *)Data4)[0] = GUID_Data4_1;
@@ -59,9 +60,10 @@ FOURCCMap::InitGUID() {
}
inline
-FOURCCMap::FOURCCMap() {
+FOURCCMap::FOURCCMap()
+{
InitGUID();
- SetFOURCC( DWORD(0));
+ SetFOURCC(DWORD(0));
}
inline
diff --git a/src/filters/BaseClasses/measure.h b/src/filters/BaseClasses/measure.h
index a71a07532..dd4d588eb 100644
--- a/src/filters/BaseClasses/measure.h
+++ b/src/filters/BaseClasses/measure.h
@@ -148,23 +148,23 @@ extern "C" {
// This must be called first - (called by the DllEntry)
-void WINAPI Msr_Init(void);
+ void WINAPI Msr_Init(void);
// Call this last to clean up (or just let it fall off the end - who cares?)
-void WINAPI Msr_Terminate(void);
+ void WINAPI Msr_Terminate(void);
// Call this to get an Id for an "incident" that you can pass to Start, Stop or Note
// everything that's logged is called an "incident".
-int WINAPI Msr_Register(__in LPTSTR Incident);
+ int WINAPI Msr_Register(__in LPTSTR Incident);
// Reset the statistical counts for an incident
-void WINAPI Msr_Reset(int Id);
+ void WINAPI Msr_Reset(int Id);
// Reset all the counts for all incidents
@@ -172,26 +172,26 @@ void WINAPI Msr_Reset(int Id);
#define MSR_PAUSE 1
#define MSR_RUN 2
-void WINAPI Msr_Control(int iAction);
+ void WINAPI Msr_Control(int iAction);
// log the start of an operation
-void WINAPI Msr_Start(int Id);
+ void WINAPI Msr_Start(int Id);
// log the end of an operation
-void WINAPI Msr_Stop(int Id);
+ void WINAPI Msr_Stop(int Id);
// log a one-off or repetitive operation
-void WINAPI Msr_Note(int Id);
+ void WINAPI Msr_Note(int Id);
// log an integer (on which we can see statistics later)
-void WINAPI Msr_Integer(int Id, int n);
+ void WINAPI Msr_Integer(int Id, int n);
// print out all the vaialable log (it may have wrapped) and then the statistics.
@@ -199,20 +199,20 @@ void WINAPI Msr_Integer(int Id, int n);
// hFIle==NULL => use DbgLog
// otherwise hFile must have come from CreateFile or OpenFile.
-void WINAPI Msr_Dump(HANDLE hFile);
+ void WINAPI Msr_Dump(HANDLE hFile);
// just dump the statistics - never mind the log
-void WINAPI Msr_DumpStats(HANDLE hFile);
+ void WINAPI Msr_DumpStats(HANDLE hFile);
// Type definitions in case you want to declare a pointer to the dump functions
// (makes it a trifle easier to do dynamic linking
// i.e. LoadModule, GetProcAddress and call that)
// Typedefs so can declare MSR_DUMPPROC *MsrDumpStats; or whatever
-typedef void WINAPI MSR_DUMPPROC(HANDLE hFile);
-typedef void WINAPI MSR_CONTROLPROC(int iAction);
+ typedef void WINAPI MSR_DUMPPROC(HANDLE hFile);
+ typedef void WINAPI MSR_CONTROLPROC(int iAction);
#ifdef __cplusplus
diff --git a/src/filters/BaseClasses/msgthrd.h b/src/filters/BaseClasses/msgthrd.h
index 45adc01cf..b91797441 100644
--- a/src/filters/BaseClasses/msgthrd.h
+++ b/src/filters/BaseClasses/msgthrd.h
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// File: MsgThrd.h
//
-// Desc: DirectShow base classes - provides support for a worker thread
+// Desc: DirectShow base classes - provides support for a worker thread
// class to which one can asynchronously post messages.
//
// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
@@ -10,7 +10,8 @@
// Message class - really just a structure.
//
-class CMsg {
+class CMsg
+{
public:
UINT uMsg;
DWORD dwFlags;
@@ -29,7 +30,8 @@ public:
// that it is prompted to perform particaular tasks by responding to messages
// posted to its message queue.
//
-class AM_NOVTABLE CMsgThread {
+class AM_NOVTABLE CMsgThread
+{
private:
static DWORD WINAPI DefaultThreadProc(__inout LPVOID lpParam);
DWORD m_ThreadId;
@@ -47,13 +49,13 @@ protected:
public:
CMsgThread()
: m_ThreadId(0),
- m_hThread(NULL),
- m_lWaiting(0),
- m_hSem(NULL),
- // make a list with a cache of 5 items
- m_ThreadQueue(NAME("MsgThread list"), 5)
- {
- }
+ m_hThread(NULL),
+ m_lWaiting(0),
+ m_hSem(NULL),
+ // make a list with a cache of 5 items
+ m_ThreadQueue(NAME("MsgThread list"), 5)
+ {
+ }
~CMsgThread();
// override this if you want to block on other things as well
@@ -61,50 +63,61 @@ public:
void virtual GetThreadMsg(__out CMsg *msg);
// override this if you want to do something on thread startup
- virtual void OnThreadInit() {
+ virtual void OnThreadInit()
+ {
};
BOOL CreateThread();
- BOOL WaitForThreadExit(__out LPDWORD lpdwExitCode) {
- if (m_hThread != NULL) {
+ BOOL WaitForThreadExit(__out LPDWORD lpdwExitCode)
+ {
+ if(m_hThread != NULL)
+ {
WaitForSingleObject(m_hThread, INFINITE);
return GetExitCodeThread(m_hThread, lpdwExitCode);
}
return FALSE;
}
- DWORD ResumeThread() {
+ DWORD ResumeThread()
+ {
return ::ResumeThread(m_hThread);
}
- DWORD SuspendThread() {
+ DWORD SuspendThread()
+ {
return ::SuspendThread(m_hThread);
}
- int GetThreadPriority() {
+ int GetThreadPriority()
+ {
return ::GetThreadPriority(m_hThread);
}
- BOOL SetThreadPriority(int nPriority) {
+ BOOL SetThreadPriority(int nPriority)
+ {
return ::SetThreadPriority(m_hThread, nPriority);
}
- HANDLE GetThreadHandle() {
+ HANDLE GetThreadHandle()
+ {
return m_hThread;
}
- DWORD GetThreadId() {
+ DWORD GetThreadId()
+ {
return m_ThreadId;
}
void PutThreadMsg(UINT uMsg, DWORD dwMsgFlags,
- __in_opt LPVOID lpMsgParam, __in_opt CAMEvent *pEvent = NULL) {
+ __in_opt LPVOID lpMsgParam, __in_opt CAMEvent *pEvent = NULL)
+ {
CAutoLock lck(&m_Lock);
CMsg* pMsg = new CMsg(uMsg, dwMsgFlags, lpMsgParam, pEvent);
m_ThreadQueue.AddTail(pMsg);
- if (m_lWaiting != 0) {
+ if(m_lWaiting != 0)
+ {
ReleaseSemaphore(m_hSem, m_lWaiting, 0);
m_lWaiting = 0;
}
diff --git a/src/filters/BaseClasses/mtype.cpp b/src/filters/BaseClasses/mtype.cpp
index fffbcf797..9feb3e0f8 100644
--- a/src/filters/BaseClasses/mtype.cpp
+++ b/src/filters/BaseClasses/mtype.cpp
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// File: MType.cpp
//
-// Desc: DirectShow base classes - implements a class that holds and
+// Desc: DirectShow base classes - implements a class that holds and
// manages media type information.
//
// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
@@ -15,7 +15,8 @@
#include <streams.h>
#include <mmreg.h>
-CMediaType::~CMediaType(){
+CMediaType::~CMediaType()
+{
FreeMediaType(*this);
}
@@ -38,7 +39,8 @@ CMediaType::CMediaType(const GUID * type)
CMediaType::CMediaType(const AM_MEDIA_TYPE& rt, __out_opt HRESULT* phr)
{
HRESULT hr = CopyMediaType(this, &rt);
- if (FAILED(hr) && (NULL != phr)) {
+ if(FAILED(hr) && (NULL != phr))
+ {
*phr = hr;
}
}
@@ -47,7 +49,8 @@ CMediaType::CMediaType(const AM_MEDIA_TYPE& rt, __out_opt HRESULT* phr)
CMediaType::CMediaType(const CMediaType& rt, __out_opt HRESULT* phr)
{
HRESULT hr = CopyMediaType(this, &rt);
- if (FAILED(hr) && (NULL != phr)) {
+ if(FAILED(hr) && (NULL != phr))
+ {
*phr = hr;
}
}
@@ -82,13 +85,13 @@ CMediaType::operator == (const CMediaType& rt) const
// the particular format representation can still see them, but
// they should duplicate information in the format block.
- return ((IsEqualGUID(majortype,rt.majortype) == TRUE) &&
- (IsEqualGUID(subtype,rt.subtype) == TRUE) &&
- (IsEqualGUID(formattype,rt.formattype) == TRUE) &&
- (cbFormat == rt.cbFormat) &&
- ( (cbFormat == 0) ||
- pbFormat != NULL && rt.pbFormat != NULL &&
- (memcmp(pbFormat, rt.pbFormat, cbFormat) == 0)));
+ return ((IsEqualGUID(majortype, rt.majortype) == TRUE) &&
+ (IsEqualGUID(subtype, rt.subtype) == TRUE) &&
+ (IsEqualGUID(formattype, rt.formattype) == TRUE) &&
+ (cbFormat == rt.cbFormat) &&
+ ((cbFormat == 0) ||
+ pbFormat != NULL && rt.pbFormat != NULL &&
+ (memcmp(pbFormat, rt.pbFormat, cbFormat) == 0)));
}
@@ -97,7 +100,8 @@ CMediaType::operator != (const CMediaType& rt) const
{
/* Check to see if they are equal */
- if (*this == rt) {
+ if(*this == rt)
+ {
return FALSE;
}
return TRUE;
@@ -114,22 +118,24 @@ CMediaType::Set(const CMediaType& rt)
HRESULT
CMediaType::Set(const AM_MEDIA_TYPE& rt)
{
- if (&rt != this) {
+ if(&rt != this)
+ {
FreeMediaType(*this);
HRESULT hr = CopyMediaType(this, &rt);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return E_OUTOFMEMORY;
}
}
- return S_OK;
+ return S_OK;
}
BOOL
CMediaType::IsValid() const
{
- return (!IsEqualGUID(majortype,GUID_NULL));
+ return (!IsEqualGUID(majortype, GUID_NULL));
}
@@ -148,20 +154,28 @@ CMediaType::SetSubtype(const GUID* ptype)
ULONG
-CMediaType::GetSampleSize() const {
- if (IsFixedSize()) {
+CMediaType::GetSampleSize() const
+{
+ if(IsFixedSize())
+ {
return lSampleSize;
- } else {
+ }
+ else
+ {
return 0;
}
}
void
-CMediaType::SetSampleSize(ULONG sz) {
- if (sz == 0) {
+CMediaType::SetSampleSize(ULONG sz)
+{
+ if(sz == 0)
+ {
SetVariableSize();
- } else {
+ }
+ else
+ {
bFixedSizeSamples = TRUE;
lSampleSize = sz;
}
@@ -169,21 +183,23 @@ CMediaType::SetSampleSize(ULONG sz) {
void
-CMediaType::SetVariableSize() {
+CMediaType::SetVariableSize()
+{
bFixedSizeSamples = FALSE;
}
void
-CMediaType::SetTemporalCompression(BOOL bCompressed) {
+CMediaType::SetTemporalCompression(BOOL bCompressed)
+{
bTemporalCompression = bCompressed;
}
BOOL
CMediaType::SetFormat(__in_bcount(cb) BYTE * pformat, ULONG cb)
{
- if (NULL == AllocFormatBuffer(cb))
- return(FALSE);
+ if(NULL == AllocFormatBuffer(cb))
+ return(FALSE);
ASSERT(pbFormat);
memcpy(pbFormat, pformat, cb);
@@ -207,7 +223,8 @@ CMediaType::SetFormatType(const GUID *pformattype)
void CMediaType::ResetFormatBuffer()
{
- if (cbFormat) {
+ if(cbFormat)
+ {
CoTaskMemFree((PVOID)pbFormat);
}
cbFormat = 0;
@@ -226,21 +243,24 @@ CMediaType::AllocFormatBuffer(ULONG length)
// do the types have the same buffer size
- if (cbFormat == length) {
+ if(cbFormat == length)
+ {
return pbFormat;
}
// allocate the new format buffer
BYTE *pNewFormat = (PBYTE)CoTaskMemAlloc(length);
- if (pNewFormat == NULL) {
- if (length <= cbFormat) return pbFormat; //reuse the old block anyway.
+ if(pNewFormat == NULL)
+ {
+ if(length <= cbFormat) return pbFormat; //reuse the old block anyway.
return NULL;
}
// delete the old format
- if (cbFormat != 0) {
+ if(cbFormat != 0)
+ {
ASSERT(pbFormat);
CoTaskMemFree((PVOID)pbFormat);
}
@@ -263,24 +283,27 @@ CMediaType::ReallocFormatBuffer(ULONG length)
// do the types have the same buffer size
- if (cbFormat == length) {
+ if(cbFormat == length)
+ {
return pbFormat;
}
// allocate the new format buffer
BYTE *pNewFormat = (PBYTE)CoTaskMemAlloc(length);
- if (pNewFormat == NULL) {
- if (length <= cbFormat) return pbFormat; //reuse the old block anyway.
+ if(pNewFormat == NULL)
+ {
+ if(length <= cbFormat) return pbFormat; //reuse the old block anyway.
return NULL;
}
// copy any previous format (or part of if new is smaller)
// delete the old format and replace with the new one
- if (cbFormat != 0) {
+ if(cbFormat != 0)
+ {
ASSERT(pbFormat);
- memcpy(pNewFormat,pbFormat,min(length,cbFormat));
+ memcpy(pNewFormat, pbFormat, min(length, cbFormat));
CoTaskMemFree((PVOID)pbFormat);
}
@@ -305,10 +328,13 @@ void CMediaType::InitMediaType()
BOOL
CMediaType::IsPartiallySpecified(void) const
{
- if ((majortype == GUID_NULL) ||
- (formattype == GUID_NULL)) {
- return TRUE;
- } else {
+ if((majortype == GUID_NULL) ||
+ (formattype == GUID_NULL))
+ {
+ return TRUE;
+ }
+ else
+ {
return FALSE;
}
}
@@ -316,26 +342,32 @@ CMediaType::IsPartiallySpecified(void) const
BOOL
CMediaType::MatchesPartial(const CMediaType* ppartial) const
{
- if ((ppartial->majortype != GUID_NULL) &&
- (majortype != ppartial->majortype)) {
- return FALSE;
+ if((ppartial->majortype != GUID_NULL) &&
+ (majortype != ppartial->majortype))
+ {
+ return FALSE;
}
- if ((ppartial->subtype != GUID_NULL) &&
- (subtype != ppartial->subtype)) {
- return FALSE;
+ if((ppartial->subtype != GUID_NULL) &&
+ (subtype != ppartial->subtype))
+ {
+ return FALSE;
}
- if (ppartial->formattype != GUID_NULL) {
+ if(ppartial->formattype != GUID_NULL)
+ {
// if the format block is specified then it must match exactly
- if (formattype != ppartial->formattype) {
+ if(formattype != ppartial->formattype)
+ {
return FALSE;
}
- if (cbFormat != ppartial->cbFormat) {
+ if(cbFormat != ppartial->cbFormat)
+ {
return FALSE;
}
- if ((cbFormat != 0) &&
- (memcmp(pbFormat, ppartial->pbFormat, cbFormat) != 0)) {
- return FALSE;
+ if((cbFormat != 0) &&
+ (memcmp(pbFormat, ppartial->pbFormat, cbFormat) != 0))
+ {
+ return FALSE;
}
}
@@ -354,7 +386,8 @@ void WINAPI DeleteMediaType(__inout_opt AM_MEDIA_TYPE *pmt)
{
// allow NULL pointers for coding simplicity
- if (pmt == NULL) {
+ if(pmt == NULL)
+ {
return;
}
@@ -377,13 +410,15 @@ AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const *pSrc)
AM_MEDIA_TYPE *pMediaType =
(AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- if (pMediaType == NULL) {
+ if(pMediaType == NULL)
+ {
return NULL;
}
// Copy the variable length format block
- HRESULT hr = CopyMediaType(pMediaType,pSrc);
- if (FAILED(hr)) {
+ HRESULT hr = CopyMediaType(pMediaType, pSrc);
+ if(FAILED(hr))
+ {
CoTaskMemFree((PVOID)pMediaType);
return NULL;
}
@@ -400,18 +435,23 @@ HRESULT WINAPI CopyMediaType(__out AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE
// case we can check like that - copying to itself.
ASSERT(pmtSource != pmtTarget);
*pmtTarget = *pmtSource;
- if (pmtSource->cbFormat != 0) {
+ if(pmtSource->cbFormat != 0)
+ {
ASSERT(pmtSource->pbFormat != NULL);
pmtTarget->pbFormat = (PBYTE)CoTaskMemAlloc(pmtSource->cbFormat);
- if (pmtTarget->pbFormat == NULL) {
+ if(pmtTarget->pbFormat == NULL)
+ {
pmtTarget->cbFormat = 0;
return E_OUTOFMEMORY;
- } else {
+ }
+ else
+ {
CopyMemory((PVOID)pmtTarget->pbFormat, (PVOID)pmtSource->pbFormat,
pmtTarget->cbFormat);
}
}
- if (pmtTarget->pUnk != NULL) {
+ if(pmtTarget->pUnk != NULL)
+ {
pmtTarget->pUnk->AddRef();
}
@@ -422,14 +462,16 @@ HRESULT WINAPI CopyMediaType(__out AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE
void WINAPI FreeMediaType(__inout AM_MEDIA_TYPE& mt)
{
- if (mt.cbFormat != 0) {
+ if(mt.cbFormat != 0)
+ {
CoTaskMemFree((PVOID)mt.pbFormat);
// Strictly unnecessary but tidier
mt.cbFormat = 0;
mt.pbFormat = NULL;
}
- if (mt.pUnk != NULL) {
+ if(mt.pUnk != NULL)
+ {
mt.pUnk->Release();
mt.pUnk = NULL;
}
@@ -444,9 +486,12 @@ STDAPI CreateAudioMediaType(
)
{
pmt->majortype = MEDIATYPE_Audio;
- if (pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
+ if(pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
+ {
pmt->subtype = ((PWAVEFORMATEXTENSIBLE)pwfx)->SubFormat;
- } else {
+ }
+ else
+ {
pmt->subtype = FOURCCMap(pwfx->wFormatTag);
}
pmt->formattype = FORMAT_WaveFormatEx;
@@ -454,20 +499,28 @@ STDAPI CreateAudioMediaType(
pmt->bTemporalCompression = FALSE;
pmt->lSampleSize = pwfx->nBlockAlign;
pmt->pUnk = NULL;
- if (bSetFormat) {
- if (pwfx->wFormatTag == WAVE_FORMAT_PCM) {
+ if(bSetFormat)
+ {
+ if(pwfx->wFormatTag == WAVE_FORMAT_PCM)
+ {
pmt->cbFormat = sizeof(WAVEFORMATEX);
- } else {
+ }
+ else
+ {
pmt->cbFormat = sizeof(WAVEFORMATEX) + pwfx->cbSize;
}
pmt->pbFormat = (PBYTE)CoTaskMemAlloc(pmt->cbFormat);
- if (pmt->pbFormat == NULL) {
+ if(pmt->pbFormat == NULL)
+ {
return E_OUTOFMEMORY;
}
- if (pwfx->wFormatTag == WAVE_FORMAT_PCM) {
+ if(pwfx->wFormatTag == WAVE_FORMAT_PCM)
+ {
CopyMemory(pmt->pbFormat, pwfx, sizeof(PCMWAVEFORMAT));
((WAVEFORMATEX *)pmt->pbFormat)->cbSize = 0;
- } else {
+ }
+ else
+ {
CopyMemory(pmt->pbFormat, pwfx, pmt->cbFormat);
}
}
diff --git a/src/filters/BaseClasses/mtype.h b/src/filters/BaseClasses/mtype.h
index fc2fe53ee..0b79f089d 100644
--- a/src/filters/BaseClasses/mtype.h
+++ b/src/filters/BaseClasses/mtype.h
@@ -15,7 +15,8 @@
types etc. Has same data members as the struct AM_MEDIA_TYPE defined
in the streams IDL file, but also has (non-virtual) functions */
-class CMediaType : public _AMMediaType {
+class CMediaType : public _AMMediaType
+{
public:
@@ -36,13 +37,25 @@ public:
BOOL IsValid() const;
- const GUID *Type() const { return &majortype;} ;
+ const GUID *Type() const
+ {
+ return &majortype;
+ } ;
void SetType(const GUID *);
- const GUID *Subtype() const { return &subtype;} ;
+ const GUID *Subtype() const
+ {
+ return &subtype;
+ } ;
void SetSubtype(const GUID *);
- BOOL IsFixedSize() const {return bFixedSizeSamples; };
- BOOL IsTemporalCompressed() const {return bTemporalCompression; };
+ BOOL IsFixedSize() const
+ {
+ return bFixedSizeSamples;
+ };
+ BOOL IsTemporalCompressed() const
+ {
+ return bTemporalCompression;
+ };
ULONG GetSampleSize() const;
void SetSampleSize(ULONG sz);
@@ -52,11 +65,20 @@ public:
// read/write pointer to format - can't change length without
// calling SetFormat, AllocFormatBuffer or ReallocFormatBuffer
- BYTE* Format() const {return pbFormat; };
- ULONG FormatLength() const { return cbFormat; };
+ BYTE* Format() const
+ {
+ return pbFormat;
+ };
+ ULONG FormatLength() const
+ {
+ return cbFormat;
+ };
void SetFormatType(const GUID *);
- const GUID *FormatType() const {return &formattype; };
+ const GUID *FormatType() const
+ {
+ return &formattype;
+ };
BOOL SetFormat(__in_bcount(length) BYTE *pFormat, ULONG length);
void ResetFormatBuffer();
BYTE* AllocFormatBuffer(ULONG length);
diff --git a/src/filters/BaseClasses/outputq.cpp b/src/filters/BaseClasses/outputq.cpp
index d3ab6175e..d60319e64 100644
--- a/src/filters/BaseClasses/outputq.cpp
+++ b/src/filters/BaseClasses/outputq.cpp
@@ -41,53 +41,57 @@
// dwPriority - If we create a thread set its priority to this
//
COutputQueue::COutputQueue(
- IPin *pInputPin, // Pin to send stuff to
- __inout HRESULT *phr, // 'Return code'
- BOOL bAuto, // Ask pin if queue or not
- BOOL bQueue, // Send through queue
- LONG lBatchSize, // Batch
- BOOL bBatchExact, // Batch exactly to BatchSize
- LONG lListSize,
- DWORD dwPriority,
- bool bFlushingOpt // flushing optimization
- ) : m_lBatchSize(lBatchSize),
- m_bBatchExact(bBatchExact && (lBatchSize > 1)),
- m_hThread(NULL),
- m_hSem(NULL),
- m_List(NULL),
- m_pPin(pInputPin),
- m_ppSamples(NULL),
- m_lWaiting(0),
- m_evFlushComplete(FALSE, phr),
- m_pInputPin(NULL),
- m_bSendAnyway(FALSE),
- m_nBatched(0),
- m_bFlushing(FALSE),
- m_bFlushed(TRUE),
- m_bFlushingOpt(bFlushingOpt),
- m_bTerminate(FALSE),
- m_hEventPop(NULL),
- m_hr(S_OK)
+ IPin *pInputPin, // Pin to send stuff to
+ __inout HRESULT *phr, // 'Return code'
+ BOOL bAuto, // Ask pin if queue or not
+ BOOL bQueue, // Send through queue
+ LONG lBatchSize, // Batch
+ BOOL bBatchExact, // Batch exactly to BatchSize
+ LONG lListSize,
+ DWORD dwPriority,
+ bool bFlushingOpt // flushing optimization
+) : m_lBatchSize(lBatchSize),
+ m_bBatchExact(bBatchExact && (lBatchSize > 1)),
+ m_hThread(NULL),
+ m_hSem(NULL),
+ m_List(NULL),
+ m_pPin(pInputPin),
+ m_ppSamples(NULL),
+ m_lWaiting(0),
+ m_evFlushComplete(FALSE, phr),
+ m_pInputPin(NULL),
+ m_bSendAnyway(FALSE),
+ m_nBatched(0),
+ m_bFlushing(FALSE),
+ m_bFlushed(TRUE),
+ m_bFlushingOpt(bFlushingOpt),
+ m_bTerminate(FALSE),
+ m_hEventPop(NULL),
+ m_hr(S_OK)
{
ASSERT(m_lBatchSize > 0);
- if (FAILED(*phr)) {
+ if(FAILED(*phr))
+ {
return;
}
// Check the input pin is OK and cache its IMemInputPin interface
*phr = pInputPin->QueryInterface(IID_IMemInputPin, (void **)&m_pInputPin);
- if (FAILED(*phr)) {
+ if(FAILED(*phr))
+ {
return;
}
// See if we should ask the downstream pin
- if (bAuto) {
+ if(bAuto)
+ {
HRESULT hr = m_pInputPin->ReceiveCanBlock();
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
bQueue = hr == S_OK;
}
}
@@ -95,17 +99,20 @@ COutputQueue::COutputQueue(
// Create our sample batch
m_ppSamples = new PMEDIASAMPLE[m_lBatchSize];
- if (m_ppSamples == NULL) {
+ if(m_ppSamples == NULL)
+ {
*phr = E_OUTOFMEMORY;
return;
}
// If we're queueing allocate resources
- if (bQueue) {
+ if(bQueue)
+ {
DbgLog((LOG_TRACE, 2, TEXT("Creating thread for output pin")));
m_hSem = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL);
- if (m_hSem == NULL) {
+ if(m_hSem == NULL)
+ {
DWORD dwError = GetLastError();
*phr = AmHresultFromWin32(dwError);
return;
@@ -114,7 +121,8 @@ COutputQueue::COutputQueue(
lListSize,
FALSE // No lock
);
- if (m_List == NULL) {
+ if(m_List == NULL)
+ {
*phr = E_OUTOFMEMORY;
return;
}
@@ -127,13 +135,16 @@ COutputQueue::COutputQueue(
(LPVOID)this,
0,
&dwThreadId);
- if (m_hThread == NULL) {
+ if(m_hThread == NULL)
+ {
DWORD dwError = GetLastError();
*phr = AmHresultFromWin32(dwError);
return;
}
SetThreadPriority(m_hThread, dwPriority);
- } else {
+ }
+ else
+ {
DbgLog((LOG_TRACE, 2, TEXT("Calling input pin directly - no thread")));
}
}
@@ -150,10 +161,12 @@ COutputQueue::~COutputQueue()
{
DbgLog((LOG_TRACE, 3, TEXT("COutputQueue::~COutputQueue")));
/* Free our pointer */
- if (m_pInputPin != NULL) {
+ if(m_pInputPin != NULL)
+ {
m_pInputPin->Release();
}
- if (m_hThread != NULL) {
+ if(m_hThread != NULL)
+ {
{
CAutoLock lck(this);
m_bTerminate = TRUE;
@@ -167,10 +180,13 @@ COutputQueue::~COutputQueue()
ASSERT(m_List->GetCount() == 0);
delete m_List;
- } else {
+ }
+ else
+ {
FreeSamples();
}
- if (m_hSem != NULL) {
+ if(m_hSem != NULL)
+ {
EXECUTE_ASSERT(CloseHandle(m_hSem));
}
delete [] m_ppSamples;
@@ -182,14 +198,15 @@ COutputQueue::~COutputQueue()
DWORD WINAPI COutputQueue::InitialThreadProc(__in LPVOID pv)
{
HRESULT hrCoInit = CAMThread::CoInitializeHelper();
-
+
COutputQueue *pSampleQueue = (COutputQueue *)pv;
DWORD dwReturn = pSampleQueue->ThreadProc();
- if(hrCoInit == S_OK) {
+ if(hrCoInit == S_OK)
+ {
CoUninitialize();
}
-
+
return dwReturn;
}
@@ -202,7 +219,8 @@ DWORD WINAPI COutputQueue::InitialThreadProc(__in LPVOID pv)
//
DWORD COutputQueue::ThreadProc()
{
- while (TRUE) {
+ while(TRUE)
+ {
BOOL bWait = FALSE;
IMediaSample *pSample;
LONG lNumberToSend; // Local copy
@@ -215,13 +233,16 @@ DWORD COutputQueue::ThreadProc()
//
{
CAutoLock lck(this);
- while (TRUE) {
+ while(TRUE)
+ {
- if (m_bTerminate) {
+ if(m_bTerminate)
+ {
FreeSamples();
return 0;
}
- if (m_bFlushing) {
+ if(m_bFlushing)
+ {
FreeSamples();
SetEvent(m_evFlushComplete);
}
@@ -229,30 +250,36 @@ DWORD COutputQueue::ThreadProc()
// Get a sample off the list
pSample = m_List->RemoveHead();
- // inform derived class we took something off the queue
- if (m_hEventPop) {
+ // inform derived class we took something off the queue
+ if(m_hEventPop)
+ {
//DbgLog((LOG_TRACE,3,TEXT("Queue: Delivered SET EVENT")));
- SetEvent(m_hEventPop);
- }
+ SetEvent(m_hEventPop);
+ }
- if (pSample != NULL &&
- !IsSpecialSample(pSample)) {
+ if(pSample != NULL &&
+ !IsSpecialSample(pSample))
+ {
// If its just a regular sample just add it to the batch
// and exit the loop if the batch is full
m_ppSamples[m_nBatched++] = pSample;
- if (m_nBatched == m_lBatchSize) {
+ if(m_nBatched == m_lBatchSize)
+ {
break;
}
- } else {
+ }
+ else
+ {
// If there was nothing in the queue and there's nothing
// to send (either because there's nothing or the batch
// isn't full) then prepare to wait
- if (pSample == NULL &&
- (m_bBatchExact || m_nBatched == 0)) {
+ if(pSample == NULL &&
+ (m_bBatchExact || m_nBatched == 0))
+ {
// Tell other thread to set the event when there's
// something do to
@@ -260,24 +287,29 @@ DWORD COutputQueue::ThreadProc()
ASSERT(m_lWaiting == 0);
m_lWaiting++;
bWait = TRUE;
- } else {
+ }
+ else
+ {
// We break out of the loop on SEND_PACKET unless
// there's nothing to send
- if (pSample == SEND_PACKET && m_nBatched == 0) {
+ if(pSample == SEND_PACKET && m_nBatched == 0)
+ {
continue;
}
- if (pSample == NEW_SEGMENT) {
+ if(pSample == NEW_SEGMENT)
+ {
// now we need the parameters - we are
// guaranteed that the next packet contains them
ppacket = (NewSegmentPacket *) m_List->RemoveHead();
- // we took something off the queue
- if (m_hEventPop) {
- //DbgLog((LOG_TRACE,3,TEXT("Queue: Delivered SET EVENT")));
- SetEvent(m_hEventPop);
- }
+ // we took something off the queue
+ if(m_hEventPop)
+ {
+ //DbgLog((LOG_TRACE,3,TEXT("Queue: Delivered SET EVENT")));
+ SetEvent(m_hEventPop);
+ }
ASSERT(ppacket);
}
@@ -287,7 +319,8 @@ DWORD COutputQueue::ThreadProc()
break;
}
}
- if (!bWait) {
+ if(!bWait)
+ {
// We look at m_nBatched from the client side so keep
// it up to date inside the critical section
lNumberToSend = m_nBatched; // Local copy
@@ -297,7 +330,8 @@ DWORD COutputQueue::ThreadProc()
// Wait for some more data
- if (bWait) {
+ if(bWait)
+ {
DbgWaitForSingleObject(m_hSem);
continue;
}
@@ -310,36 +344,42 @@ DWORD COutputQueue::ThreadProc()
// SEND_PACKET or EOS_PACKET - both of which imply we should
// flush our batch
- if (lNumberToSend != 0) {
+ if(lNumberToSend != 0)
+ {
long nProcessed;
- if (m_hr == S_OK) {
+ if(m_hr == S_OK)
+ {
ASSERT(!m_bFlushed);
HRESULT hr = m_pInputPin->ReceiveMultiple(m_ppSamples,
- lNumberToSend,
- &nProcessed);
+ lNumberToSend,
+ &nProcessed);
/* Don't overwrite a flushing state HRESULT */
CAutoLock lck(this);
- if (m_hr == S_OK) {
+ if(m_hr == S_OK)
+ {
m_hr = hr;
}
ASSERT(!m_bFlushed);
}
- while (lNumberToSend != 0) {
+ while(lNumberToSend != 0)
+ {
m_ppSamples[--lNumberToSend]->Release();
}
- if (m_hr != S_OK) {
+ if(m_hr != S_OK)
+ {
// In any case wait for more data - S_OK just
// means there wasn't an error
DbgLog((LOG_ERROR, 2, TEXT("ReceiveMultiple returned %8.8X"),
- m_hr));
+ m_hr));
}
}
// Check for end of stream
- if (pSample == EOS_PACKET) {
+ if(pSample == EOS_PACKET)
+ {
// We don't send even end of stream on if we've previously
// returned something other than S_OK
@@ -347,10 +387,12 @@ DWORD COutputQueue::ThreadProc()
// something other than S_OK should have either sent
// EndOfStream() or notified the filter graph
- if (m_hr == S_OK) {
+ if(m_hr == S_OK)
+ {
DbgLog((LOG_TRACE, 2, TEXT("COutputQueue sending EndOfStream()")));
HRESULT hr = m_pPin->EndOfStream();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
DbgLog((LOG_ERROR, 2, TEXT("COutputQueue got code 0x%8.8X from EndOfStream()")));
}
}
@@ -358,12 +400,14 @@ DWORD COutputQueue::ThreadProc()
// Data from a new source
- if (pSample == RESET_PACKET) {
+ if(pSample == RESET_PACKET)
+ {
m_hr = S_OK;
SetEvent(m_evFlushComplete);
}
- if (pSample == NEW_SEGMENT) {
+ if(pSample == NEW_SEGMENT)
+ {
m_pPin->NewSegment(ppacket->tStart, ppacket->tStop, ppacket->dRate);
delete ppacket;
}
@@ -373,7 +417,8 @@ DWORD COutputQueue::ThreadProc()
// Send batched stuff anyway
void COutputQueue::SendAnyway()
{
- if (!IsQueued()) {
+ if(!IsQueued())
+ {
// m_bSendAnyway is a private parameter checked in ReceiveMultiple
@@ -382,7 +427,9 @@ void COutputQueue::SendAnyway()
ReceiveMultiple(NULL, 0, &nProcessed);
m_bSendAnyway = FALSE;
- } else {
+ }
+ else
+ {
CAutoLock lck(this);
QueueSample(SEND_PACKET);
NotifyThread();
@@ -395,15 +442,21 @@ COutputQueue::NewSegment(
REFERENCE_TIME tStop,
double dRate)
{
- if (!IsQueued()) {
- if (S_OK == m_hr) {
- if (m_bBatchExact) {
+ if(!IsQueued())
+ {
+ if(S_OK == m_hr)
+ {
+ if(m_bBatchExact)
+ {
SendAnyway();
}
m_pPin->NewSegment(tStart, tStop, dRate);
}
- } else {
- if (m_hr == S_OK) {
+ }
+ else
+ {
+ if(m_hr == S_OK)
+ {
//
// we need to queue the new segment to appear in order in the
// data, but we need to pass parameters to it. Rather than
@@ -414,7 +467,8 @@ COutputQueue::NewSegment(
// NEW_SEGMENT value is a NewSegmentPacket containing the
// parameters.
NewSegmentPacket * ppack = new NewSegmentPacket;
- if (ppack == NULL) {
+ if(ppack == NULL)
+ {
return;
}
ppack->tStart = tStart;
@@ -423,7 +477,7 @@ COutputQueue::NewSegment(
CAutoLock lck(this);
QueueSample(NEW_SEGMENT);
- QueueSample( (IMediaSample*) ppack);
+ QueueSample((IMediaSample*) ppack);
NotifyThread();
}
}
@@ -436,20 +490,27 @@ COutputQueue::NewSegment(
void COutputQueue::EOS()
{
CAutoLock lck(this);
- if (!IsQueued()) {
- if (m_bBatchExact) {
+ if(!IsQueued())
+ {
+ if(m_bBatchExact)
+ {
SendAnyway();
}
- if (m_hr == S_OK) {
+ if(m_hr == S_OK)
+ {
DbgLog((LOG_TRACE, 2, TEXT("COutputQueue sending EndOfStream()")));
m_bFlushed = FALSE;
HRESULT hr = m_pPin->EndOfStream();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
DbgLog((LOG_ERROR, 2, TEXT("COutputQueue got code 0x%8.8X from EndOfStream()")));
}
}
- } else {
- if (m_hr == S_OK) {
+ }
+ else
+ {
+ if(m_hr == S_OK)
+ {
m_bFlushed = FALSE;
QueueSample(EOS_PACKET);
NotifyThread();
@@ -462,7 +523,8 @@ void COutputQueue::EOS()
//
void COutputQueue::BeginFlush()
{
- if (IsQueued()) {
+ if(IsQueued())
+ {
{
CAutoLock lck(this);
@@ -475,13 +537,15 @@ void COutputQueue::BeginFlush()
// Make sure we discard all samples from now on
- if (m_hr == S_OK) {
+ if(m_hr == S_OK)
+ {
m_hr = S_FALSE;
}
// Optimize so we don't keep calling downstream all the time
- if (m_bFlushed && m_bFlushingOpt) {
+ if(m_bFlushed && m_bFlushingOpt)
+ {
return;
}
@@ -494,7 +558,9 @@ void COutputQueue::BeginFlush()
// pass this downstream
m_pPin->BeginFlush();
- } else {
+ }
+ else
+ {
// pass downstream first to avoid deadlocks
m_pPin->BeginFlush();
CAutoLock lck(this);
@@ -504,7 +570,8 @@ void COutputQueue::BeginFlush()
// Make sure we discard all samples from now on
- if (m_hr == S_OK) {
+ if(m_hr == S_OK)
+ {
m_hr = S_FALSE;
}
}
@@ -518,7 +585,8 @@ void COutputQueue::EndFlush()
{
CAutoLock lck(this);
ASSERT(m_bFlushing);
- if (m_bFlushingOpt && m_bFlushed && IsQueued()) {
+ if(m_bFlushingOpt && m_bFlushed && IsQueued())
+ {
m_bFlushing = FALSE;
m_hr = S_OK;
return;
@@ -531,9 +599,12 @@ void COutputQueue::EndFlush()
// Because we are synching here there is no need to hold the critical
// section (in fact we'd deadlock if we did!)
- if (IsQueued()) {
+ if(IsQueued())
+ {
m_evFlushComplete.Wait();
- } else {
+ }
+ else
+ {
FreeSamples();
}
@@ -557,8 +628,10 @@ void COutputQueue::EndFlush()
void COutputQueue::QueueSample(IMediaSample *pSample)
{
- if (NULL == m_List->AddTail(pSample)) {
- if (!IsSpecialSample(pSample)) {
+ if(NULL == m_List->AddTail(pSample))
+ {
+ if(!IsSpecialSample(pSample))
+ {
pSample->Release();
}
}
@@ -591,23 +664,26 @@ HRESULT COutputQueue::Receive(IMediaSample *pSample)
// On return all samples will have been Release()'d
//
-HRESULT COutputQueue::ReceiveMultiple (
+HRESULT COutputQueue::ReceiveMultiple(
__in_ecount(nSamples) IMediaSample **ppSamples,
long nSamples,
__out long *nSamplesProcessed)
{
- if (nSamples < 0) {
+ if(nSamples < 0)
+ {
return E_INVALIDARG;
}
-
+
CAutoLock lck(this);
// Either call directly or queue up the samples
- if (!IsQueued()) {
+ if(!IsQueued())
+ {
// If we already had a bad return code then just return
- if (S_OK != m_hr) {
+ if(S_OK != m_hr)
+ {
// If we've never received anything since the last Flush()
// and the sticky return code is not S_OK we must be
@@ -617,7 +693,8 @@ HRESULT COutputQueue::ReceiveMultiple (
// We're supposed to Release() them anyway!
*nSamplesProcessed = 0;
- for (int i = 0; i < nSamples; i++) {
+ for(int i = 0; i < nSamples; i++)
+ {
DbgLog((LOG_TRACE, 3, TEXT("COutputQueue (direct) : Discarding %d samples code 0x%8.8X"),
nSamples, m_hr));
ppSamples[i]->Release();
@@ -638,59 +715,73 @@ HRESULT COutputQueue::ReceiveMultiple (
LONG iLost = 0;
long iDone = 0;
- for (iDone = 0;
- iDone < nSamples || (m_nBatched != 0 && m_bSendAnyway);
- ) {
+ for(iDone = 0;
+ iDone < nSamples || (m_nBatched != 0 && m_bSendAnyway);
+ )
+ {
//pragma message (REMIND("Implement threshold scheme"))
ASSERT(m_nBatched < m_lBatchSize);
- if (iDone < nSamples) {
+ if(iDone < nSamples)
+ {
m_ppSamples[m_nBatched++] = ppSamples[iDone++];
}
- if (m_nBatched == m_lBatchSize ||
- nSamples == 0 && (m_bSendAnyway || !m_bBatchExact)) {
+ if(m_nBatched == m_lBatchSize ||
+ nSamples == 0 && (m_bSendAnyway || !m_bBatchExact))
+ {
LONG nDone;
DbgLog((LOG_TRACE, 4, TEXT("Batching %d samples"),
- m_nBatched));
+ m_nBatched));
- if (m_hr == S_OK) {
+ if(m_hr == S_OK)
+ {
m_hr = m_pInputPin->ReceiveMultiple(m_ppSamples,
m_nBatched,
&nDone);
- } else {
+ }
+ else
+ {
nDone = 0;
}
iLost += m_nBatched - nDone;
- for (LONG i = 0; i < m_nBatched; i++) {
+ for(LONG i = 0; i < m_nBatched; i++)
+ {
m_ppSamples[i]->Release();
}
m_nBatched = 0;
}
}
*nSamplesProcessed = iDone - iLost;
- if (*nSamplesProcessed < 0) {
+ if(*nSamplesProcessed < 0)
+ {
*nSamplesProcessed = 0;
}
return m_hr;
- } else {
+ }
+ else
+ {
/* We're sending to our thread */
- if (m_hr != S_OK) {
+ if(m_hr != S_OK)
+ {
*nSamplesProcessed = 0;
DbgLog((LOG_TRACE, 3, TEXT("COutputQueue (queued) : Discarding %d samples code 0x%8.8X"),
nSamples, m_hr));
- for (int i = 0; i < nSamples; i++) {
+ for(int i = 0; i < nSamples; i++)
+ {
ppSamples[i]->Release();
}
return m_hr;
}
m_bFlushed = FALSE;
- for (long i = 0; i < nSamples; i++) {
+ for(long i = 0; i < nSamples; i++)
+ {
QueueSample(ppSamples[i]);
}
*nSamplesProcessed = nSamples;
- if (!m_bBatchExact ||
- m_nBatched + m_List->GetCount() >= m_lBatchSize) {
+ if(!m_bBatchExact ||
+ m_nBatched + m_List->GetCount() >= m_lBatchSize)
+ {
NotifyThread();
}
return S_OK;
@@ -700,9 +791,12 @@ HRESULT COutputQueue::ReceiveMultiple (
// Get ready for new data - cancels sticky m_hr
void COutputQueue::Reset()
{
- if (!IsQueued()) {
+ if(!IsQueued())
+ {
m_hr = S_OK;
- } else {
+ }
+ else
+ {
{
CAutoLock lck(this);
QueueSample(RESET_PACKET);
@@ -716,30 +810,39 @@ void COutputQueue::Reset()
void COutputQueue::FreeSamples()
{
CAutoLock lck(this);
- if (IsQueued()) {
- while (TRUE) {
+ if(IsQueued())
+ {
+ while(TRUE)
+ {
IMediaSample *pSample = m_List->RemoveHead();
- // inform derived class we took something off the queue
- if (m_hEventPop) {
+ // inform derived class we took something off the queue
+ if(m_hEventPop)
+ {
//DbgLog((LOG_TRACE,3,TEXT("Queue: Delivered SET EVENT")));
- SetEvent(m_hEventPop);
- }
+ SetEvent(m_hEventPop);
+ }
- if (pSample == NULL) {
+ if(pSample == NULL)
+ {
break;
}
- if (!IsSpecialSample(pSample)) {
+ if(!IsSpecialSample(pSample))
+ {
pSample->Release();
- } else {
- if (pSample == NEW_SEGMENT) {
+ }
+ else
+ {
+ if(pSample == NEW_SEGMENT)
+ {
// Free NEW_SEGMENT packet
NewSegmentPacket *ppacket =
(NewSegmentPacket *) m_List->RemoveHead();
- // inform derived class we took something off the queue
- if (m_hEventPop) {
+ // inform derived class we took something off the queue
+ if(m_hEventPop)
+ {
//DbgLog((LOG_TRACE,3,TEXT("Queue: Delivered SET EVENT")));
- SetEvent(m_hEventPop);
- }
+ SetEvent(m_hEventPop);
+ }
ASSERT(ppacket != NULL);
delete ppacket;
@@ -747,7 +850,8 @@ void COutputQueue::FreeSamples()
}
}
}
- for (int i = 0; i < m_nBatched; i++) {
+ for(int i = 0; i < m_nBatched; i++)
+ {
m_ppSamples[i]->Release();
}
m_nBatched = 0;
@@ -760,7 +864,8 @@ void COutputQueue::NotifyThread()
{
// Optimize - no need to signal if it's not waiting
ASSERT(IsQueued());
- if (m_lWaiting) {
+ if(m_lWaiting)
+ {
ReleaseSemaphore(m_hSem, m_lWaiting, NULL);
m_lWaiting = 0;
}
@@ -782,9 +887,12 @@ BOOL COutputQueue::IsIdle()
// AND
// there's nothing in the current batch (m_nBatched == 0)
- if (IsQueued() && m_lWaiting == 0 || m_nBatched != 0) {
+ if(IsQueued() && m_lWaiting == 0 || m_nBatched != 0)
+ {
return FALSE;
- } else {
+ }
+ else
+ {
// If we're idle it shouldn't be possible for there
// to be anything on the work queue
diff --git a/src/filters/BaseClasses/outputq.h b/src/filters/BaseClasses/outputq.h
index db3d42433..4d870762c 100644
--- a/src/filters/BaseClasses/outputq.h
+++ b/src/filters/BaseClasses/outputq.h
@@ -2,7 +2,7 @@
// File: OutputQ.h
//
// Desc: DirectShow base classes - defines the COutputQueue class, which
-// makes a queue of samples and sends them to an output pin. The
+// makes a queue of samples and sends them to an output pin. The
// class will optionally send the samples to the pin directly.
//
// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
@@ -19,13 +19,13 @@ public:
__inout HRESULT *phr, // 'Return code'
BOOL bAuto = TRUE, // Ask pin if blocks
BOOL bQueue = TRUE, // Send through queue (ignored if
- // bAuto set)
+ // bAuto set)
LONG lBatchSize = 1, // Batch
BOOL bBatchExact = FALSE,// Batch exactly to BatchSize
LONG lListSize = // Likely number in the list
- DEFAULTCACHE,
+ DEFAULTCACHE,
DWORD dwPriority = // Priority of thread to create
- THREAD_PRIORITY_NORMAL,
+ THREAD_PRIORITY_NORMAL,
bool bFlushingOpt = false // flushing optimization
);
~COutputQueue();
@@ -35,21 +35,21 @@ public:
// re-enable receives (pass this downstream)
void EndFlush(); // Complete flush of samples - downstream
- // pin guaranteed not to block at this stage
+ // pin guaranteed not to block at this stage
void EOS(); // Call this on End of stream
void SendAnyway(); // Send batched samples anyway (if bBatchExact set)
void NewSegment(
- REFERENCE_TIME tStart,
- REFERENCE_TIME tStop,
- double dRate);
+ REFERENCE_TIME tStart,
+ REFERENCE_TIME tStop,
+ double dRate);
HRESULT Receive(IMediaSample *pSample);
// do something with these media samples
- HRESULT ReceiveMultiple (
+ HRESULT ReceiveMultiple(
__in_ecount(nSamples) IMediaSample **pSamples,
long nSamples,
__out long *nSamplesProcessed);
@@ -87,13 +87,14 @@ protected:
protected:
// Queue 'messages'
- #define SEND_PACKET ((IMediaSample *)(LONG_PTR)(-2)) // Send batch
- #define EOS_PACKET ((IMediaSample *)(LONG_PTR)(-3)) // End of stream
- #define RESET_PACKET ((IMediaSample *)(LONG_PTR)(-4)) // Reset m_hr
- #define NEW_SEGMENT ((IMediaSample *)(LONG_PTR)(-5)) // send NewSegment
+#define SEND_PACKET ((IMediaSample *)(LONG_PTR)(-2)) // Send batch
+#define EOS_PACKET ((IMediaSample *)(LONG_PTR)(-3)) // End of stream
+#define RESET_PACKET ((IMediaSample *)(LONG_PTR)(-4)) // Reset m_hr
+#define NEW_SEGMENT ((IMediaSample *)(LONG_PTR)(-5)) // send NewSegment
// new segment packet is always followed by one of these
- struct NewSegmentPacket {
+ struct NewSegmentPacket
+ {
REFERENCE_TIME tStart;
REFERENCE_TIME tStop;
double dRate;
diff --git a/src/filters/BaseClasses/perflog.cpp b/src/filters/BaseClasses/perflog.cpp
index e64253870..60e40e47a 100644
--- a/src/filters/BaseClasses/perflog.cpp
+++ b/src/filters/BaseClasses/perflog.cpp
@@ -23,12 +23,12 @@
ULONG
WINAPI
-PerflogCallback (
+PerflogCallback(
WMIDPREQUESTCODE RequestCode,
__in PVOID Context,
__out ULONG* BufferSize,
__in PVOID Buffer
- );
+);
//
// Event tracing function pointers.
@@ -38,7 +38,7 @@ PerflogCallback (
#ifdef UNICODE
ULONG
-(__stdcall * _RegisterTraceGuids) (
+(__stdcall * _RegisterTraceGuids)(
__in IN WMIDPREQUEST RequestAddress,
__in IN PVOID RequestContext,
IN LPCGUID ControlGuid,
@@ -47,14 +47,14 @@ ULONG
IN LPCWSTR MofImagePath,
IN LPCWSTR MofResourceName,
OUT PTRACEHANDLE RegistrationHandle
- );
+);
#define REGISTERTRACEGUIDS_NAME "RegisterTraceGuidsW"
#else
ULONG
-(__stdcall * _RegisterTraceGuids) (
+(__stdcall * _RegisterTraceGuids)(
__in IN WMIDPREQUEST RequestAddress,
__in IN PVOID RequestContext,
IN LPCGUID ControlGuid,
@@ -63,37 +63,37 @@ ULONG
IN LPCSTR MofImagePath,
IN LPCSTR MofResourceName,
__out OUT PTRACEHANDLE RegistrationHandle
- );
+);
#define REGISTERTRACEGUIDS_NAME "RegisterTraceGuidsA"
#endif
ULONG
-(__stdcall * _UnregisterTraceGuids) (
+(__stdcall * _UnregisterTraceGuids)(
TRACEHANDLE RegistrationHandle
- );
+);
TRACEHANDLE
-(__stdcall * _GetTraceLoggerHandle) (
+(__stdcall * _GetTraceLoggerHandle)(
__in PVOID Buffer
- );
+);
UCHAR
-(__stdcall * _GetTraceEnableLevel) (
+(__stdcall * _GetTraceEnableLevel)(
TRACEHANDLE TraceHandle
- );
+);
ULONG
-(__stdcall * _GetTraceEnableFlags) (
+(__stdcall * _GetTraceEnableFlags)(
TRACEHANDLE TraceHandle
- );
+);
ULONG
-(__stdcall * _TraceEvent) (
+(__stdcall * _TraceEvent)(
TRACEHANDLE TraceHandle,
__in PEVENT_TRACE_HEADER EventTrace
- );
+);
HINSTANCE _Advapi32;
@@ -101,12 +101,12 @@ HINSTANCE _Advapi32;
// Global variables.
//
-BOOL EventTracingAvailable=FALSE;
+BOOL EventTracingAvailable = FALSE;
ULONG PerflogEnableFlags;
UCHAR PerflogEnableLevel;
ULONG PerflogModuleLevel = 0;
void (*OnStateChanged)(void);
-TRACEHANDLE PerflogTraceHandle=NULL;
+TRACEHANDLE PerflogTraceHandle = NULL;
TRACEHANDLE PerflogRegHandle;
// The Win32 wsprintf() function writes a maximum of 1024 characters to it's output buffer.
@@ -122,7 +122,7 @@ const INT iDEBUGINFO = 1024; // Used to format strings
VOID
PerflogReadModuleLevel(
HINSTANCE hInstance
- )
+)
{
LONG lReturn; // Create key return value
TCHAR szInfo[iDEBUGINFO]; // Constructs key names
@@ -132,23 +132,27 @@ PerflogReadModuleLevel(
DWORD dwKeySize, dwKeyType, dwKeyValue;
DWORD dwSize = GetModuleFileName(
- (hInstance ? hInstance : GetModuleHandle( NULL )),
- szFullName,
- iDEBUGINFO );
+ (hInstance ? hInstance : GetModuleHandle(NULL)),
+ szFullName,
+ iDEBUGINFO);
- if (0 == dwSize || iDEBUGINFO == dwSize) {
+ if(0 == dwSize || iDEBUGINFO == dwSize)
+ {
return;
}
- pName = _tcsrchr(szFullName,'\\');
- if (pName == NULL) {
+ pName = _tcsrchr(szFullName, '\\');
+ if(pName == NULL)
+ {
pName = szFullName;
- } else {
+ }
+ else
+ {
pName++;
}
/* Construct the base key name */
- (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("SOFTWARE\\Debug\\%s"),pName);
+ (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("SOFTWARE\\Debug\\%s"), pName);
/* Open the key for this module */
lReturn =
@@ -157,22 +161,23 @@ PerflogReadModuleLevel(
szInfo, // Address of subkey name
(DWORD) 0, // Reserved value
KEY_QUERY_VALUE, // Desired security access
- &hModuleKey ); // Opened handle buffer
+ &hModuleKey); // Opened handle buffer
- if (lReturn != ERROR_SUCCESS) {
+ if(lReturn != ERROR_SUCCESS)
+ {
return;
}
dwKeySize = sizeof(DWORD);
lReturn = RegQueryValueEx(
- hModuleKey, // Handle to an open key
- TEXT("PERFLOG"),
- NULL, // Reserved field
- &dwKeyType, // Returns the field type
- (LPBYTE) &dwKeyValue, // Returns the field's value
- &dwKeySize ); // Number of bytes transferred
-
- if ((lReturn == ERROR_SUCCESS) && (dwKeyType == REG_DWORD))
+ hModuleKey, // Handle to an open key
+ TEXT("PERFLOG"),
+ NULL, // Reserved field
+ &dwKeyType, // Returns the field type
+ (LPBYTE) &dwKeyValue, // Returns the field's value
+ &dwKeySize); // Number of bytes transferred
+
+ if((lReturn == ERROR_SUCCESS) && (dwKeyType == REG_DWORD))
{
PerflogModuleLevel = dwKeyValue;
}
@@ -183,12 +188,12 @@ PerflogReadModuleLevel(
BOOL PerflogInitIfEnabled(
IN HINSTANCE hInstance,
__in IN PPERFLOG_LOGGING_PARAMS LogParams
- )
+)
{
- PerflogReadModuleLevel( hInstance );
- if (PerflogModuleLevel)
+ PerflogReadModuleLevel(hInstance);
+ if(PerflogModuleLevel)
{
- return PerflogInitialize( LogParams );
+ return PerflogInitialize(LogParams);
}
else
{
@@ -197,9 +202,9 @@ BOOL PerflogInitIfEnabled(
}
BOOL
-PerflogInitialize (
+PerflogInitialize(
__in IN PPERFLOG_LOGGING_PARAMS LogParams
- )
+)
{
ULONG status;
@@ -208,23 +213,25 @@ PerflogInitialize (
// pointers to the event tracing routines.
//
- _Advapi32 = GetModuleHandle (_T("ADVAPI32.DLL"));
- if (_Advapi32 == NULL) {
+ _Advapi32 = GetModuleHandle(_T("ADVAPI32.DLL"));
+ if(_Advapi32 == NULL)
+ {
return FALSE;
}
- *((FARPROC*) &_RegisterTraceGuids) = GetProcAddress (_Advapi32, REGISTERTRACEGUIDS_NAME);
- *((FARPROC*) &_UnregisterTraceGuids) = GetProcAddress (_Advapi32, "UnregisterTraceGuids");
- *((FARPROC*) &_GetTraceLoggerHandle) = GetProcAddress (_Advapi32, "GetTraceLoggerHandle");
- *((FARPROC*) &_GetTraceEnableLevel) = GetProcAddress (_Advapi32, "GetTraceEnableLevel");
- *((FARPROC*) &_GetTraceEnableFlags) = GetProcAddress (_Advapi32, "GetTraceEnableFlags");
- *((FARPROC*) &_TraceEvent) = GetProcAddress (_Advapi32, "TraceEvent");
-
- if (_RegisterTraceGuids == NULL ||
- _UnregisterTraceGuids == NULL ||
- _GetTraceEnableLevel == NULL ||
- _GetTraceEnableFlags == NULL ||
- _TraceEvent == NULL) {
+ *((FARPROC*) &_RegisterTraceGuids) = GetProcAddress(_Advapi32, REGISTERTRACEGUIDS_NAME);
+ *((FARPROC*) &_UnregisterTraceGuids) = GetProcAddress(_Advapi32, "UnregisterTraceGuids");
+ *((FARPROC*) &_GetTraceLoggerHandle) = GetProcAddress(_Advapi32, "GetTraceLoggerHandle");
+ *((FARPROC*) &_GetTraceEnableLevel) = GetProcAddress(_Advapi32, "GetTraceEnableLevel");
+ *((FARPROC*) &_GetTraceEnableFlags) = GetProcAddress(_Advapi32, "GetTraceEnableFlags");
+ *((FARPROC*) &_TraceEvent) = GetProcAddress(_Advapi32, "TraceEvent");
+
+ if(_RegisterTraceGuids == NULL ||
+ _UnregisterTraceGuids == NULL ||
+ _GetTraceEnableLevel == NULL ||
+ _GetTraceEnableFlags == NULL ||
+ _TraceEvent == NULL)
+ {
return FALSE;
}
@@ -237,14 +244,14 @@ PerflogInitialize (
// Register our GUIDs.
//
- status = _RegisterTraceGuids (PerflogCallback,
- LogParams,
- &LogParams->ControlGuid,
- LogParams->NumberOfTraceGuids,
- LogParams->TraceGuids,
- NULL,
- NULL,
- &PerflogRegHandle);
+ status = _RegisterTraceGuids(PerflogCallback,
+ LogParams,
+ &LogParams->ControlGuid,
+ LogParams->NumberOfTraceGuids,
+ LogParams->TraceGuids,
+ NULL,
+ NULL,
+ &PerflogRegHandle);
return (status == ERROR_SUCCESS);
}
@@ -254,15 +261,16 @@ PerflogInitialize (
//
VOID
-PerflogShutdown (
+PerflogShutdown(
VOID
- )
+)
{
- if (!EventTracingAvailable) {
+ if(!EventTracingAvailable)
+ {
return;
}
- _UnregisterTraceGuids (PerflogRegHandle);
+ _UnregisterTraceGuids(PerflogRegHandle);
PerflogRegHandle = NULL;
PerflogTraceHandle = NULL;
}
@@ -274,27 +282,28 @@ PerflogShutdown (
ULONG
WINAPI
-PerflogCallback (
+PerflogCallback(
WMIDPREQUESTCODE RequestCode,
__in PVOID Context,
__out ULONG* BufferSize,
__in PVOID Buffer
- )
+)
{
ULONG status;
- UNREFERENCED_PARAMETER (Context);
+ UNREFERENCED_PARAMETER(Context);
- ASSERT (EventTracingAvailable);
+ ASSERT(EventTracingAvailable);
status = ERROR_SUCCESS;
- switch (RequestCode) {
+ switch(RequestCode)
+ {
case WMI_ENABLE_EVENTS:
- PerflogTraceHandle = _GetTraceLoggerHandle (Buffer);
- PerflogEnableFlags = _GetTraceEnableFlags (PerflogTraceHandle);
- PerflogEnableLevel = _GetTraceEnableLevel (PerflogTraceHandle);
+ PerflogTraceHandle = _GetTraceLoggerHandle(Buffer);
+ PerflogEnableFlags = _GetTraceEnableFlags(PerflogTraceHandle);
+ PerflogEnableLevel = _GetTraceEnableLevel(PerflogTraceHandle);
break;
case WMI_DISABLE_EVENTS:
@@ -307,7 +316,8 @@ PerflogCallback (
status = ERROR_INVALID_PARAMETER;
}
- if (OnStateChanged != NULL) {
+ if(OnStateChanged != NULL)
+ {
OnStateChanged();
}
@@ -320,28 +330,30 @@ PerflogCallback (
//
VOID
-PerflogTraceEvent (
+PerflogTraceEvent(
__in PEVENT_TRACE_HEADER Event
- )
+)
{
- if (!EventTracingAvailable) {
+ if(!EventTracingAvailable)
+ {
return;
}
- _TraceEvent (PerflogTraceHandle, Event);
+ _TraceEvent(PerflogTraceHandle, Event);
}
VOID
PerflogTraceEventLevel(
ULONG Level,
__in PEVENT_TRACE_HEADER Event
- )
+)
{
- if ((!EventTracingAvailable) || (Level <= PerflogModuleLevel)) {
+ if((!EventTracingAvailable) || (Level <= PerflogModuleLevel))
+ {
return;
}
- _TraceEvent (PerflogTraceHandle, Event);
+ _TraceEvent(PerflogTraceHandle, Event);
}
diff --git a/src/filters/BaseClasses/perflog.h b/src/filters/BaseClasses/perflog.h
index 503a1304f..988b1eee7 100644
--- a/src/filters/BaseClasses/perflog.h
+++ b/src/filters/BaseClasses/perflog.h
@@ -6,7 +6,8 @@
// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
-typedef struct _PERFLOG_LOGGING_PARAMS {
+typedef struct _PERFLOG_LOGGING_PARAMS
+{
GUID ControlGuid;
void (*OnStateChanged)(void);
ULONG NumberOfTraceGuids;
@@ -17,22 +18,22 @@ BOOL
PerflogInitIfEnabled(
IN HINSTANCE hInstance,
__in PPERFLOG_LOGGING_PARAMS LogParams
- );
+);
BOOL
-PerflogInitialize (
+PerflogInitialize(
__in PPERFLOG_LOGGING_PARAMS LogParams
- );
+);
VOID
-PerflogShutdown (
+PerflogShutdown(
VOID
- );
+);
VOID
-PerflogTraceEvent (
+PerflogTraceEvent(
__in PEVENT_TRACE_HEADER Event
- );
+);
extern ULONG PerflogEnableFlags;
extern UCHAR PerflogEnableLevel;
@@ -48,9 +49,9 @@ VOID
PerflogTraceEventLevel(
ULONG Level,
__in PEVENT_TRACE_HEADER Event
- );
+);
VOID
-PerflogTraceEvent (
+PerflogTraceEvent(
__in PEVENT_TRACE_HEADER Event
- );
+);
diff --git a/src/filters/BaseClasses/perfstruct.h b/src/filters/BaseClasses/perfstruct.h
index 9c67b738d..cb14edd75 100644
--- a/src/filters/BaseClasses/perfstruct.h
+++ b/src/filters/BaseClasses/perfstruct.h
@@ -15,54 +15,55 @@
// {28CF047A-2437-4b24-B653-B9446A419A69}
DEFINE_GUID(GUID_DSHOW_CTL,
-0x28cf047a, 0x2437, 0x4b24, 0xb6, 0x53, 0xb9, 0x44, 0x6a, 0x41, 0x9a, 0x69);
+ 0x28cf047a, 0x2437, 0x4b24, 0xb6, 0x53, 0xb9, 0x44, 0x6a, 0x41, 0x9a, 0x69);
// {D0DA7AD6-AE80-4de5-AAFC-C126711E7593}
DEFINE_GUID(GUID_VIDEOREND,
-0xd0da7ad6, 0xae80, 0x4de5, 0xaa, 0xfc, 0xc1, 0x26, 0x71, 0x1e, 0x75, 0x93);
+ 0xd0da7ad6, 0xae80, 0x4de5, 0xaa, 0xfc, 0xc1, 0x26, 0x71, 0x1e, 0x75, 0x93);
// {DC70AC3E-93E5-48db-88AB-E42064EC276A}
DEFINE_GUID(GUID_DSOUNDGLITCH,
-0xdc70ac3e, 0x93e5, 0x48db, 0x88, 0xab, 0xe4, 0x20, 0x64, 0xec, 0x27, 0x6a);
+ 0xdc70ac3e, 0x93e5, 0x48db, 0x88, 0xab, 0xe4, 0x20, 0x64, 0xec, 0x27, 0x6a);
// {3d7e7d93-2fc8-4a07-a719-e0922ff2899}
DEFINE_GUID(GUID_STREAMTRACE,
-0x3d7e7d93, 0x2fc8, 0x4a07, 0xa7, 0x19, 0xe0, 0x92, 0x2f, 0xf2, 0x89, 0x9e);
+ 0x3d7e7d93, 0x2fc8, 0x4a07, 0xa7, 0x19, 0xe0, 0x92, 0x2f, 0xf2, 0x89, 0x9e);
// AZFIX: the following GUIDs aren't useful right now.
// {3C33F7F5-EE54-493c-BA25-1656539C05AC}
DEFINE_GUID(GUID_GETTIME,
-0x3c33f7f5, 0xee54, 0x493c, 0xba, 0x25, 0x16, 0x56, 0x53, 0x9c, 0x5, 0xac);
+ 0x3c33f7f5, 0xee54, 0x493c, 0xba, 0x25, 0x16, 0x56, 0x53, 0x9c, 0x5, 0xac);
// {CC44B44D-8169-4952-9E4A-A4E13295E492}
DEFINE_GUID(GUID_AUDIOREND,
-0xcc44b44d, 0x8169, 0x4952, 0x9e, 0x4a, 0xa4, 0xe1, 0x32, 0x95, 0xe4, 0x92);
+ 0xcc44b44d, 0x8169, 0x4952, 0x9e, 0x4a, 0xa4, 0xe1, 0x32, 0x95, 0xe4, 0x92);
// {775D19BF-4D8B-4de6-8DC9-66BAC7B310A2}
DEFINE_GUID(GUID_FRAMEDROP,
-0x775d19bf, 0x4d8b, 0x4de6, 0x8d, 0xc9, 0x66, 0xba, 0xc7, 0xb3, 0x10, 0xa2);
+ 0x775d19bf, 0x4d8b, 0x4de6, 0x8d, 0xc9, 0x66, 0xba, 0xc7, 0xb3, 0x10, 0xa2);
// {56D29065-EFBE-42dc-8C29-E325DC9C27D5}
DEFINE_GUID(GUID_AUDIOBREAK,
-0x56d29065, 0xefbe, 0x42dc, 0x8c, 0x29, 0xe3, 0x25, 0xdc, 0x9c, 0x27, 0xd5);
+ 0x56d29065, 0xefbe, 0x42dc, 0x8c, 0x29, 0xe3, 0x25, 0xdc, 0x9c, 0x27, 0xd5);
// {E1E6EA87-95A8-497e-BFBA-0295AEBCC707}
DEFINE_GUID(GUID_AUDIORECV,
-0xe1e6ea87, 0x95a8, 0x497e, 0xbf, 0xba, 0x2, 0x95, 0xae, 0xbc, 0xc7, 0x7);
+ 0xe1e6ea87, 0x95a8, 0x497e, 0xbf, 0xba, 0x2, 0x95, 0xae, 0xbc, 0xc7, 0x7);
// {10F7768A-B1E7-4242-AD90-A2D44683D9F0}
DEFINE_GUID(GUID_AUDIOSLAVE,
-0x10f7768a, 0xb1e7, 0x4242, 0xad, 0x90, 0xa2, 0xd4, 0x46, 0x83, 0xd9, 0xf0);
+ 0x10f7768a, 0xb1e7, 0x4242, 0xad, 0x90, 0xa2, 0xd4, 0x46, 0x83, 0xd9, 0xf0);
// {8983803D-691A-49bc-8FF6-962A39C0198F}
DEFINE_GUID(GUID_AUDIOADDBREAK,
-0x8983803d, 0x691a, 0x49bc, 0x8f, 0xf6, 0x96, 0x2a, 0x39, 0xc0, 0x19, 0x8f);
+ 0x8983803d, 0x691a, 0x49bc, 0x8f, 0xf6, 0x96, 0x2a, 0x39, 0xc0, 0x19, 0x8f);
#define GLITCHTYPE_DSOUNDFIRSTGOOD 0
#define GLITCHTYPE_DSOUNDFIRSTBAD 1
-typedef struct PERFINFO_DSHOW_AUDIOGLITCH {
+typedef struct PERFINFO_DSHOW_AUDIOGLITCH
+{
ULONGLONG cycleCounter;
DWORD glitchType;
LONGLONG sampleTime;
@@ -70,51 +71,60 @@ typedef struct PERFINFO_DSHOW_AUDIOGLITCH {
ULONG_PTR instanceId;
} PERFINFO_DSHOW_AUDIOGLITCH, *PPERFINFO_DSHOW_AUDIOGLITCH;
-typedef struct PERFINFO_WMI_AUDIOGLITCH {
+typedef struct PERFINFO_WMI_AUDIOGLITCH
+{
EVENT_TRACE_HEADER header;
PERFINFO_DSHOW_AUDIOGLITCH data;
} PERFINFO_WMI_AUDIO_GLITCH, *PPERFINFO_WMI_AUDIOGLITCH;
-typedef struct PERFINFO_DSHOW_GETTIME {
+typedef struct PERFINFO_DSHOW_GETTIME
+{
ULONGLONG cycleCounter;
ULONGLONG dshowClock;
} PERFINFO_DSHOW_GETTIME, *PPERFINFO_DSHOW_GETTIME;
-typedef struct PERFINFO_WMI_GETTIME {
+typedef struct PERFINFO_WMI_GETTIME
+{
EVENT_TRACE_HEADER header;
PERFINFO_DSHOW_GETTIME data;
} PERFINFO_WMI_GETTIME, *PPERFINFO_WMI_GETTIME;
-typedef struct PERFINFO_DSHOW_AVREND {
+typedef struct PERFINFO_DSHOW_AVREND
+{
ULONGLONG cycleCounter;
ULONGLONG dshowClock;
ULONGLONG sampleTime;
} PERFINFO_DSHOW_AVREND, *PPERFINFO_DSHOW_AVREND;
-typedef struct PERFINFO_WMI_AVREND {
+typedef struct PERFINFO_WMI_AVREND
+{
EVENT_TRACE_HEADER header;
PERFINFO_DSHOW_AVREND data;
} PERFINFO_WMI_AVREND, *PPERFINFO_WMI_AVREND;
-typedef struct PERFINFO_DSHOW_AUDIOBREAK {
+typedef struct PERFINFO_DSHOW_AUDIOBREAK
+{
ULONGLONG cycleCounter;
ULONGLONG dshowClock;
ULONGLONG sampleTime;
ULONGLONG sampleDuration;
} PERFINFO_DSHOW_AUDIOBREAK, *PPERFINFO_DSHOW_AUDIOBREAK;
-typedef struct PERFINFO_WMI_AUDIOBREAK {
+typedef struct PERFINFO_WMI_AUDIOBREAK
+{
EVENT_TRACE_HEADER header;
PERFINFO_DSHOW_AUDIOBREAK data;
} PERFINFO_WMI_AUDIOBREAK, *PPERFINFO_WMI_AUDIOBREAK;
-typedef struct PERFINFO_DSHOW_FRAMEDROP {
+typedef struct PERFINFO_DSHOW_FRAMEDROP
+{
ULONGLONG cycleCounter;
ULONGLONG dshowClock;
ULONGLONG frameTime;
} PERFINFO_DSHOW_FRAMEDROP, *PPERFINFO_DSHOW_FRAMEDROP;
-typedef struct PERFINFO_WMI_FRAMEDROP {
+typedef struct PERFINFO_WMI_FRAMEDROP
+{
EVENT_TRACE_HEADER header;
PERFINFO_DSHOW_FRAMEDROP data;
} PERFINFO_WMI_FRAMEDROP, *PPERFINFO_WMI_FRAMEDROP;
@@ -140,20 +150,23 @@ typedef struct PERFINFO_WMI_FRAMEDROP {
#define PERFINFO_STREAMTRACE_SBE_DVROUTPUTPIN_RECEIVE 19
#define PERFINFO_STREAMTRACE_VMR_RENDER_TIME 20
-typedef struct _PERFINFO_DSHOW_STREAMTRACE {
+typedef struct _PERFINFO_DSHOW_STREAMTRACE
+{
ULONG id;
ULONG reserved;
ULONGLONG dshowClock;
ULONGLONG data[ 4 ];
} PERFINFO_DSHOW_STREAMTRACE, *PPERFINFO_DSHOW_STREAMTRACE;
-typedef struct _PERFINFO_WMI_STREAMTRACE {
+typedef struct _PERFINFO_WMI_STREAMTRACE
+{
EVENT_TRACE_HEADER header;
PERFINFO_DSHOW_STREAMTRACE data;
} PERFINFO_WMI_STREAMTRACE, *PPERFINFO_WMI_STREAMTRACE;
-typedef struct PERFINFO_DSHOW_AUDIORECV {
+typedef struct PERFINFO_DSHOW_AUDIORECV
+{
LONGLONG streamTime ;
LONGLONG sampleStart ;
LONGLONG sampleStop ;
@@ -161,12 +174,14 @@ typedef struct PERFINFO_DSHOW_AUDIORECV {
BOOL discontinuity ;
} PERFINFO_DSHOW_AUDIORECV, *PPERFINFO_DSHOW_AUDIORECV;
-typedef struct PERFINFO_WMI_AUDIORECV {
+typedef struct PERFINFO_WMI_AUDIORECV
+{
EVENT_TRACE_HEADER header;
PERFINFO_DSHOW_AUDIORECV data;
} PERFINFO_WMI_AUDIORECV, *PPERFINFO_WMI_AUDIORECV;
-typedef struct PERFINFO_DSHOW_AUDIOSLAVE {
+typedef struct PERFINFO_DSHOW_AUDIOSLAVE
+{
LONGLONG masterClock ;
LONGLONG slaveClock ;
LONGLONG errorAccum ;
@@ -174,19 +189,22 @@ typedef struct PERFINFO_DSHOW_AUDIOSLAVE {
LONGLONG lastLowErrorSeen ;
} PERFINFO_DSHOW_AUDIOSLAVE, *PPERFINFO_DSHOW_AUDIOSLAVE;
-typedef struct PERFINFO_WMI_AUDIOSLAVE {
+typedef struct PERFINFO_WMI_AUDIOSLAVE
+{
EVENT_TRACE_HEADER header;
PERFINFO_DSHOW_AUDIOSLAVE data;
} PERFINFO_WMI_AUDIOSLAVE, *PPERFINFO_WMI_AUDIOSLAVE;
-typedef struct PERFINFO_DSHOW_AUDIOADDBREAK {
+typedef struct PERFINFO_DSHOW_AUDIOADDBREAK
+{
DWORD iterNextWrite ;
DWORD offsetNextWrite ;
DWORD iterWrite ;
DWORD offsetWrite ;
} PERFINFO_DSHOW_AUDIOADDBREAK, *PPERFINFO_DSHOW_AUDIOADDBREAK;
-typedef struct PERFINFO_WMI_AUDIOADDBREAK {
+typedef struct PERFINFO_WMI_AUDIOADDBREAK
+{
EVENT_TRACE_HEADER header;
PERFINFO_DSHOW_AUDIOADDBREAK data;
} PERFINFO_WMI_AUDIOADDBREAK, *PPERFINFO_WMI_AUDIOADDBREAK;
diff --git a/src/filters/BaseClasses/pstream.cpp b/src/filters/BaseClasses/pstream.cpp
index d20171f5c..7555c3059 100644
--- a/src/filters/BaseClasses/pstream.cpp
+++ b/src/filters/BaseClasses/pstream.cpp
@@ -28,7 +28,8 @@ CPersistStream::CPersistStream(IUnknown *punk, __inout HRESULT *phr)
//
// Destructor
//
-CPersistStream::~CPersistStream() {
+CPersistStream::~CPersistStream()
+{
// Nothing to do
}
@@ -41,13 +42,16 @@ SAMPLE CODE TO COPY - not active at the moment
// This object supports IPersist & IPersistStream
STDMETHODIMP CPersistStream::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
- if (riid == IID_IPersist) {
+ if(riid == IID_IPersist)
+ {
return GetInterface((IPersist *) this, ppv); // ???
}
- else if (riid == IID_IPersistStream) {
+ else if(riid == IID_IPersistStream)
+ {
return GetInterface((IPersistStream *) this, ppv);
}
- else {
+ else
+ {
return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -86,7 +90,8 @@ STDMETHODIMP CPersistStream::Load(LPSTREAM pStm)
HRESULT hr;
// Load the version number then the data
mPS_dwFileVersion = ReadInt(pStm, hr);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -103,12 +108,14 @@ STDMETHODIMP CPersistStream::Save(LPSTREAM pStm, BOOL fClearDirty)
{
HRESULT hr = WriteInt(pStm, GetSoftwareVersion());
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
hr = WriteToStream(pStm);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -129,8 +136,8 @@ STDMETHODIMP CPersistStream::Save(LPSTREAM pStm, BOOL fClearDirty)
STDAPI WriteInt(IStream *pIStream, int n)
{
WCHAR Buff[13]; // Allows for trailing null that we don't write
- (void)StringCchPrintfW(Buff, NUMELMS(Buff),L"%011d ",n);
- return pIStream->Write(&(Buff[0]), 12*sizeof(WCHAR), NULL);
+ (void)StringCchPrintfW(Buff, NUMELMS(Buff), L"%011d ", n);
+ return pIStream->Write(&(Buff[0]), 12 * sizeof(WCHAR), NULL);
} // WriteInt
@@ -148,41 +155,52 @@ STDAPI_(int) ReadInt(IStream *pIStream, __out HRESULT &hr)
unsigned int n = 0; // result wil be n*Sign
WCHAR wch;
- hr = pIStream->Read( &wch, sizeof(wch), NULL);
- if (FAILED(hr)) {
+ hr = pIStream->Read(&wch, sizeof(wch), NULL);
+ if(FAILED(hr))
+ {
return 0;
}
- if (wch==L'-'){
+ if(wch == L'-')
+ {
Sign = -1;
- hr = pIStream->Read( &wch, sizeof(wch), NULL);
- if (FAILED(hr)) {
+ hr = pIStream->Read(&wch, sizeof(wch), NULL);
+ if(FAILED(hr))
+ {
return 0;
}
}
- for( ; ; ) {
- if (wch>=L'0' && wch<=L'9') {
- n = 10*n+(int)(wch-L'0');
- } else if ( wch == L' '
- || wch == L'\t'
- || wch == L'\r'
- || wch == L'\n'
- || wch == L'\0'
- ) {
+ for(; ;)
+ {
+ if(wch >= L'0' && wch <= L'9')
+ {
+ n = 10 * n + (int)(wch - L'0');
+ }
+ else if(wch == L' '
+ || wch == L'\t'
+ || wch == L'\r'
+ || wch == L'\n'
+ || wch == L'\0'
+ )
+ {
break;
- } else {
+ }
+ else
+ {
hr = VFW_E_INVALID_FILE_FORMAT;
return 0;
}
- hr = pIStream->Read( &wch, sizeof(wch), NULL);
- if (FAILED(hr)) {
+ hr = pIStream->Read(&wch, sizeof(wch), NULL);
+ if(FAILED(hr))
+ {
return 0;
}
}
- if (n==0x80000000 && Sign==-1) {
+ if(n == 0x80000000 && Sign == -1)
+ {
// This is the negative number that has no positive version!
return (int)n;
}
diff --git a/src/filters/BaseClasses/pstream.h b/src/filters/BaseClasses/pstream.h
index 04b6af624..5fca1b88d 100644
--- a/src/filters/BaseClasses/pstream.h
+++ b/src/filters/BaseClasses/pstream.h
@@ -44,60 +44,75 @@
// Implements IPersistStream.
// See 'OLE Programmers Reference (Vol 1):Structured Storage Overview' for
// more implementation information.
-class CPersistStream : public IPersistStream {
- private:
+class CPersistStream : public IPersistStream
+{
+private:
- // Internal state:
+ // Internal state:
- protected:
- DWORD mPS_dwFileVersion; // version number of file (being read)
- BOOL mPS_fDirty;
+protected:
+ DWORD mPS_dwFileVersion; // version number of file (being read)
+ BOOL mPS_fDirty;
- public:
+public:
- // IPersistStream methods
+ // IPersistStream methods
- STDMETHODIMP IsDirty()
- {return (mPS_fDirty ? S_OK : S_FALSE);} // note FALSE means clean
- STDMETHODIMP Load(LPSTREAM pStm);
- STDMETHODIMP Save(LPSTREAM pStm, BOOL fClearDirty);
- STDMETHODIMP GetSizeMax(__out ULARGE_INTEGER * pcbSize)
- // Allow 24 bytes for version.
- { pcbSize->QuadPart = 12*sizeof(WCHAR)+SizeMax(); return NOERROR; }
+ STDMETHODIMP IsDirty()
+ {
+ return (mPS_fDirty ? S_OK : S_FALSE); // note FALSE means clean
+ }
+ STDMETHODIMP Load(LPSTREAM pStm);
+ STDMETHODIMP Save(LPSTREAM pStm, BOOL fClearDirty);
+ STDMETHODIMP GetSizeMax(__out ULARGE_INTEGER * pcbSize)
+ // Allow 24 bytes for version.
+ {
+ pcbSize->QuadPart = 12 * sizeof(WCHAR) + SizeMax();
+ return NOERROR;
+ }
- // implementation
+ // implementation
- CPersistStream(IUnknown *punk, __inout HRESULT *phr);
- ~CPersistStream();
+ CPersistStream(IUnknown *punk, __inout HRESULT *phr);
+ ~CPersistStream();
- HRESULT SetDirty(BOOL fDirty)
- { mPS_fDirty = fDirty; return NOERROR;}
+ HRESULT SetDirty(BOOL fDirty)
+ {
+ mPS_fDirty = fDirty;
+ return NOERROR;
+ }
- // override to reveal IPersist & IPersistStream
- // STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
+ // override to reveal IPersist & IPersistStream
+ // STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
- // --- IPersist ---
+ // --- IPersist ---
- // You must override this to provide your own class id
- STDMETHODIMP GetClassID(__out CLSID *pClsid) PURE;
+ // You must override this to provide your own class id
+ STDMETHODIMP GetClassID(__out CLSID *pClsid) PURE;
- // overrideable if you want
- // file version number. Override it if you ever change format
- virtual DWORD GetSoftwareVersion(void) { return 0; }
+ // overrideable if you want
+ // file version number. Override it if you ever change format
+ virtual DWORD GetSoftwareVersion(void)
+ {
+ return 0;
+ }
- //=========================================================================
- // OVERRIDE THESE to read and write your data
- // OVERRIDE THESE to read and write your data
- // OVERRIDE THESE to read and write your data
+ //=========================================================================
+ // OVERRIDE THESE to read and write your data
+ // OVERRIDE THESE to read and write your data
+ // OVERRIDE THESE to read and write your data
- virtual int SizeMax() {return 0;}
- virtual HRESULT WriteToStream(IStream *pStream);
- virtual HRESULT ReadFromStream(IStream *pStream);
- //=========================================================================
+ virtual int SizeMax()
+ {
+ return 0;
+ }
+ virtual HRESULT WriteToStream(IStream *pStream);
+ virtual HRESULT ReadFromStream(IStream *pStream);
+ //=========================================================================
- private:
+private:
};
diff --git a/src/filters/BaseClasses/pullpin.cpp b/src/filters/BaseClasses/pullpin.cpp
index a197ba58a..988747cb8 100644
--- a/src/filters/BaseClasses/pullpin.cpp
+++ b/src/filters/BaseClasses/pullpin.cpp
@@ -17,12 +17,12 @@
CPullPin::CPullPin()
- : m_pReader(NULL),
- m_pAlloc(NULL),
- m_State(TM_Exit)
+ : m_pReader(NULL),
+ m_pAlloc(NULL),
+ m_State(TM_Exit)
{
#ifdef DXMPERF
- PERFLOG_CTOR( L"CPullPin", this );
+ PERFLOG_CTOR(L"CPullPin", this);
#endif // DXMPERF
}
@@ -32,7 +32,7 @@ CPullPin::~CPullPin()
Disconnect();
#ifdef DXMPERF
- PERFLOG_DTOR( L"CPullPin", this );
+ PERFLOG_DTOR(L"CPullPin", this);
#endif // DXMPERF
}
@@ -46,50 +46,54 @@ CPullPin::Connect(IUnknown* pUnk, IMemAllocator* pAlloc, BOOL bSync)
{
CAutoLock lock(&m_AccessLock);
- if (m_pReader) {
- return VFW_E_ALREADY_CONNECTED;
+ if(m_pReader)
+ {
+ return VFW_E_ALREADY_CONNECTED;
}
HRESULT hr = pUnk->QueryInterface(IID_IAsyncReader, (void**)&m_pReader);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
#ifdef DXMPERF
- {
- AM_MEDIA_TYPE * pmt = NULL;
- PERFLOG_CONNECT( this, pUnk, hr, pmt );
- }
+ {
+ AM_MEDIA_TYPE * pmt = NULL;
+ PERFLOG_CONNECT(this, pUnk, hr, pmt);
+ }
#endif // DXMPERF
- return(hr);
+ return(hr);
}
hr = DecideAllocator(pAlloc, NULL);
- if (FAILED(hr)) {
- Disconnect();
+ if(FAILED(hr))
+ {
+ Disconnect();
#ifdef DXMPERF
- {
- AM_MEDIA_TYPE * pmt = NULL;
- PERFLOG_CONNECT( this, pUnk, hr, pmt );
- }
+ {
+ AM_MEDIA_TYPE * pmt = NULL;
+ PERFLOG_CONNECT(this, pUnk, hr, pmt);
+ }
#endif // DXMPERF
- return hr;
+ return hr;
}
LONGLONG llTotal, llAvail;
hr = m_pReader->Length(&llTotal, &llAvail);
- if (FAILED(hr)) {
- Disconnect();
+ if(FAILED(hr))
+ {
+ Disconnect();
#ifdef DXMPERF
- {
- AM_MEDIA_TYPE * pmt = NULL;
- PERFLOG_CONNECT( this, pUnk, hr, pmt );
- }
+ {
+ AM_MEDIA_TYPE * pmt = NULL;
+ PERFLOG_CONNECT(this, pUnk, hr, pmt);
+ }
#endif
- return hr;
+ return hr;
}
// convert from file position to reference time
@@ -100,10 +104,10 @@ CPullPin::Connect(IUnknown* pUnk, IMemAllocator* pAlloc, BOOL bSync)
m_bSync = bSync;
#ifdef DXMPERF
- {
- AM_MEDIA_TYPE * pmt = NULL;
- PERFLOG_CONNECT( this, pUnk, S_OK, pmt );
- }
+ {
+ AM_MEDIA_TYPE * pmt = NULL;
+ PERFLOG_CONNECT(this, pUnk, S_OK, pmt);
+ }
#endif // DXMPERF
@@ -120,18 +124,20 @@ CPullPin::Disconnect()
#ifdef DXMPERF
- PERFLOG_DISCONNECT( this, m_pReader, S_OK );
+ PERFLOG_DISCONNECT(this, m_pReader, S_OK);
#endif // DXMPERF
- if (m_pReader) {
- m_pReader->Release();
- m_pReader = NULL;
+ if(m_pReader)
+ {
+ m_pReader->Release();
+ m_pReader = NULL;
}
- if (m_pAlloc) {
- m_pAlloc->Release();
- m_pAlloc = NULL;
+ if(m_pAlloc)
+ {
+ m_pAlloc->Release();
+ m_pAlloc = NULL;
}
return S_OK;
@@ -149,19 +155,22 @@ CPullPin::DecideAllocator(
{
ALLOCATOR_PROPERTIES *pRequest;
ALLOCATOR_PROPERTIES Request;
- if (pProps == NULL) {
- Request.cBuffers = 3;
- Request.cbBuffer = 64*1024;
- Request.cbAlign = 0;
- Request.cbPrefix = 0;
- pRequest = &Request;
- } else {
- pRequest = pProps;
+ if(pProps == NULL)
+ {
+ Request.cBuffers = 3;
+ Request.cbBuffer = 64 * 1024;
+ Request.cbAlign = 0;
+ Request.cbPrefix = 0;
+ pRequest = &Request;
+ }
+ else
+ {
+ pRequest = pProps;
}
HRESULT hr = m_pReader->RequestAllocator(
- pAlloc,
- pRequest,
- &m_pAlloc);
+ pAlloc,
+ pRequest,
+ &m_pAlloc);
return hr;
}
@@ -189,18 +198,20 @@ CPullPin::Seek(REFERENCE_TIME tStart, REFERENCE_TIME tStop)
ThreadMsg AtStart = m_State;
- if (AtStart == TM_Start) {
- BeginFlush();
- PauseThread();
- EndFlush();
+ if(AtStart == TM_Start)
+ {
+ BeginFlush();
+ PauseThread();
+ EndFlush();
}
m_tStart = tStart;
m_tStop = tStop;
HRESULT hr = S_OK;
- if (AtStart == TM_Start) {
- hr = StartThread();
+ if(AtStart == TM_Start)
+ {
+ hr = StartThread();
}
return hr;
@@ -219,23 +230,27 @@ CPullPin::StartThread()
{
CAutoLock lock(&m_AccessLock);
- if (!m_pAlloc || !m_pReader) {
- return E_UNEXPECTED;
+ if(!m_pAlloc || !m_pReader)
+ {
+ return E_UNEXPECTED;
}
HRESULT hr;
- if (!ThreadExists()) {
+ if(!ThreadExists())
+ {
- // commit allocator
- hr = m_pAlloc->Commit();
- if (FAILED(hr)) {
- return hr;
- }
+ // commit allocator
+ hr = m_pAlloc->Commit();
+ if(FAILED(hr))
+ {
+ return hr;
+ }
- // start thread
- if (!Create()) {
- return E_FAIL;
- }
+ // start thread
+ if(!Create())
+ {
+ return E_FAIL;
+ }
}
m_State = TM_Start;
@@ -248,15 +263,17 @@ CPullPin::PauseThread()
{
CAutoLock lock(&m_AccessLock);
- if (!ThreadExists()) {
- return E_UNEXPECTED;
+ if(!ThreadExists())
+ {
+ return E_UNEXPECTED;
}
// need to flush to ensure the thread is not blocked
// in WaitForNext
HRESULT hr = m_pReader->BeginFlush();
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
m_State = TM_Pause;
@@ -271,15 +288,17 @@ CPullPin::StopThread()
{
CAutoLock lock(&m_AccessLock);
- if (!ThreadExists()) {
- return S_FALSE;
+ 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;
+ if(FAILED(hr))
+ {
+ return hr;
}
m_State = TM_Exit;
@@ -291,8 +310,9 @@ CPullPin::StopThread()
Close();
// decommit allocator
- if (m_pAlloc) {
- m_pAlloc->Decommit();
+ if(m_pAlloc)
+ {
+ m_pAlloc->Decommit();
}
return S_OK;
@@ -302,33 +322,35 @@ CPullPin::StopThread()
DWORD
CPullPin::ThreadProc(void)
{
- while(1) {
- DWORD cmd = GetRequest();
- switch(cmd) {
- case TM_Exit:
- Reply(S_OK);
- return 0;
-
- case TM_Pause:
- // we are paused already
- Reply(S_OK);
- break;
-
- case TM_Start:
- Reply(S_OK);
- Process();
- break;
- }
-
- // at this point, there should be no outstanding requests on the
- // upstream filter.
- // We should force begin/endflush to ensure that this is true.
- // !!!Note that we may currently be inside a BeginFlush/EndFlush pair
- // on another thread, but the premature EndFlush will do no harm now
- // that we are idle.
- m_pReader->BeginFlush();
- CleanupCancelled();
- m_pReader->EndFlush();
+ while(1)
+ {
+ DWORD cmd = GetRequest();
+ switch(cmd)
+ {
+ case TM_Exit:
+ Reply(S_OK);
+ return 0;
+
+ case TM_Pause:
+ // we are paused already
+ Reply(S_OK);
+ break;
+
+ case TM_Start:
+ Reply(S_OK);
+ Process();
+ break;
+ }
+
+ // at this point, there should be no outstanding requests on the
+ // upstream filter.
+ // We should force begin/endflush to ensure that this is true.
+ // !!!Note that we may currently be inside a BeginFlush/EndFlush pair
+ // on another thread, but the premature EndFlush will do no harm now
+ // that we are idle.
+ m_pReader->BeginFlush();
+ CleanupCancelled();
+ m_pReader->EndFlush();
}
}
@@ -337,18 +359,20 @@ CPullPin::QueueSample(
__inout REFERENCE_TIME& tCurrent,
REFERENCE_TIME tAlignStop,
BOOL bDiscontinuity
- )
+)
{
IMediaSample* pSample;
HRESULT hr = m_pAlloc->GetBuffer(&pSample, NULL, NULL, 0);
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
LONGLONG tStopThis = tCurrent + (pSample->GetSize() * UNITS);
- if (tStopThis > tAlignStop) {
- tStopThis = tAlignStop;
+ if(tStopThis > tAlignStop)
+ {
+ tStopThis = tAlignStop;
}
pSample->SetTime(&tCurrent, &tStopThis);
tCurrent = tStopThis;
@@ -356,13 +380,14 @@ CPullPin::QueueSample(
pSample->SetDiscontinuity(bDiscontinuity);
hr = m_pReader->Request(
- pSample,
- 0);
- if (FAILED(hr)) {
- pSample->Release();
-
- CleanupCancelled();
- OnError(hr);
+ pSample,
+ 0);
+ if(FAILED(hr))
+ {
+ pSample->Release();
+
+ CleanupCancelled();
+ OnError(hr);
}
return hr;
}
@@ -375,19 +400,24 @@ CPullPin::CollectAndDeliver(
IMediaSample* pSample = NULL; // better be sure pSample is set
DWORD_PTR dwUnused;
HRESULT hr = m_pReader->WaitForNext(
- INFINITE,
- &pSample,
- &dwUnused);
- if (FAILED(hr)) {
- if (pSample) {
- pSample->Release();
- }
- } else {
- hr = DeliverSample(pSample, tStart, tStop);
- }
- if (FAILED(hr)) {
- CleanupCancelled();
- OnError(hr);
+ INFINITE,
+ &pSample,
+ &dwUnused);
+ if(FAILED(hr))
+ {
+ if(pSample)
+ {
+ pSample->Release();
+ }
+ }
+ else
+ {
+ hr = DeliverSample(pSample, tStart, tStop);
+ }
+ if(FAILED(hr))
+ {
+ CleanupCancelled();
+ OnError(hr);
}
return hr;
@@ -398,12 +428,14 @@ CPullPin::DeliverSample(
IMediaSample* pSample,
REFERENCE_TIME tStart,
REFERENCE_TIME tStop
- )
+)
{
// fix up sample if past actual stop (for sector alignment)
REFERENCE_TIME t1, t2;
- if (S_OK == pSample->GetTime(&t1, &t2)) {
- if (t2 > tStop) {
+ if(S_OK == pSample->GetTime(&t1, &t2))
+ {
+ if(t2 > tStop)
+ {
t2 = tStop;
}
@@ -411,17 +443,18 @@ CPullPin::DeliverSample(
t1 -= tStart;
t2 -= tStart;
HRESULT hr = pSample->SetTime(&t1, &t2);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
}
#ifdef DXMPERF
- {
- AM_MEDIA_TYPE * pmt = NULL;
- pSample->GetMediaType( &pmt );
- PERFLOG_RECEIVE( L"CPullPin", m_pReader, this, pSample, pmt );
- }
+ {
+ AM_MEDIA_TYPE * pmt = NULL;
+ pSample->GetMediaType(&pmt);
+ PERFLOG_RECEIVE(L"CPullPin", m_pReader, this, pSample, pmt);
+ }
#endif
HRESULT hr = Receive(pSample);
@@ -433,9 +466,10 @@ void
CPullPin::Process(void)
{
// is there anything to do?
- if (m_tStop <= m_tStart) {
- EndOfStream();
- return;
+ if(m_tStop <= m_tStart)
+ {
+ EndOfStream();
+ return;
}
BOOL bDiscontinuity = TRUE;
@@ -451,8 +485,9 @@ CPullPin::Process(void)
REFERENCE_TIME tCurrent = tStart;
REFERENCE_TIME tStop = m_tStop;
- if (tStop > m_tDuration) {
- tStop = m_tDuration;
+ if(tStop > m_tDuration)
+ {
+ tStop = m_tDuration;
}
// align the stop position - may be past stop, but that
@@ -462,104 +497,124 @@ CPullPin::Process(void)
DWORD dwRequest;
- if (!m_bSync) {
-
- // Break out of the loop either if we get to the end or we're asked
- // to do something else
- while (tCurrent < tAlignStop) {
-
- // Break out without calling EndOfStream if we're asked to
- // do something different
- if (CheckRequest(&dwRequest)) {
- return;
- }
-
- // queue a first sample
- if (Actual.cBuffers > 1) {
-
- hr = QueueSample(tCurrent, tAlignStop, TRUE);
- bDiscontinuity = FALSE;
-
- if (FAILED(hr)) {
- return;
- }
- }
-
-
-
- // loop queueing second and waiting for first..
- while (tCurrent < tAlignStop) {
-
- hr = QueueSample(tCurrent, tAlignStop, bDiscontinuity);
- bDiscontinuity = FALSE;
-
- if (FAILED(hr)) {
- return;
- }
-
- hr = CollectAndDeliver(tStart, tStop);
- if (S_OK != hr) {
-
- // stop if error, or if downstream filter said
- // to stop.
- return;
- }
- }
-
- if (Actual.cBuffers > 1) {
- hr = CollectAndDeliver(tStart, tStop);
- if (FAILED(hr)) {
- return;
- }
- }
- }
- } else {
-
- // sync version of above loop
- while (tCurrent < tAlignStop) {
-
- // Break out without calling EndOfStream if we're asked to
- // do something different
- if (CheckRequest(&dwRequest)) {
- return;
- }
-
- IMediaSample* pSample;
-
- hr = m_pAlloc->GetBuffer(&pSample, NULL, NULL, 0);
- if (FAILED(hr)) {
- OnError(hr);
- return;
- }
-
- LONGLONG tStopThis = tCurrent + (pSample->GetSize() * UNITS);
- if (tStopThis > tAlignStop) {
- tStopThis = tAlignStop;
- }
- pSample->SetTime(&tCurrent, &tStopThis);
- tCurrent = tStopThis;
-
- if (bDiscontinuity) {
- pSample->SetDiscontinuity(TRUE);
- bDiscontinuity = FALSE;
- }
-
- hr = m_pReader->SyncReadAligned(pSample);
-
- if (FAILED(hr)) {
- pSample->Release();
- OnError(hr);
- return;
- }
-
- hr = DeliverSample(pSample, tStart, tStop);
- if (hr != S_OK) {
- if (FAILED(hr)) {
- OnError(hr);
- }
- return;
- }
- }
+ if(!m_bSync)
+ {
+
+ // Break out of the loop either if we get to the end or we're asked
+ // to do something else
+ while(tCurrent < tAlignStop)
+ {
+
+ // Break out without calling EndOfStream if we're asked to
+ // do something different
+ if(CheckRequest(&dwRequest))
+ {
+ return;
+ }
+
+ // queue a first sample
+ if(Actual.cBuffers > 1)
+ {
+
+ hr = QueueSample(tCurrent, tAlignStop, TRUE);
+ bDiscontinuity = FALSE;
+
+ if(FAILED(hr))
+ {
+ return;
+ }
+ }
+
+
+
+ // loop queueing second and waiting for first..
+ while(tCurrent < tAlignStop)
+ {
+
+ hr = QueueSample(tCurrent, tAlignStop, bDiscontinuity);
+ bDiscontinuity = FALSE;
+
+ if(FAILED(hr))
+ {
+ return;
+ }
+
+ hr = CollectAndDeliver(tStart, tStop);
+ if(S_OK != hr)
+ {
+
+ // stop if error, or if downstream filter said
+ // to stop.
+ return;
+ }
+ }
+
+ if(Actual.cBuffers > 1)
+ {
+ hr = CollectAndDeliver(tStart, tStop);
+ if(FAILED(hr))
+ {
+ return;
+ }
+ }
+ }
+ }
+ else
+ {
+
+ // sync version of above loop
+ while(tCurrent < tAlignStop)
+ {
+
+ // Break out without calling EndOfStream if we're asked to
+ // do something different
+ if(CheckRequest(&dwRequest))
+ {
+ return;
+ }
+
+ IMediaSample* pSample;
+
+ hr = m_pAlloc->GetBuffer(&pSample, NULL, NULL, 0);
+ if(FAILED(hr))
+ {
+ OnError(hr);
+ return;
+ }
+
+ LONGLONG tStopThis = tCurrent + (pSample->GetSize() * UNITS);
+ if(tStopThis > tAlignStop)
+ {
+ tStopThis = tAlignStop;
+ }
+ pSample->SetTime(&tCurrent, &tStopThis);
+ tCurrent = tStopThis;
+
+ if(bDiscontinuity)
+ {
+ pSample->SetDiscontinuity(TRUE);
+ bDiscontinuity = FALSE;
+ }
+
+ hr = m_pReader->SyncReadAligned(pSample);
+
+ if(FAILED(hr))
+ {
+ pSample->Release();
+ OnError(hr);
+ return;
+ }
+
+ hr = DeliverSample(pSample, tStart, tStop);
+ if(hr != S_OK)
+ {
+ if(FAILED(hr))
+ {
+ OnError(hr);
+ }
+ return;
+ }
+ }
}
EndOfStream();
@@ -570,19 +625,23 @@ CPullPin::Process(void)
void
CPullPin::CleanupCancelled(void)
{
- while (1) {
- IMediaSample * pSample;
- DWORD_PTR dwUnused;
-
- HRESULT hr = m_pReader->WaitForNext(
- 0, // no wait
- &pSample,
- &dwUnused);
- if(pSample) {
- pSample->Release();
- } else {
- // no more samples
- return;
- }
+ while(1)
+ {
+ IMediaSample * pSample;
+ DWORD_PTR dwUnused;
+
+ HRESULT hr = m_pReader->WaitForNext(
+ 0, // no wait
+ &pSample,
+ &dwUnused);
+ if(pSample)
+ {
+ pSample->Release();
+ }
+ else
+ {
+ // no more samples
+ return;
+ }
}
}
diff --git a/src/filters/BaseClasses/pullpin.h b/src/filters/BaseClasses/pullpin.h
index 03ad40ec9..502f01e55 100644
--- a/src/filters/BaseClasses/pullpin.h
+++ b/src/filters/BaseClasses/pullpin.h
@@ -29,10 +29,11 @@ class CPullPin : public CAMThread
REFERENCE_TIME m_tDuration;
BOOL m_bSync;
- enum ThreadMsg {
- TM_Pause, // stop pulling and wait for next message
- TM_Start, // start pulling
- TM_Exit, // stop and exit
+ enum ThreadMsg
+ {
+ TM_Pause, // stop pulling and wait for next message
+ TM_Start, // start pulling
+ TM_Exit, // stop and exit
};
ThreadMsg m_State;
@@ -57,18 +58,18 @@ class CPullPin : public CAMThread
// called from ProcessAsync to queue and collect requests
HRESULT QueueSample(
- __inout REFERENCE_TIME& tCurrent,
- REFERENCE_TIME tAlignStop,
- BOOL bDiscontinuity);
+ __inout REFERENCE_TIME& tCurrent,
+ REFERENCE_TIME tAlignStop,
+ BOOL bDiscontinuity);
HRESULT CollectAndDeliver(
- REFERENCE_TIME tStart,
- REFERENCE_TIME tStop);
+ REFERENCE_TIME tStart,
+ REFERENCE_TIME tStop);
HRESULT DeliverSample(
- IMediaSample* pSample,
- REFERENCE_TIME tStart,
- REFERENCE_TIME tStop);
+ IMediaSample* pSample,
+ REFERENCE_TIME tStart,
+ REFERENCE_TIME tStop);
protected:
IMemAllocator * m_pAlloc;
@@ -94,8 +95,8 @@ public:
// optional IMemAllocator interface is offered as a preferred allocator
// but no error occurs if it can't be met.
virtual HRESULT DecideAllocator(
- IMemAllocator* pAlloc,
- __inout_opt ALLOCATOR_PROPERTIES * pProps);
+ IMemAllocator* pAlloc,
+ __inout_opt ALLOCATOR_PROPERTIES * pProps);
// set start and stop position. if active, will start immediately at
// the new position. Default is 0 to duration
@@ -111,21 +112,24 @@ public:
HRESULT Inactive(void);
// helper functions
- LONGLONG AlignDown(LONGLONG ll, LONG lAlign) {
- // aligning downwards is just truncation
- return ll & ~(lAlign-1);
+ LONGLONG AlignDown(LONGLONG ll, LONG lAlign)
+ {
+ // aligning downwards is just truncation
+ return ll & ~(lAlign - 1);
};
- LONGLONG AlignUp(LONGLONG ll, LONG lAlign) {
- // align up: round up to next boundary
- return (ll + (lAlign -1)) & ~(lAlign -1);
+ LONGLONG AlignUp(LONGLONG ll, LONG lAlign)
+ {
+ // align up: round up to next boundary
+ return (ll + (lAlign - 1)) & ~(lAlign - 1);
};
// GetReader returns the (addrefed) IAsyncReader interface
// for SyncRead etc
- IAsyncReader* GetReader() {
- m_pReader->AddRef();
- return m_pReader;
+ IAsyncReader* GetReader()
+ {
+ m_pReader->AddRef();
+ return m_pReader;
};
// -- pure --
diff --git a/src/filters/BaseClasses/refclock.cpp b/src/filters/BaseClasses/refclock.cpp
index 814a60f8a..9a647fb72 100644
--- a/src/filters/BaseClasses/refclock.cpp
+++ b/src/filters/BaseClasses/refclock.cpp
@@ -25,11 +25,11 @@ STDMETHODIMP CBaseReferenceClock::NonDelegatingQueryInterface(
{
HRESULT hr;
- if (riid == IID_IReferenceClock)
+ if(riid == IID_IReferenceClock)
{
hr = GetInterface((IReferenceClock *) this, ppv);
}
- else if (riid == IID_IReferenceClockTimerControl)
+ else if(riid == IID_IReferenceClockTimerControl)
{
hr = GetInterface((IReferenceClockTimerControl *) this, ppv);
}
@@ -43,49 +43,49 @@ STDMETHODIMP CBaseReferenceClock::NonDelegatingQueryInterface(
CBaseReferenceClock::~CBaseReferenceClock()
{
#ifdef DXMPERF
- PERFLOG_DTOR( L"CBaseReferenceClock", (IReferenceClock *) this );
+ PERFLOG_DTOR(L"CBaseReferenceClock", (IReferenceClock *) this);
#endif // DXMPERF
- if (m_TimerResolution) timeEndPeriod(m_TimerResolution);
+ if(m_TimerResolution) timeEndPeriod(m_TimerResolution);
- if (m_pSchedule)
+ if(m_pSchedule)
{
m_pSchedule->DumpLinkedList();
}
- if (m_hThread)
+ if(m_hThread)
{
m_bAbort = TRUE;
TriggerThread();
- WaitForSingleObject( m_hThread, INFINITE );
- EXECUTE_ASSERT( CloseHandle(m_hThread) );
+ WaitForSingleObject(m_hThread, INFINITE);
+ EXECUTE_ASSERT(CloseHandle(m_hThread));
m_hThread = 0;
- EXECUTE_ASSERT( CloseHandle(m_pSchedule->GetEvent()) );
- delete m_pSchedule;
+ EXECUTE_ASSERT(CloseHandle(m_pSchedule->GetEvent()));
+ delete m_pSchedule;
}
}
// A derived class may supply a hThreadEvent if it has its own thread that will take care
// of calling the schedulers Advise method. (Refere to CBaseReferenceClock::AdviseThread()
// to see what such a thread has to do.)
-CBaseReferenceClock::CBaseReferenceClock( __in_opt LPCTSTR pName,
- __inout_opt LPUNKNOWN pUnk,
- __inout HRESULT *phr,
- __inout_opt CAMSchedule * pShed )
-: CUnknown( pName, pUnk )
-, m_rtLastGotTime(0)
-, m_TimerResolution(0)
-, m_bAbort( FALSE )
-, m_pSchedule( pShed ? pShed : new CAMSchedule(CreateEvent(NULL, FALSE, FALSE, NULL)) )
-, m_hThread(0)
+CBaseReferenceClock::CBaseReferenceClock(__in_opt LPCTSTR pName,
+ __inout_opt LPUNKNOWN pUnk,
+ __inout HRESULT *phr,
+ __inout_opt CAMSchedule * pShed)
+ : CUnknown(pName, pUnk)
+ , m_rtLastGotTime(0)
+ , m_TimerResolution(0)
+ , m_bAbort(FALSE)
+ , m_pSchedule(pShed ? pShed : new CAMSchedule(CreateEvent(NULL, FALSE, FALSE, NULL)))
+ , m_hThread(0)
{
#ifdef DXMPERF
- PERFLOG_CTOR( pName ? pName : L"CBaseReferenceClock", (IReferenceClock *) this );
+ PERFLOG_CTOR(pName ? pName : L"CBaseReferenceClock", (IReferenceClock *) this);
#endif // DXMPERF
ASSERT(m_pSchedule);
- if (!m_pSchedule)
+ if(!m_pSchedule)
{
*phr = E_OUTOFMEMORY;
}
@@ -103,11 +103,11 @@ CBaseReferenceClock::CBaseReferenceClock( __in_opt LPCTSTR pName,
m_dwPrevSystemTime = timeGetTime();
m_rtPrivateTime = (UNITS / MILLISECONDS) * m_dwPrevSystemTime;
- #ifdef PERF
- m_idGetSystemTime = MSR_REGISTER(TEXT("CBaseReferenceClock::GetTime"));
- #endif
+#ifdef PERF
+ m_idGetSystemTime = MSR_REGISTER(TEXT("CBaseReferenceClock::GetTime"));
+#endif
- if ( !pShed )
+ if(!pShed)
{
DWORD ThreadID;
m_hThread = ::CreateThread(NULL, // Security attributes
@@ -117,14 +117,14 @@ CBaseReferenceClock::CBaseReferenceClock( __in_opt LPCTSTR pName,
(DWORD) 0, // Creation flags
&ThreadID); // Thread identifier
- if (m_hThread)
+ if(m_hThread)
{
- SetThreadPriority( m_hThread, THREAD_PRIORITY_TIME_CRITICAL );
+ SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
}
else
{
*phr = E_FAIL;
- EXECUTE_ASSERT( CloseHandle(m_pSchedule->GetEvent()) );
+ EXECUTE_ASSERT(CloseHandle(m_pSchedule->GetEvent()));
delete m_pSchedule;
m_pSchedule = NULL;
}
@@ -132,7 +132,7 @@ CBaseReferenceClock::CBaseReferenceClock( __in_opt LPCTSTR pName,
}
}
-void CBaseReferenceClock::Restart (IN REFERENCE_TIME rtMinTime)
+void CBaseReferenceClock::Restart(IN REFERENCE_TIME rtMinTime)
{
Lock();
m_rtLastGotTime = rtMinTime ;
@@ -142,12 +142,12 @@ void CBaseReferenceClock::Restart (IN REFERENCE_TIME rtMinTime)
STDMETHODIMP CBaseReferenceClock::GetTime(__out REFERENCE_TIME *pTime)
{
HRESULT hr;
- if (pTime)
+ if(pTime)
{
REFERENCE_TIME rtNow;
Lock();
rtNow = GetPrivateTime();
- if (rtNow > m_rtLastGotTime)
+ if(rtNow > m_rtLastGotTime)
{
m_rtLastGotTime = rtNow;
hr = S_OK;
@@ -158,10 +158,10 @@ STDMETHODIMP CBaseReferenceClock::GetTime(__out REFERENCE_TIME *pTime)
}
*pTime = m_rtLastGotTime;
Unlock();
- MSR_INTEGER(m_idGetSystemTime, LONG((*pTime) / (UNITS/MILLISECONDS)) );
+ MSR_INTEGER(m_idGetSystemTime, LONG((*pTime) / (UNITS / MILLISECONDS)));
#ifdef DXMPERF
- PERFLOG_GETTIME( (IReferenceClock *) this, *pTime );
+ PERFLOG_GETTIME((IReferenceClock *) this, *pTime);
#endif // DXMPERF
}
@@ -182,18 +182,18 @@ STDMETHODIMP CBaseReferenceClock::AdviseTime(
*pdwAdviseCookie = 0;
// Check that the event is not already set
- ASSERT(WAIT_TIMEOUT == WaitForSingleObject(HANDLE(hEvent),0));
+ ASSERT(WAIT_TIMEOUT == WaitForSingleObject(HANDLE(hEvent), 0));
HRESULT hr;
const REFERENCE_TIME lRefTime = baseTime + streamTime;
- if ( lRefTime <= 0 || lRefTime == MAX_TIME )
+ if(lRefTime <= 0 || lRefTime == MAX_TIME)
{
hr = E_INVALIDARG;
}
else
{
- *pdwAdviseCookie = m_pSchedule->AddAdvisePacket( lRefTime, 0, HANDLE(hEvent), FALSE );
+ *pdwAdviseCookie = m_pSchedule->AddAdvisePacket(lRefTime, 0, HANDLE(hEvent), FALSE);
hr = *pdwAdviseCookie ? NOERROR : E_OUTOFMEMORY;
}
return hr;
@@ -212,9 +212,9 @@ STDMETHODIMP CBaseReferenceClock::AdvisePeriodic(
*pdwAdviseCookie = 0;
HRESULT hr;
- if (StartTime > 0 && PeriodTime > 0 && StartTime != MAX_TIME )
+ if(StartTime > 0 && PeriodTime > 0 && StartTime != MAX_TIME)
{
- *pdwAdviseCookie = m_pSchedule->AddAdvisePacket( StartTime, PeriodTime, HANDLE(hSemaphore), TRUE );
+ *pdwAdviseCookie = m_pSchedule->AddAdvisePacket(StartTime, PeriodTime, HANDLE(hSemaphore), TRUE);
hr = *pdwAdviseCookie ? NOERROR : E_OUTOFMEMORY;
}
else hr = E_INVALIDARG;
@@ -267,7 +267,8 @@ STDMETHODIMP CBaseReferenceClock::SetTimeDelta(const REFERENCE_TIME & TimeDelta)
// Just break if passed an improper time delta value
LONGLONG llDelta = TimeDelta > 0 ? TimeDelta : -TimeDelta;
- if (llDelta > UNITS * 1000) {
+ if(llDelta > UNITS * 1000)
+ {
DbgLog((LOG_TRACE, 0, TEXT("Bad Time Delta")));
//DebugBreak();
}
@@ -275,12 +276,12 @@ STDMETHODIMP CBaseReferenceClock::SetTimeDelta(const REFERENCE_TIME & TimeDelta)
// 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
+ 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 )
+ while(delta > 0)
{
delta >>= 3; // div 8
Severity--;
@@ -288,16 +289,16 @@ STDMETHODIMP CBaseReferenceClock::SetTimeDelta(const REFERENCE_TIME & TimeDelta)
// 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)) ));
+ 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
+#ifdef BREAK_ON_SEVERE_TIME_DELTA
+ if(Severity < 0)
+ DbgBreakPoint(TEXT("SetTimeDelta > 16 seconds!"),
+ TEXT(__FILE__), __LINE__);
+#endif
#endif
@@ -310,7 +311,7 @@ STDMETHODIMP CBaseReferenceClock::SetTimeDelta(const REFERENCE_TIME & TimeDelta)
// 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();
+ if(TimeDelta > 5000 && m_pSchedule->GetAdviseCount() > 0) TriggerThread();
return NOERROR;
}
@@ -331,12 +332,12 @@ HRESULT CBaseReferenceClock::AdviseThread()
// routine and the derived class may not yet be constructed. (This
// thread is created in the base class constructor.)
- while ( !m_bAbort )
+ while(!m_bAbort)
{
// Wait for an interesting event to happen
- DbgLog((LOG_TIMING, 3, TEXT("CBaseRefClock::AdviseThread() Delay: %lu ms"), dwWait ));
+ DbgLog((LOG_TIMING, 3, TEXT("CBaseRefClock::AdviseThread() Delay: %lu ms"), dwWait));
WaitForSingleObject(m_pSchedule->GetEvent(), dwWait);
- if (m_bAbort) break;
+ if(m_bAbort) break;
// There are several reasons why we need to work from the internal
// time, mainly to do with what happens when time goes backwards.
@@ -346,16 +347,16 @@ HRESULT CBaseReferenceClock::AdviseThread()
const REFERENCE_TIME rtNow = GetPrivateTime();
DbgLog((LOG_TIMING, 3,
- TEXT("CBaseRefClock::AdviseThread() Woke at = %lu ms"),
- ConvertToMilliseconds(rtNow) ));
+ TEXT("CBaseRefClock::AdviseThread() Woke at = %lu ms"),
+ ConvertToMilliseconds(rtNow)));
// We must add in a millisecond, since this is the resolution of our
// WaitForSingleObject timer. Failure to do so will cause us to loop
// franticly for (approx) 1 a millisecond.
- m_rtNextAdvise = m_pSchedule->Advise( 10000 + rtNow );
+ m_rtNextAdvise = m_pSchedule->Advise(10000 + rtNow);
LONGLONG llWait = m_rtNextAdvise - rtNow;
- ASSERT( llWait > 0 );
+ ASSERT(llWait > 0);
llWait = ConvertToMilliseconds(llWait);
// DON'T replace this with a max!! (The type's of these things is VERY important)
@@ -365,35 +366,41 @@ HRESULT CBaseReferenceClock::AdviseThread()
}
HRESULT CBaseReferenceClock::SetDefaultTimerResolution(
- REFERENCE_TIME timerResolution // in 100ns
- )
+ REFERENCE_TIME timerResolution // in 100ns
+)
{
CAutoLock cObjectLock(this);
- if( 0 == timerResolution ) {
- if( m_TimerResolution ) {
- timeEndPeriod( m_TimerResolution );
- m_TimerResolution = 0;
+ if(0 == timerResolution)
+ {
+ if(m_TimerResolution)
+ {
+ timeEndPeriod(m_TimerResolution);
+ m_TimerResolution = 0;
}
- } else {
+ }
+ else
+ {
TIMECAPS tc;
DWORD dwMinResolution = (TIMERR_NOERROR == timeGetDevCaps(&tc, sizeof(tc)))
- ? tc.wPeriodMin
- : 1;
- DWORD dwResolution = max( dwMinResolution, DWORD(timerResolution / 10000) );
- if( dwResolution != m_TimerResolution ) {
+ ? tc.wPeriodMin
+ : 1;
+ DWORD dwResolution = max(dwMinResolution, DWORD(timerResolution / 10000));
+ if(dwResolution != m_TimerResolution)
+ {
timeEndPeriod(m_TimerResolution);
m_TimerResolution = dwResolution;
- timeBeginPeriod( m_TimerResolution );
+ timeBeginPeriod(m_TimerResolution);
}
}
return S_OK;
}
HRESULT CBaseReferenceClock::GetDefaultTimerResolution(
- __out REFERENCE_TIME* pTimerResolution // in 100ns
- )
+ __out REFERENCE_TIME* pTimerResolution // in 100ns
+)
{
- if( !pTimerResolution ) {
+ if(!pTimerResolution)
+ {
return E_POINTER;
}
CAutoLock cObjectLock(this);
diff --git a/src/filters/BaseClasses/refclock.h b/src/filters/BaseClasses/refclock.h
index bf685fba0..429e96496 100644
--- a/src/filters/BaseClasses/refclock.h
+++ b/src/filters/BaseClasses/refclock.h
@@ -75,15 +75,15 @@ inline LONGLONG WINAPI ConvertToMilliseconds(const REFERENCE_TIME& RT)
*/
class CBaseReferenceClock
-: public CUnknown, public IReferenceClock, public CCritSec, public IReferenceClockTimerControl
+ : public CUnknown, public IReferenceClock, public CCritSec, public IReferenceClockTimerControl
{
protected:
virtual ~CBaseReferenceClock(); // Don't let me be created on the stack!
public:
- CBaseReferenceClock(__in_opt LPCTSTR pName,
- __inout_opt LPUNKNOWN pUnk,
- __inout HRESULT *phr,
- __inout_opt CAMSchedule * pSched = 0 );
+ CBaseReferenceClock(__in_opt LPCTSTR pName,
+ __inout_opt LPUNKNOWN pUnk,
+ __inout HRESULT *phr,
+ __inout_opt CAMSchedule * pSched = 0);
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv);
@@ -137,9 +137,12 @@ public:
virtual REFERENCE_TIME GetPrivateTime();
/* Provide a method for correcting drift */
- STDMETHODIMP SetTimeDelta( const REFERENCE_TIME& TimeDelta );
+ STDMETHODIMP SetTimeDelta(const REFERENCE_TIME& TimeDelta);
- CAMSchedule * GetSchedule() const { return m_pSchedule; }
+ CAMSchedule * GetSchedule() const
+ {
+ return m_pSchedule;
+ }
// IReferenceClockTimerControl methods
//
@@ -165,7 +168,8 @@ private:
// Thread stuff
public:
void TriggerThread() // Wakes thread up. Need to do this if
- { // time to next advise needs reevaluating.
+ {
+ // time to next advise needs reevaluating.
EXECUTE_ASSERT(SetEvent(m_pSchedule->GetEvent()));
}
@@ -180,7 +184,7 @@ private:
protected:
CAMSchedule * m_pSchedule;
- void Restart (IN REFERENCE_TIME rtMinTime = 0I64) ;
+ void Restart(IN REFERENCE_TIME rtMinTime = 0I64) ;
};
#endif
diff --git a/src/filters/BaseClasses/renbase.cpp b/src/filters/BaseClasses/renbase.cpp
index c9766baf1..4f4d2505a 100644
--- a/src/filters/BaseClasses/renbase.cpp
+++ b/src/filters/BaseClasses/renbase.cpp
@@ -17,12 +17,15 @@
// Helper function for clamping time differences
int inline TimeDiff(REFERENCE_TIME rt)
{
- if (rt < - (50 * UNITS)) {
+ if(rt < - (50 * UNITS))
+ {
return -(50 * UNITS);
- } else
- if (rt > 50 * UNITS) {
+ }
+ else if(rt > 50 * UNITS)
+ {
return 50 * UNITS;
- } else return (int)rt;
+ }
+ else return (int)rt;
}
// Implements the CBaseRenderer class
@@ -32,7 +35,7 @@ CBaseRenderer::CBaseRenderer(REFCLSID RenderClass, // CLSID for this renderer
__inout_opt LPUNKNOWN pUnk, // Aggregated owner object
__inout HRESULT *phr) : // General OLE return code
- CBaseFilter(pName,pUnk,&m_InterfaceLock,RenderClass),
+ CBaseFilter(pName, pUnk, &m_InterfaceLock, RenderClass),
m_evComplete(TRUE, phr),
m_RenderEvent(FALSE, phr),
m_bAbort(FALSE),
@@ -50,7 +53,8 @@ CBaseRenderer::CBaseRenderer(REFCLSID RenderClass, // CLSID for this renderer
m_bInReceive(FALSE),
m_EndOfStreamTimer(0)
{
- if (SUCCEEDED(*phr)) {
+ if(SUCCEEDED(*phr))
+ {
Ready();
#ifdef PERF
m_idBaseStamp = MSR_REGISTER(TEXT("BaseRenderer: sample time stamp"));
@@ -76,14 +80,16 @@ CBaseRenderer::~CBaseRenderer()
// Delete any IMediaPosition implementation
- if (m_pPosition) {
+ if(m_pPosition)
+ {
delete m_pPosition;
m_pPosition = NULL;
}
// Delete any input pin created
- if (m_pInputPin) {
+ if(m_pInputPin)
+ {
delete m_pInputPin;
m_pInputPin = NULL;
}
@@ -99,12 +105,14 @@ CBaseRenderer::~CBaseRenderer()
HRESULT CBaseRenderer::GetMediaPositionInterface(REFIID riid, __deref_out void **ppv)
{
CAutoLock cObjectCreationLock(&m_ObjectCreationLock);
- if (m_pPosition) {
- return m_pPosition->NonDelegatingQueryInterface(riid,ppv);
+ if(m_pPosition)
+ {
+ return m_pPosition->NonDelegatingQueryInterface(riid, ppv);
}
CBasePin *pPin = GetPin(0);
- if (NULL == pPin) {
+ if(NULL == pPin)
+ {
return E_OUTOFMEMORY;
}
@@ -119,16 +127,18 @@ HRESULT CBaseRenderer::GetMediaPositionInterface(REFIID riid, __deref_out void *
CBaseFilter::GetOwner(),
(HRESULT *) &hr,
pPin);
- if (m_pPosition == NULL) {
+ if(m_pPosition == NULL)
+ {
return E_OUTOFMEMORY;
}
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
delete m_pPosition;
m_pPosition = NULL;
return E_NOINTERFACE;
}
- return GetMediaPositionInterface(riid,ppv);
+ return GetMediaPositionInterface(riid, ppv);
}
@@ -138,10 +148,13 @@ STDMETHODIMP CBaseRenderer::NonDelegatingQueryInterface(REFIID riid, __deref_out
{
// Do we have this interface
- if (riid == IID_IMediaPosition || riid == IID_IMediaSeeking) {
- return GetMediaPositionInterface(riid,ppv);
- } else {
- return CBaseFilter::NonDelegatingQueryInterface(riid,ppv);
+ if(riid == IID_IMediaPosition || riid == IID_IMediaSeeking)
+ {
+ return GetMediaPositionInterface(riid, ppv);
+ }
+ else
+ {
+ return CBaseFilter::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -154,9 +167,12 @@ STDMETHODIMP CBaseRenderer::NonDelegatingQueryInterface(REFIID riid, __deref_out
HRESULT CBaseRenderer::SourceThreadCanWait(BOOL bCanWait)
{
- if (bCanWait == TRUE) {
+ if(bCanWait == TRUE)
+ {
m_ThreadSignal.Reset();
- } else {
+ }
+ else
+ {
m_ThreadSignal.Set();
}
return NOERROR;
@@ -177,68 +193,68 @@ void CBaseRenderer::DisplayRendererState()
// No way should this be signalled at this point
BOOL bSignalled = m_ThreadSignal.Check();
- DbgLog((LOG_TIMING, 1, TEXT("Signal sanity check %d"),bSignalled));
+ DbgLog((LOG_TIMING, 1, TEXT("Signal sanity check %d"), bSignalled));
// Now output the current renderer state variables
- DbgLog((LOG_TIMING, 1, TEXT("Filter state %d"),m_State));
+ DbgLog((LOG_TIMING, 1, TEXT("Filter state %d"), m_State));
- DbgLog((LOG_TIMING, 1, TEXT("Abort flag %d"),m_bAbort));
+ DbgLog((LOG_TIMING, 1, TEXT("Abort flag %d"), m_bAbort));
- DbgLog((LOG_TIMING, 1, TEXT("Streaming flag %d"),m_bStreaming));
+ DbgLog((LOG_TIMING, 1, TEXT("Streaming flag %d"), m_bStreaming));
- DbgLog((LOG_TIMING, 1, TEXT("Clock advise link %d"),m_dwAdvise));
+ DbgLog((LOG_TIMING, 1, TEXT("Clock advise link %d"), m_dwAdvise));
- DbgLog((LOG_TIMING, 1, TEXT("Current media sample %x"),m_pMediaSample));
+ DbgLog((LOG_TIMING, 1, TEXT("Current media sample %x"), m_pMediaSample));
- DbgLog((LOG_TIMING, 1, TEXT("EOS signalled %d"),m_bEOS));
+ DbgLog((LOG_TIMING, 1, TEXT("EOS signalled %d"), m_bEOS));
- DbgLog((LOG_TIMING, 1, TEXT("EOS delivered %d"),m_bEOSDelivered));
+ DbgLog((LOG_TIMING, 1, TEXT("EOS delivered %d"), m_bEOSDelivered));
- DbgLog((LOG_TIMING, 1, TEXT("Repaint status %d"),m_bRepaintStatus));
+ DbgLog((LOG_TIMING, 1, TEXT("Repaint status %d"), m_bRepaintStatus));
// Output the delayed end of stream timer information
- DbgLog((LOG_TIMING, 1, TEXT("End of stream timer %x"),m_EndOfStreamTimer));
+ DbgLog((LOG_TIMING, 1, TEXT("End of stream timer %x"), m_EndOfStreamTimer));
- DbgLog((LOG_TIMING, 1, TEXT("Deliver time %s"),CDisp((LONGLONG)m_SignalTime)));
+ DbgLog((LOG_TIMING, 1, TEXT("Deliver time %s"), CDisp((LONGLONG)m_SignalTime)));
// Should never timeout during a flushing state
BOOL bFlushing = m_pInputPin->IsFlushing();
- DbgLog((LOG_TIMING, 1, TEXT("Flushing sanity check %d"),bFlushing));
+ DbgLog((LOG_TIMING, 1, TEXT("Flushing sanity check %d"), bFlushing));
// Display the time we were told to start at
- DbgLog((LOG_TIMING, 1, TEXT("Last run time %s"),CDisp((LONGLONG)m_tStart.m_time)));
+ DbgLog((LOG_TIMING, 1, TEXT("Last run time %s"), CDisp((LONGLONG)m_tStart.m_time)));
// Have we got a reference clock
- if (m_pClock == NULL) return;
+ if(m_pClock == NULL) return;
// Get the current time from the wall clock
- CRefTime CurrentTime,StartTime,EndTime;
+ CRefTime CurrentTime, StartTime, EndTime;
m_pClock->GetTime((REFERENCE_TIME*) &CurrentTime);
CRefTime Offset = CurrentTime - m_tStart;
// Display the current time from the clock
- DbgLog((LOG_TIMING, 1, TEXT("Clock time %s"),CDisp((LONGLONG)CurrentTime.m_time)));
+ DbgLog((LOG_TIMING, 1, TEXT("Clock time %s"), CDisp((LONGLONG)CurrentTime.m_time)));
- DbgLog((LOG_TIMING, 1, TEXT("Time difference %dms"),Offset.Millisecs()));
+ DbgLog((LOG_TIMING, 1, TEXT("Time difference %dms"), Offset.Millisecs()));
// Do we have a sample ready to render
- if (m_pMediaSample == NULL) return;
+ if(m_pMediaSample == NULL) return;
m_pMediaSample->GetTime((REFERENCE_TIME*)&StartTime, (REFERENCE_TIME*)&EndTime);
DbgLog((LOG_TIMING, 1, TEXT("Next sample stream times (Start %d End %d ms)"),
- StartTime.Millisecs(),EndTime.Millisecs()));
+ StartTime.Millisecs(), EndTime.Millisecs()));
// Calculate how long it is until it is due for rendering
CRefTime Wait = (m_tStart + StartTime) - CurrentTime;
- DbgLog((LOG_TIMING, 1, TEXT("Wait required %d ms"),Wait.Millisecs()));
+ DbgLog((LOG_TIMING, 1, TEXT("Wait required %d ms"), Wait.Millisecs()));
}
#endif
@@ -259,11 +275,12 @@ HRESULT CBaseRenderer::WaitForRenderTime()
// Wait for either the time to arrive or for us to be stopped
OnWaitStart();
- while (Result == WAIT_TIMEOUT) {
- Result = WaitForMultipleObjects(2,WaitObjects,FALSE,RENDER_TIMEOUT);
+ while(Result == WAIT_TIMEOUT)
+ {
+ Result = WaitForMultipleObjects(2, WaitObjects, FALSE, RENDER_TIMEOUT);
#ifdef _DEBUG
- if (Result == WAIT_TIMEOUT) DisplayRendererState();
+ if(Result == WAIT_TIMEOUT) DisplayRendererState();
#endif
}
@@ -271,7 +288,8 @@ HRESULT CBaseRenderer::WaitForRenderTime()
// We may have been awoken without the timer firing
- if (Result == WAIT_OBJECT_0) {
+ if(Result == WAIT_OBJECT_0)
+ {
return VFW_E_STATE_CHANGED;
}
@@ -289,8 +307,10 @@ HRESULT CBaseRenderer::WaitForRenderTime()
// the renderer's Receive processing
void CBaseRenderer::WaitForReceiveToComplete()
{
- for (;;) {
- if (!m_bInReceive) {
+ for(;;)
+ {
+ if(!m_bInReceive)
+ {
break;
}
@@ -305,7 +325,8 @@ void CBaseRenderer::WaitForReceiveToComplete()
// above just cleared the changebit which will cause some messaging
// calls to block (waitMessage, MsgWaitFor...) now.
// Post a dummy message to set the QS_POSTMESSAGE bit again
- if (HIWORD(GetQueueStatus(QS_POSTMESSAGE)) & QS_POSTMESSAGE) {
+ if(HIWORD(GetQueueStatus(QS_POSTMESSAGE)) & QS_POSTMESSAGE)
+ {
// Send dummy message
PostThreadMessage(GetCurrentThreadId(), WM_NULL, 0, 0);
}
@@ -328,7 +349,8 @@ void CBaseRenderer::WaitForReceiveToComplete()
// Simple internal way of getting the real state
-FILTER_STATE CBaseRenderer::GetRealState() {
+FILTER_STATE CBaseRenderer::GetRealState()
+{
return m_State;
}
@@ -337,11 +359,12 @@ FILTER_STATE CBaseRenderer::GetRealState() {
// it has got one media sample to render. If you ask it for its state while
// it's waiting it will return the state along with VFW_S_STATE_INTERMEDIATE
-STDMETHODIMP CBaseRenderer::GetState(DWORD dwMSecs,FILTER_STATE *State)
+STDMETHODIMP CBaseRenderer::GetState(DWORD dwMSecs, FILTER_STATE *State)
{
- CheckPointer(State,E_POINTER);
+ CheckPointer(State, E_POINTER);
- if (WaitDispatchingMessages(m_evComplete, dwMSecs) == WAIT_TIMEOUT) {
+ if(WaitDispatchingMessages(m_evComplete, dwMSecs) == WAIT_TIMEOUT)
+ {
*State = m_State;
return VFW_S_STATE_INTERMEDIATE;
}
@@ -361,22 +384,26 @@ HRESULT CBaseRenderer::CompleteStateChange(FILTER_STATE OldState)
{
// Allow us to be paused when disconnected
- if (m_pInputPin->IsConnected() == FALSE) {
+ if(m_pInputPin->IsConnected() == FALSE)
+ {
Ready();
return S_OK;
}
// Have we run off the end of stream
- if (IsEndOfStream() == TRUE) {
+ if(IsEndOfStream() == TRUE)
+ {
Ready();
return S_OK;
}
// Make sure we get fresh data after being stopped
- if (HaveCurrentSample() == TRUE) {
- if (OldState != State_Stopped) {
+ if(HaveCurrentSample() == TRUE)
+ {
+ if(OldState != State_Stopped)
+ {
Ready();
return S_OK;
}
@@ -400,13 +427,15 @@ STDMETHODIMP CBaseRenderer::Stop()
// Make sure there really is a state change
- if (m_State == State_Stopped) {
+ if(m_State == State_Stopped)
+ {
return NOERROR;
}
// Is our input pin connected
- if (m_pInputPin->IsConnected() == FALSE) {
+ if(m_pInputPin->IsConnected() == FALSE)
+ {
NOTE("Input pin is not connected");
m_State = State_Stopped;
return NOERROR;
@@ -418,7 +447,8 @@ STDMETHODIMP CBaseRenderer::Stop()
// allocator we are using it so that any source filter waiting in the
// GetBuffer can be released and unlock themselves for a state change
- if (m_pInputPin->Allocator()) {
+ if(m_pInputPin->Allocator())
+ {
m_pInputPin->Allocator()->Decommit();
}
@@ -432,7 +462,7 @@ STDMETHODIMP CBaseRenderer::Stop()
// There should be no outstanding clock advise
ASSERT(CancelNotification() == S_FALSE);
- ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent,0));
+ ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent, 0));
ASSERT(m_EndOfStreamTimer == 0);
Ready();
@@ -459,13 +489,15 @@ STDMETHODIMP CBaseRenderer::Pause()
// Make sure there really is a state change
- if (m_State == State_Paused) {
+ if(m_State == State_Paused)
+ {
return CompleteStateChange(State_Paused);
}
// Has our input pin been connected
- if (m_pInputPin->IsConnected() == FALSE) {
+ if(m_pInputPin->IsConnected() == FALSE)
+ {
NOTE("Input pin is not connected");
m_State = State_Paused;
return CompleteStateChange(State_Paused);
@@ -474,7 +506,8 @@ STDMETHODIMP CBaseRenderer::Pause()
// Pause the base filter class
HRESULT hr = CBaseFilter::Pause();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
NOTE("Pause failed");
return hr;
}
@@ -491,13 +524,14 @@ STDMETHODIMP CBaseRenderer::Pause()
// allocator we are using it so that any source filter can call the
// GetBuffer and expect to get a buffer without returning an error
- if (m_pInputPin->Allocator()) {
+ if(m_pInputPin->Allocator())
+ {
m_pInputPin->Allocator()->Commit();
}
// There should be no outstanding advise
ASSERT(CancelNotification() == S_FALSE);
- ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent,0));
+ ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent, 0));
ASSERT(m_EndOfStreamTimer == 0);
ASSERT(m_pInputPin->IsFlushing() == FALSE);
@@ -507,7 +541,8 @@ STDMETHODIMP CBaseRenderer::Pause()
// Paused or running after being stopped causes the current position to
// be reset so we're not interested in passing end of stream signals
- if (OldState == State_Stopped) {
+ if(OldState == State_Stopped)
+ {
m_bAbort = FALSE;
ClearPendingSample();
}
@@ -531,14 +566,16 @@ STDMETHODIMP CBaseRenderer::Run(REFERENCE_TIME StartTime)
// Make sure there really is a state change
- if (m_State == State_Running) {
+ if(m_State == State_Running)
+ {
return NOERROR;
}
// Send EC_COMPLETE if we're not connected
- if (m_pInputPin->IsConnected() == FALSE) {
- NotifyEvent(EC_COMPLETE,S_OK,(LONG_PTR)(IBaseFilter *)this);
+ if(m_pInputPin->IsConnected() == FALSE)
+ {
+ NotifyEvent(EC_COMPLETE, S_OK, (LONG_PTR)(IBaseFilter *)this);
m_State = State_Running;
return NOERROR;
}
@@ -548,7 +585,8 @@ STDMETHODIMP CBaseRenderer::Run(REFERENCE_TIME StartTime)
// Pause the base filter class
HRESULT hr = CBaseFilter::Run(StartTime);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
NOTE("Run failed");
return hr;
}
@@ -560,7 +598,7 @@ STDMETHODIMP CBaseRenderer::Run(REFERENCE_TIME StartTime)
// There should be no outstanding advise
ASSERT(CancelNotification() == S_FALSE);
- ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent,0));
+ ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent, 0));
ASSERT(m_EndOfStreamTimer == 0);
ASSERT(m_pInputPin->IsFlushing() == FALSE);
@@ -568,7 +606,8 @@ STDMETHODIMP CBaseRenderer::Run(REFERENCE_TIME StartTime)
// allocator we are using it so that any source filter can call the
// GetBuffer and expect to get a buffer without returning an error
- if (m_pInputPin->Allocator()) {
+ if(m_pInputPin->Allocator())
+ {
m_pInputPin->Allocator()->Commit();
}
@@ -578,7 +617,8 @@ STDMETHODIMP CBaseRenderer::Run(REFERENCE_TIME StartTime)
// Paused or running after being stopped causes the current position to
// be reset so we're not interested in passing end of stream signals
- if (OldState == State_Stopped) {
+ if(OldState == State_Stopped)
+ {
m_bAbort = FALSE;
ClearPendingSample();
}
@@ -590,7 +630,8 @@ STDMETHODIMP CBaseRenderer::Run(REFERENCE_TIME StartTime)
int CBaseRenderer::GetPinCount()
{
- if (m_pInputPin == NULL) {
+ if(m_pInputPin == NULL)
+ {
// Try to create it
(void)GetPin(0);
}
@@ -607,25 +648,29 @@ CBasePin *CBaseRenderer::GetPin(int n)
// Should only ever be called with zero
ASSERT(n == 0);
- if (n != 0) {
+ if(n != 0)
+ {
return NULL;
}
// Create the input pin if not already done so
- if (m_pInputPin == NULL) {
+ if(m_pInputPin == NULL)
+ {
// hr must be initialized to NOERROR because
// CRendererInputPin's constructor only changes
// hr's value if an error occurs.
HRESULT hr = NOERROR;
- m_pInputPin = new CRendererInputPin(this,&hr,L"In");
- if (NULL == m_pInputPin) {
+ m_pInputPin = new CRendererInputPin(this, &hr, L"In");
+ if(NULL == m_pInputPin)
+ {
return NULL;
}
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
delete m_pInputPin;
m_pInputPin = NULL;
return NULL;
@@ -639,16 +684,22 @@ CBasePin *CBaseRenderer::GetPin(int n)
STDMETHODIMP CBaseRenderer::FindPin(LPCWSTR Id, __deref_out IPin **ppPin)
{
- CheckPointer(ppPin,E_POINTER);
+ CheckPointer(ppPin, E_POINTER);
- if (0==lstrcmpW(Id,L"In")) {
+ if(0 == lstrcmpW(Id, L"In"))
+ {
*ppPin = GetPin(0);
- if (*ppPin) {
+ if(*ppPin)
+ {
(*ppPin)->AddRef();
- } else {
+ }
+ else
+ {
return E_OUTOFMEMORY;
}
- } else {
+ }
+ else
+ {
*ppPin = NULL;
return VFW_E_NOT_FOUND;
}
@@ -665,14 +716,16 @@ HRESULT CBaseRenderer::EndOfStream()
{
// Ignore these calls if we are stopped
- if (m_State == State_Stopped) {
+ if(m_State == State_Stopped)
+ {
return NOERROR;
}
// If we have a sample then wait for it to be rendered
m_bEOS = TRUE;
- if (m_pMediaSample) {
+ if(m_pMediaSample)
+ {
return NOERROR;
}
@@ -686,7 +739,8 @@ HRESULT CBaseRenderer::EndOfStream()
// we do run in StartStreaming. This is used when we seek because a seek
// causes a pause where early notification of completion is misleading
- if (m_bStreaming) {
+ if(m_bStreaming)
+ {
SendEndOfStream();
}
return NOERROR;
@@ -699,7 +753,8 @@ HRESULT CBaseRenderer::BeginFlush()
{
// If paused then report state intermediate until we get some data
- if (m_State == State_Paused) {
+ if(m_State == State_Paused)
+ {
NotReady();
}
@@ -718,7 +773,7 @@ HRESULT CBaseRenderer::BeginFlush()
HRESULT CBaseRenderer::EndFlush()
{
// Reset the current sample media time
- if (m_pPosition) m_pPosition->ResetMediaTime();
+ if(m_pPosition) m_pPosition->ResetMediaTime();
// There should be no outstanding advise
@@ -738,14 +793,18 @@ HRESULT CBaseRenderer::CompleteConnect(IPin *pReceivePin)
m_bAbort = FALSE;
- if (State_Running == GetRealState()) {
+ if(State_Running == GetRealState())
+ {
HRESULT hr = StartStreaming();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
SetRepaintStatus(FALSE);
- } else {
+ }
+ else
+ {
SetRepaintStatus(TRUE);
}
@@ -765,7 +824,8 @@ HRESULT CBaseRenderer::Active()
HRESULT CBaseRenderer::Inactive()
{
- if (m_pPosition) {
+ if(m_pPosition)
+ {
m_pPosition->ResetMediaTime();
}
// People who derive from this may want to override this behaviour
@@ -794,19 +854,22 @@ HRESULT CBaseRenderer::BreakConnect()
{
// Do we have a quality management sink
- if (m_pQSink) {
+ if(m_pQSink)
+ {
m_pQSink->Release();
m_pQSink = NULL;
}
// Check we have a valid connection
- if (m_pInputPin->IsConnected() == FALSE) {
+ if(m_pInputPin->IsConnected() == FALSE)
+ {
return S_FALSE;
}
// Check we are stopped before disconnecting
- if (m_State != State_Stopped && !m_pInputPin->CanReconnectWhenActive()) {
+ if(m_State != State_Stopped && !m_pInputPin->CanReconnectWhenActive())
+ {
return VFW_E_NOT_STOPPED;
}
@@ -815,7 +878,8 @@ HRESULT CBaseRenderer::BreakConnect()
ClearPendingSample();
m_bAbort = FALSE;
- if (State_Running == m_State) {
+ if(State_Running == m_State)
+ {
StopStreaming();
}
@@ -839,11 +903,15 @@ HRESULT CBaseRenderer::GetSampleTimes(IMediaSample *pMediaSample,
// then just ignore it (release it) and schedule the next one in line
// Source filters should always fill in the start and end times properly!
- if (SUCCEEDED(pMediaSample->GetTime(pStartTime, pEndTime))) {
- if (*pEndTime < *pStartTime) {
+ if(SUCCEEDED(pMediaSample->GetTime(pStartTime, pEndTime)))
+ {
+ if(*pEndTime < *pStartTime)
+ {
return VFW_E_START_TIME_AFTER_END;
}
- } else {
+ }
+ else
+ {
// no time set in the sample... draw it now?
return S_OK;
}
@@ -852,10 +920,11 @@ HRESULT CBaseRenderer::GetSampleTimes(IMediaSample *pMediaSample,
// caller that the sample should be rendered immediately without going
// through the overhead of setting a timer advise link with the clock
- if (m_pClock == NULL) {
+ if(m_pClock == NULL)
+ {
return S_OK;
}
- return ShouldDrawSampleNow(pMediaSample,pStartTime,pEndTime);
+ return ShouldDrawSampleNow(pMediaSample, pStartTime, pEndTime);
}
@@ -864,8 +933,8 @@ HRESULT CBaseRenderer::GetSampleTimes(IMediaSample *pMediaSample,
// by the derived video renderer class in its quality management.
HRESULT CBaseRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
- __out REFERENCE_TIME *ptrStart,
- __out REFERENCE_TIME *ptrEnd)
+ __out REFERENCE_TIME *ptrStart,
+ __out REFERENCE_TIME *ptrEnd)
{
return S_FALSE;
}
@@ -896,7 +965,8 @@ HRESULT CBaseRenderer::CancelNotification()
// Have we a live advise link
- if (m_dwAdvise) {
+ if(m_dwAdvise)
+ {
m_pClock->Unadvise(m_dwAdvise);
SignalTimerFired();
ASSERT(m_dwAdvise == 0);
@@ -920,7 +990,8 @@ BOOL CBaseRenderer::ScheduleSample(IMediaSample *pMediaSample)
// Is someone pulling our leg
- if (pMediaSample == NULL) {
+ if(pMediaSample == NULL)
+ {
return FALSE;
}
@@ -930,7 +1001,8 @@ BOOL CBaseRenderer::ScheduleSample(IMediaSample *pMediaSample)
// it returns S_OK other if it's to be done when due it returns S_FALSE
HRESULT hr = GetSampleTimes(pMediaSample, &StartSample, &EndSample);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return FALSE;
}
@@ -938,14 +1010,15 @@ BOOL CBaseRenderer::ScheduleSample(IMediaSample *pMediaSample)
// time so we simply set the event indicating an image to render. This
// will cause us to run flat out without any timing or synchronisation
- if (hr == S_OK) {
+ if(hr == S_OK)
+ {
EXECUTE_ASSERT(SetEvent((HANDLE) m_RenderEvent));
return TRUE;
}
ASSERT(m_dwAdvise == 0);
ASSERT(m_pClock);
- ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent,0));
+ ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent, 0));
// We do have a valid reference clock interface so we can ask it to
// set an event when the image comes due for rendering. We pass in
@@ -953,12 +1026,13 @@ BOOL CBaseRenderer::ScheduleSample(IMediaSample *pMediaSample)
// stream time which is the offset from the start reference time
hr = m_pClock->AdviseTime(
- (REFERENCE_TIME) m_tStart, // Start run time
- StartSample, // Stream time
- (HEVENT)(HANDLE) m_RenderEvent, // Render notification
- &m_dwAdvise); // Advise cookie
+ (REFERENCE_TIME) m_tStart, // Start run time
+ StartSample, // Stream time
+ (HEVENT)(HANDLE) m_RenderEvent, // Render notification
+ &m_dwAdvise); // Advise cookie
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
return TRUE;
}
@@ -982,7 +1056,8 @@ HRESULT CBaseRenderer::Render(IMediaSample *pMediaSample)
// clock that another sample is ready but in the mean time someone has
// stopped us streaming which causes the next sample to be released
- if (pMediaSample == NULL) {
+ if(pMediaSample == NULL)
+ {
return S_FALSE;
}
@@ -990,7 +1065,8 @@ HRESULT CBaseRenderer::Render(IMediaSample *pMediaSample)
// thread that got in and locked us and then reset this flag does not
// clear the pending sample as we can use it to refresh any output device
- if (m_bStreaming == FALSE) {
+ if(m_bStreaming == FALSE)
+ {
return S_FALSE;
}
@@ -1021,7 +1097,8 @@ BOOL CBaseRenderer::HaveCurrentSample()
IMediaSample *CBaseRenderer::GetCurrentSample()
{
CAutoLock cRendererLock(&m_RendererLock);
- if (m_pMediaSample) {
+ if(m_pMediaSample)
+ {
m_pMediaSample->AddRef();
}
return m_pMediaSample;
@@ -1043,12 +1120,13 @@ HRESULT CBaseRenderer::PrepareReceive(IMediaSample *pMediaSample)
// Check our flushing and filter state
- // This function must hold the interface lock because it calls
+ // This function must hold the interface lock because it calls
// CBaseInputPin::Receive() and CBaseInputPin::Receive() uses
// CBasePin::m_bRunTimeError.
HRESULT hr = m_pInputPin->CBaseInputPin::Receive(pMediaSample);
- if (hr != NOERROR) {
+ if(hr != NOERROR)
+ {
m_bInReceive = FALSE;
return E_FAIL;
}
@@ -1059,10 +1137,12 @@ HRESULT CBaseRenderer::PrepareReceive(IMediaSample *pMediaSample)
// have Receive called we can go ahead and change the format
// Since the format change can cause a SendMessage we just don't
// lock
- if (m_pInputPin->SampleProps()->pMediaType) {
+ if(m_pInputPin->SampleProps()->pMediaType)
+ {
hr = m_pInputPin->SetMediaType(
- (CMediaType *)m_pInputPin->SampleProps()->pMediaType);
- if (FAILED(hr)) {
+ (CMediaType *)m_pInputPin->SampleProps()->pMediaType);
+ if(FAILED(hr))
+ {
m_bInReceive = FALSE;
return hr;
}
@@ -1080,19 +1160,21 @@ HRESULT CBaseRenderer::PrepareReceive(IMediaSample *pMediaSample)
// source pins must serialise the Receive calls - we also check that
// no data is being sent after the source signalled an end of stream
- if (m_pMediaSample || m_bEOS || m_bAbort) {
+ if(m_pMediaSample || m_bEOS || m_bAbort)
+ {
Ready();
m_bInReceive = FALSE;
return E_UNEXPECTED;
}
// Store the media times from this sample
- if (m_pPosition) m_pPosition->RegisterMediaTime(pMediaSample);
+ if(m_pPosition) m_pPosition->RegisterMediaTime(pMediaSample);
// Schedule the next sample if we are streaming
- if ((m_bStreaming == TRUE) && (ScheduleSample(pMediaSample) == FALSE)) {
- ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent,0));
+ if((m_bStreaming == TRUE) && (ScheduleSample(pMediaSample) == FALSE))
+ {
+ ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent, 0));
ASSERT(CancelNotification() == S_FALSE);
m_bInReceive = FALSE;
return VFW_E_SAMPLE_REJECTED;
@@ -1110,7 +1192,8 @@ HRESULT CBaseRenderer::PrepareReceive(IMediaSample *pMediaSample)
m_pMediaSample = pMediaSample;
m_pMediaSample->AddRef();
- if (m_bStreaming == FALSE) {
+ if(m_bStreaming == FALSE)
+ {
SetRepaintStatus(TRUE);
}
return NOERROR;
@@ -1131,8 +1214,10 @@ HRESULT CBaseRenderer::Receive(IMediaSample *pSample)
HRESULT hr = PrepareReceive(pSample);
ASSERT(m_bInReceive == SUCCEEDED(hr));
- if (FAILED(hr)) {
- if (hr == VFW_E_SAMPLE_REJECTED) {
+ if(FAILED(hr))
+ {
+ if(hr == VFW_E_SAMPLE_REJECTED)
+ {
return NOERROR;
}
return hr;
@@ -1140,14 +1225,15 @@ HRESULT CBaseRenderer::Receive(IMediaSample *pSample)
// We realize the palette in "PrepareRender()" so we have to give away the
// filter lock here.
- if (m_State == State_Paused) {
+ if(m_State == State_Paused)
+ {
PrepareRender();
// no need to use InterlockedExchange
m_bInReceive = FALSE;
{
// We must hold both these locks
CAutoLock cRendererLock(&m_InterfaceLock);
- if (m_State == State_Stopped)
+ if(m_State == State_Stopped)
return NOERROR;
m_bInReceive = TRUE;
@@ -1161,7 +1247,8 @@ HRESULT CBaseRenderer::Receive(IMediaSample *pSample)
// will lock the critical section and check we can still render the data
hr = WaitForRenderTime();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
m_bInReceive = FALSE;
return NOERROR;
}
@@ -1179,7 +1266,7 @@ HRESULT CBaseRenderer::Receive(IMediaSample *pSample)
// since we gave away the filter wide lock, the sate of the filter could
// have chnaged to Stopped
- if (m_State == State_Stopped)
+ if(m_State == State_Stopped)
return NOERROR;
CAutoLock cSampleLock(&m_RendererLock);
@@ -1203,7 +1290,8 @@ HRESULT CBaseRenderer::Receive(IMediaSample *pSample)
HRESULT CBaseRenderer::ClearPendingSample()
{
CAutoLock cRendererLock(&m_RendererLock);
- if (m_pMediaSample) {
+ if(m_pMediaSample)
+ {
m_pMediaSample->Release();
m_pMediaSample = NULL;
}
@@ -1220,7 +1308,7 @@ void CALLBACK EndOfStreamTimer(UINT uID, // Timer identifier
DWORD_PTR dw2) // is also reserved
{
CBaseRenderer *pRenderer = (CBaseRenderer *) dwUser;
- NOTE1("EndOfStreamTimer called (%d)",uID);
+ NOTE1("EndOfStreamTimer called (%d)", uID);
pRenderer->TimerCallback();
}
@@ -1233,7 +1321,8 @@ void CBaseRenderer::TimerCallback()
// See if we should signal end of stream now
- if (m_EndOfStreamTimer) {
+ if(m_EndOfStreamTimer)
+ {
m_EndOfStreamTimer = 0;
SendEndOfStream();
}
@@ -1252,12 +1341,14 @@ void CBaseRenderer::TimerCallback()
HRESULT CBaseRenderer::SendEndOfStream()
{
ASSERT(CritCheckIn(&m_RendererLock));
- if (m_bEOS == FALSE || m_bEOSDelivered || m_EndOfStreamTimer) {
+ if(m_bEOS == FALSE || m_bEOSDelivered || m_EndOfStreamTimer)
+ {
return NOERROR;
}
// If there is no clock then signal immediately
- if (m_pClock == NULL) {
+ if(m_pClock == NULL)
+ {
return NotifyEndOfStream();
}
@@ -1270,24 +1361,26 @@ HRESULT CBaseRenderer::SendEndOfStream()
// Dump the timing information to the debugger
- NOTE1("Delay until end of stream delivery %d",Delay);
- NOTE1("Current %s",(LPCTSTR)CDisp((LONGLONG)CurrentTime));
- NOTE1("Signal %s",(LPCTSTR)CDisp((LONGLONG)Signal));
+ NOTE1("Delay until end of stream delivery %d", Delay);
+ NOTE1("Current %s", (LPCTSTR)CDisp((LONGLONG)CurrentTime));
+ NOTE1("Signal %s", (LPCTSTR)CDisp((LONGLONG)Signal));
// Wait for the delivery time to arrive
- if (Delay < TIMEOUT_DELIVERYWAIT) {
+ if(Delay < TIMEOUT_DELIVERYWAIT)
+ {
return NotifyEndOfStream();
}
// Signal a timer callback on another worker thread
m_EndOfStreamTimer = CompatibleTimeSetEvent((UINT) Delay, // Period of timer
- TIMEOUT_RESOLUTION, // Timer resolution
- EndOfStreamTimer, // Callback function
- DWORD_PTR(this), // Used information
- TIME_ONESHOT); // Type of callback
- if (m_EndOfStreamTimer == 0) {
+ TIMEOUT_RESOLUTION, // Timer resolution
+ EndOfStreamTimer, // Callback function
+ DWORD_PTR(this), // Used information
+ TIME_ONESHOT); // Type of callback
+ if(m_EndOfStreamTimer == 0)
+ {
return NotifyEndOfStream();
}
return NOERROR;
@@ -1304,7 +1397,8 @@ HRESULT CBaseRenderer::NotifyEndOfStream()
// Has the filter changed state
- if (m_bStreaming == FALSE) {
+ if(m_bStreaming == FALSE)
+ {
ASSERT(m_EndOfStreamTimer == 0);
return NOERROR;
}
@@ -1317,10 +1411,10 @@ HRESULT CBaseRenderer::NotifyEndOfStream()
// that we actually get to the end, even if the MPEG guestimate has
// been bad or if the quality management dropped the last few frames
- if (m_pPosition) m_pPosition->EOS();
+ if(m_pPosition) m_pPosition->EOS();
m_bEOSDelivered = TRUE;
NOTE("Sending EC_COMPLETE...");
- return NotifyEvent(EC_COMPLETE,S_OK,(LONG_PTR)(IBaseFilter *)this);
+ return NotifyEvent(EC_COMPLETE, S_OK, (LONG_PTR)(IBaseFilter *)this);
}
@@ -1350,7 +1444,8 @@ HRESULT CBaseRenderer::ResetEndOfStream()
void CBaseRenderer::ResetEndOfStreamTimer()
{
ASSERT(CritCheckOut(&m_RendererLock));
- if (m_EndOfStreamTimer) {
+ if(m_EndOfStreamTimer)
+ {
timeKillEvent(m_EndOfStreamTimer);
m_EndOfStreamTimer = 0;
}
@@ -1366,7 +1461,8 @@ void CBaseRenderer::ResetEndOfStreamTimer()
HRESULT CBaseRenderer::StartStreaming()
{
CAutoLock cRendererLock(&m_RendererLock);
- if (m_bStreaming == TRUE) {
+ if(m_bStreaming == TRUE)
+ {
return NOERROR;
}
@@ -1378,19 +1474,20 @@ HRESULT CBaseRenderer::StartStreaming()
OnStartStreaming();
// There should be no outstanding advise
- ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent,0));
+ ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent, 0));
ASSERT(CancelNotification() == S_FALSE);
// If we have an EOS and no data then deliver it now
- if (m_pMediaSample == NULL) {
+ if(m_pMediaSample == NULL)
+ {
return SendEndOfStream();
}
// Have the data rendered
ASSERT(m_pMediaSample);
- if (!ScheduleSample(m_pMediaSample))
+ if(!ScheduleSample(m_pMediaSample))
m_RenderEvent.Set();
return NOERROR;
@@ -1407,7 +1504,8 @@ HRESULT CBaseRenderer::StopStreaming()
CAutoLock cRendererLock(&m_RendererLock);
m_bEOSDelivered = FALSE;
- if (m_bStreaming == TRUE) {
+ if(m_bStreaming == TRUE)
+ {
m_bStreaming = FALSE;
OnStopStreaming();
timeEndPeriod(1);
@@ -1433,17 +1531,18 @@ void CBaseRenderer::SetRepaintStatus(BOOL bRepaint)
// Pass the window handle to the upstream filter
-void CBaseRenderer::SendNotifyWindow(IPin *pPin,HWND hwnd)
+void CBaseRenderer::SendNotifyWindow(IPin *pPin, HWND hwnd)
{
IMediaEventSink *pSink;
// Does the pin support IMediaEventSink
- HRESULT hr = pPin->QueryInterface(IID_IMediaEventSink,(void **)&pSink);
- if (SUCCEEDED(hr)) {
- pSink->Notify(EC_NOTIFY_WINDOW,LONG_PTR(hwnd),0);
+ HRESULT hr = pPin->QueryInterface(IID_IMediaEventSink, (void **)&pSink);
+ if(SUCCEEDED(hr))
+ {
+ pSink->Notify(EC_NOTIFY_WINDOW, LONG_PTR(hwnd), 0);
pSink->Release();
}
- NotifyEvent(EC_NOTIFY_WINDOW,LONG_PTR(hwnd),0);
+ NotifyEvent(EC_NOTIFY_WINDOW, LONG_PTR(hwnd), 0);
}
@@ -1468,13 +1567,18 @@ void CBaseRenderer::SendRepaint()
// - We have aborted a video playback
// - There is a repaint already sent
- if (m_bAbort == FALSE) {
- if (m_pInputPin->IsConnected() == TRUE) {
- if (m_pInputPin->IsFlushing() == FALSE) {
- if (IsEndOfStream() == FALSE) {
- if (m_bRepaintStatus == TRUE) {
+ if(m_bAbort == FALSE)
+ {
+ if(m_pInputPin->IsConnected() == TRUE)
+ {
+ if(m_pInputPin->IsFlushing() == FALSE)
+ {
+ if(IsEndOfStream() == FALSE)
+ {
+ if(m_bRepaintStatus == TRUE)
+ {
IPin *pPin = (IPin *) m_pInputPin;
- NotifyEvent(EC_REPAINT,(LONG_PTR) pPin,0);
+ NotifyEvent(EC_REPAINT, (LONG_PTR) pPin, 0);
SetRepaintStatus(FALSE);
RLOG("Sending repaint");
}
@@ -1496,7 +1600,8 @@ BOOL CBaseRenderer::OnDisplayChange()
// Ignore if we are not connected yet
CAutoLock cSampleLock(&m_RendererLock);
- if (m_pInputPin->IsConnected() == FALSE) {
+ if(m_pInputPin->IsConnected() == FALSE)
+ {
return FALSE;
}
@@ -1506,7 +1611,7 @@ BOOL CBaseRenderer::OnDisplayChange()
IPin *pPin = (IPin *) m_pInputPin;
m_pInputPin->AddRef();
- NotifyEvent(EC_DISPLAY_CHANGED,(LONG_PTR) pPin,0);
+ NotifyEvent(EC_DISPLAY_CHANGED, (LONG_PTR) pPin, 0);
SetAbortSignal(TRUE);
ClearPendingSample();
m_pInputPin->Release();
@@ -1530,11 +1635,11 @@ void CBaseRenderer::OnRenderStart(IMediaSample *pMediaSample)
m_pClock->GetTime(&m_trRenderStart);
MSR_INTEGER(0, (int)m_trRenderStart);
REFERENCE_TIME trStream;
- trStream = m_trRenderStart-m_tStart; // convert reftime to stream time
- MSR_INTEGER(0,(int)trStream);
+ trStream = m_trRenderStart - m_tStart; // convert reftime to stream time
+ MSR_INTEGER(0, (int)trStream);
const int trLate = (int)(trStream - trStart);
- MSR_INTEGER(m_idBaseAccuracy, trLate/10000); // dump in mSec
+ MSR_INTEGER(m_idBaseAccuracy, trLate / 10000); // dump in mSec
#endif
} // OnRenderStart
@@ -1548,8 +1653,8 @@ void CBaseRenderer::OnRenderEnd(IMediaSample *pMediaSample)
#ifdef PERF
REFERENCE_TIME trNow;
m_pClock->GetTime(&trNow);
- MSR_INTEGER(0,(int)trNow);
- int t = (int)((trNow - m_trRenderStart)/10000); // convert UNITS->msec
+ MSR_INTEGER(0, (int)trNow);
+ int t = (int)((trNow - m_trRenderStart) / 10000); // convert UNITS->msec
MSR_INTEGER(m_idBaseRenderTime, t);
#endif
} // OnRenderEnd
@@ -1583,14 +1688,16 @@ STDMETHODIMP CRendererInputPin::EndOfStream()
// Make sure we're streaming ok
HRESULT hr = CheckStreaming();
- if (hr != NOERROR) {
+ if(hr != NOERROR)
+ {
return hr;
}
// Pass it onto the renderer
hr = m_pRenderer->EndOfStream();
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
hr = CBaseInputPin::EndOfStream();
}
return hr;
@@ -1623,7 +1730,8 @@ STDMETHODIMP CRendererInputPin::EndFlush()
CAutoLock cSampleLock(&m_pRenderer->m_RendererLock);
HRESULT hr = m_pRenderer->EndFlush();
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
hr = CBaseInputPin::EndFlush();
}
return hr;
@@ -1635,7 +1743,8 @@ STDMETHODIMP CRendererInputPin::EndFlush()
STDMETHODIMP CRendererInputPin::Receive(IMediaSample *pSample)
{
HRESULT hr = m_pRenderer->Receive(pSample);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
// A deadlock could occur if the caller holds the renderer lock and
// attempts to acquire the interface lock.
@@ -1648,23 +1757,25 @@ STDMETHODIMP CRendererInputPin::Receive(IMediaSample *pSample)
CAutoLock cRendererLock(&m_pRenderer->m_InterfaceLock);
// We do not report errors which occur while the filter is stopping,
- // flushing or if the m_bAbort flag is set . Errors are expected to
- // occur during these operations and the streaming thread correctly
- // handles the errors.
- if (!IsStopped() && !IsFlushing() && !m_pRenderer->m_bAbort && !m_bRunTimeError) {
+ // flushing or if the m_bAbort flag is set . Errors are expected to
+ // occur during these operations and the streaming thread correctly
+ // handles the errors.
+ if(!IsStopped() && !IsFlushing() && !m_pRenderer->m_bAbort && !m_bRunTimeError)
+ {
// EC_ERRORABORT's first parameter is the error which caused
// the event and its' last parameter is 0. See the Direct
// Show SDK documentation for more information.
- m_pRenderer->NotifyEvent(EC_ERRORABORT,hr,0);
+ m_pRenderer->NotifyEvent(EC_ERRORABORT, hr, 0);
{
CAutoLock alRendererLock(&m_pRenderer->m_RendererLock);
- if (m_pRenderer->IsStreaming() && !m_pRenderer->IsEndOfStreamDelivered()) {
+ if(m_pRenderer->IsStreaming() && !m_pRenderer->IsEndOfStreamDelivered())
+ {
m_pRenderer->NotifyEndOfStream();
}
}
-
+
m_bRunTimeError = TRUE;
}
}
@@ -1679,7 +1790,8 @@ STDMETHODIMP CRendererInputPin::Receive(IMediaSample *pSample)
HRESULT CRendererInputPin::BreakConnect()
{
HRESULT hr = m_pRenderer->BreakConnect();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return CBaseInputPin::BreakConnect();
@@ -1691,7 +1803,8 @@ HRESULT CRendererInputPin::BreakConnect()
HRESULT CRendererInputPin::CompleteConnect(IPin *pReceivePin)
{
HRESULT hr = m_pRenderer->CompleteConnect(pReceivePin);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return CBaseInputPin::CompleteConnect(pReceivePin);
@@ -1702,12 +1815,13 @@ HRESULT CRendererInputPin::CompleteConnect(IPin *pReceivePin)
STDMETHODIMP CRendererInputPin::QueryId(__deref_out LPWSTR *Id)
{
- CheckPointer(Id,E_POINTER);
+ CheckPointer(Id, E_POINTER);
const WCHAR szIn[] = L"In";
*Id = (LPWSTR)CoTaskMemAlloc(sizeof(szIn));
- if (*Id == NULL) {
+ if(*Id == NULL)
+ {
return E_OUTOFMEMORY;
}
CopyMemory(*Id, szIn, sizeof(szIn));
@@ -1735,7 +1849,7 @@ HRESULT CRendererInputPin::Active()
HRESULT CRendererInputPin::Inactive()
{
- // The caller must hold the interface lock because
+ // The caller must hold the interface lock because
// this function uses m_bRunTimeError.
ASSERT(CritCheckIn(&m_pRenderer->m_InterfaceLock));
@@ -1750,7 +1864,8 @@ HRESULT CRendererInputPin::Inactive()
HRESULT CRendererInputPin::SetMediaType(const CMediaType *pmt)
{
HRESULT hr = CBaseInputPin::SetMediaType(pmt);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return m_pRenderer->SetMediaType(pmt);
@@ -1768,12 +1883,12 @@ const TCHAR AMQUALITY[] = TEXT("ActiveMovie");
const TCHAR DRAWLATEFRAMES[] = TEXT("DrawLateFrames");
CBaseVideoRenderer::CBaseVideoRenderer(
- REFCLSID RenderClass, // CLSID for this renderer
- __in_opt LPCTSTR pName, // Debug ONLY description
- __inout_opt LPUNKNOWN pUnk, // Aggregated owner object
- __inout HRESULT *phr) : // General OLE return code
+ REFCLSID RenderClass, // CLSID for this renderer
+ __in_opt LPCTSTR pName, // Debug ONLY description
+ __inout_opt LPUNKNOWN pUnk, // Aggregated owner object
+ __inout HRESULT *phr) : // General OLE return code
- CBaseRenderer(RenderClass,pName,pUnk,phr),
+ CBaseRenderer(RenderClass, pName, pUnk, phr),
m_cFramesDropped(0),
m_cFramesDrawn(0),
m_bSupplierHandlingQuality(FALSE)
@@ -1884,7 +1999,7 @@ HRESULT CBaseVideoRenderer::OnStartStreaming()
HRESULT CBaseVideoRenderer::OnStopStreaming()
{
- m_tStreamingStart = timeGetTime()-m_tStreamingStart;
+ m_tStreamingStart = timeGetTime() - m_tStreamingStart;
return NOERROR;
} // OnStopStreaming
@@ -1919,18 +2034,21 @@ void CBaseVideoRenderer::OnWaitEnd()
// We will be discarding overflows like mad here!
// This is wrong really because timeGetTime() can wrap but it's
// only for PERF
- REFERENCE_TIME tr = timeGetTime()*10000;
+ REFERENCE_TIME tr = timeGetTime() * 10000;
trRealStream = tr + m_llTimeOffset;
#endif
trRealStream -= m_tStart; // convert to stream time (this is a reftime)
- if (m_trRememberStampForPerf==0) {
+ if(m_trRememberStampForPerf == 0)
+ {
// This is probably the poster frame at the start, and it is not scheduled
// in the usual way at all. Just count it. The rememberstamp gets set
// in ShouldDrawSampleNow, so this does invalid frame recording until we
// actually start playing.
PreparePerformanceData(0, 0);
- } else {
+ }
+ else
+ {
int trLate = (int)(trRealStream - m_trRememberStampForPerf);
int trFrame = (int)(tr - m_trRememberFrameForPerf);
PreparePerformanceData(trLate, trFrame);
@@ -1965,44 +2083,52 @@ void CBaseVideoRenderer::PreparePerformanceData(int trLate, int trFrame)
void CBaseVideoRenderer::RecordFrameLateness(int trLate, int trFrame)
{
// Record how timely we are.
- int tLate = trLate/10000;
+ int tLate = trLate / 10000;
// Best estimate of moment of appearing on the screen is average of
// start and end draw times. Here we have only the end time. This may
// tend to show us as spuriously late by up to 1/2 frame rate achieved.
// Decoder probably monitors draw time. We don't bother.
- MSR_INTEGER( m_idFrameAccuracy, tLate );
+ MSR_INTEGER(m_idFrameAccuracy, tLate);
// This is a kludge - we can get frames that are very late
// especially (at start-up) and they invalidate the statistics.
// So ignore things that are more than 1 sec off.
- if (tLate>1000 || tLate<-1000) {
- if (m_cFramesDrawn<=1) {
+ if(tLate > 1000 || tLate < -1000)
+ {
+ if(m_cFramesDrawn <= 1)
+ {
tLate = 0;
- } else if (tLate>0) {
+ }
+ else if(tLate > 0)
+ {
tLate = 1000;
- } else {
+ }
+ else
+ {
tLate = -1000;
}
}
// The very first frame often has a invalid time, so don't
// count it into the statistics. (???)
- if (m_cFramesDrawn>1) {
+ if(m_cFramesDrawn > 1)
+ {
m_iTotAcc += tLate;
- m_iSumSqAcc += (tLate*tLate);
+ m_iSumSqAcc += (tLate * tLate);
}
// calculate inter-frame time. Doesn't make sense for first frame
// second frame suffers from invalid first frame stamp.
- if (m_cFramesDrawn>2) {
- int tFrame = trFrame/10000; // convert to mSec else it overflows
+ if(m_cFramesDrawn > 2)
+ {
+ int tFrame = trFrame / 10000; // convert to mSec else it overflows
// This is a kludge. It can overflow anyway (a pause can cause
// a very long inter-frame time) and it overflows at 2**31/10**7
// or about 215 seconds i.e. 3min 35sec
- if (tFrame>1000||tFrame<0) tFrame = 1000;
- m_iSumSqFrameTime += tFrame*tFrame;
- ASSERT(m_iSumSqFrameTime>=0);
+ if(tFrame > 1000 || tFrame < 0) tFrame = 1000;
+ m_iSumSqFrameTime += tFrame * tFrame;
+ ASSERT(m_iSumSqFrameTime >= 0);
m_iSumFrameTime += tFrame;
}
++m_cFramesDrawn;
@@ -2012,12 +2138,15 @@ void CBaseVideoRenderer::RecordFrameLateness(int trLate, int trFrame)
void CBaseVideoRenderer::ThrottleWait()
{
- if (m_trThrottle>0) {
- int iThrottle = m_trThrottle/10000; // convert to mSec
- MSR_INTEGER( m_idThrottle, iThrottle);
+ if(m_trThrottle > 0)
+ {
+ int iThrottle = m_trThrottle / 10000; // convert to mSec
+ MSR_INTEGER(m_idThrottle, iThrottle);
DbgLog((LOG_TRACE, 0, TEXT("Throttle %d ms"), iThrottle));
Sleep(iThrottle);
- } else {
+ }
+ else
+ {
Sleep(0);
}
} // ThrottleWait
@@ -2034,8 +2163,8 @@ void CBaseVideoRenderer::OnDirectRender(IMediaSample *pMediaSample)
{
m_trRenderAvg = 0;
m_trRenderLast = 5000000; // If we mode switch, we do NOT want this
- // to inhibit the new average getting going!
- // so we set it to half a second
+ // to inhibit the new average getting going!
+ // so we set it to half a second
// MSR_INTEGER(m_idRenderAvg, m_trRenderAvg/10000);
RecordFrameLateness(m_trLate, m_trFrame);
ThrottleWait();
@@ -2065,17 +2194,18 @@ void CBaseVideoRenderer::OnRenderEnd(IMediaSample *pMediaSample)
// some smoothing to help get more sensible figures out but even that is
// not enough as figures can go 9,10,9,9,83,9 and we must disregard 83
- int tr = (timeGetTime() - m_tRenderStart)*10000; // convert mSec->UNITS
- if (tr < m_trRenderAvg*2 || tr < 2 * m_trRenderLast) {
+ int tr = (timeGetTime() - m_tRenderStart) * 10000; // convert mSec->UNITS
+ if(tr < m_trRenderAvg * 2 || tr < 2 * m_trRenderLast)
+ {
// DO_MOVING_AVG(m_trRenderAvg, tr);
- m_trRenderAvg = (tr + (AVGPERIOD-1)*m_trRenderAvg)/AVGPERIOD;
+ m_trRenderAvg = (tr + (AVGPERIOD - 1) * m_trRenderAvg) / AVGPERIOD;
}
m_trRenderLast = tr;
ThrottleWait();
} // OnRenderEnd
-STDMETHODIMP CBaseVideoRenderer::SetSink( IQualityControl * piqc)
+STDMETHODIMP CBaseVideoRenderer::SetSink(IQualityControl * piqc)
{
m_pQSink = piqc;
@@ -2084,7 +2214,7 @@ STDMETHODIMP CBaseVideoRenderer::SetSink( IQualityControl * piqc)
} // SetSink
-STDMETHODIMP CBaseVideoRenderer::Notify( IBaseFilter * pSelf, Quality q)
+STDMETHODIMP CBaseVideoRenderer::Notify(IBaseFilter * pSelf, Quality q)
{
// NOTE: We are NOT getting any locks here. We could be called
// asynchronously and possibly even on a time critical thread of
@@ -2121,11 +2251,15 @@ STDMETHODIMP CBaseVideoRenderer::Notify( IBaseFilter * pSelf, Quality q)
// P60-ish machine). The easy way to get these coefficients is to use
// Renbase.xls follow the instructions therein using excel solver.
- if (q.Proportion>=1000) { m_trThrottle = 0; }
- else {
+ if(q.Proportion >= 1000)
+ {
+ m_trThrottle = 0;
+ }
+ else
+ {
// The DWORD is to make quite sure I get unsigned arithmetic
// as the constant is between 2**31 and 2**32
- m_trThrottle = -330000 + (388880000/(q.Proportion+167));
+ m_trThrottle = -330000 + (388880000 / (q.Proportion + 167));
}
return NOERROR;
} // Notify
@@ -2187,47 +2321,64 @@ HRESULT CBaseVideoRenderer::SendQuality(REFERENCE_TIME trLate,
q.TimeStamp = (REFERENCE_TIME)trRealStream;
- if (m_trFrameAvg<0) {
+ if(m_trFrameAvg < 0)
+ {
q.Type = Famine; // guess
}
// Is the greater part of the time taken bltting or something else
- else if (m_trFrameAvg > 2*m_trRenderAvg) {
+ else if(m_trFrameAvg > 2 * m_trRenderAvg)
+ {
q.Type = Famine; // mainly other
- } else {
+ }
+ else
+ {
q.Type = Flood; // mainly bltting
}
q.Proportion = 1000; // default
- if (m_trFrameAvg<0) {
+ if(m_trFrameAvg < 0)
+ {
// leave it alone - we don't know enough
}
- else if ( trLate> 0 ) {
+ else if(trLate > 0)
+ {
// try to catch up over the next second
// We could be Really, REALLY late, but rendering all the frames
// anyway, just because it's so cheap.
- q.Proportion = 1000 - (int)((trLate)/(UNITS/1000));
- if (q.Proportion<500) {
- q.Proportion = 500; // don't go daft. (could've been negative!)
- } else {
+ q.Proportion = 1000 - (int)((trLate) / (UNITS / 1000));
+ if(q.Proportion < 500)
+ {
+ q.Proportion = 500; // don't go daft. (could've been negative!)
+ }
+ else
+ {
}
- } else if ( m_trWaitAvg>20000
- && trLate<-20000
- ){
+ }
+ else if(m_trWaitAvg > 20000
+ && trLate < -20000
+ )
+ {
// Go cautiously faster - aim at 2mSec wait.
- if (m_trWaitAvg>=m_trFrameAvg) {
+ if(m_trWaitAvg >= m_trFrameAvg)
+ {
// This can happen because of some fudges.
// The waitAvg is how long we originally planned to wait
// The frameAvg is more honest.
// It means that we are spending a LOT of time waiting
q.Proportion = 2000; // double.
- } else {
- if (m_trFrameAvg+20000 > m_trWaitAvg) {
+ }
+ else
+ {
+ if(m_trFrameAvg + 20000 > m_trWaitAvg)
+ {
q.Proportion
- = 1000 * (m_trFrameAvg / (m_trFrameAvg + 20000 - m_trWaitAvg));
- } else {
+ = 1000 * (m_trFrameAvg / (m_trFrameAvg + 20000 - m_trWaitAvg));
+ }
+ else
+ {
// We're apparently spending more than the whole frame time waiting.
// Assume that the averages are slightly out of kilter, but that we
// are indeed doing a lot of waiting. (This leg probably never
@@ -2236,7 +2387,8 @@ HRESULT CBaseVideoRenderer::SendQuality(REFERENCE_TIME trLate,
}
}
- if (q.Proportion>2000) {
+ if(q.Proportion > 2000)
+ {
q.Proportion = 2000; // don't go crazy.
}
}
@@ -2254,15 +2406,16 @@ HRESULT CBaseVideoRenderer::SendQuality(REFERENCE_TIME trLate,
// to be the same. We don't, we expect the average to be a better shot.
// In direct draw mode the RenderAvg will be zero.
- q.Late = trLate + m_trRenderAvg/2;
+ q.Late = trLate + m_trRenderAvg / 2;
// log what we're doing
MSR_INTEGER(m_idQualityRate, q.Proportion);
- MSR_INTEGER( m_idQualityTime, (int)q.Late / 10000 );
+ MSR_INTEGER(m_idQualityTime, (int)q.Late / 10000);
// A specific sink interface may be set through IPin
- if (m_pQSink==NULL) {
+ if(m_pQSink == NULL)
+ {
// Get our input pin's peer. We send quality management messages
// to any nominated receiver of these things (set in the IPin
// interface), or else to our source filter.
@@ -2273,13 +2426,15 @@ HRESULT CBaseVideoRenderer::SendQuality(REFERENCE_TIME trLate,
// And get an AddRef'd quality control interface
- hr = pOutputPin->QueryInterface(IID_IQualityControl,(void**) &pQC);
- if (SUCCEEDED(hr)) {
+ hr = pOutputPin->QueryInterface(IID_IQualityControl, (void**) &pQC);
+ if(SUCCEEDED(hr))
+ {
m_pQSink = pQC;
}
}
- if (m_pQSink) {
- return m_pQSink->Notify(this,q);
+ if(m_pQSink)
+ {
+ return m_pQSink->Notify(this, q);
}
return S_FALSE;
@@ -2298,14 +2453,14 @@ HRESULT CBaseVideoRenderer::SendQuality(REFERENCE_TIME trLate,
// to make the decision
HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
- __inout REFERENCE_TIME *ptrStart,
- __inout REFERENCE_TIME *ptrEnd)
+ __inout REFERENCE_TIME *ptrStart,
+ __inout REFERENCE_TIME *ptrEnd)
{
// Don't call us unless there's a clock interface to synchronise with
ASSERT(m_pClock);
- MSR_INTEGER(m_idTimeStamp, (int)((*ptrStart)>>32)); // high order 32 bits
+ MSR_INTEGER(m_idTimeStamp, (int)((*ptrStart) >> 32)); // high order 32 bits
MSR_INTEGER(m_idTimeStamp, (int)(*ptrStart)); // low order 32 bits
// We lose a bit of time depending on the monitor type waiting for the next
@@ -2313,7 +2468,8 @@ HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
// later than we think when the picture appears. To compensate a bit
// we bias the media samples by -8mSec i.e. 80000 UNITs.
// We don't ever make a stream time negative (call it paranoia)
- if (*ptrStart>=80000) {
+ if(*ptrStart >= 80000)
+ {
*ptrStart -= 80000;
*ptrEnd -= 80000; // bias stop to to retain valid frame duration
}
@@ -2330,7 +2486,7 @@ HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
// Remember the offset from timeGetTime and use that.
// This overflows all over the place, but when we subtract to get
// differences the overflows all cancel out.
- m_llTimeOffset = trRealStream-timeGetTime()*10000;
+ m_llTimeOffset = trRealStream - timeGetTime() * 10000;
#endif
trRealStream -= m_tStart; // convert to stream time (this is a reftime)
@@ -2344,12 +2500,12 @@ HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
const int trTrueLate = TimeDiff(trRealStream - *ptrStart);
const int trLate = trTrueLate;
- MSR_INTEGER(m_idSchLateTime, trTrueLate/10000);
+ MSR_INTEGER(m_idSchLateTime, trTrueLate / 10000);
// Send quality control messages upstream, measured against target
HRESULT hr = SendQuality(trLate, trRealStream);
// Note: the filter upstream is allowed to this FAIL meaning "you do it".
- m_bSupplierHandlingQuality = (hr==S_OK);
+ m_bSupplierHandlingQuality = (hr == S_OK);
// Decision time! Do we drop, draw when ready or draw immediately?
@@ -2360,10 +2516,11 @@ HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
// frame rate inefficent. Hang on a moment though. I've seen files
// where the frames vary between 33 and 34 mSec so as to average
// 30fps. A minor variation like that won't hurt us.
- int t = m_trDuration/32;
- if ( trDuration > m_trDuration+t
- || trDuration < m_trDuration-t
- ) {
+ int t = m_trDuration / 32;
+ if(trDuration > m_trDuration + t
+ || trDuration < m_trDuration - t
+ )
+ {
// There's a major variation. Reset the average frame rate to
// exactly the current rate to disable decision 9002 for this frame,
// and remember the new rate.
@@ -2372,14 +2529,15 @@ HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
}
}
- MSR_INTEGER(m_idEarliness, m_trEarliness/10000);
- MSR_INTEGER(m_idRenderAvg, m_trRenderAvg/10000);
- MSR_INTEGER(m_idFrameAvg, m_trFrameAvg/10000);
- MSR_INTEGER(m_idWaitAvg, m_trWaitAvg/10000);
- MSR_INTEGER(m_idDuration, trDuration/10000);
+ MSR_INTEGER(m_idEarliness, m_trEarliness / 10000);
+ MSR_INTEGER(m_idRenderAvg, m_trRenderAvg / 10000);
+ MSR_INTEGER(m_idFrameAvg, m_trFrameAvg / 10000);
+ MSR_INTEGER(m_idWaitAvg, m_trWaitAvg / 10000);
+ MSR_INTEGER(m_idDuration, trDuration / 10000);
#ifdef PERF
- if (S_OK==pMediaSample->IsDiscontinuity()) {
+ if(S_OK == pMediaSample->IsDiscontinuity())
+ {
MSR_INTEGER(m_idDecision, 9000);
}
#endif
@@ -2390,21 +2548,26 @@ HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
// otherwise do the standard slide (reduce by about 12% per frame).
// Note: earliness is normally NEGATIVE
BOOL bJustDroppedFrame
- = ( m_bSupplierHandlingQuality
- // Can't use the pin sample properties because we might
- // not be in Receive when we call this
- && (S_OK == pMediaSample->IsDiscontinuity()) // he just dropped one
- )
- || (m_nNormal==-1); // we just dropped one
+ = (m_bSupplierHandlingQuality
+ // Can't use the pin sample properties because we might
+ // not be in Receive when we call this
+ && (S_OK == pMediaSample->IsDiscontinuity()) // he just dropped one
+ )
+ || (m_nNormal == -1); // we just dropped one
// Set m_trEarliness (slide back from slow to fast machine mode)
- if (trLate>0) {
+ if(trLate > 0)
+ {
m_trEarliness = 0; // we are no longer in fast machine mode at all!
- } else if ( (trLate>=m_trEarliness) || bJustDroppedFrame) {
+ }
+ else if((trLate >= m_trEarliness) || bJustDroppedFrame)
+ {
m_trEarliness = trLate; // Things have slipped of their own accord
- } else {
- m_trEarliness = m_trEarliness - m_trEarliness/8; // graceful slide
+ }
+ else
+ {
+ m_trEarliness = m_trEarliness - m_trEarliness / 8; // graceful slide
}
// prepare the new wait average - but don't pollute the old one until
@@ -2413,44 +2576,46 @@ HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
{
// We never mix in a negative wait. This causes us to believe in fast machines
// slightly more.
- int trL = trLate<0 ? -trLate : 0;
- trWaitAvg = (trL + m_trWaitAvg*(AVGPERIOD-1))/AVGPERIOD;
+ int trL = trLate < 0 ? -trLate : 0;
+ trWaitAvg = (trL + m_trWaitAvg * (AVGPERIOD - 1)) / AVGPERIOD;
}
int trFrame;
{
REFERENCE_TIME tr = trRealStream - m_trLastDraw; // Cd be large - 4 min pause!
- if (tr>10000000) {
+ if(tr > 10000000)
+ {
tr = 10000000; // 1 second - arbitrarily.
}
trFrame = int(tr);
}
// We will DRAW this frame IF...
- if (
- // ...the time we are spending drawing is a small fraction of the total
- // observed inter-frame time so that dropping it won't help much.
- (3*m_trRenderAvg <= m_trFrameAvg)
-
- // ...or our supplier is NOT handling things and the next frame would
- // be less timely than this one or our supplier CLAIMS to be handling
- // things, and is now less than a full FOUR frames late.
- || ( m_bSupplierHandlingQuality
- ? (trLate <= trDuration*4)
- : (trLate+trLate < trDuration)
- )
-
- // ...or we are on average waiting for over eight milliseconds then
- // this may be just a glitch. Draw it and we'll hope to catch up.
- || (m_trWaitAvg > 80000)
-
- // ...or we haven't drawn an image for over a second. We will update
- // the display, which stops the video looking hung.
- // Do this regardless of how late this media sample is.
- || ((trRealStream - m_trLastDraw) > UNITS)
-
- ) {
+ if(
+ // ...the time we are spending drawing is a small fraction of the total
+ // observed inter-frame time so that dropping it won't help much.
+ (3 * m_trRenderAvg <= m_trFrameAvg)
+
+ // ...or our supplier is NOT handling things and the next frame would
+ // be less timely than this one or our supplier CLAIMS to be handling
+ // things, and is now less than a full FOUR frames late.
+ || (m_bSupplierHandlingQuality
+ ? (trLate <= trDuration * 4)
+ : (trLate + trLate < trDuration)
+ )
+
+ // ...or we are on average waiting for over eight milliseconds then
+ // this may be just a glitch. Draw it and we'll hope to catch up.
+ || (m_trWaitAvg > 80000)
+
+ // ...or we haven't drawn an image for over a second. We will update
+ // the display, which stops the video looking hung.
+ // Do this regardless of how late this media sample is.
+ || ((trRealStream - m_trLastDraw) > UNITS)
+
+ )
+ {
HRESULT Result;
// We are going to play this frame. We may want to play it early.
@@ -2463,30 +2628,33 @@ HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
// we will play it AT ONCE (slow machine mode) if...
- // ...we are playing catch-up
- if ( bJustDroppedFrame) {
+ // ...we are playing catch-up
+ if(bJustDroppedFrame)
+ {
bPlayASAP = TRUE;
MSR_INTEGER(m_idDecision, 9001);
}
- // ...or if we are running below the true frame rate
- // exact comparisons are glitchy, for these measurements,
- // so add an extra 5% or so
- else if ( (m_trFrameAvg > trDuration + trDuration/16)
+ // ...or if we are running below the true frame rate
+ // exact comparisons are glitchy, for these measurements,
+ // so add an extra 5% or so
+ else if((m_trFrameAvg > trDuration + trDuration / 16)
- // It's possible to get into a state where we are losing ground, but
- // are a very long way ahead. To avoid this or recover from it
- // we refuse to play early by more than 10 frames.
- && (trLate > - trDuration*10)
- ){
+ // It's possible to get into a state where we are losing ground, but
+ // are a very long way ahead. To avoid this or recover from it
+ // we refuse to play early by more than 10 frames.
+ && (trLate > - trDuration * 10)
+ )
+ {
bPlayASAP = TRUE;
MSR_INTEGER(m_idDecision, 9002);
}
#if 0
- // ...or if we have been late and are less than one frame early
- else if ( (trLate + trDuration > 0)
- && (m_trWaitAvg<=20000)
- ) {
+ // ...or if we have been late and are less than one frame early
+ else if((trLate + trDuration > 0)
+ && (m_trWaitAvg <= 20000)
+ )
+ {
bPlayASAP = TRUE;
MSR_INTEGER(m_idDecision, 9003);
}
@@ -2495,11 +2663,13 @@ HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
// rate movies - e.g. clock.avi - it is not a good idea to leap ahead just
// because we got starved (for instance by the net) and dropped one frame
// some time or other. If we are more than 900mSec early, then wait.
- if (trLate<-9000000) {
+ if(trLate < -9000000)
+ {
bPlayASAP = FALSE;
}
- if (bPlayASAP) {
+ if(bPlayASAP)
+ {
m_nNormal = 0;
MSR_INTEGER(m_idDecision, 0);
@@ -2508,10 +2678,10 @@ HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
// dropping frames to keep sync. We should not let that mislead
// us into thinking that we have as much as zero spare time!
// We just update with a zero wait.
- m_trWaitAvg = (m_trWaitAvg*(AVGPERIOD-1))/AVGPERIOD;
+ m_trWaitAvg = (m_trWaitAvg * (AVGPERIOD - 1)) / AVGPERIOD;
// Assume that we draw it immediately. Update inter-frame stats
- m_trFrameAvg = (trFrame + m_trFrameAvg*(AVGPERIOD-1))/AVGPERIOD;
+ m_trFrameAvg = (trFrame + m_trFrameAvg * (AVGPERIOD - 1)) / AVGPERIOD;
#ifndef PERF
// If this is NOT a perf build, then report what we know so far
// without looking at the clock any more. This assumes that we
@@ -2522,12 +2692,15 @@ HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
PreparePerformanceData(trTrueLate, trFrame);
#endif
m_trLastDraw = trRealStream;
- if (m_trEarliness > trLate) {
+ if(m_trEarliness > trLate)
+ {
m_trEarliness = trLate; // if we are actually early, this is neg
}
Result = S_OK; // Draw it now
- } else {
+ }
+ else
+ {
++m_nNormal;
// Set the average frame rate to EXACTLY the ideal rate.
// If we are exiting slow-machine mode then we will have caught up
@@ -2542,32 +2715,39 @@ HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
{
int trE = m_trEarliness;
- if (trE < -m_trFrameAvg) {
+ if(trE < -m_trFrameAvg)
+ {
trE = -m_trFrameAvg;
}
*ptrStart += trE; // N.B. earliness is negative
}
int Delay = -trTrueLate;
- Result = Delay<=0 ? S_OK : S_FALSE; // OK = draw now, FALSE = wait
+ Result = Delay <= 0 ? S_OK : S_FALSE; // OK = draw now, FALSE = wait
m_trWaitAvg = trWaitAvg;
// Predict when it will actually be drawn and update frame stats
- if (Result==S_FALSE) { // We are going to wait
- trFrame = TimeDiff(*ptrStart-m_trLastDraw);
+ if(Result == S_FALSE) // We are going to wait
+ {
+ trFrame = TimeDiff(*ptrStart - m_trLastDraw);
m_trLastDraw = *ptrStart;
- } else {
+ }
+ else
+ {
// trFrame is already = trRealStream-m_trLastDraw;
m_trLastDraw = trRealStream;
}
#ifndef PERF
int iAccuracy;
- if (Delay>0) {
+ if(Delay > 0)
+ {
// Report lateness based on when we intend to play it
- iAccuracy = TimeDiff(*ptrStart-m_trRememberStampForPerf);
- } else {
+ iAccuracy = TimeDiff(*ptrStart - m_trRememberStampForPerf);
+ }
+ else
+ {
// Report lateness based on playing it *now*.
iAccuracy = trTrueLate; // trRealStream-RememberStampForPerf;
}
@@ -2585,8 +2765,9 @@ HRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample,
#ifdef PERF
// Respect registry setting - debug only!
- if (m_bDrawLateFrames) {
- return S_OK; // draw it when it's ready
+ if(m_bDrawLateFrames)
+ {
+ return S_OK; // draw it when it's ready
} // even though it's late.
#endif
@@ -2614,9 +2795,10 @@ BOOL CBaseVideoRenderer::ScheduleSample(IMediaSample *pMediaSample)
// We override ShouldDrawSampleNow to add quality management
BOOL bDrawImage = CBaseRenderer::ScheduleSample(pMediaSample);
- if (bDrawImage == FALSE) {
- ++m_cFramesDropped;
- return FALSE;
+ if(bDrawImage == FALSE)
+ {
+ ++m_cFramesDropped;
+ return FALSE;
}
// m_cFramesDrawn must NOT be updated here. It has to be updated
@@ -2636,7 +2818,7 @@ BOOL CBaseVideoRenderer::ScheduleSample(IMediaSample *pMediaSample)
STDMETHODIMP CBaseVideoRenderer::get_FramesDroppedInRenderer(__out int *pcFramesDropped)
{
- CheckPointer(pcFramesDropped,E_POINTER);
+ CheckPointer(pcFramesDropped, E_POINTER);
CAutoLock cVideoLock(&m_InterfaceLock);
*pcFramesDropped = m_cFramesDropped;
return NOERROR;
@@ -2646,9 +2828,9 @@ STDMETHODIMP CBaseVideoRenderer::get_FramesDroppedInRenderer(__out int *pcFrames
// Set *pcFramesDrawn to the number of frames drawn since
// streaming started.
-STDMETHODIMP CBaseVideoRenderer::get_FramesDrawn( int *pcFramesDrawn)
+STDMETHODIMP CBaseVideoRenderer::get_FramesDrawn(int *pcFramesDrawn)
{
- CheckPointer(pcFramesDrawn,E_POINTER);
+ CheckPointer(pcFramesDrawn, E_POINTER);
CAutoLock cVideoLock(&m_InterfaceLock);
*pcFramesDrawn = m_cFramesDrawn;
return NOERROR;
@@ -2658,22 +2840,28 @@ STDMETHODIMP CBaseVideoRenderer::get_FramesDrawn( int *pcFramesDrawn)
// Set iAvgFrameRate to the frames per hundred secs since
// streaming started. 0 otherwise.
-STDMETHODIMP CBaseVideoRenderer::get_AvgFrameRate( int *piAvgFrameRate)
+STDMETHODIMP CBaseVideoRenderer::get_AvgFrameRate(int *piAvgFrameRate)
{
- CheckPointer(piAvgFrameRate,E_POINTER);
+ CheckPointer(piAvgFrameRate, E_POINTER);
CAutoLock cVideoLock(&m_InterfaceLock);
int t;
- if (m_bStreaming) {
- t = timeGetTime()-m_tStreamingStart;
- } else {
+ if(m_bStreaming)
+ {
+ t = timeGetTime() - m_tStreamingStart;
+ }
+ else
+ {
t = m_tStreamingStart;
}
- if (t<=0) {
+ if(t <= 0)
+ {
*piAvgFrameRate = 0;
ASSERT(m_cFramesDrawn == 0);
- } else {
+ }
+ else
+ {
// i is frames per hundred seconds
*piAvgFrameRate = MulDiv(100000, m_cFramesDrawn, t);
}
@@ -2687,20 +2875,24 @@ STDMETHODIMP CBaseVideoRenderer::get_AvgFrameRate( int *piAvgFrameRate)
STDMETHODIMP CBaseVideoRenderer::get_AvgSyncOffset(__out int *piAvg)
{
- CheckPointer(piAvg,E_POINTER);
+ CheckPointer(piAvg, E_POINTER);
CAutoLock cVideoLock(&m_InterfaceLock);
- if (NULL==m_pClock) {
+ if(NULL == m_pClock)
+ {
*piAvg = 0;
return NOERROR;
}
// Note that we didn't gather the stats on the first frame
// so we use m_cFramesDrawn-1 here
- if (m_cFramesDrawn<=1) {
+ if(m_cFramesDrawn <= 1)
+ {
*piAvg = 0;
- } else {
- *piAvg = (int)(m_iTotAcc / (m_cFramesDrawn-1));
+ }
+ else
+ {
+ *piAvg = (int)(m_iTotAcc / (m_cFramesDrawn - 1));
}
return NOERROR;
} // get_AvgSyncOffset
@@ -2728,20 +2920,27 @@ int isqrt(int x)
{
int s = 1;
// Make s an initial guess for sqrt(x)
- if (x > 0x40000000) {
- s = 0x8000; // prevent any conceivable closed loop
- } else {
- while (s*s<x) { // loop cannot possible go more than 31 times
- s = 2*s; // normally it goes about 6 times
+ if(x > 0x40000000)
+ {
+ s = 0x8000; // prevent any conceivable closed loop
+ }
+ else
+ {
+ while(s * s < x) // loop cannot possible go more than 31 times
+ {
+ s = 2 * s; // normally it goes about 6 times
}
// Three NR iterations.
- if (x==0) {
- s= 0; // Wouldn't it be tragic to divide by zero whenever our
- // accuracy was perfect!
- } else {
- s = (s*s+x)/(2*s);
- if (s>=0) s = (s*s+x)/(2*s);
- if (s>=0) s = (s*s+x)/(2*s);
+ if(x == 0)
+ {
+ s = 0; // Wouldn't it be tragic to divide by zero whenever our
+ // accuracy was perfect!
+ }
+ else
+ {
+ s = (s * s + x) / (2 * s);
+ if(s >= 0) s = (s * s + x) / (2 * s);
+ if(s >= 0) s = (s * s + x) / (2 * s);
}
}
return s;
@@ -2758,10 +2957,11 @@ HRESULT CBaseVideoRenderer::GetStdDev(
LONGLONG iTot
)
{
- CheckPointer(piResult,E_POINTER);
+ CheckPointer(piResult, E_POINTER);
CAutoLock cVideoLock(&m_InterfaceLock);
- if (NULL==m_pClock) {
+ if(NULL == m_pClock)
+ {
*piResult = 0;
return NOERROR;
}
@@ -2771,17 +2971,20 @@ HRESULT CBaseVideoRenderer::GetStdDev(
// N observations, then an estimate of the standard deviation is
// sqrt( (S - T**2/N) / (N-1) )
- if (nSamples<=1) {
+ if(nSamples <= 1)
+ {
*piResult = 0;
- } else {
+ }
+ else
+ {
LONGLONG x;
// First frames have invalid stamps, so we get no stats for them
// So we need 2 frames to get 1 datum, so N is cFramesDrawn-1
// so we use m_cFramesDrawn-1 here
x = llSumSq - llMulDiv(iTot, iTot, nSamples, 0);
- x = x / (nSamples-1);
- ASSERT(x>=0);
+ x = x / (nSamples - 1);
+ ASSERT(x >= 0);
*piResult = isqrt((LONG)x);
}
return NOERROR;
@@ -2819,16 +3022,19 @@ STDMETHODIMP CBaseVideoRenderer::get_Jitter(__out int *piJitter)
// Overidden to return our IQualProp interface
STDMETHODIMP
-CBaseVideoRenderer::NonDelegatingQueryInterface(REFIID riid,__deref_out VOID **ppv)
+CBaseVideoRenderer::NonDelegatingQueryInterface(REFIID riid, __deref_out VOID **ppv)
{
// We return IQualProp and delegate everything else
- if (riid == IID_IQualProp) {
- return GetInterface( (IQualProp *)this, ppv);
- } else if (riid == IID_IQualityControl) {
- return GetInterface( (IQualityControl *)this, ppv);
+ if(riid == IID_IQualProp)
+ {
+ return GetInterface((IQualProp *)this, ppv);
}
- return CBaseRenderer::NonDelegatingQueryInterface(riid,ppv);
+ else if(riid == IID_IQualityControl)
+ {
+ return GetInterface((IQualityControl *)this, ppv);
+ }
+ return CBaseRenderer::NonDelegatingQueryInterface(riid, ppv);
}
@@ -2841,7 +3047,8 @@ CBaseVideoRenderer::JoinFilterGraph(__inout_opt IFilterGraph *pGraph, __in_opt L
// Since we send EC_ACTIVATE, we also need to ensure
// we send EC_WINDOW_DESTROYED or the resource manager may be
// holding us as a focus object
- if (!pGraph && m_pGraph) {
+ if(!pGraph && m_pGraph)
+ {
// We were in a graph and now we're not
// Do this properly in case we are aggregated
diff --git a/src/filters/BaseClasses/renbase.h b/src/filters/BaseClasses/renbase.h
index 695f07837..a5eb8a21b 100644
--- a/src/filters/BaseClasses/renbase.h
+++ b/src/filters/BaseClasses/renbase.h
@@ -86,13 +86,13 @@ protected:
BOOL m_bRepaintStatus; // Can we signal an EC_REPAINT
// Avoid some deadlocks by tracking filter during stop
volatile BOOL m_bInReceive; // Inside Receive between PrepareReceive
- // And actually processing the sample
+ // And actually processing the sample
REFERENCE_TIME m_SignalTime; // Time when we signal EC_COMPLETE
UINT m_EndOfStreamTimer; // Used to signal end of stream
CCritSec m_ObjectCreationLock; // This lock protects the creation and
- // of m_pPosition and m_pInputPin. It
- // ensures that two threads cannot create
- // either object simultaneously.
+ // of m_pPosition and m_pInputPin. It
+ // ensures that two threads cannot create
+ // either object simultaneously.
public:
@@ -119,24 +119,48 @@ public:
// Return internal information about this filter
- BOOL IsEndOfStream() { return m_bEOS; };
- BOOL IsEndOfStreamDelivered() { return m_bEOSDelivered; };
- BOOL IsStreaming() { return m_bStreaming; };
- void SetAbortSignal(BOOL bAbort) { m_bAbort = bAbort; };
+ BOOL IsEndOfStream()
+ {
+ return m_bEOS;
+ };
+ BOOL IsEndOfStreamDelivered()
+ {
+ return m_bEOSDelivered;
+ };
+ BOOL IsStreaming()
+ {
+ return m_bStreaming;
+ };
+ void SetAbortSignal(BOOL bAbort)
+ {
+ m_bAbort = bAbort;
+ };
virtual void OnReceiveFirstSample(IMediaSample *pMediaSample) { };
- CAMEvent *GetRenderEvent() { return &m_RenderEvent; };
+ CAMEvent *GetRenderEvent()
+ {
+ return &m_RenderEvent;
+ };
// Permit access to the transition state
- void Ready() { m_evComplete.Set(); };
- void NotReady() { m_evComplete.Reset(); };
- BOOL CheckReady() { return m_evComplete.Check(); };
+ void Ready()
+ {
+ m_evComplete.Set();
+ };
+ void NotReady()
+ {
+ m_evComplete.Reset();
+ };
+ BOOL CheckReady()
+ {
+ return m_evComplete.Check();
+ };
virtual int GetPinCount();
virtual CBasePin *GetPin(int n);
FILTER_STATE GetRealState();
void SendRepaint();
- void SendNotifyWindow(IPin *pPin,HWND hwnd);
+ void SendNotifyWindow(IPin *pPin, HWND hwnd);
BOOL OnDisplayChange();
void SetRepaintStatus(BOOL bRepaint);
@@ -152,15 +176,21 @@ public:
virtual void OnRenderStart(IMediaSample *pMediaSample);
virtual void OnRenderEnd(IMediaSample *pMediaSample);
- virtual HRESULT OnStartStreaming() { return NOERROR; };
- virtual HRESULT OnStopStreaming() { return NOERROR; };
+ virtual HRESULT OnStartStreaming()
+ {
+ return NOERROR;
+ };
+ virtual HRESULT OnStopStreaming()
+ {
+ return NOERROR;
+ };
virtual void OnWaitStart() { };
virtual void OnWaitEnd() { };
virtual void PrepareRender() { };
#ifdef PERF
REFERENCE_TIME m_trRenderStart; // Just before we started drawing
- // Set in OnRenderStart, Used in OnRenderEnd
+ // Set in OnRenderStart, Used in OnRenderEnd
int m_idBaseStamp; // MSR_id for frame time stamp
int m_idBaseRenderTime; // MSR_id for true wait time
int m_idBaseAccuracy; // MSR_id for time frame is late (int)
@@ -248,8 +278,8 @@ public:
// Spot the bug in this macro - I can't. but it doesn't work!
class CBaseVideoRenderer : public CBaseRenderer, // Base renderer class
- public IQualProp, // Property page guff
- public IQualityControl // Allow throttling
+ public IQualProp, // Property page guff
+ public IQualityControl // Allow throttling
{
protected:
@@ -271,19 +301,19 @@ protected:
// We therefore need to know whether we are playing frames early or not.
int m_nNormal; // The number of consecutive frames
- // drawn at their normal time (not early)
- // -1 means we just dropped a frame.
+ // drawn at their normal time (not early)
+ // -1 means we just dropped a frame.
#ifdef PERF
BOOL m_bDrawLateFrames; // Don't drop any frames (debug and I'm
- // not keen on people using it!)
+ // not keen on people using it!)
#endif
BOOL m_bSupplierHandlingQuality;// The response to Quality messages says
- // our supplier is handling things.
- // We will allow things to go extra late
- // before dropping frames. We will play
- // very early after he has dropped one.
+ // our supplier is handling things.
+ // We will allow things to go extra late
+ // before dropping frames. We will play
+ // very early after he has dropped one.
// Control of scheduling, frame dropping etc.
// We need to know where the time is being spent so as to tell whether
@@ -313,7 +343,7 @@ protected:
int m_trRenderAvg; // Time frames are taking to blt
int m_trRenderLast; // Time for last frame blt
int m_tRenderStart; // Just before we started drawing (mSec)
- // derived from timeGetTime.
+ // derived from timeGetTime.
// When frames are dropped we will play the next frame as early as we can.
// If it was a false alarm and the machine is fast we slide gently back to
@@ -335,8 +365,8 @@ protected:
// controls whether we bother to drop a frame or whether we reckon that
// we're doing well enough that we can stand a one-frame glitch.
int m_trWaitAvg; // Average of last few wait times
- // (actually we just average how early
- // we were). Negative here means LATE.
+ // (actually we just average how early
+ // we were). Negative here means LATE.
// The average inter-frame time.
// This is used to calculate the proportion of the time used by the
@@ -363,7 +393,7 @@ protected:
//int m_idSendQuality; // MSR_id for timing the notifications per se
#endif // PERF
REFERENCE_TIME m_trRememberStampForPerf; // original time stamp of frame
- // with no earliness fudges etc.
+ // with no earliness fudges etc.
#ifdef PERF
REFERENCE_TIME m_trRememberFrameForPerf; // time when previous frame rendered
@@ -378,7 +408,7 @@ protected:
int m_cFramesDropped; // cumulative frames dropped IN THE RENDERER
int m_cFramesDrawn; // Frames since streaming started seen BY THE
- // RENDERER (some may be dropped upstream)
+ // RENDERER (some may be dropped upstream)
// Next two support average sync offset and standard deviation of sync offset.
LONGLONG m_iTotAcc; // Sum of accuracies in mSec
@@ -398,8 +428,8 @@ protected:
int m_trFrame; // hold onto inter-frame time
int m_tStreamingStart; // if streaming then time streaming started
- // else time of last streaming session
- // used for property page statistics
+ // else time of last streaming session
+ // used for property page statistics
#ifdef PERF
LONGLONG m_llTimeOffset; // timeGetTime()*10000+m_llTimeOffset==ref time
#endif
@@ -416,8 +446,8 @@ public:
// IQualityControl methods - Notify allows audio-video throttling
- STDMETHODIMP SetSink( IQualityControl * piqc);
- STDMETHODIMP Notify( IBaseFilter * pSelf, Quality q);
+ STDMETHODIMP SetSink(IQualityControl * piqc);
+ STDMETHODIMP Notify(IBaseFilter * pSelf, Quality q);
// These provide a full video quality management implementation
@@ -471,7 +501,7 @@ public:
// Implement an IUnknown interface and expose IQualProp
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,__deref_out VOID **ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out VOID **ppv);
};
#endif // __RENBASE__
diff --git a/src/filters/BaseClasses/schedule.cpp b/src/filters/BaseClasses/schedule.cpp
index 1b4a38190..519f72b24 100644
--- a/src/filters/BaseClasses/schedule.cpp
+++ b/src/filters/BaseClasses/schedule.cpp
@@ -17,12 +17,12 @@
/* Construct & destructors */
-CAMSchedule::CAMSchedule( HANDLE ev )
-: CBaseObject(TEXT("CAMSchedule"))
-, head(&z, 0), z(0, MAX_TIME)
-, m_dwNextCookie(0), m_dwAdviseCount(0)
-, m_pAdviseCache(0), m_dwCacheCount(0)
-, m_ev( ev )
+CAMSchedule::CAMSchedule(HANDLE ev)
+ : CBaseObject(TEXT("CAMSchedule"))
+ , head(&z, 0), z(0, MAX_TIME)
+ , m_dwNextCookie(0), m_dwAdviseCount(0)
+ , m_pAdviseCache(0), m_dwCacheCount(0)
+ , m_ev(ev)
{
head.m_dwAdviseCookie = z.m_dwAdviseCookie = 0;
}
@@ -33,19 +33,19 @@ CAMSchedule::~CAMSchedule()
// Delete cache
CAdvisePacket * p = m_pAdviseCache;
- while (p)
+ while(p)
{
CAdvisePacket *const p_next = p->m_next;
delete p;
p = p_next;
}
- ASSERT( m_dwAdviseCount == 0 );
+ ASSERT(m_dwAdviseCount == 0);
// Better to be safe than sorry
- if ( m_dwAdviseCount > 0 )
+ if(m_dwAdviseCount > 0)
{
DumpLinkedList();
- while ( !head.m_next->IsZ() )
+ while(!head.m_next->IsZ())
{
head.DeleteNext();
--m_dwAdviseCount;
@@ -55,7 +55,7 @@ CAMSchedule::~CAMSchedule()
// If, in the debug version, we assert twice, it means, not only
// did we have left over advises, but we have also let m_dwAdviseCount
// get out of sync. with the number of advises actually on the list.
- ASSERT( m_dwAdviseCount == 0 );
+ ASSERT(m_dwAdviseCount == 0);
m_Serialize.Unlock();
}
@@ -75,20 +75,20 @@ REFERENCE_TIME CAMSchedule::GetNextAdviseTime()
}
DWORD_PTR CAMSchedule::AddAdvisePacket
-( const REFERENCE_TIME & time1
-, const REFERENCE_TIME & time2
-, HANDLE h, BOOL periodic
+(const REFERENCE_TIME & time1
+ , const REFERENCE_TIME & time2
+ , HANDLE h, BOOL periodic
)
{
// Since we use MAX_TIME as a sentry, we can't afford to
// schedule a notification at MAX_TIME
- ASSERT( time1 < MAX_TIME );
+ ASSERT(time1 < MAX_TIME);
DWORD_PTR Result;
CAdvisePacket * p;
m_Serialize.Lock();
- if (m_pAdviseCache)
+ if(m_pAdviseCache)
{
p = m_pAdviseCache;
m_pAdviseCache = p->m_next;
@@ -98,11 +98,13 @@ DWORD_PTR CAMSchedule::AddAdvisePacket
{
p = new CAdvisePacket();
}
- if (p)
+ if(p)
{
- p->m_rtEventTime = time1; p->m_rtPeriod = time2;
- p->m_hNotify = h; p->m_bPeriodic = periodic;
- Result = AddAdvisePacket( p );
+ p->m_rtEventTime = time1;
+ p->m_rtPeriod = time2;
+ p->m_hNotify = h;
+ p->m_bPeriodic = periodic;
+ Result = AddAdvisePacket(p);
}
else Result = 0;
@@ -117,21 +119,21 @@ HRESULT CAMSchedule::Unadvise(DWORD_PTR dwAdviseCookie)
CAdvisePacket * p_prev = &head;
CAdvisePacket * p_n;
m_Serialize.Lock();
- while ( p_n = p_prev->Next() ) // The Next() method returns NULL when it hits z
+ while(p_n = p_prev->Next()) // The Next() method returns NULL when it hits z
{
- if ( p_n->m_dwAdviseCookie == dwAdviseCookie )
+ if(p_n->m_dwAdviseCookie == dwAdviseCookie)
{
- Delete( p_prev->RemoveNext() );
+ Delete(p_prev->RemoveNext());
--m_dwAdviseCount;
hr = S_OK;
- // Having found one cookie that matches, there should be no more
- #ifdef _DEBUG
- while (p_n = p_prev->Next())
- {
- ASSERT(p_n->m_dwAdviseCookie != dwAdviseCookie);
- p_prev = p_n;
- }
- #endif
+ // Having found one cookie that matches, there should be no more
+#ifdef _DEBUG
+ while(p_n = p_prev->Next())
+ {
+ ASSERT(p_n->m_dwAdviseCookie != dwAdviseCookie);
+ p_prev = p_n;
+ }
+#endif
break;
}
p_prev = p_n;
@@ -140,54 +142,54 @@ HRESULT CAMSchedule::Unadvise(DWORD_PTR dwAdviseCookie)
return hr;
}
-REFERENCE_TIME CAMSchedule::Advise( const REFERENCE_TIME & rtTime )
+REFERENCE_TIME CAMSchedule::Advise(const REFERENCE_TIME & rtTime)
{
REFERENCE_TIME rtNextTime;
CAdvisePacket * pAdvise;
DbgLog((LOG_TIMING, 2,
- TEXT("CAMSchedule::Advise( %lu ms )"), ULONG(rtTime / (UNITS / MILLISECONDS))));
+ TEXT("CAMSchedule::Advise( %lu ms )"), ULONG(rtTime / (UNITS / MILLISECONDS))));
CAutoLock lck(&m_Serialize);
- #ifdef _DEBUG
- if (DbgCheckModuleLevel(LOG_TIMING, 4)) DumpLinkedList();
- #endif
+#ifdef _DEBUG
+ if(DbgCheckModuleLevel(LOG_TIMING, 4)) DumpLinkedList();
+#endif
- // Note - DON'T cache the difference, it might overflow
- while ( rtTime >= (rtNextTime = (pAdvise=head.m_next)->m_rtEventTime) &&
- !pAdvise->IsZ() )
+ // Note - DON'T cache the difference, it might overflow
+ while(rtTime >= (rtNextTime = (pAdvise = head.m_next)->m_rtEventTime) &&
+ !pAdvise->IsZ())
{
ASSERT(pAdvise->m_dwAdviseCookie); // If this is zero, its the head or the tail!!
ASSERT(pAdvise->m_hNotify != INVALID_HANDLE_VALUE);
- if (pAdvise->m_bPeriodic == TRUE)
+ if(pAdvise->m_bPeriodic == TRUE)
{
- ReleaseSemaphore(pAdvise->m_hNotify,1,NULL);
+ ReleaseSemaphore(pAdvise->m_hNotify, 1, NULL);
pAdvise->m_rtEventTime += pAdvise->m_rtPeriod;
ShuntHead();
}
else
{
- ASSERT( pAdvise->m_bPeriodic == FALSE );
+ ASSERT(pAdvise->m_bPeriodic == FALSE);
EXECUTE_ASSERT(SetEvent(pAdvise->m_hNotify));
--m_dwAdviseCount;
- Delete( head.RemoveNext() );
+ Delete(head.RemoveNext());
}
}
DbgLog((LOG_TIMING, 3,
TEXT("CAMSchedule::Advise() Next time stamp: %lu ms, for advise %lu."),
- DWORD(rtNextTime / (UNITS / MILLISECONDS)), pAdvise->m_dwAdviseCookie ));
+ DWORD(rtNextTime / (UNITS / MILLISECONDS)), pAdvise->m_dwAdviseCookie));
return rtNextTime;
}
/* Private methods */
-DWORD_PTR CAMSchedule::AddAdvisePacket( __inout CAdvisePacket * pPacket )
+DWORD_PTR CAMSchedule::AddAdvisePacket(__inout CAdvisePacket * pPacket)
{
ASSERT(pPacket->m_rtEventTime >= 0 && pPacket->m_rtEventTime < MAX_TIME);
ASSERT(CritCheckIn(&m_Serialize));
@@ -197,26 +199,26 @@ DWORD_PTR CAMSchedule::AddAdvisePacket( __inout CAdvisePacket * pPacket )
const DWORD_PTR Result = pPacket->m_dwAdviseCookie = ++m_dwNextCookie;
// This relies on the fact that z is a sentry with a maximal m_rtEventTime
- for(;;p_prev = p_n)
+ for(;; p_prev = p_n)
{
p_n = p_prev->m_next;
- if ( p_n->m_rtEventTime >= pPacket->m_rtEventTime ) break;
+ if(p_n->m_rtEventTime >= pPacket->m_rtEventTime) break;
}
- p_prev->InsertAfter( pPacket );
+ p_prev->InsertAfter(pPacket);
++m_dwAdviseCount;
DbgLog((LOG_TIMING, 2, TEXT("Added advise %lu, for thread 0x%02X, scheduled at %lu"),
- pPacket->m_dwAdviseCookie, GetCurrentThreadId(), (pPacket->m_rtEventTime / (UNITS / MILLISECONDS)) ));
+ pPacket->m_dwAdviseCookie, GetCurrentThreadId(), (pPacket->m_rtEventTime / (UNITS / MILLISECONDS))));
// If packet added at the head, then clock needs to re-evaluate wait time.
- if ( p_prev == &head ) SetEvent( m_ev );
+ if(p_prev == &head) SetEvent(m_ev);
return Result;
}
-void CAMSchedule::Delete( __inout CAdvisePacket * pPacket )
+void CAMSchedule::Delete(__inout CAdvisePacket * pPacket)
{
- if ( m_dwCacheCount >= dwCacheMax ) delete pPacket;
+ if(m_dwCacheCount >= dwCacheMax) delete pPacket;
else
{
m_Serialize.Lock();
@@ -240,24 +242,24 @@ void CAMSchedule::ShuntHead()
// This will catch both an empty list,
// and if somehow a MAX_TIME time gets into the list
// (which would also break this method).
- ASSERT( pPacket->m_rtEventTime < MAX_TIME );
+ ASSERT(pPacket->m_rtEventTime < MAX_TIME);
// This relies on the fact that z is a sentry with a maximal m_rtEventTime
- for(;;p_prev = p_n)
+ for(;; p_prev = p_n)
{
p_n = p_prev->m_next;
- if ( p_n->m_rtEventTime > pPacket->m_rtEventTime ) break;
+ if(p_n->m_rtEventTime > pPacket->m_rtEventTime) break;
}
// If p_prev == pPacket then we're already in the right place
- if (p_prev != pPacket)
+ if(p_prev != pPacket)
{
head.m_next = pPacket->m_next;
(p_prev->m_next = pPacket)->m_next = p_n;
}
- #ifdef _DEBUG
- DbgLog((LOG_TIMING, 2, TEXT("Periodic advise %lu, shunted to %lu"),
- pPacket->m_dwAdviseCookie, (pPacket->m_rtEventTime / (UNITS / MILLISECONDS)) ));
- #endif
+#ifdef _DEBUG
+ DbgLog((LOG_TIMING, 2, TEXT("Periodic advise %lu, shunted to %lu"),
+ pPacket->m_dwAdviseCookie, (pPacket->m_rtEventTime / (UNITS / MILLISECONDS))));
+#endif
m_Serialize.Unlock();
}
@@ -266,18 +268,18 @@ void CAMSchedule::ShuntHead()
void CAMSchedule::DumpLinkedList()
{
m_Serialize.Lock();
- int i=0;
+ int i = 0;
DbgLog((LOG_TIMING, 1, TEXT("CAMSchedule::DumpLinkedList() this = 0x%p"), this));
- for ( CAdvisePacket * p = &head
- ; p
+ for(CAdvisePacket * p = &head
+ ; p
; p = p->m_next , i++
- )
+ )
{
DbgLog((LOG_TIMING, 1, TEXT("Advise List # %lu, Cookie %d, RefTime %lu"),
- i,
- p->m_dwAdviseCookie,
- p->m_rtEventTime / (UNITS / MILLISECONDS)
- ));
+ i,
+ p->m_dwAdviseCookie,
+ p->m_rtEventTime / (UNITS / MILLISECONDS)
+ ));
}
m_Serialize.Unlock();
}
diff --git a/src/filters/BaseClasses/schedule.h b/src/filters/BaseClasses/schedule.h
index 058d76442..216859efa 100644
--- a/src/filters/BaseClasses/schedule.h
+++ b/src/filters/BaseClasses/schedule.h
@@ -15,23 +15,26 @@ class CAMSchedule : private CBaseObject
public:
virtual ~CAMSchedule();
// ev is the event we should fire if the advise time needs re-evaluating
- CAMSchedule( HANDLE ev );
+ CAMSchedule(HANDLE ev);
DWORD GetAdviseCount();
REFERENCE_TIME GetNextAdviseTime();
// We need a method for derived classes to add advise packets, we return the cookie
- DWORD_PTR AddAdvisePacket( const REFERENCE_TIME & time1, const REFERENCE_TIME & time2, HANDLE h, BOOL periodic );
+ DWORD_PTR AddAdvisePacket(const REFERENCE_TIME & time1, const REFERENCE_TIME & time2, HANDLE h, BOOL periodic);
// And a way to cancel
HRESULT Unadvise(DWORD_PTR dwAdviseCookie);
// Tell us the time please, and we'll dispatch the expired events. We return the time of the next event.
// NB: The time returned will be "useless" if you start adding extra Advises. But that's the problem of
// whoever is using this helper class (typically a clock).
- REFERENCE_TIME Advise( const REFERENCE_TIME & rtTime );
+ REFERENCE_TIME Advise(const REFERENCE_TIME & rtTime);
// Get the event handle which will be set if advise time requires re-evaluation.
- HANDLE GetEvent() const { return m_ev; }
+ HANDLE GetEvent() const
+ {
+ return m_ev;
+ }
private:
// We define the nodes that will be used in our singly linked list
@@ -50,17 +53,19 @@ private:
HANDLE m_hNotify; // Handle to event or semephore
BOOL m_bPeriodic; // TRUE => Periodic event
- CAdvisePacket( __inout_opt CAdvisePacket * next, LONGLONG time ) : m_next(next), m_rtEventTime(time)
+ CAdvisePacket(__inout_opt CAdvisePacket * next, LONGLONG time) : m_next(next), m_rtEventTime(time)
{}
- void InsertAfter( __inout CAdvisePacket * p )
+ void InsertAfter(__inout CAdvisePacket * p)
{
p->m_next = m_next;
m_next = p;
}
int IsZ() const // That is, is it the node that represents the end of the list
- { return m_next == 0; }
+ {
+ return m_next == 0;
+ }
CAdvisePacket * RemoveNext()
{
@@ -78,12 +83,14 @@ private:
CAdvisePacket * Next() const
{
CAdvisePacket * result = m_next;
- if (result->IsZ()) result = 0;
+ if(result->IsZ()) result = 0;
return result;
}
DWORD_PTR Cookie() const
- { return m_dwAdviseCookie; }
+ {
+ return m_dwAdviseCookie;
+ }
};
// Structure is:
@@ -99,7 +106,7 @@ private:
CCritSec m_Serialize;
// AddAdvisePacket: adds the packet, returns the cookie (0 if failed)
- DWORD_PTR AddAdvisePacket( __inout CAdvisePacket * pPacket );
+ DWORD_PTR AddAdvisePacket(__inout CAdvisePacket * pPacket);
// Event that we should set if the packed added above will be the next to fire.
const HANDLE m_ev;
@@ -113,7 +120,7 @@ private:
DWORD m_dwCacheCount;
enum { dwCacheMax = 5 }; // Don't bother caching more than five
- void Delete( __inout CAdvisePacket * pLink );// This "Delete" will cache the Link
+ void Delete(__inout CAdvisePacket * pLink); // This "Delete" will cache the Link
// Attributes and methods for debugging
public:
diff --git a/src/filters/BaseClasses/seekpt.cpp b/src/filters/BaseClasses/seekpt.cpp
index bb13d6f0a..856259d1e 100644
--- a/src/filters/BaseClasses/seekpt.cpp
+++ b/src/filters/BaseClasses/seekpt.cpp
@@ -19,29 +19,35 @@
CUnknown * CSeekingPassThru::CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)
{
- return new CSeekingPassThru(NAME("Seeking PassThru"),pUnk, phr);
+ return new CSeekingPassThru(NAME("Seeking PassThru"), pUnk, phr);
}
STDMETHODIMP CSeekingPassThru::NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv)
{
- if (riid == IID_ISeekingPassThru) {
+ if(riid == IID_ISeekingPassThru)
+ {
return GetInterface((ISeekingPassThru *) this, ppv);
- } else {
- if (m_pPosPassThru &&
- (riid == IID_IMediaSeeking ||
- riid == IID_IMediaPosition)) {
- return m_pPosPassThru->NonDelegatingQueryInterface(riid,ppv);
- } else {
+ }
+ else
+ {
+ if(m_pPosPassThru &&
+ (riid == IID_IMediaSeeking ||
+ riid == IID_IMediaPosition))
+ {
+ return m_pPosPassThru->NonDelegatingQueryInterface(riid, ppv);
+ }
+ else
+ {
return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
}
-CSeekingPassThru::CSeekingPassThru( __in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr )
- : CUnknown(pName, pUnk, phr),
- m_pPosPassThru(NULL)
+CSeekingPassThru::CSeekingPassThru(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)
+ : CUnknown(pName, pUnk, phr),
+ m_pPosPassThru(NULL)
{
}
@@ -54,25 +60,32 @@ CSeekingPassThru::~CSeekingPassThru()
STDMETHODIMP CSeekingPassThru::Init(BOOL bRendererSeeking, IPin *pPin)
{
HRESULT hr = NOERROR;
- if (m_pPosPassThru) {
+ if(m_pPosPassThru)
+ {
hr = E_FAIL;
- } else {
+ }
+ else
+ {
m_pPosPassThru =
bRendererSeeking ?
- new CRendererPosPassThru(
- NAME("Render Seeking COM object"),
- (IUnknown *)this,
- &hr,
- pPin) :
- new CPosPassThru(
- NAME("Render Seeking COM object"),
- (IUnknown *)this,
- &hr,
- pPin);
- if (!m_pPosPassThru) {
+ new CRendererPosPassThru(
+ NAME("Render Seeking COM object"),
+ (IUnknown *)this,
+ &hr,
+ pPin) :
+ new CPosPassThru(
+ NAME("Render Seeking COM object"),
+ (IUnknown *)this,
+ &hr,
+ pPin);
+ if(!m_pPosPassThru)
+ {
hr = E_OUTOFMEMORY;
- } else {
- if (FAILED(hr)) {
+ }
+ else
+ {
+ if(FAILED(hr))
+ {
delete m_pPosPassThru;
m_pPosPassThru = NULL;
}
diff --git a/src/filters/BaseClasses/source.cpp b/src/filters/BaseClasses/source.cpp
index ef7795c42..0df928bf1 100644
--- a/src/filters/BaseClasses/source.cpp
+++ b/src/filters/BaseClasses/source.cpp
@@ -64,9 +64,10 @@ CSource::CSource(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid
CSource::~CSource()
{
/* Free our pins and pin array */
- while (m_iPins != 0) {
- // deleting the pins causes them to be removed from the array...
- delete m_paStreams[m_iPins - 1];
+ while(m_iPins != 0)
+ {
+ // deleting the pins causes them to be removed from the array...
+ delete m_paStreams[m_iPins - 1];
}
ASSERT(m_paStreams == NULL);
@@ -82,10 +83,12 @@ HRESULT CSource::AddPin(__in CSourceStream *pStream)
/* Allocate space for this pin and the old ones */
CSourceStream **paStreams = new CSourceStream *[m_iPins + 1];
- if (paStreams == NULL) {
+ if(paStreams == NULL)
+ {
return E_OUTOFMEMORY;
}
- if (m_paStreams != NULL) {
+ if(m_paStreams != NULL)
+ {
CopyMemory((PVOID)paStreams, (PVOID)m_paStreams,
m_iPins * sizeof(m_paStreams[0]));
paStreams[m_iPins] = pStream;
@@ -103,15 +106,20 @@ HRESULT CSource::AddPin(__in CSourceStream *pStream)
HRESULT CSource::RemovePin(__in CSourceStream *pStream)
{
int i;
- for (i = 0; i < m_iPins; i++) {
- if (m_paStreams[i] == pStream) {
- if (m_iPins == 1) {
+ for(i = 0; i < m_iPins; i++)
+ {
+ if(m_paStreams[i] == pStream)
+ {
+ if(m_iPins == 1)
+ {
delete [] m_paStreams;
m_paStreams = NULL;
- } else {
+ }
+ else
+ {
/* no need to reallocate */
- while (++i < m_iPins)
- m_paStreams[i - 1] = m_paStreams[i];
+ while(++i < m_iPins)
+ m_paStreams[i - 1] = m_paStreams[i];
}
m_iPins--;
return S_OK;
@@ -127,16 +135,19 @@ HRESULT CSource::RemovePin(__in CSourceStream *pStream)
// or to NULL if the Id cannot be matched.
STDMETHODIMP CSource::FindPin(LPCWSTR Id, __deref_out IPin **ppPin)
{
- CheckPointer(ppPin,E_POINTER);
- ValidateReadWritePtr(ppPin,sizeof(IPin *));
+ CheckPointer(ppPin, E_POINTER);
+ ValidateReadWritePtr(ppPin, sizeof(IPin *));
// The -1 undoes the +1 in QueryId and ensures that totally invalid
// strings (for which WstrToInt delivers 0) give a deliver a NULL pin.
- int i = WstrToInt(Id) -1;
+ int i = WstrToInt(Id) - 1;
*ppPin = GetPin(i);
- if (*ppPin!=NULL){
+ if(*ppPin != NULL)
+ {
(*ppPin)->AddRef();
return NOERROR;
- } else {
+ }
+ else
+ {
return VFW_E_NOT_FOUND;
}
}
@@ -145,10 +156,13 @@ STDMETHODIMP CSource::FindPin(LPCWSTR Id, __deref_out IPin **ppPin)
// FindPinNumber
//
// return the number of the pin with this IPin* or -1 if none
-int CSource::FindPinNumber(__in IPin *iPin) {
+int CSource::FindPinNumber(__in IPin *iPin)
+{
int i;
- for (i=0; i<m_iPins; ++i) {
- if ((IPin *)(m_paStreams[i])==iPin) {
+ for(i = 0; i < m_iPins; ++i)
+ {
+ if((IPin *)(m_paStreams[i]) == iPin)
+ {
return i;
}
}
@@ -159,7 +173,8 @@ int CSource::FindPinNumber(__in IPin *iPin) {
// GetPinCount
//
// Returns the number of pins this filter has
-int CSource::GetPinCount(void) {
+int CSource::GetPinCount(void)
+{
CAutoLock lock(&m_cStateLock);
return m_iPins;
@@ -171,17 +186,19 @@ int CSource::GetPinCount(void) {
//
// Return a non-addref'd pointer to pin n
// needed by CBaseFilter
-CBasePin *CSource::GetPin(int n) {
+CBasePin *CSource::GetPin(int n)
+{
CAutoLock lock(&m_cStateLock);
// n must be in the range 0..m_iPins-1
// if m_iPins>n && n>=0 it follows that m_iPins>0
// which is what used to be checked (i.e. checking that we have a pin)
- if ((n >= 0) && (n < m_iPins)) {
+ if((n >= 0) && (n < m_iPins))
+ {
ASSERT(m_paStreams[n]);
- return m_paStreams[n];
+ return m_paStreams[n];
}
return NULL;
}
@@ -196,17 +213,19 @@ CBasePin *CSource::GetPin(int n) {
//
// Set Id to point to a CoTaskMemAlloc'd
-STDMETHODIMP CSourceStream::QueryId(__deref_out LPWSTR *Id) {
- CheckPointer(Id,E_POINTER);
- ValidateReadWritePtr(Id,sizeof(LPWSTR));
+STDMETHODIMP CSourceStream::QueryId(__deref_out LPWSTR *Id)
+{
+ CheckPointer(Id, E_POINTER);
+ ValidateReadWritePtr(Id, sizeof(LPWSTR));
// We give the pins id's which are 1,2,...
// FindPinNumber returns -1 for an invalid pin
- int i = 1+ m_pFilter->FindPinNumber(this);
- if (i<1) return VFW_E_NOT_FOUND;
+ int i = 1 + m_pFilter->FindPinNumber(this);
+ if(i < 1) return VFW_E_NOT_FOUND;
*Id = (LPWSTR)CoTaskMemAlloc(sizeof(WCHAR) * 12);
- if (*Id==NULL) {
- return E_OUTOFMEMORY;
+ if(*Id == NULL)
+ {
+ return E_OUTOFMEMORY;
}
IntToWstr(i, *Id);
return NOERROR;
@@ -224,9 +243,10 @@ CSourceStream::CSourceStream(
__inout CSource *ps,
__in_opt LPCWSTR pPinName)
: CBaseOutputPin(pObjectName, ps, ps->pStateLock(), phr, pPinName),
- m_pFilter(ps) {
+ m_pFilter(ps)
+{
- *phr = m_pFilter->AddPin(this);
+ *phr = m_pFilter->AddPin(this);
}
#ifdef UNICODE
@@ -236,18 +256,20 @@ CSourceStream::CSourceStream(
__inout CSource *ps,
__in_opt LPCWSTR pPinName)
: CBaseOutputPin(pObjectName, ps, ps->pStateLock(), phr, pPinName),
- m_pFilter(ps) {
+ m_pFilter(ps)
+{
- *phr = m_pFilter->AddPin(this);
+ *phr = m_pFilter->AddPin(this);
}
#endif
//
// CSourceStream::Destructor
//
// Decrements the number of pins on this filter
-CSourceStream::~CSourceStream(void) {
+CSourceStream::~CSourceStream(void)
+{
- m_pFilter->RemovePin(this);
+ m_pFilter->RemovePin(this);
}
@@ -255,14 +277,16 @@ CSourceStream::~CSourceStream(void) {
// CheckMediaType
//
// Do we support this type? Provides the default support for 1 type.
-HRESULT CSourceStream::CheckMediaType(const CMediaType *pMediaType) {
+HRESULT CSourceStream::CheckMediaType(const CMediaType *pMediaType)
+{
CAutoLock lock(m_pFilter->pStateLock());
CMediaType mt;
GetMediaType(&mt);
- if (mt == *pMediaType) {
+ if(mt == *pMediaType)
+ {
return NOERROR;
}
@@ -275,14 +299,17 @@ HRESULT CSourceStream::CheckMediaType(const CMediaType *pMediaType) {
//
// By default we support only one type
// iPosition indexes are 0-n
-HRESULT CSourceStream::GetMediaType(int iPosition, __inout CMediaType *pMediaType) {
+HRESULT CSourceStream::GetMediaType(int iPosition, __inout CMediaType *pMediaType)
+{
CAutoLock lock(m_pFilter->pStateLock());
- if (iPosition<0) {
+ if(iPosition < 0)
+ {
return E_INVALIDARG;
}
- if (iPosition>0) {
+ if(iPosition > 0)
+ {
return VFW_S_NO_MORE_ITEMS;
}
return GetMediaType(pMediaType);
@@ -293,38 +320,43 @@ HRESULT CSourceStream::GetMediaType(int iPosition, __inout CMediaType *pMediaTyp
// Active
//
// The pin is active - start up the worker thread
-HRESULT CSourceStream::Active(void) {
+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...)
+ 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()) {
+ if(!IsConnected())
+ {
return NOERROR;
}
hr = CBaseOutputPin::Active();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
ASSERT(!ThreadExists());
// start the thread
- if (!Create()) {
+ if(!Create())
+ {
return E_FAIL;
}
// Tell thread to initialize. If OnThreadCreate Fails, so does this.
hr = Init();
- if (FAILED(hr))
- return hr;
+ if(FAILED(hr))
+ return hr;
return Pause();
}
@@ -335,7 +367,8 @@ HRESULT CSourceStream::Active(void) {
//
// Pin is inactive - shut down the worker thread
// Waits for the worker to exit before returning.
-HRESULT CSourceStream::Inactive(void) {
+HRESULT CSourceStream::Inactive(void)
+{
CAutoLock lock(m_pFilter->pStateLock());
@@ -343,7 +376,8 @@ HRESULT CSourceStream::Inactive(void) {
// do nothing if not connected - its ok not to connect to
// all pins of a source filter
- if (!IsConnected()) {
+ if(!IsConnected())
+ {
return NOERROR;
}
@@ -351,23 +385,27 @@ HRESULT CSourceStream::Inactive(void) {
// 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(FAILED(hr))
+ {
+ return hr;
}
- if (ThreadExists()) {
- hr = Stop();
+ if(ThreadExists())
+ {
+ hr = Stop();
- if (FAILED(hr)) {
- return hr;
- }
+ if(FAILED(hr))
+ {
+ return hr;
+ }
- hr = Exit();
- if (FAILED(hr)) {
- return hr;
- }
+ hr = Exit();
+ if(FAILED(hr))
+ {
+ return hr;
+ }
- Close(); // Wait for the thread to exit, then tidy up.
+ Close(); // Wait for the thread to exit, then tidy up.
}
// hr = CBaseOutputPin::Inactive(); // call this first to Decommit the allocator
@@ -384,26 +422,31 @@ HRESULT CSourceStream::Inactive(void) {
//
// When this returns the thread exits
// Return codes > 0 indicate an error occured
-DWORD CSourceStream::ThreadProc(void) {
+DWORD CSourceStream::ThreadProc(void)
+{
HRESULT hr; // the return code from calls
Command com;
- do {
- com = GetRequest();
- if (com != CMD_INIT) {
- DbgLog((LOG_ERROR, 1, TEXT("Thread expected init command")));
- Reply((DWORD) E_UNEXPECTED);
- }
- } while (com != CMD_INIT);
+ do
+ {
+ com = GetRequest();
+ if(com != CMD_INIT)
+ {
+ DbgLog((LOG_ERROR, 1, TEXT("Thread expected init command")));
+ Reply((DWORD) E_UNEXPECTED);
+ }
+ }
+ while(com != CMD_INIT);
DbgLog((LOG_TRACE, 1, TEXT("CSourceStream worker thread initializing")));
hr = OnThreadCreate(); // perform set up tasks
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
DbgLog((LOG_ERROR, 1, TEXT("CSourceStream::OnThreadCreate failed. Aborting thread.")));
OnThreadDestroy();
- Reply(hr); // send failed return code from OnThreadCreate
+ Reply(hr); // send failed return code from OnThreadCreate
return 1;
}
@@ -411,37 +454,41 @@ DWORD CSourceStream::ThreadProc(void) {
Reply(NOERROR);
Command cmd;
- do {
- cmd = GetRequest();
-
- switch (cmd) {
-
- case CMD_EXIT:
- Reply(NOERROR);
- break;
-
- case CMD_RUN:
- DbgLog((LOG_ERROR, 1, TEXT("CMD_RUN received before a CMD_PAUSE???")));
- // !!! fall through???
-
- case CMD_PAUSE:
- Reply(NOERROR);
- DoBufferProcessingLoop();
- break;
-
- case CMD_STOP:
- Reply(NOERROR);
- break;
-
- default:
- DbgLog((LOG_ERROR, 1, TEXT("Unknown command %d received!"), cmd));
- Reply((DWORD) E_NOTIMPL);
- break;
- }
- } while (cmd != CMD_EXIT);
+ do
+ {
+ cmd = GetRequest();
+
+ switch(cmd)
+ {
+
+ case CMD_EXIT:
+ Reply(NOERROR);
+ break;
+
+ case CMD_RUN:
+ DbgLog((LOG_ERROR, 1, TEXT("CMD_RUN received before a CMD_PAUSE???")));
+ // !!! fall through???
+
+ case CMD_PAUSE:
+ Reply(NOERROR);
+ DoBufferProcessingLoop();
+ break;
+
+ case CMD_STOP:
+ Reply(NOERROR);
+ break;
+
+ default:
+ DbgLog((LOG_ERROR, 1, TEXT("Unknown command %d received!"), cmd));
+ Reply((DWORD) E_NOTIMPL);
+ break;
+ }
+ }
+ while(cmd != CMD_EXIT);
hr = OnThreadDestroy(); // tidy up.
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
DbgLog((LOG_ERROR, 1, TEXT("CSourceStream::OnThreadDestroy failed. Exiting thread.")));
return 1;
}
@@ -456,66 +503,79 @@ DWORD CSourceStream::ThreadProc(void) {
//
// Grabs a buffer and calls the users processing function.
// Overridable, so that different delivery styles can be catered for.
-HRESULT CSourceStream::DoBufferProcessingLoop(void) {
+HRESULT CSourceStream::DoBufferProcessingLoop(void)
+{
Command com;
OnThreadStartPlay();
- do {
- while (!CheckRequest(&com)) {
+ do
+ {
+ while(!CheckRequest(&com))
+ {
- IMediaSample *pSample;
+ IMediaSample *pSample;
- HRESULT hr = GetDeliveryBuffer(&pSample,NULL,NULL,0);
- if (FAILED(hr)) {
+ HRESULT hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0);
+ if(FAILED(hr))
+ {
Sleep(1);
- continue; // go round again. Perhaps the error will go away
- // or the allocator is decommited & we will be asked to
- // exit soon.
- }
+ continue; // go round again. Perhaps the error will go away
+ // or the allocator is decommited & we will be asked to
+ // exit soon.
+ }
- // Virtual function user will override.
- hr = FillBuffer(pSample);
+ // Virtual function user will override.
+ hr = FillBuffer(pSample);
- if (hr == S_OK) {
- hr = Deliver(pSample);
+ if(hr == S_OK)
+ {
+ hr = Deliver(pSample);
pSample->Release();
// downstream filter returns S_FALSE if it wants us to
// stop or an error if it's reporting an error.
if(hr != S_OK)
{
- DbgLog((LOG_TRACE, 2, TEXT("Deliver() returned %08x; stopping"), hr));
- return S_OK;
+ DbgLog((LOG_TRACE, 2, TEXT("Deliver() returned %08x; stopping"), hr));
+ return S_OK;
}
- } else if (hr == S_FALSE) {
+ }
+ else if(hr == S_FALSE)
+ {
// derived class wants us to stop pushing data
- pSample->Release();
- DeliverEndOfStream();
- return S_OK;
- } else {
+ pSample->Release();
+ DeliverEndOfStream();
+ return S_OK;
+ }
+ else
+ {
// derived class encountered an error
pSample->Release();
- DbgLog((LOG_ERROR, 1, TEXT("Error %08lX from FillBuffer!!!"), hr));
+ DbgLog((LOG_ERROR, 1, TEXT("Error %08lX from FillBuffer!!!"), hr));
DeliverEndOfStream();
m_pFilter->NotifyEvent(EC_ERRORABORT, hr, 0);
return hr;
- }
+ }
// all paths release the sample
- }
+ }
// For all commands sent to us there must be a Reply call!
- if (com == CMD_RUN || com == CMD_PAUSE) {
- Reply(NOERROR);
- } else if (com != CMD_STOP) {
- Reply((DWORD) E_UNEXPECTED);
- DbgLog((LOG_ERROR, 1, TEXT("Unexpected command!!!")));
- }
- } while (com != CMD_STOP);
+ if(com == CMD_RUN || com == CMD_PAUSE)
+ {
+ Reply(NOERROR);
+ }
+ else if(com != CMD_STOP)
+ {
+ Reply((DWORD) E_UNEXPECTED);
+ DbgLog((LOG_ERROR, 1, TEXT("Unexpected command!!!")));
+ }
+ }
+ while(com != CMD_STOP);
return S_FALSE;
}
diff --git a/src/filters/BaseClasses/source.h b/src/filters/BaseClasses/source.h
index 528d5bcbf..33e23064a 100644
--- a/src/filters/BaseClasses/source.h
+++ b/src/filters/BaseClasses/source.h
@@ -40,7 +40,8 @@ class CSourceStream; // The class that will handle each pin
//
// Override construction to provide a means of creating
// CSourceStream derived objects - ie a way of creating pins.
-class CSource : public CBaseFilter {
+class CSource : public CBaseFilter
+{
public:
CSource(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid, __inout HRESULT *phr);
@@ -56,7 +57,10 @@ public:
// -- Utilities --
- CCritSec* pStateLock(void) { return &m_cStateLock; } // provide our critical section
+ CCritSec* pStateLock(void)
+ {
+ return &m_cStateLock; // provide our critical section
+ }
HRESULT AddPin(__in CSourceStream *);
HRESULT RemovePin(__in CSourceStream *);
@@ -67,11 +71,11 @@ public:
);
int FindPinNumber(__in IPin *iPin);
-
+
protected:
int m_iPins; // The number of pins on this filter. Updated by CSourceStream
- // constructors & destructors.
+ // constructors & destructors.
CSourceStream **m_paStreams; // the pins on this filter.
CCritSec m_cStateLock; // Lock this to serialize function accesses to the filter state
@@ -85,7 +89,8 @@ protected:
// Use this class to manage a stream of data that comes from a
// pin.
// Uses a worker thread to put data on the pin.
-class CSourceStream : public CAMThread, public CBaseOutputPin {
+class CSourceStream : public CAMThread, public CBaseOutputPin
+{
public:
CSourceStream(__in_opt LPCTSTR pObjectName,
@@ -119,9 +124,18 @@ protected:
// Called as the thread is created/destroyed - use to perform
// jobs such as start/stop streaming mode
// If OnThreadCreate returns an error the thread will exit.
- virtual HRESULT OnThreadCreate(void) {return NOERROR;};
- virtual HRESULT OnThreadDestroy(void) {return NOERROR;};
- virtual HRESULT OnThreadStartPlay(void) {return NOERROR;};
+ virtual HRESULT OnThreadCreate(void)
+ {
+ return NOERROR;
+ };
+ virtual HRESULT OnThreadDestroy(void)
+ {
+ return NOERROR;
+ };
+ virtual HRESULT OnThreadStartPlay(void)
+ {
+ return NOERROR;
+ };
// *
// * Worker Thread
@@ -133,15 +147,36 @@ protected:
public:
// thread commands
enum Command {CMD_INIT, CMD_PAUSE, CMD_RUN, CMD_STOP, CMD_EXIT};
- HRESULT Init(void) { return CallWorker(CMD_INIT); }
- HRESULT Exit(void) { return CallWorker(CMD_EXIT); }
- HRESULT Run(void) { return CallWorker(CMD_RUN); }
- HRESULT Pause(void) { return CallWorker(CMD_PAUSE); }
- HRESULT Stop(void) { return CallWorker(CMD_STOP); }
+ HRESULT Init(void)
+ {
+ return CallWorker(CMD_INIT);
+ }
+ HRESULT Exit(void)
+ {
+ return CallWorker(CMD_EXIT);
+ }
+ HRESULT Run(void)
+ {
+ return CallWorker(CMD_RUN);
+ }
+ HRESULT Pause(void)
+ {
+ return CallWorker(CMD_PAUSE);
+ }
+ HRESULT Stop(void)
+ {
+ return CallWorker(CMD_STOP);
+ }
protected:
- Command GetRequest(void) { return (Command) CAMThread::GetRequest(); }
- BOOL CheckRequest(Command *pCom) { return CAMThread::CheckRequest( (DWORD *) pCom); }
+ Command GetRequest(void)
+ {
+ return (Command) CAMThread::GetRequest();
+ }
+ BOOL CheckRequest(Command *pCom)
+ {
+ return CAMThread::CheckRequest((DWORD *) pCom);
+ }
// override these if you want to add thread commands
virtual DWORD ThreadProc(void); // the thread function
@@ -161,7 +196,10 @@ protected:
// This will only be called by the default implementations
// of CheckMediaType and GetMediaType(int, CMediaType*)
// You must override this fn. or the above 2!
- virtual HRESULT GetMediaType(__inout CMediaType *pMediaType) {return E_UNEXPECTED;}
+ virtual HRESULT GetMediaType(__inout CMediaType *pMediaType)
+ {
+ return E_UNEXPECTED;
+ }
STDMETHODIMP QueryId(
__deref_out LPWSTR * Id
diff --git a/src/filters/BaseClasses/streams.h b/src/filters/BaseClasses/streams.h
index 7d1afd0d5..b31e02e5c 100644
--- a/src/filters/BaseClasses/streams.h
+++ b/src/filters/BaseClasses/streams.h
@@ -45,10 +45,10 @@
#ifndef NUMELMS
#if _WIN32_WINNT < 0x0600
- #define NUMELMS(aa) (sizeof(aa)/sizeof((aa)[0]))
+#define NUMELMS(aa) (sizeof(aa)/sizeof((aa)[0]))
#else
- #define NUMELMS(aa) ARRAYSIZE(aa)
-#endif
+#define NUMELMS(aa) ARRAYSIZE(aa)
+#endif
#endif
///////////////////////////////////////////////////////////////////////////
@@ -56,21 +56,23 @@
// the applicaiton is being compiled with the headers from Visual C++ 6.0.
/////////////////////////////////////////////////// ////////////////////////
#ifndef InterlockedExchangePointer
- #define InterlockedExchangePointer(Target, Value) \
+#define InterlockedExchangePointer(Target, Value) \
(PVOID)InterlockedExchange((PLONG)(Target), (LONG)(Value))
#endif
#ifndef _WAVEFORMATEXTENSIBLE_
#define _WAVEFORMATEXTENSIBLE_
-typedef struct {
+typedef struct
+{
WAVEFORMATEX Format;
- union {
+ union
+ {
WORD wValidBitsPerSample; /* bits of precision */
WORD wSamplesPerBlock; /* valid if wBitsPerSample==0 */
WORD wReserved; /* If neither applies, set to zero. */
} Samples;
DWORD dwChannelMask; /* which channels are */
- /* present in stream */
+ /* present in stream */
GUID SubFormat;
} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
#endif // !_WAVEFORMATEXTENSIBLE_
@@ -80,48 +82,48 @@ typedef struct {
#endif // !defined(WAVE_FORMAT_EXTENSIBLE)
#ifndef GetWindowLongPtr
- #define GetWindowLongPtrA GetWindowLongA
- #define GetWindowLongPtrW GetWindowLongW
- #ifdef UNICODE
- #define GetWindowLongPtr GetWindowLongPtrW
- #else
- #define GetWindowLongPtr GetWindowLongPtrA
- #endif // !UNICODE
+#define GetWindowLongPtrA GetWindowLongA
+#define GetWindowLongPtrW GetWindowLongW
+#ifdef UNICODE
+#define GetWindowLongPtr GetWindowLongPtrW
+#else
+#define GetWindowLongPtr GetWindowLongPtrA
+#endif // !UNICODE
#endif // !GetWindowLongPtr
#ifndef SetWindowLongPtr
- #define SetWindowLongPtrA SetWindowLongA
- #define SetWindowLongPtrW SetWindowLongW
- #ifdef UNICODE
- #define SetWindowLongPtr SetWindowLongPtrW
- #else
- #define SetWindowLongPtr SetWindowLongPtrA
- #endif // !UNICODE
+#define SetWindowLongPtrA SetWindowLongA
+#define SetWindowLongPtrW SetWindowLongW
+#ifdef UNICODE
+#define SetWindowLongPtr SetWindowLongPtrW
+#else
+#define SetWindowLongPtr SetWindowLongPtrA
+#endif // !UNICODE
#endif // !SetWindowLongPtr
#ifndef GWLP_WNDPROC
- #define GWLP_WNDPROC (-4)
+#define GWLP_WNDPROC (-4)
#endif
#ifndef GWLP_HINSTANCE
- #define GWLP_HINSTANCE (-6)
+#define GWLP_HINSTANCE (-6)
#endif
#ifndef GWLP_HWNDPARENT
- #define GWLP_HWNDPARENT (-8)
+#define GWLP_HWNDPARENT (-8)
#endif
#ifndef GWLP_USERDATA
- #define GWLP_USERDATA (-21)
+#define GWLP_USERDATA (-21)
#endif
#ifndef GWLP_ID
- #define GWLP_ID (-12)
+#define GWLP_ID (-12)
#endif
#ifndef DWLP_MSGRESULT
- #define DWLP_MSGRESULT 0
+#define DWLP_MSGRESULT 0
#endif
-#ifndef DWLP_DLGPROC
- #define DWLP_DLGPROC DWLP_MSGRESULT + sizeof(LRESULT)
+#ifndef DWLP_DLGPROC
+#define DWLP_DLGPROC DWLP_MSGRESULT + sizeof(LRESULT)
#endif
#ifndef DWLP_USER
- #define DWLP_USER DWLP_DLGPROC + sizeof(DLGPROC)
+#define DWLP_USER DWLP_DLGPROC + sizeof(DLGPROC)
#endif
@@ -195,8 +197,8 @@ LONG_PTR _SetWindowLongPtr(HWND hwnd, int nIndex, T p)
#else
- #ifdef _DEBUG
- #pragma message("STREAMS.H included TWICE")
- #endif
+#ifdef _DEBUG
+#pragma message("STREAMS.H included TWICE")
+#endif
#endif // __STREAMS__
diff --git a/src/filters/BaseClasses/strmctl.cpp b/src/filters/BaseClasses/strmctl.cpp
index b7f595217..e59e0e154 100644
--- a/src/filters/BaseClasses/strmctl.cpp
+++ b/src/filters/BaseClasses/strmctl.cpp
@@ -11,17 +11,17 @@
#include <strmctl.h>
CBaseStreamControl::CBaseStreamControl(__inout HRESULT *phr)
-: m_StreamState(STREAM_FLOWING)
-, m_StreamStateOnStop(STREAM_FLOWING) // means no pending stop
-, m_tStartTime(MAX_TIME)
-, m_tStopTime(MAX_TIME)
-, m_StreamEvent(FALSE, phr)
-, m_dwStartCookie(0)
-, m_dwStopCookie(0)
-, m_pRefClock(NULL)
-, m_FilterState(State_Stopped)
-, m_bIsFlushing(FALSE)
-, m_bStopSendExtra(FALSE)
+ : m_StreamState(STREAM_FLOWING)
+ , m_StreamStateOnStop(STREAM_FLOWING) // means no pending stop
+ , m_tStartTime(MAX_TIME)
+ , m_tStopTime(MAX_TIME)
+ , m_StreamEvent(FALSE, phr)
+ , m_dwStartCookie(0)
+ , m_dwStopCookie(0)
+ , m_pRefClock(NULL)
+ , m_FilterState(State_Stopped)
+ , m_bIsFlushing(FALSE)
+ , m_bStopSendExtra(FALSE)
{}
CBaseStreamControl::~CBaseStreamControl()
@@ -37,28 +37,30 @@ STDMETHODIMP CBaseStreamControl::StopAt(const REFERENCE_TIME * ptStop, BOOL bSen
CAutoLock lck(&m_CritSec);
m_bStopSendExtra = FALSE; // reset
m_bStopExtraSent = FALSE;
- if (ptStop)
+ if(ptStop)
{
- if (*ptStop == MAX_TIME)
+ if(*ptStop == MAX_TIME)
{
- DbgLog((LOG_TRACE,2,TEXT("StopAt: Cancel stop")));
+ DbgLog((LOG_TRACE, 2, TEXT("StopAt: Cancel stop")));
CancelStop();
- // If there's now a command to start in the future, we assume
- // they want to be stopped when the graph is first run
- if (m_FilterState == State_Stopped && m_tStartTime < MAX_TIME) {
- m_StreamState = STREAM_DISCARDING;
- DbgLog((LOG_TRACE,2,TEXT("graph will begin by DISCARDING")));
- }
+ // If there's now a command to start in the future, we assume
+ // they want to be stopped when the graph is first run
+ if(m_FilterState == State_Stopped && m_tStartTime < MAX_TIME)
+ {
+ m_StreamState = STREAM_DISCARDING;
+ DbgLog((LOG_TRACE, 2, TEXT("graph will begin by DISCARDING")));
+ }
return NOERROR;
}
- DbgLog((LOG_TRACE,2,TEXT("StopAt: %dms extra=%d"),
- (int)(*ptStop/10000), bSendExtra));
- // if the first command is to stop in the future, then we assume they
+ DbgLog((LOG_TRACE, 2, TEXT("StopAt: %dms extra=%d"),
+ (int)(*ptStop / 10000), bSendExtra));
+ // if the first command is to stop in the future, then we assume they
// want to be started when the graph is first run
- if (m_FilterState == State_Stopped && m_tStartTime > *ptStop) {
- m_StreamState = STREAM_FLOWING;
- DbgLog((LOG_TRACE,2,TEXT("graph will begin by FLOWING")));
- }
+ if(m_FilterState == State_Stopped && m_tStartTime > *ptStop)
+ {
+ m_StreamState = STREAM_FLOWING;
+ DbgLog((LOG_TRACE, 2, TEXT("graph will begin by FLOWING")));
+ }
m_bStopSendExtra = bSendExtra;
m_tStopTime = *ptStop;
m_dwStopCookie = dwCookie;
@@ -66,8 +68,8 @@ STDMETHODIMP CBaseStreamControl::StopAt(const REFERENCE_TIME * ptStop, BOOL bSen
}
else
{
- DbgLog((LOG_TRACE,2,TEXT("StopAt: now")));
- // sending an extra frame when told to stop now would mess people up
+ DbgLog((LOG_TRACE, 2, TEXT("StopAt: now")));
+ // sending an extra frame when told to stop now would mess people up
m_bStopSendExtra = FALSE;
m_tStopTime = MAX_TIME;
m_dwStopCookie = 0;
@@ -80,37 +82,39 @@ STDMETHODIMP CBaseStreamControl::StopAt(const REFERENCE_TIME * ptStop, BOOL bSen
}
STDMETHODIMP CBaseStreamControl::StartAt
-( const REFERENCE_TIME *ptStart, DWORD dwCookie )
+(const REFERENCE_TIME *ptStart, DWORD dwCookie)
{
CAutoLock lck(&m_CritSec);
- if (ptStart)
+ if(ptStart)
{
- if (*ptStart == MAX_TIME)
+ if(*ptStart == MAX_TIME)
{
- DbgLog((LOG_TRACE,2,TEXT("StartAt: Cancel start")));
+ DbgLog((LOG_TRACE, 2, TEXT("StartAt: Cancel start")));
CancelStart();
- // If there's now a command to stop in the future, we assume
- // they want to be started when the graph is first run
- if (m_FilterState == State_Stopped && m_tStopTime < MAX_TIME) {
- DbgLog((LOG_TRACE,2,TEXT("graph will begin by FLOWING")));
- m_StreamState = STREAM_FLOWING;
- }
+ // If there's now a command to stop in the future, we assume
+ // they want to be started when the graph is first run
+ if(m_FilterState == State_Stopped && m_tStopTime < MAX_TIME)
+ {
+ DbgLog((LOG_TRACE, 2, TEXT("graph will begin by FLOWING")));
+ m_StreamState = STREAM_FLOWING;
+ }
return NOERROR;
}
- DbgLog((LOG_TRACE,2,TEXT("StartAt: %dms"), (int)(*ptStart/10000)));
- // if the first command is to start in the future, then we assume they
+ DbgLog((LOG_TRACE, 2, TEXT("StartAt: %dms"), (int)(*ptStart / 10000)));
+ // if the first command is to start in the future, then we assume they
// want to be stopped when the graph is first run
- if (m_FilterState == State_Stopped && m_tStopTime >= *ptStart) {
- DbgLog((LOG_TRACE,2,TEXT("graph will begin by DISCARDING")));
- m_StreamState = STREAM_DISCARDING;
- }
+ if(m_FilterState == State_Stopped && m_tStopTime >= *ptStart)
+ {
+ DbgLog((LOG_TRACE, 2, TEXT("graph will begin by DISCARDING")));
+ m_StreamState = STREAM_DISCARDING;
+ }
m_tStartTime = *ptStart;
m_dwStartCookie = dwCookie;
// if (m_tStopTime == m_tStartTime) CancelStop();
}
else
{
- DbgLog((LOG_TRACE,2,TEXT("StartAt: now")));
+ DbgLog((LOG_TRACE, 2, TEXT("StartAt: now")));
m_tStartTime = MAX_TIME;
m_dwStartCookie = 0;
m_StreamState = STREAM_FLOWING;
@@ -123,8 +127,8 @@ STDMETHODIMP CBaseStreamControl::StartAt
// Retrieve information about current settings
STDMETHODIMP CBaseStreamControl::GetInfo(__out AM_STREAM_INFO *pInfo)
{
- if (pInfo == NULL)
- return E_POINTER;
+ if(pInfo == NULL)
+ return E_POINTER;
pInfo->tStart = m_tStartTime;
pInfo->tStop = m_tStopTime;
@@ -133,7 +137,8 @@ STDMETHODIMP CBaseStreamControl::GetInfo(__out AM_STREAM_INFO *pInfo)
pInfo->dwFlags = m_bStopSendExtra ? AM_STREAM_INFO_STOP_SEND_EXTRA : 0;
pInfo->dwFlags |= m_tStartTime == MAX_TIME ? 0 : AM_STREAM_INFO_START_DEFINED;
pInfo->dwFlags |= m_tStopTime == MAX_TIME ? 0 : AM_STREAM_INFO_STOP_DEFINED;
- switch (m_StreamState) {
+ switch(m_StreamState)
+ {
default:
DbgBreak("Invalid stream state");
case STREAM_FLOWING:
@@ -150,9 +155,10 @@ void CBaseStreamControl::ExecuteStop()
{
ASSERT(CritCheckIn(&m_CritSec));
m_StreamState = m_StreamStateOnStop;
- if (m_dwStopCookie && m_pSink) {
- DbgLog((LOG_TRACE,2,TEXT("*sending EC_STREAM_CONTROL_STOPPED (%d)"),
- m_dwStopCookie));
+ if(m_dwStopCookie && m_pSink)
+ {
+ DbgLog((LOG_TRACE, 2, TEXT("*sending EC_STREAM_CONTROL_STOPPED (%d)"),
+ m_dwStopCookie));
m_pSink->Notify(EC_STREAM_CONTROL_STOPPED, (LONG_PTR)this, m_dwStopCookie);
}
CancelStop(); // This will do the tidy up
@@ -162,9 +168,10 @@ void CBaseStreamControl::ExecuteStart()
{
ASSERT(CritCheckIn(&m_CritSec));
m_StreamState = STREAM_FLOWING;
- if (m_dwStartCookie) {
- DbgLog((LOG_TRACE,2,TEXT("*sending EC_STREAM_CONTROL_STARTED (%d)"),
- m_dwStartCookie));
+ if(m_dwStartCookie)
+ {
+ DbgLog((LOG_TRACE, 2, TEXT("*sending EC_STREAM_CONTROL_STARTED (%d)"),
+ m_dwStartCookie));
m_pSink->Notify(EC_STREAM_CONTROL_STARTED, (LONG_PTR)this, m_dwStartCookie);
}
CancelStart(); // This will do the tidy up
@@ -232,7 +239,7 @@ void CBaseStreamControl::CancelStart()
enum CBaseStreamControl::StreamControlState CBaseStreamControl::CheckSampleTimes
-( __in const REFERENCE_TIME * pSampleStart, __in const REFERENCE_TIME * pSampleStop )
+(__in const REFERENCE_TIME * pSampleStart, __in const REFERENCE_TIME * pSampleStop)
{
CAutoLock lck(&m_CritSec);
@@ -242,152 +249,170 @@ enum CBaseStreamControl::StreamControlState CBaseStreamControl::CheckSampleTimes
// Don't ask me how I came up with the code below to handle all 19 cases
// - DannyMi
- if (m_tStopTime >= *pSampleStart)
+ if(m_tStopTime >= *pSampleStart)
{
- if (m_tStartTime >= *pSampleStop)
- return m_StreamState; // cases 8 11 12 15 17 18 19
- if (m_tStopTime < m_tStartTime)
- ExecuteStop(); // case 10
- ExecuteStart(); // cases 3 5 7 9 13 14
- return m_StreamState;
+ if(m_tStartTime >= *pSampleStop)
+ return m_StreamState; // cases 8 11 12 15 17 18 19
+ if(m_tStopTime < m_tStartTime)
+ ExecuteStop(); // case 10
+ ExecuteStart(); // cases 3 5 7 9 13 14
+ return m_StreamState;
}
- if (m_tStartTime >= *pSampleStop)
+ if(m_tStartTime >= *pSampleStop)
{
ExecuteStop(); // cases 6 16
return m_StreamState;
}
- if (m_tStartTime <= m_tStopTime)
+ if(m_tStartTime <= m_tStopTime)
{
- ExecuteStart();
- ExecuteStop();
+ ExecuteStart();
+ ExecuteStop();
return m_StreamState; // case 1
}
else
{
- ExecuteStop();
- ExecuteStart();
+ ExecuteStop();
+ ExecuteStart();
return m_StreamState; // cases 2 4
}
}
-enum CBaseStreamControl::StreamControlState CBaseStreamControl::CheckStreamState( IMediaSample * pSample )
+enum CBaseStreamControl::StreamControlState CBaseStreamControl::CheckStreamState(IMediaSample * pSample)
{
REFERENCE_TIME rtBufferStart, rtBufferStop;
const BOOL bNoBufferTimes =
- pSample == NULL ||
- FAILED(pSample->GetTime(&rtBufferStart, &rtBufferStop));
+ pSample == NULL ||
+ FAILED(pSample->GetTime(&rtBufferStart, &rtBufferStop));
StreamControlState state;
LONG lWait;
do
+ {
+ // something has to break out of the blocking
+ if(m_bIsFlushing || m_FilterState == State_Stopped)
+ return STREAM_DISCARDING;
+
+ if(bNoBufferTimes)
+ {
+ // Can't do anything until we get a time stamp
+ state = m_StreamState;
+ break;
+ }
+ else
{
- // something has to break out of the blocking
- if (m_bIsFlushing || m_FilterState == State_Stopped)
- return STREAM_DISCARDING;
+ state = CheckSampleTimes(&rtBufferStart, &rtBufferStop);
+ if(state == STREAM_FLOWING)
+ break;
- if (bNoBufferTimes) {
- // Can't do anything until we get a time stamp
- state = m_StreamState;
+ // we aren't supposed to send this, but we've been
+ // told to send one more than we were supposed to
+ // (and the stop isn't still pending and we're streaming)
+ if(m_bStopSendExtra && !m_bStopExtraSent &&
+ m_tStopTime == MAX_TIME &&
+ m_FilterState != State_Stopped)
+ {
+ m_bStopExtraSent = TRUE;
+ DbgLog((LOG_TRACE, 2, TEXT("%d sending an EXTRA frame"),
+ m_dwStopCookie));
+ state = STREAM_FLOWING;
break;
- } else {
- state = CheckSampleTimes( &rtBufferStart, &rtBufferStop );
- if (state == STREAM_FLOWING)
- break;
-
- // we aren't supposed to send this, but we've been
- // told to send one more than we were supposed to
- // (and the stop isn't still pending and we're streaming)
- if (m_bStopSendExtra && !m_bStopExtraSent &&
- m_tStopTime == MAX_TIME &&
- m_FilterState != State_Stopped) {
- m_bStopExtraSent = TRUE;
- DbgLog((LOG_TRACE,2,TEXT("%d sending an EXTRA frame"),
- m_dwStopCookie));
- state = STREAM_FLOWING;
- break;
- }
}
+ }
- // We're in discarding mode
+ // We're in discarding mode
- // If we've no clock, discard as fast as we can
- if (!m_pRefClock) {
- break;
+ // If we've no clock, discard as fast as we can
+ if(!m_pRefClock)
+ {
+ break;
- // If we're paused, we can't discard in a timely manner because
- // there's no such thing as stream times. We must block until
- // we run or stop, or we'll end up throwing the whole stream away
- // as quickly as possible
- } else if (m_FilterState == State_Paused) {
- lWait = INFINITE;
+ // If we're paused, we can't discard in a timely manner because
+ // there's no such thing as stream times. We must block until
+ // we run or stop, or we'll end up throwing the whole stream away
+ // as quickly as possible
+ }
+ else if(m_FilterState == State_Paused)
+ {
+ lWait = INFINITE;
- } else {
- // wait until it's time for the sample until we say "discard"
- // ("discard in a timely fashion")
- REFERENCE_TIME rtNow;
- EXECUTE_ASSERT(SUCCEEDED(m_pRefClock->GetTime(&rtNow)));
- rtNow -= m_tRunStart; // Into relative ref-time
- lWait = LONG((rtBufferStart - rtNow)/10000); // 100ns -> ms
- if (lWait < 10) break; // Not worth waiting - discard early
- }
+ }
+ else
+ {
+ // wait until it's time for the sample until we say "discard"
+ // ("discard in a timely fashion")
+ REFERENCE_TIME rtNow;
+ EXECUTE_ASSERT(SUCCEEDED(m_pRefClock->GetTime(&rtNow)));
+ rtNow -= m_tRunStart; // Into relative ref-time
+ lWait = LONG((rtBufferStart - rtNow) / 10000); // 100ns -> ms
+ if(lWait < 10) break; // Not worth waiting - discard early
+ }
- } while(WaitForSingleObject(GetStreamEventHandle(), lWait) != WAIT_TIMEOUT);
+ }
+ while(WaitForSingleObject(GetStreamEventHandle(), lWait) != WAIT_TIMEOUT);
return state;
}
-void CBaseStreamControl::NotifyFilterState( FILTER_STATE new_state, REFERENCE_TIME tStart )
+void CBaseStreamControl::NotifyFilterState(FILTER_STATE new_state, REFERENCE_TIME tStart)
{
CAutoLock lck(&m_CritSec);
// or we will get confused
- if (m_FilterState == new_state)
- return;
+ if(m_FilterState == new_state)
+ return;
- switch (new_state)
+ switch(new_state)
{
- case State_Stopped:
-
- DbgLog((LOG_TRACE,2,TEXT("Filter is STOPPED")));
-
- // execute any pending starts and stops in the right order,
- // to make sure all notifications get sent, and we end up
- // in the right state to begin next time (??? why not?)
-
- if (m_tStartTime != MAX_TIME && m_tStopTime == MAX_TIME) {
- ExecuteStart();
- } else if (m_tStopTime != MAX_TIME && m_tStartTime == MAX_TIME) {
- ExecuteStop();
- } else if (m_tStopTime != MAX_TIME && m_tStartTime != MAX_TIME) {
- if (m_tStartTime <= m_tStopTime) {
- ExecuteStart();
- ExecuteStop();
- } else {
- ExecuteStop();
- ExecuteStart();
- }
- }
- // always start off flowing when the graph starts streaming
- // unless told otherwise
- m_StreamState = STREAM_FLOWING;
- m_FilterState = new_state;
- break;
+ case State_Stopped:
+
+ DbgLog((LOG_TRACE, 2, TEXT("Filter is STOPPED")));
+
+ // execute any pending starts and stops in the right order,
+ // to make sure all notifications get sent, and we end up
+ // in the right state to begin next time (??? why not?)
+
+ if(m_tStartTime != MAX_TIME && m_tStopTime == MAX_TIME)
+ {
+ ExecuteStart();
+ }
+ else if(m_tStopTime != MAX_TIME && m_tStartTime == MAX_TIME)
+ {
+ ExecuteStop();
+ }
+ else if(m_tStopTime != MAX_TIME && m_tStartTime != MAX_TIME)
+ {
+ if(m_tStartTime <= m_tStopTime)
+ {
+ ExecuteStart();
+ ExecuteStop();
+ }
+ else
+ {
+ ExecuteStop();
+ ExecuteStart();
+ }
+ }
+ // always start off flowing when the graph starts streaming
+ // unless told otherwise
+ m_StreamState = STREAM_FLOWING;
+ m_FilterState = new_state;
+ break;
- case State_Running:
+ case State_Running:
- DbgLog((LOG_TRACE,2,TEXT("Filter is RUNNING")));
+ DbgLog((LOG_TRACE, 2, TEXT("Filter is RUNNING")));
- m_tRunStart = tStart;
- // fall-through
+ m_tRunStart = tStart;
+ // fall-through
- default: // case State_Paused:
- m_FilterState = new_state;
+ default: // case State_Paused:
+ m_FilterState = new_state;
}
// unblock!
m_StreamEvent.Set();
diff --git a/src/filters/BaseClasses/strmctl.h b/src/filters/BaseClasses/strmctl.h
index cb2adf308..5caabaaee 100644
--- a/src/filters/BaseClasses/strmctl.h
+++ b/src/filters/BaseClasses/strmctl.h
@@ -15,14 +15,15 @@ class CBaseStreamControl : public IAMStreamControl
public:
// Used by the implementation
enum StreamControlState
- { STREAM_FLOWING = 0x1000,
- STREAM_DISCARDING
+ {
+ STREAM_FLOWING = 0x1000,
+ STREAM_DISCARDING
};
private:
enum StreamControlState m_StreamState; // Current stream state
enum StreamControlState m_StreamStateOnStop; // State after next stop
- // (i.e.Blocking or Discarding)
+ // (i.e.Blocking or Discarding)
REFERENCE_TIME m_tStartTime; // MAX_TIME implies none
REFERENCE_TIME m_tStopTime; // MAX_TIME implies none
@@ -51,14 +52,14 @@ private:
// Your pin must also expose IAMStreamControl when QI'd for it!
//
IReferenceClock * m_pRefClock; // Need it to set advises
- // Filter must tell us via
- // SetSyncSource
+ // Filter must tell us via
+ // SetSyncSource
IMediaEventSink * m_pSink; // Event sink
- // Filter must tell us after it
- // creates it in JoinFilterGraph()
+ // Filter must tell us after it
+ // creates it in JoinFilterGraph()
FILTER_STATE m_FilterState; // Just need it!
- // Filter must tell us via
- // NotifyFilterState
+ // Filter must tell us via
+ // NotifyFilterState
REFERENCE_TIME m_tRunStart; // Per the Run call to the filter
// This guy will return one of the three StreamControlState's. Here's what
@@ -71,8 +72,8 @@ private:
// expires, throw the sample away. If the event
// fires, call me back - I've changed my mind.
//
- enum StreamControlState CheckSampleTimes( __in const REFERENCE_TIME * pSampleStart,
- __in const REFERENCE_TIME * pSampleStop );
+ enum StreamControlState CheckSampleTimes(__in const REFERENCE_TIME * pSampleStart,
+ __in const REFERENCE_TIME * pSampleStop);
public:
// You don't have to tell us much when we're created, but there are other
@@ -90,25 +91,26 @@ public:
// We need a clock to see what time it is. This is for the
// "discard in a timely fashion" logic. If we discard everything as
// quick as possible, a whole 60 minute file could get discarded in the
- // first 10 seconds, and if somebody wants to turn streaming on at 30
+ // first 10 seconds, and if somebody wants to turn streaming on at 30
// minutes into the file, and they make the call more than a few seconds
// after the graph is run, it may be too late!
// So we hold every sample until it's time has gone, then we discard it.
// The filter should call this when it gets a SetSyncSource
//
- void SetSyncSource( IReferenceClock * pRefClock )
+ void SetSyncSource(IReferenceClock * pRefClock)
{
- CAutoLock lck(&m_CritSec);
- if (m_pRefClock) m_pRefClock->Release();
- m_pRefClock = pRefClock;
- if (m_pRefClock) m_pRefClock->AddRef();
+ CAutoLock lck(&m_CritSec);
+ if(m_pRefClock) m_pRefClock->Release();
+ m_pRefClock = pRefClock;
+ if(m_pRefClock) m_pRefClock->AddRef();
}
// Set event sink for notifications
// The filter should call this in its JoinFilterGraph after it creates the
// IMediaEventSink
//
- void SetFilterGraph( IMediaEventSink *pSink ) {
+ void SetFilterGraph(IMediaEventSink *pSink)
+ {
m_pSink = pSink;
}
@@ -116,12 +118,12 @@ public:
// state of our owning filter.
// The app should call this ever state change
//
- void NotifyFilterState( FILTER_STATE new_state, REFERENCE_TIME tStart = 0 );
+ void NotifyFilterState(FILTER_STATE new_state, REFERENCE_TIME tStart = 0);
// Filter should call Flushing(TRUE) in BeginFlush,
// and Flushing(FALSE) in EndFlush.
//
- void Flushing( BOOL bInProgress );
+ void Flushing(BOOL bInProgress);
// The two main methods of IAMStreamControl
@@ -129,12 +131,12 @@ public:
// Class adds default values suitable for immediate
// muting and unmuting of the stream.
- STDMETHODIMP StopAt( const REFERENCE_TIME * ptStop = NULL,
- BOOL bSendExtra = FALSE,
- DWORD dwCookie = 0 );
- STDMETHODIMP StartAt( const REFERENCE_TIME * ptStart = NULL,
- DWORD dwCookie = 0 );
- STDMETHODIMP GetInfo( __out AM_STREAM_INFO *pInfo);
+ STDMETHODIMP StopAt(const REFERENCE_TIME * ptStop = NULL,
+ BOOL bSendExtra = FALSE,
+ DWORD dwCookie = 0);
+ STDMETHODIMP StartAt(const REFERENCE_TIME * ptStart = NULL,
+ DWORD dwCookie = 0);
+ STDMETHODIMP GetInfo(__out AM_STREAM_INFO *pInfo);
// Helper function for pin's receive method. Call this with
// the sample and we'll tell you what to do with it. We'll do a
@@ -143,15 +145,24 @@ public:
// caller to either flow it or discard it.
// If pSample is NULL we evaluate based on the current state
// settings
- enum StreamControlState CheckStreamState( IMediaSample * pSample );
+ enum StreamControlState CheckStreamState(IMediaSample * pSample);
private:
// These don't require locking, but we are relying on the fact that
// m_StreamState can be retrieved with integrity, and is a snap shot that
// may have just been, or may be just about to be, changed.
- HANDLE GetStreamEventHandle() const { return m_StreamEvent; }
- enum StreamControlState GetStreamState() const { return m_StreamState; }
- BOOL IsStreaming() const { return m_StreamState == STREAM_FLOWING; }
+ HANDLE GetStreamEventHandle() const
+ {
+ return m_StreamEvent;
+ }
+ enum StreamControlState GetStreamState() const
+ {
+ return m_StreamState;
+ }
+ BOOL IsStreaming() const
+ {
+ return m_StreamState == STREAM_FLOWING;
+ }
};
#endif
diff --git a/src/filters/BaseClasses/sysclock.cpp b/src/filters/BaseClasses/sysclock.cpp
index 0d5829176..a91084019 100644
--- a/src/filters/BaseClasses/sysclock.cpp
+++ b/src/filters/BaseClasses/sysclock.cpp
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// File: SysClock.cpp
//
-// Desc: DirectShow base classes - implements a system clock based on
+// Desc: DirectShow base classes - implements a system clock based on
// IReferenceClock.
//
// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
@@ -19,7 +19,8 @@
being created. The class factory will call the static CreateInstance
function when it is asked to create a CLSID_SystemClock object */
-CFactoryTemplate g_Templates[1] = {
+CFactoryTemplate g_Templates[1] =
+{
{&CLSID_SystemClock, CSystemClock::CreateInstance}
};
@@ -29,7 +30,7 @@ int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
/* This goes in the factory template table to create new instances */
CUnknown * WINAPI CSystemClock::CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)
{
- return new CSystemClock(NAME("System reference clock"),pUnk, phr);
+ return new CSystemClock(NAME("System reference clock"), pUnk, phr);
}
@@ -42,11 +43,11 @@ STDMETHODIMP CSystemClock::NonDelegatingQueryInterface(
REFIID riid,
__deref_out void ** ppv)
{
- if (riid == IID_IPersist)
+ if(riid == IID_IPersist)
{
return GetInterface(static_cast<IPersist *>(this), ppv);
}
- else if (riid == IID_IAMClockAdjust)
+ else if(riid == IID_IAMClockAdjust)
{
return GetInterface(static_cast<IAMClockAdjust *>(this), ppv);
}
@@ -60,14 +61,14 @@ STDMETHODIMP CSystemClock::NonDelegatingQueryInterface(
STDMETHODIMP
CSystemClock::GetClassID(__out CLSID *pClsID)
{
- CheckPointer(pClsID,E_POINTER);
- ValidateReadWritePtr(pClsID,sizeof(CLSID));
+ CheckPointer(pClsID, E_POINTER);
+ ValidateReadWritePtr(pClsID, sizeof(CLSID));
*pClsID = CLSID_SystemClock;
return NOERROR;
}
-STDMETHODIMP
+STDMETHODIMP
CSystemClock::SetClockDelta(REFERENCE_TIME rtDelta)
{
return SetTimeDelta(rtDelta);
diff --git a/src/filters/BaseClasses/transfrm.cpp b/src/filters/BaseClasses/transfrm.cpp
index 62b4cc3f4..7f262face 100644
--- a/src/filters/BaseClasses/transfrm.cpp
+++ b/src/filters/BaseClasses/transfrm.cpp
@@ -19,7 +19,7 @@
CTransformFilter::CTransformFilter(__in_opt LPCTSTR pName,
__inout_opt LPUNKNOWN pUnk,
REFCLSID clsid) :
- CBaseFilter(pName,pUnk,&m_csFilter, clsid),
+ CBaseFilter(pName, pUnk, &m_csFilter, clsid),
m_pInput(NULL),
m_pOutput(NULL),
m_bEOSDelivered(FALSE),
@@ -35,7 +35,7 @@ CTransformFilter::CTransformFilter(__in_opt LPCTSTR pName,
CTransformFilter::CTransformFilter(__in_opt LPCSTR pName,
__inout_opt LPUNKNOWN pUnk,
REFCLSID clsid) :
- CBaseFilter(pName,pUnk,&m_csFilter, clsid),
+ CBaseFilter(pName, pUnk, &m_csFilter, clsid),
m_pInput(NULL),
m_pOutput(NULL),
m_bEOSDelivered(FALSE),
@@ -93,7 +93,8 @@ CTransformFilter::GetPin(int n)
// Create an input pin if necessary
- if (m_pInput == NULL) {
+ if(m_pInput == NULL)
+ {
m_pInput = new CTransformInputPin(NAME("Transform input pin"),
this, // Owner filter
@@ -103,11 +104,12 @@ CTransformFilter::GetPin(int n)
// Can't fail
ASSERT(SUCCEEDED(hr));
- if (m_pInput == NULL) {
+ if(m_pInput == NULL)
+ {
return NULL;
}
m_pOutput = (CTransformOutputPin *)
- new CTransformOutputPin(NAME("Transform output pin"),
+ new CTransformOutputPin(NAME("Transform output pin"),
this, // Owner filter
&hr, // Result code
L"XForm Out"); // Pin name
@@ -115,7 +117,8 @@ CTransformFilter::GetPin(int n)
// Can't fail
ASSERT(SUCCEEDED(hr));
- if (m_pOutput == NULL) {
+ if(m_pOutput == NULL)
+ {
delete m_pInput;
m_pInput = NULL;
}
@@ -123,12 +126,16 @@ CTransformFilter::GetPin(int n)
// Return the appropriate pin
- if (n == 0) {
+ if(n == 0)
+ {
return m_pInput;
- } else
- if (n == 1) {
+ }
+ else if(n == 1)
+ {
return m_pOutput;
- } else {
+ }
+ else
+ {
return NULL;
}
}
@@ -142,23 +149,31 @@ CTransformFilter::GetPin(int n)
STDMETHODIMP CTransformFilter::FindPin(LPCWSTR Id, __deref_out IPin **ppPin)
{
- CheckPointer(ppPin,E_POINTER);
- ValidateReadWritePtr(ppPin,sizeof(IPin *));
+ CheckPointer(ppPin, E_POINTER);
+ ValidateReadWritePtr(ppPin, sizeof(IPin *));
- if (0==lstrcmpW(Id,L"In")) {
+ if(0 == lstrcmpW(Id, L"In"))
+ {
*ppPin = GetPin(0);
- } else if (0==lstrcmpW(Id,L"Out")) {
+ }
+ else if(0 == lstrcmpW(Id, L"Out"))
+ {
*ppPin = GetPin(1);
- } else {
+ }
+ else
+ {
*ppPin = NULL;
return VFW_E_NOT_FOUND;
}
HRESULT hr = NOERROR;
// AddRef() returned pointer - but GetPin could fail if memory is low.
- if (*ppPin) {
+ if(*ppPin)
+ {
(*ppPin)->AddRef();
- } else {
+ }
+ else
+ {
hr = E_OUTOFMEMORY; // probably. There's no pin anyway.
}
return hr;
@@ -206,7 +221,7 @@ CTransformFilter::BreakConnect(PIN_DIRECTION dir)
// Let derived classes know about connection completion
HRESULT
-CTransformFilter::CompleteConnect(PIN_DIRECTION direction,IPin *pReceivePin)
+CTransformFilter::CompleteConnect(PIN_DIRECTION direction, IPin *pReceivePin)
{
UNREFERENCED_PARAMETER(direction);
UNREFERENCED_PARAMETER(pReceivePin);
@@ -217,7 +232,7 @@ CTransformFilter::CompleteConnect(PIN_DIRECTION direction,IPin *pReceivePin)
// override this to know when the media type is really set
HRESULT
-CTransformFilter::SetMediaType(PIN_DIRECTION direction,const CMediaType *pmt)
+CTransformFilter::SetMediaType(PIN_DIRECTION direction, const CMediaType *pmt)
{
UNREFERENCED_PARAMETER(direction);
UNREFERENCED_PARAMETER(pmt);
@@ -240,33 +255,36 @@ CTransformFilter::InitializeOutputSample(IMediaSample *pSample, __deref_out IMed
// when we can't do it without skipping frames because we're not on a
// keyframe. If it really has to switch us, it still will, but then we
// will have to wait for the next keyframe
- if (!(pProps->dwSampleFlags & AM_SAMPLE_SPLICEPOINT)) {
- dwFlags |= AM_GBF_NOTASYNCPOINT;
+ if(!(pProps->dwSampleFlags & AM_SAMPLE_SPLICEPOINT))
+ {
+ dwFlags |= AM_GBF_NOTASYNCPOINT;
}
ASSERT(m_pOutput->m_pAllocator != NULL);
HRESULT hr = m_pOutput->m_pAllocator->GetBuffer(
- &pOutSample
- , pProps->dwSampleFlags & AM_SAMPLE_TIMEVALID ?
- &pProps->tStart : NULL
- , pProps->dwSampleFlags & AM_SAMPLE_STOPVALID ?
- &pProps->tStop : NULL
- , dwFlags
- );
+ &pOutSample
+ , pProps->dwSampleFlags & AM_SAMPLE_TIMEVALID ?
+ &pProps->tStart : NULL
+ , pProps->dwSampleFlags & AM_SAMPLE_STOPVALID ?
+ &pProps->tStop : NULL
+ , dwFlags
+ );
*ppOutSample = pOutSample;
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
ASSERT(pOutSample);
IMediaSample2 *pOutSample2;
- if (SUCCEEDED(pOutSample->QueryInterface(IID_IMediaSample2,
- (void **)&pOutSample2))) {
+ if(SUCCEEDED(pOutSample->QueryInterface(IID_IMediaSample2,
+ (void **)&pOutSample2)))
+ {
/* Modify it */
AM_SAMPLE2_PROPERTIES OutProps;
EXECUTE_ASSERT(SUCCEEDED(pOutSample2->GetProperties(
- FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, tStart), (PBYTE)&OutProps)
- ));
+ FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, tStart), (PBYTE)&OutProps)
+ ));
OutProps.dwTypeSpecificFlags = pProps->dwTypeSpecificFlags;
OutProps.dwSampleFlags =
(OutProps.dwSampleFlags & AM_SAMPLE_TYPECHANGED) |
@@ -275,30 +293,37 @@ CTransformFilter::InitializeOutputSample(IMediaSample *pSample, __deref_out IMed
OutProps.tStop = pProps->tStop;
OutProps.cbData = FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, dwStreamId);
hr = pOutSample2->SetProperties(
- FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, dwStreamId),
- (PBYTE)&OutProps
- );
- if (pProps->dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY) {
+ FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, dwStreamId),
+ (PBYTE)&OutProps
+ );
+ if(pProps->dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY)
+ {
m_bSampleSkipped = FALSE;
}
pOutSample2->Release();
- } else {
- if (pProps->dwSampleFlags & AM_SAMPLE_TIMEVALID) {
+ }
+ else
+ {
+ if(pProps->dwSampleFlags & AM_SAMPLE_TIMEVALID)
+ {
pOutSample->SetTime(&pProps->tStart,
&pProps->tStop);
}
- if (pProps->dwSampleFlags & AM_SAMPLE_SPLICEPOINT) {
+ if(pProps->dwSampleFlags & AM_SAMPLE_SPLICEPOINT)
+ {
pOutSample->SetSyncPoint(TRUE);
}
- if (pProps->dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY) {
+ if(pProps->dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY)
+ {
pOutSample->SetDiscontinuity(TRUE);
m_bSampleSkipped = FALSE;
}
// Copy the media times
LONGLONG MediaStart, MediaEnd;
- if (pSample->GetMediaTime(&MediaStart,&MediaEnd) == NOERROR) {
- pOutSample->SetMediaTime(&MediaStart,&MediaEnd);
+ if(pSample->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR)
+ {
+ pOutSample->SetMediaTime(&MediaStart, &MediaEnd);
}
}
return S_OK;
@@ -311,7 +336,8 @@ CTransformFilter::Receive(IMediaSample *pSample)
{
/* Check for other streams and pass them on */
AM_SAMPLE2_PROPERTIES * const pProps = m_pInput->SampleProps();
- if (pProps->dwStreamId != AM_STREAM_MEDIA) {
+ if(pProps->dwStreamId != AM_STREAM_MEDIA)
+ {
return m_pOutput->m_pInputPin->Receive(pSample);
}
HRESULT hr;
@@ -320,12 +346,13 @@ CTransformFilter::Receive(IMediaSample *pSample)
// If no output to deliver to then no point sending us data
- ASSERT (m_pOutput != NULL) ;
+ ASSERT(m_pOutput != NULL) ;
// Set up the output sample
hr = InitializeOutputSample(pSample, &pOutSample);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -339,29 +366,37 @@ CTransformFilter::Receive(IMediaSample *pSample)
// Stop the clock and log it (if PERF is defined)
MSR_STOP(m_idTransform);
- if (FAILED(hr)) {
- DbgLog((LOG_TRACE,1,TEXT("Error from transform")));
- } else {
+ if(FAILED(hr))
+ {
+ DbgLog((LOG_TRACE, 1, TEXT("Error from transform")));
+ }
+ else
+ {
// the Transform() function can return S_FALSE to indicate that the
// sample should not be delivered; we only deliver the sample if it's
// really S_OK (same as NOERROR, of course.)
- if (hr == NOERROR) {
- hr = m_pOutput->m_pInputPin->Receive(pOutSample);
+ if(hr == NOERROR)
+ {
+ hr = m_pOutput->m_pInputPin->Receive(pOutSample);
m_bSampleSkipped = FALSE; // last thing no longer dropped
- } else {
+ }
+ else
+ {
// S_FALSE returned from Transform is a PRIVATE agreement
// We should return NOERROR from Receive() in this cause because returning S_FALSE
// from Receive() means that this is the end of the stream and no more data should
// be sent.
- if (S_FALSE == hr) {
+ if(S_FALSE == hr)
+ {
// Release the sample before calling notify to avoid
// deadlocks if the sample holds a lock on the system
// such as DirectDraw buffers do
pOutSample->Release();
m_bSampleSkipped = TRUE;
- if (!m_bQualityChanged) {
- NotifyEvent(EC_QUALITY_CHANGE,0,0);
+ if(!m_bQualityChanged)
+ {
+ NotifyEvent(EC_QUALITY_CHANGE, 0, 0);
m_bQualityChanged = TRUE;
}
return NOERROR;
@@ -395,7 +430,8 @@ HRESULT
CTransformFilter::EndOfStream(void)
{
HRESULT hr = NOERROR;
- if (m_pOutput != NULL) {
+ if(m_pOutput != NULL)
+ {
hr = m_pOutput->DeliverEndOfStream();
}
@@ -409,15 +445,16 @@ HRESULT
CTransformFilter::BeginFlush(void)
{
HRESULT hr = NOERROR;
- if (m_pOutput != NULL) {
- // block receives -- done by caller (CBaseInputPin::BeginFlush)
+ if(m_pOutput != NULL)
+ {
+ // block receives -- done by caller (CBaseInputPin::BeginFlush)
- // discard queued data -- we have no queued data
+ // discard queued data -- we have no queued data
- // free anyone blocked on receive - not possible in this filter
+ // free anyone blocked on receive - not possible in this filter
- // call downstream
- hr = m_pOutput->DeliverBeginFlush();
+ // call downstream
+ hr = m_pOutput->DeliverBeginFlush();
}
return hr;
}
@@ -433,7 +470,7 @@ CTransformFilter::EndFlush(void)
// ensure no more data to go downstream -- we have no queued data
// call EndFlush on downstream pins
- ASSERT (m_pOutput != NULL);
+ ASSERT(m_pOutput != NULL);
return m_pOutput->DeliverEndFlush();
// caller (the input pin's method) will unblock Receives
@@ -446,18 +483,20 @@ STDMETHODIMP
CTransformFilter::Stop()
{
CAutoLock lck1(&m_csFilter);
- if (m_State == State_Stopped) {
+ if(m_State == State_Stopped)
+ {
return NOERROR;
}
// Succeed the Stop if we are not completely connected
ASSERT(m_pInput == NULL || m_pOutput != NULL);
- if (m_pInput == NULL || m_pInput->IsConnected() == FALSE ||
- m_pOutput->IsConnected() == FALSE) {
- m_State = State_Stopped;
- m_bEOSDelivered = FALSE;
- return NOERROR;
+ if(m_pInput == NULL || m_pInput->IsConnected() == FALSE ||
+ m_pOutput->IsConnected() == FALSE)
+ {
+ m_State = State_Stopped;
+ m_bEOSDelivered = FALSE;
+ return NOERROR;
}
ASSERT(m_pInput);
@@ -475,10 +514,11 @@ CTransformFilter::Stop()
// to know about starting and stopping streaming
HRESULT hr = StopStreaming();
- if (SUCCEEDED(hr)) {
- // complete the state transition
- m_State = State_Stopped;
- m_bEOSDelivered = FALSE;
+ if(SUCCEEDED(hr))
+ {
+ // complete the state transition
+ m_State = State_Stopped;
+ m_bEOSDelivered = FALSE;
}
return hr;
}
@@ -490,7 +530,8 @@ CTransformFilter::Pause()
CAutoLock lck(&m_csFilter);
HRESULT hr = NOERROR;
- if (m_State == State_Paused) {
+ if(m_State == State_Paused)
+ {
// (This space left deliberately blank)
}
@@ -499,8 +540,10 @@ CTransformFilter::Pause()
// This makes sure that it doesn't sit there forever waiting for
// samples which we cannot ever deliver without an input connection.
- else if (m_pInput == NULL || m_pInput->IsConnected() == FALSE) {
- if (m_pOutput && m_bEOSDelivered == FALSE) {
+ else if(m_pInput == NULL || m_pInput->IsConnected() == FALSE)
+ {
+ if(m_pOutput && m_bEOSDelivered == FALSE)
+ {
m_pOutput->DeliverEndOfStream();
m_bEOSDelivered = TRUE;
}
@@ -510,20 +553,24 @@ CTransformFilter::Pause()
// We may have an input connection but no output connection
// However, if we have an input pin we do have an output pin
- else if (m_pOutput->IsConnected() == FALSE) {
+ else if(m_pOutput->IsConnected() == FALSE)
+ {
m_State = State_Paused;
}
- else {
- if (m_State == State_Stopped) {
- // allow a class derived from CTransformFilter
- // to know about starting and stopping streaming
+ else
+ {
+ if(m_State == State_Stopped)
+ {
+ // allow a class derived from CTransformFilter
+ // to know about starting and stopping streaming
CAutoLock lck2(&m_csReceive);
- hr = StartStreaming();
- }
- if (SUCCEEDED(hr)) {
- hr = CBaseFilter::Pause();
- }
+ hr = StartStreaming();
+ }
+ if(SUCCEEDED(hr))
+ {
+ hr = CBaseFilter::Pause();
+ }
}
m_bSampleSkipped = FALSE;
@@ -537,7 +584,8 @@ CTransformFilter::NewSegment(
REFERENCE_TIME tStop,
double dRate)
{
- if (m_pOutput != NULL) {
+ if(m_pOutput != NULL)
+ {
return m_pOutput->DeliverNewSegment(tStart, tStop, dRate);
}
return S_OK;
@@ -548,22 +596,28 @@ HRESULT
CTransformInputPin::CheckStreaming()
{
ASSERT(m_pTransformFilter->m_pOutput != NULL);
- if (!m_pTransformFilter->m_pOutput->IsConnected()) {
+ if(!m_pTransformFilter->m_pOutput->IsConnected())
+ {
return VFW_E_NOT_CONNECTED;
- } else {
+ }
+ else
+ {
// Shouldn't be able to get any data if we're not connected!
ASSERT(IsConnected());
// we're flushing
- if (m_bFlushing) {
+ if(m_bFlushing)
+ {
return S_FALSE;
}
// Don't process stuff in Stopped state
- if (IsStopped()) {
+ if(IsStopped())
+ {
return VFW_E_WRONG_STATE;
}
- if (m_bRunTimeError) {
- return VFW_E_RUNTIME_ERROR;
+ if(m_bRunTimeError)
+ {
+ return VFW_E_RUNTIME_ERROR;
}
return S_OK;
}
@@ -584,7 +638,7 @@ CTransformInputPin::CTransformInputPin(
__in_opt LPCWSTR pName)
: CBaseInputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pName)
{
- DbgLog((LOG_TRACE,2,TEXT("CTransformInputPin::CTransformInputPin")));
+ DbgLog((LOG_TRACE, 2, TEXT("CTransformInputPin::CTransformInputPin")));
m_pTransformFilter = pTransformFilter;
}
@@ -596,7 +650,7 @@ CTransformInputPin::CTransformInputPin(
__in_opt LPCWSTR pName)
: CBaseInputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pName)
{
- DbgLog((LOG_TRACE,2,TEXT("CTransformInputPin::CTransformInputPin")));
+ DbgLog((LOG_TRACE, 2, TEXT("CTransformInputPin::CTransformInputPin")));
m_pTransformFilter = pTransformFilter;
}
#endif
@@ -606,9 +660,10 @@ CTransformInputPin::CTransformInputPin(
HRESULT
CTransformInputPin::CheckConnect(IPin *pPin)
{
- HRESULT hr = m_pTransformFilter->CheckConnect(PINDIR_INPUT,pPin);
- if (FAILED(hr)) {
- return hr;
+ HRESULT hr = m_pTransformFilter->CheckConnect(PINDIR_INPUT, pPin);
+ if(FAILED(hr))
+ {
+ return hr;
}
return CBaseInputPin::CheckConnect(pPin);
}
@@ -631,8 +686,9 @@ CTransformInputPin::BreakConnect()
HRESULT
CTransformInputPin::CompleteConnect(IPin *pReceivePin)
{
- HRESULT hr = m_pTransformFilter->CompleteConnect(PINDIR_INPUT,pReceivePin);
- if (FAILED(hr)) {
+ HRESULT hr = m_pTransformFilter->CompleteConnect(PINDIR_INPUT, pReceivePin);
+ if(FAILED(hr))
+ {
return hr;
}
return CBaseInputPin::CompleteConnect(pReceivePin);
@@ -647,19 +703,23 @@ CTransformInputPin::CheckMediaType(const CMediaType* pmt)
// Check the input type
HRESULT hr = m_pTransformFilter->CheckInputType(pmt);
- if (S_OK != hr) {
+ if(S_OK != hr)
+ {
return hr;
}
// if the output pin is still connected, then we have
// to check the transform not just the input format
- if ((m_pTransformFilter->m_pOutput != NULL) &&
- (m_pTransformFilter->m_pOutput->IsConnected())) {
- return m_pTransformFilter->CheckTransform(
- pmt,
- &m_pTransformFilter->m_pOutput->CurrentMediaType());
- } else {
+ if((m_pTransformFilter->m_pOutput != NULL) &&
+ (m_pTransformFilter->m_pOutput->IsConnected()))
+ {
+ return m_pTransformFilter->CheckTransform(
+ pmt,
+ &m_pTransformFilter->m_pOutput->CurrentMediaType());
+ }
+ else
+ {
return hr;
}
}
@@ -672,14 +732,15 @@ CTransformInputPin::SetMediaType(const CMediaType* mtIn)
{
// Set the base class media type (should always succeed)
HRESULT hr = CBasePin::SetMediaType(mtIn);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
// check the transform can be done (should always succeed)
ASSERT(SUCCEEDED(m_pTransformFilter->CheckInputType(mtIn)));
- return m_pTransformFilter->SetMediaType(PINDIR_INPUT,mtIn);
+ return m_pTransformFilter->SetMediaType(PINDIR_INPUT, mtIn);
}
@@ -695,8 +756,9 @@ CTransformInputPin::EndOfStream(void)
{
CAutoLock lck(&m_pTransformFilter->m_csReceive);
HRESULT hr = CheckStreaming();
- if (S_OK == hr) {
- hr = m_pTransformFilter->EndOfStream();
+ if(S_OK == hr)
+ {
+ hr = m_pTransformFilter->EndOfStream();
}
return hr;
}
@@ -710,13 +772,15 @@ CTransformInputPin::BeginFlush(void)
CAutoLock lck(&m_pTransformFilter->m_csFilter);
// Are we actually doing anything?
ASSERT(m_pTransformFilter->m_pOutput != NULL);
- if (!IsConnected() ||
- !m_pTransformFilter->m_pOutput->IsConnected()) {
+ if(!IsConnected() ||
+ !m_pTransformFilter->m_pOutput->IsConnected())
+ {
return VFW_E_NOT_CONNECTED;
}
HRESULT hr = CBaseInputPin::BeginFlush();
- if (FAILED(hr)) {
- return hr;
+ if(FAILED(hr))
+ {
+ return hr;
}
return m_pTransformFilter->BeginFlush();
@@ -732,13 +796,15 @@ CTransformInputPin::EndFlush(void)
CAutoLock lck(&m_pTransformFilter->m_csFilter);
// Are we actually doing anything?
ASSERT(m_pTransformFilter->m_pOutput != NULL);
- if (!IsConnected() ||
- !m_pTransformFilter->m_pOutput->IsConnected()) {
+ if(!IsConnected() ||
+ !m_pTransformFilter->m_pOutput->IsConnected())
+ {
return VFW_E_NOT_CONNECTED;
}
HRESULT hr = m_pTransformFilter->EndFlush();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -759,7 +825,8 @@ CTransformInputPin::Receive(IMediaSample * pSample)
// check all is well with the base class
hr = CBaseInputPin::Receive(pSample);
- if (S_OK == hr) {
+ if(S_OK == hr)
+ {
hr = m_pTransformFilter->Receive(pSample);
}
return hr;
@@ -798,7 +865,7 @@ CTransformOutputPin::CTransformOutputPin(
: CBaseOutputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pPinName),
m_pPosition(NULL)
{
- DbgLog((LOG_TRACE,2,TEXT("CTransformOutputPin::CTransformOutputPin")));
+ DbgLog((LOG_TRACE, 2, TEXT("CTransformOutputPin::CTransformOutputPin")));
m_pTransformFilter = pTransformFilter;
}
@@ -812,7 +879,7 @@ CTransformOutputPin::CTransformOutputPin(
: CBaseOutputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pPinName),
m_pPosition(NULL)
{
- DbgLog((LOG_TRACE,2,TEXT("CTransformOutputPin::CTransformOutputPin")));
+ DbgLog((LOG_TRACE, 2, TEXT("CTransformOutputPin::CTransformOutputPin")));
m_pTransformFilter = pTransformFilter;
}
@@ -822,9 +889,9 @@ CTransformOutputPin::CTransformOutputPin(
CTransformOutputPin::~CTransformOutputPin()
{
- DbgLog((LOG_TRACE,2,TEXT("CTransformOutputPin::~CTransformOutputPin")));
+ DbgLog((LOG_TRACE, 2, TEXT("CTransformOutputPin::~CTransformOutputPin")));
- if (m_pPosition) m_pPosition->Release();
+ if(m_pPosition) m_pPosition->Release();
}
@@ -833,29 +900,34 @@ CTransformOutputPin::~CTransformOutputPin()
STDMETHODIMP
CTransformOutputPin::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)
{
- CheckPointer(ppv,E_POINTER);
- ValidateReadWritePtr(ppv,sizeof(PVOID));
+ CheckPointer(ppv, E_POINTER);
+ ValidateReadWritePtr(ppv, sizeof(PVOID));
*ppv = NULL;
- if (riid == IID_IMediaPosition || riid == IID_IMediaSeeking) {
+ if(riid == IID_IMediaPosition || riid == IID_IMediaSeeking)
+ {
// we should have an input pin by now
ASSERT(m_pTransformFilter->m_pInput != NULL);
- if (m_pPosition == NULL) {
+ if(m_pPosition == NULL)
+ {
HRESULT hr = CreatePosPassThru(
GetOwner(),
FALSE,
(IPin *)m_pTransformFilter->m_pInput,
&m_pPosition);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
}
return m_pPosition->QueryInterface(riid, ppv);
- } else {
+ }
+ else
+ {
return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -869,13 +941,15 @@ CTransformOutputPin::CheckConnect(IPin *pPin)
// we should have an input connection first
ASSERT(m_pTransformFilter->m_pInput != NULL);
- if ((m_pTransformFilter->m_pInput->IsConnected() == FALSE)) {
- return E_UNEXPECTED;
+ if((m_pTransformFilter->m_pInput->IsConnected() == FALSE))
+ {
+ return E_UNEXPECTED;
}
- HRESULT hr = m_pTransformFilter->CheckConnect(PINDIR_OUTPUT,pPin);
- if (FAILED(hr)) {
- return hr;
+ HRESULT hr = m_pTransformFilter->CheckConnect(PINDIR_OUTPUT, pPin);
+ if(FAILED(hr))
+ {
+ return hr;
}
return CBaseOutputPin::CheckConnect(pPin);
}
@@ -898,8 +972,9 @@ CTransformOutputPin::BreakConnect()
HRESULT
CTransformOutputPin::CompleteConnect(IPin *pReceivePin)
{
- HRESULT hr = m_pTransformFilter->CompleteConnect(PINDIR_OUTPUT,pReceivePin);
- if (FAILED(hr)) {
+ HRESULT hr = m_pTransformFilter->CompleteConnect(PINDIR_OUTPUT, pReceivePin);
+ if(FAILED(hr))
+ {
return hr;
}
return CBaseOutputPin::CompleteConnect(pReceivePin);
@@ -913,13 +988,14 @@ CTransformOutputPin::CheckMediaType(const CMediaType* pmtOut)
{
// must have selected input first
ASSERT(m_pTransformFilter->m_pInput != NULL);
- if ((m_pTransformFilter->m_pInput->IsConnected() == FALSE)) {
- return E_INVALIDARG;
+ if((m_pTransformFilter->m_pInput->IsConnected() == FALSE))
+ {
+ return E_INVALIDARG;
}
return m_pTransformFilter->CheckTransform(
- &m_pTransformFilter->m_pInput->CurrentMediaType(),
- pmtOut);
+ &m_pTransformFilter->m_pInput->CurrentMediaType(),
+ pmtOut);
}
@@ -936,20 +1012,22 @@ CTransformOutputPin::SetMediaType(const CMediaType* pmtOut)
// Set the base class media type (should always succeed)
hr = CBasePin::SetMediaType(pmtOut);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
#ifdef _DEBUG
- if (FAILED(m_pTransformFilter->CheckTransform(&m_pTransformFilter->
- m_pInput->CurrentMediaType(),pmtOut))) {
- DbgLog((LOG_ERROR,0,TEXT("*** This filter is accepting an output media type")));
- DbgLog((LOG_ERROR,0,TEXT(" that it can't currently transform to. I hope")));
- DbgLog((LOG_ERROR,0,TEXT(" it's smart enough to reconnect its input.")));
+ if(FAILED(m_pTransformFilter->CheckTransform(&m_pTransformFilter->
+ m_pInput->CurrentMediaType(), pmtOut)))
+ {
+ DbgLog((LOG_ERROR, 0, TEXT("*** This filter is accepting an output media type")));
+ DbgLog((LOG_ERROR, 0, TEXT(" that it can't currently transform to. I hope")));
+ DbgLog((LOG_ERROR, 0, TEXT(" it's smart enough to reconnect its input.")));
}
#endif
- return m_pTransformFilter->SetMediaType(PINDIR_OUTPUT,pmtOut);
+ return m_pTransformFilter->SetMediaType(PINDIR_OUTPUT, pmtOut);
}
@@ -976,9 +1054,12 @@ CTransformOutputPin::GetMediaType(
// We don't have any media types if our input is not connected
- if (m_pTransformFilter->m_pInput->IsConnected()) {
- return m_pTransformFilter->GetMediaType(iPosition,pMediaType);
- } else {
+ if(m_pTransformFilter->m_pInput->IsConnected())
+ {
+ return m_pTransformFilter->GetMediaType(iPosition, pMediaType);
+ }
+ else
+ {
return VFW_S_NO_MORE_ITEMS;
}
}
@@ -993,11 +1074,12 @@ STDMETHODIMP
CTransformOutputPin::Notify(IBaseFilter * pSender, Quality q)
{
UNREFERENCED_PARAMETER(pSender);
- ValidateReadPtr(pSender,sizeof(IBaseFilter));
+ ValidateReadPtr(pSender, sizeof(IBaseFilter));
// First see if we want to handle this ourselves
HRESULT hr = m_pTransformFilter->AlterQuality(q);
- if (hr!=S_FALSE) {
+ if(hr != S_FALSE)
+ {
return hr; // either S_OK or a failure
}
diff --git a/src/filters/BaseClasses/transfrm.h b/src/filters/BaseClasses/transfrm.h
index 9b276471b..a9cdc3686 100644
--- a/src/filters/BaseClasses/transfrm.h
+++ b/src/filters/BaseClasses/transfrm.h
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// File: Transfrm.h
//
-// Desc: DirectShow base classes - defines classes from which simple
+// Desc: DirectShow base classes - defines classes from which simple
// transform codecs may be derived.
//
// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
@@ -88,16 +88,19 @@ public:
STDMETHODIMP EndFlush(void);
STDMETHODIMP NewSegment(
- REFERENCE_TIME tStart,
- REFERENCE_TIME tStop,
- double dRate);
+ REFERENCE_TIME tStart,
+ REFERENCE_TIME tStop,
+ double dRate);
// Check if it's OK to process samples
virtual HRESULT CheckStreaming();
// Media type
public:
- CMediaType& CurrentMediaType() { return m_mt; };
+ CMediaType& CurrentMediaType()
+ {
+ return m_mt;
+ };
};
@@ -156,8 +159,8 @@ public:
// called from CBaseOutputPin during connection to ask for
// the count and size of buffers we need.
HRESULT DecideBufferSize(
- IMemAllocator * pAlloc,
- __inout ALLOCATOR_PROPERTIES *pProp);
+ IMemAllocator * pAlloc,
+ __inout ALLOCATOR_PROPERTIES *pProp);
// returns the preferred formats for a pin
HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType);
@@ -167,7 +170,10 @@ public:
// Media type
public:
- CMediaType& CurrentMediaType() { return m_mt; };
+ CMediaType& CurrentMediaType()
+ {
+ return m_mt;
+ };
};
@@ -215,8 +221,8 @@ public:
// call the SetProperties function with appropriate arguments
virtual HRESULT DecideBufferSize(
- IMemAllocator * pAllocator,
- __inout ALLOCATOR_PROPERTIES *pprop) PURE;
+ IMemAllocator * pAllocator,
+ __inout ALLOCATOR_PROPERTIES *pprop) PURE;
// override to suggest OUTPUT pin media types
virtual HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType) PURE;
@@ -235,12 +241,12 @@ public:
virtual HRESULT AlterQuality(Quality q);
// override this to know when the media type is actually set
- virtual HRESULT SetMediaType(PIN_DIRECTION direction,const CMediaType *pmt);
+ virtual HRESULT SetMediaType(PIN_DIRECTION direction, const CMediaType *pmt);
// chance to grab extra interfaces on connection
- virtual HRESULT CheckConnect(PIN_DIRECTION dir,IPin *pPin);
+ virtual HRESULT CheckConnect(PIN_DIRECTION dir, IPin *pPin);
virtual HRESULT BreakConnect(PIN_DIRECTION dir);
- virtual HRESULT CompleteConnect(PIN_DIRECTION direction,IPin *pReceivePin);
+ virtual HRESULT CompleteConnect(PIN_DIRECTION direction, IPin *pReceivePin);
// chance to customize the transform process
virtual HRESULT Receive(IMediaSample *pSample);
@@ -253,15 +259,17 @@ public:
virtual HRESULT BeginFlush(void);
virtual HRESULT EndFlush(void);
virtual HRESULT NewSegment(
- REFERENCE_TIME tStart,
- REFERENCE_TIME tStop,
- double dRate);
+ REFERENCE_TIME tStart,
+ REFERENCE_TIME tStop,
+ double dRate);
#ifdef PERF
// Override to register performance measurement with a less generic string
// You should do this to avoid confusion with other filters
virtual void RegisterPerfId()
- {m_idTransform = MSR_REGISTER(TEXT("Transform"));}
+ {
+ m_idTransform = MSR_REGISTER(TEXT("Transform"));
+ }
#endif // PERF
diff --git a/src/filters/BaseClasses/transip.cpp b/src/filters/BaseClasses/transip.cpp
index e8e12eb5c..d3bb38908 100644
--- a/src/filters/BaseClasses/transip.cpp
+++ b/src/filters/BaseClasses/transip.cpp
@@ -261,14 +261,14 @@
// =================================================================
CTransInPlaceFilter::CTransInPlaceFilter
- ( __in_opt LPCTSTR pName,
- __inout_opt LPUNKNOWN pUnk,
- REFCLSID clsid,
- __inout HRESULT *phr,
- bool bModifiesData
- )
- : CTransformFilter(pName, pUnk, clsid),
- m_bModifiesData(bModifiesData)
+(__in_opt LPCTSTR pName,
+ __inout_opt LPUNKNOWN pUnk,
+ REFCLSID clsid,
+ __inout HRESULT *phr,
+ bool bModifiesData
+)
+ : CTransformFilter(pName, pUnk, clsid),
+ m_bModifiesData(bModifiesData)
{
#ifdef PERF
RegisterPerfId();
@@ -278,14 +278,14 @@ CTransInPlaceFilter::CTransInPlaceFilter
#ifdef UNICODE
CTransInPlaceFilter::CTransInPlaceFilter
- ( __in_opt LPCSTR pName,
- __inout_opt LPUNKNOWN pUnk,
- REFCLSID clsid,
- __inout HRESULT *phr,
- bool bModifiesData
- )
- : CTransformFilter(pName, pUnk, clsid),
- m_bModifiesData(bModifiesData)
+(__in_opt LPCSTR pName,
+ __inout_opt LPUNKNOWN pUnk,
+ REFCLSID clsid,
+ __inout HRESULT *phr,
+ bool bModifiesData
+)
+ : CTransformFilter(pName, pUnk, clsid),
+ m_bModifiesData(bModifiesData)
{
#ifdef PERF
RegisterPerfId();
@@ -311,12 +311,13 @@ CTransInPlaceFilter::GetPin(int n)
// Create an input pin if not already done
- if (m_pInput == NULL) {
+ if(m_pInput == NULL)
+ {
- m_pInput = new CTransInPlaceInputPin( NAME("TransInPlace input pin")
- , this // Owner filter
- , &hr // Result code
- , L"Input" // Pin name
+ m_pInput = new CTransInPlaceInputPin(NAME("TransInPlace input pin")
+ , this // Owner filter
+ , &hr // Result code
+ , L"Input" // Pin name
);
// Constructor for CTransInPlaceInputPin can't fail
@@ -325,18 +326,20 @@ CTransInPlaceFilter::GetPin(int n)
// Create an output pin if not already done
- if (m_pInput!=NULL && m_pOutput == NULL) {
+ if(m_pInput != NULL && m_pOutput == NULL)
+ {
- m_pOutput = new CTransInPlaceOutputPin( NAME("TransInPlace output pin")
- , this // Owner filter
- , &hr // Result code
- , L"Output" // Pin name
+ m_pOutput = new CTransInPlaceOutputPin(NAME("TransInPlace output pin")
+ , this // Owner filter
+ , &hr // Result code
+ , L"Output" // Pin name
);
// a failed return code should delete the object
ASSERT(SUCCEEDED(hr));
- if (m_pOutput == NULL) {
+ if(m_pOutput == NULL)
+ {
delete m_pInput;
m_pInput = NULL;
}
@@ -344,12 +347,17 @@ CTransInPlaceFilter::GetPin(int n)
// Return the appropriate pin
- ASSERT (n>=0 && n<=1);
- if (n == 0) {
+ ASSERT(n >= 0 && n <= 1);
+ if(n == 0)
+ {
return m_pInput;
- } else if (n==1) {
+ }
+ else if(n == 1)
+ {
return m_pOutput;
- } else {
+ }
+ else
+ {
return NULL;
}
@@ -367,7 +375,8 @@ HRESULT CTransInPlaceFilter::CompleteConnect(PIN_DIRECTION dir, IPin *pReceivePi
// if we are not part of a graph, then don't indirect the pointer
// this probably prevents use of the filter without a filtergraph
- if (!m_pGraph) {
+ if(!m_pGraph)
+ {
return VFW_E_NOT_IN_GRAPH;
}
@@ -381,9 +390,11 @@ HRESULT CTransInPlaceFilter::CompleteConnect(PIN_DIRECTION dir, IPin *pReceivePi
// call ReconnectEx passing the type we want to reconnect with
// via the base class ReconeectPin method.
- if (dir == PINDIR_OUTPUT) {
- if( m_pInput->IsConnected() ) {
- return ReconnectPin( m_pInput, &m_pOutput->CurrentMediaType() );
+ if(dir == PINDIR_OUTPUT)
+ {
+ if(m_pInput->IsConnected())
+ {
+ return ReconnectPin(m_pInput, &m_pOutput->CurrentMediaType());
}
return NOERROR;
}
@@ -392,12 +403,14 @@ HRESULT CTransInPlaceFilter::CompleteConnect(PIN_DIRECTION dir, IPin *pReceivePi
// Reconnect output if necessary
- if( m_pOutput->IsConnected() ) {
+ if(m_pOutput->IsConnected())
+ {
- if ( m_pInput->CurrentMediaType()
+ if(m_pInput->CurrentMediaType()
!= m_pOutput->CurrentMediaType()
- ) {
- return ReconnectPin( m_pOutput, &m_pInput->CurrentMediaType() );
+ )
+ {
+ return ReconnectPin(m_pOutput, &m_pInput->CurrentMediaType());
}
}
return NOERROR;
@@ -413,24 +426,28 @@ HRESULT CTransInPlaceFilter::CompleteConnect(PIN_DIRECTION dir, IPin *pReceivePi
//
HRESULT CTransInPlaceFilter::DecideBufferSize
- ( IMemAllocator *pAlloc
- , __inout ALLOCATOR_PROPERTIES *pProperties
- )
+(IMemAllocator *pAlloc
+ , __inout ALLOCATOR_PROPERTIES *pProperties
+)
{
ALLOCATOR_PROPERTIES Request, Actual;
HRESULT hr;
// If we are connected upstream, get his views
- if (m_pInput->IsConnected()) {
+ if(m_pInput->IsConnected())
+ {
// Get the input pin allocator, and get its size and count.
// we don't care about his alignment and prefix.
hr = InputPin()->PeekAllocator()->GetProperties(&Request);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
// Input connected but with a secretive allocator - enough!
return hr;
}
- } else {
+ }
+ else
+ {
// Propose one byte
// If this isn't enough then when the other pin does get connected
// we can revise it.
@@ -440,9 +457,9 @@ HRESULT CTransInPlaceFilter::DecideBufferSize
}
- DbgLog((LOG_MEMORY,1,TEXT("Setting Allocator Requirements")));
- DbgLog((LOG_MEMORY,1,TEXT("Count %d, Size %d"),
- Request.cBuffers, Request.cbBuffer));
+ DbgLog((LOG_MEMORY, 1, TEXT("Setting Allocator Requirements")));
+ DbgLog((LOG_MEMORY, 1, TEXT("Count %d, Size %d"),
+ Request.cBuffers, Request.cbBuffer));
// Pass the allocator requirements to our output side
// but do a little sanity checking first or we'll just hit
@@ -451,24 +468,32 @@ HRESULT CTransInPlaceFilter::DecideBufferSize
pProperties->cBuffers = Request.cBuffers;
pProperties->cbBuffer = Request.cbBuffer;
pProperties->cbAlign = Request.cbAlign;
- if (pProperties->cBuffers<=0) {pProperties->cBuffers = 1; }
- if (pProperties->cbBuffer<=0) {pProperties->cbBuffer = 1; }
+ if(pProperties->cBuffers <= 0)
+ {
+ pProperties->cBuffers = 1;
+ }
+ if(pProperties->cbBuffer <= 0)
+ {
+ pProperties->cbBuffer = 1;
+ }
hr = pAlloc->SetProperties(pProperties, &Actual);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
- DbgLog((LOG_MEMORY,1,TEXT("Obtained Allocator Requirements")));
- DbgLog((LOG_MEMORY,1,TEXT("Count %d, Size %d, Alignment %d"),
- Actual.cBuffers, Actual.cbBuffer, Actual.cbAlign));
+ DbgLog((LOG_MEMORY, 1, TEXT("Obtained Allocator Requirements")));
+ DbgLog((LOG_MEMORY, 1, TEXT("Count %d, Size %d, Alignment %d"),
+ Actual.cBuffers, Actual.cbBuffer, Actual.cbAlign));
// Make sure we got the right alignment and at least the minimum required
- if ( (Request.cBuffers > Actual.cBuffers)
+ if((Request.cBuffers > Actual.cBuffers)
|| (Request.cbBuffer > Actual.cbBuffer)
|| (Request.cbAlign > Actual.cbAlign)
- ) {
+ )
+ {
return E_FAIL;
}
return NOERROR;
@@ -485,51 +510,61 @@ __out_opt IMediaSample * CTransInPlaceFilter::Copy(IMediaSample *pSource)
HRESULT hr;
REFERENCE_TIME tStart, tStop;
- const BOOL bTime = S_OK == pSource->GetTime( &tStart, &tStop);
+ const BOOL bTime = S_OK == pSource->GetTime(&tStart, &tStop);
// this may block for an indeterminate amount of time
hr = OutputPin()->PeekAllocator()->GetBuffer(
- &pDest
- , bTime ? &tStart : NULL
- , bTime ? &tStop : NULL
- , m_bSampleSkipped ? AM_GBF_PREVFRAMESKIPPED : 0
- );
+ &pDest
+ , bTime ? &tStart : NULL
+ , bTime ? &tStop : NULL
+ , m_bSampleSkipped ? AM_GBF_PREVFRAMESKIPPED : 0
+ );
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return NULL;
}
ASSERT(pDest);
IMediaSample2 *pSample2;
- if (SUCCEEDED(pDest->QueryInterface(IID_IMediaSample2, (void **)&pSample2))) {
+ if(SUCCEEDED(pDest->QueryInterface(IID_IMediaSample2, (void **)&pSample2)))
+ {
HRESULT hrProps = pSample2->SetProperties(
- FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, pbBuffer),
- (PBYTE)m_pInput->SampleProps());
+ FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, pbBuffer),
+ (PBYTE)m_pInput->SampleProps());
pSample2->Release();
- if (FAILED(hrProps)) {
+ if(FAILED(hrProps))
+ {
pDest->Release();
return NULL;
}
- } else {
- if (bTime) {
+ }
+ else
+ {
+ if(bTime)
+ {
pDest->SetTime(&tStart, &tStop);
}
- if (S_OK == pSource->IsSyncPoint()) {
+ if(S_OK == pSource->IsSyncPoint())
+ {
pDest->SetSyncPoint(TRUE);
}
- if (S_OK == pSource->IsDiscontinuity() || m_bSampleSkipped) {
+ if(S_OK == pSource->IsDiscontinuity() || m_bSampleSkipped)
+ {
pDest->SetDiscontinuity(TRUE);
}
- if (S_OK == pSource->IsPreroll()) {
+ if(S_OK == pSource->IsPreroll())
+ {
pDest->SetPreroll(TRUE);
}
// Copy the media type
AM_MEDIA_TYPE *pMediaType;
- if (S_OK == pSource->GetMediaType(&pMediaType)) {
+ if(S_OK == pSource->GetMediaType(&pMediaType))
+ {
pDest->SetMediaType(pMediaType);
- DeleteMediaType( pMediaType );
+ DeleteMediaType(pMediaType);
}
}
@@ -538,14 +573,16 @@ __out_opt IMediaSample * CTransInPlaceFilter::Copy(IMediaSample *pSource)
// Copy the sample media times
REFERENCE_TIME TimeStart, TimeEnd;
- if (pSource->GetMediaTime(&TimeStart,&TimeEnd) == NOERROR) {
- pDest->SetMediaTime(&TimeStart,&TimeEnd);
+ if(pSource->GetMediaTime(&TimeStart, &TimeEnd) == NOERROR)
+ {
+ pDest->SetMediaTime(&TimeStart, &TimeEnd);
}
// Copy the actual data length and the actual data.
{
const long lDataLength = pSource->GetActualDataLength();
- if (FAILED(pDest->SetActualDataLength(lDataLength))) {
+ if(FAILED(pDest->SetActualDataLength(lDataLength)))
+ {
pDest->Release();
return NULL;
}
@@ -558,16 +595,17 @@ __out_opt IMediaSample * CTransInPlaceFilter::Copy(IMediaSample *pSource)
ASSERT(lDestSize >= lSourceSize && lDestSize >= lDataLength);
- if (FAILED(pSource->GetPointer(&pSourceBuffer)) ||
- FAILED(pDest->GetPointer(&pDestBuffer)) ||
- lDestSize < lDataLength ||
- lDataLength < 0) {
+ if(FAILED(pSource->GetPointer(&pSourceBuffer)) ||
+ FAILED(pDest->GetPointer(&pDestBuffer)) ||
+ lDestSize < lDataLength ||
+ lDataLength < 0)
+ {
pDest->Release();
return NULL;
}
ASSERT(lDestSize == 0 || pSourceBuffer != NULL && pDestBuffer != NULL);
- CopyMemory( (PVOID) pDestBuffer, (PVOID) pSourceBuffer, lDataLength );
+ CopyMemory((PVOID) pDestBuffer, (PVOID) pSourceBuffer, lDataLength);
}
}
@@ -583,7 +621,8 @@ CTransInPlaceFilter::Receive(IMediaSample *pSample)
{
/* Check for other streams and pass them on */
AM_SAMPLE2_PROPERTIES * const pProps = m_pInput->SampleProps();
- if (pProps->dwStreamId != AM_STREAM_MEDIA) {
+ if(pProps->dwStreamId != AM_STREAM_MEDIA)
+ {
return m_pOutput->Deliver(pSample);
}
HRESULT hr;
@@ -591,13 +630,15 @@ CTransInPlaceFilter::Receive(IMediaSample *pSample)
// Start timing the TransInPlace (if PERF is defined)
MSR_START(m_idTransInPlace);
- if (UsingDifferentAllocators()) {
+ if(UsingDifferentAllocators())
+ {
// We have to copy the data.
pSample = Copy(pSample);
- if (pSample==NULL) {
+ if(pSample == NULL)
+ {
MSR_STOP(m_idTransInPlace);
return E_UNEXPECTED;
}
@@ -609,9 +650,11 @@ CTransInPlaceFilter::Receive(IMediaSample *pSample)
// Stop the clock and log it (if PERF is defined)
MSR_STOP(m_idTransInPlace);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
DbgLog((LOG_TRACE, 1, TEXT("Error from TransInPlace")));
- if (UsingDifferentAllocators()) {
+ if(UsingDifferentAllocators())
+ {
pSample->Release();
}
return hr;
@@ -620,19 +663,24 @@ CTransInPlaceFilter::Receive(IMediaSample *pSample)
// the Transform() function can return S_FALSE to indicate that the
// sample should not be delivered; we only deliver the sample if it's
// really S_OK (same as NOERROR, of course.)
- if (hr == NOERROR) {
+ if(hr == NOERROR)
+ {
hr = m_pOutput->Deliver(pSample);
- } else {
+ }
+ else
+ {
// But it would be an error to return this private workaround
// to the caller ...
- if (S_FALSE == hr) {
+ if(S_FALSE == hr)
+ {
// S_FALSE returned from Transform is a PRIVATE agreement
// We should return NOERROR from Receive() in this cause because
// returning S_FALSE from Receive() means that this is the end
// of the stream and no more data should be sent.
m_bSampleSkipped = TRUE;
- if (!m_bQualityChanged) {
- NotifyEvent(EC_QUALITY_CHANGE,0,0);
+ if(!m_bQualityChanged)
+ {
+ NotifyEvent(EC_QUALITY_CHANGE, 0, 0);
m_bQualityChanged = TRUE;
}
hr = NOERROR;
@@ -641,7 +689,8 @@ CTransInPlaceFilter::Receive(IMediaSample *pSample)
// release the output buffer. If the connected pin still needs it,
// it will have addrefed it itself.
- if (UsingDifferentAllocators()) {
+ if(UsingDifferentAllocators())
+ {
pSample->Release();
}
@@ -659,11 +708,11 @@ CTransInPlaceFilter::Receive(IMediaSample *pSample)
// constructor
CTransInPlaceInputPin::CTransInPlaceInputPin
- ( __in_opt LPCTSTR pObjectName
- , __inout CTransInPlaceFilter *pFilter
- , __inout HRESULT *phr
- , __in_opt LPCWSTR pName
- )
+(__in_opt LPCTSTR pObjectName
+ , __inout CTransInPlaceFilter *pFilter
+ , __inout HRESULT *phr
+ , __in_opt LPCWSTR pName
+)
: CTransformInputPin(pObjectName,
pFilter,
phr,
@@ -672,7 +721,7 @@ CTransInPlaceInputPin::CTransInPlaceInputPin
, m_pTIPFilter(pFilter)
{
DbgLog((LOG_TRACE, 2
- , TEXT("CTransInPlaceInputPin::CTransInPlaceInputPin")));
+ , TEXT("CTransInPlaceInputPin::CTransInPlaceInputPin")));
} // constructor
@@ -693,26 +742,29 @@ CTransInPlaceInputPin::CTransInPlaceInputPin
STDMETHODIMP CTransInPlaceInputPin::GetAllocator(__deref_out IMemAllocator ** ppAllocator)
{
- CheckPointer(ppAllocator,E_POINTER);
- ValidateReadWritePtr(ppAllocator,sizeof(IMemAllocator *));
+ CheckPointer(ppAllocator, E_POINTER);
+ ValidateReadWritePtr(ppAllocator, sizeof(IMemAllocator *));
CAutoLock cObjectLock(m_pLock);
HRESULT hr;
- if ( m_pTIPFilter->m_pOutput->IsConnected() ) {
+ 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 );
+ ->GetAllocator(ppAllocator);
+ if(SUCCEEDED(hr))
+ {
+ m_pTIPFilter->OutputPin()->SetAllocator(*ppAllocator);
}
}
- else {
+ 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 );
+ hr = CTransformInputPin::GetAllocator(ppAllocator);
}
return hr;
@@ -729,8 +781,8 @@ CTransInPlaceInputPin::NotifyAllocator(
BOOL bReadOnly)
{
HRESULT hr = S_OK;
- CheckPointer(pAllocator,E_POINTER);
- ValidateReadPtr(pAllocator,sizeof(IMemAllocator));
+ CheckPointer(pAllocator, E_POINTER);
+ ValidateReadPtr(pAllocator, sizeof(IMemAllocator));
CAutoLock cObjectLock(m_pLock);
@@ -741,68 +793,84 @@ CTransInPlaceInputPin::NotifyAllocator(
// If our output is not connected just accept the allocator
// We're never going to use this allocator because when our
// output pin is connected we'll reconnect this pin
- if (!m_pTIPFilter->OutputPin()->IsConnected()) {
+ if(!m_pTIPFilter->OutputPin()->IsConnected())
+ {
return CTransformInputPin::NotifyAllocator(pAllocator, bReadOnly);
}
// If the allocator is read-only and we're modifying data
// and the allocator is the same as the output pin's
// then reject
- if (bReadOnly && m_pTIPFilter->m_bModifiesData) {
+ if(bReadOnly && m_pTIPFilter->m_bModifiesData)
+ {
IMemAllocator *pOutputAllocator =
m_pTIPFilter->OutputPin()->PeekAllocator();
// Make sure we have an output allocator
- if (pOutputAllocator == NULL) {
+ if(pOutputAllocator == NULL)
+ {
hr = m_pTIPFilter->OutputPin()->ConnectedIMemInputPin()->
- GetAllocator(&pOutputAllocator);
- if(FAILED(hr)) {
+ GetAllocator(&pOutputAllocator);
+ if(FAILED(hr))
+ {
hr = CreateMemoryAllocator(&pOutputAllocator);
}
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
m_pTIPFilter->OutputPin()->SetAllocator(pOutputAllocator);
pOutputAllocator->Release();
}
}
- if (pAllocator == pOutputAllocator) {
+ if(pAllocator == pOutputAllocator)
+ {
hr = E_FAIL;
- } else if(SUCCEEDED(hr)) {
+ }
+ else if(SUCCEEDED(hr))
+ {
// Must copy so set the allocator properties on the output
ALLOCATOR_PROPERTIES Props, Actual;
hr = pAllocator->GetProperties(&Props);
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
hr = pOutputAllocator->SetProperties(&Props, &Actual);
}
- if (SUCCEEDED(hr)) {
- if ( (Props.cBuffers > Actual.cBuffers)
+ if(SUCCEEDED(hr))
+ {
+ if((Props.cBuffers > Actual.cBuffers)
|| (Props.cbBuffer > Actual.cbBuffer)
|| (Props.cbAlign > Actual.cbAlign)
- ) {
+ )
+ {
hr = E_FAIL;
}
}
// Set the allocator on the output pin
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
hr = m_pTIPFilter->OutputPin()->ConnectedIMemInputPin()
- ->NotifyAllocator( pOutputAllocator, FALSE );
+ ->NotifyAllocator(pOutputAllocator, FALSE);
}
}
- } else {
+ }
+ else
+ {
hr = m_pTIPFilter->OutputPin()->ConnectedIMemInputPin()
- ->NotifyAllocator( pAllocator, bReadOnly );
- if (SUCCEEDED(hr)) {
- m_pTIPFilter->OutputPin()->SetAllocator( pAllocator );
+ ->NotifyAllocator(pAllocator, bReadOnly);
+ if(SUCCEEDED(hr))
+ {
+ m_pTIPFilter->OutputPin()->SetAllocator(pAllocator);
}
}
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
// It's possible that the old and the new are the same thing.
// AddRef before release ensures that we don't unload it.
pAllocator->AddRef();
- if( m_pAllocator != NULL )
+ if(m_pAllocator != NULL)
m_pAllocator->Release();
m_pAllocator = pAllocator; // We have an allocator for the input pin
@@ -815,13 +883,13 @@ CTransInPlaceInputPin::NotifyAllocator(
// EnumMediaTypes
// - pass through to our downstream filter
-STDMETHODIMP CTransInPlaceInputPin::EnumMediaTypes( __deref_out IEnumMediaTypes **ppEnum )
+STDMETHODIMP CTransInPlaceInputPin::EnumMediaTypes(__deref_out IEnumMediaTypes **ppEnum)
{
// Can only pass through if connected
- if( !m_pTIPFilter->m_pOutput->IsConnected() )
+ if(!m_pTIPFilter->m_pOutput->IsConnected())
return VFW_E_NOT_CONNECTED;
- return m_pTIPFilter->m_pOutput->GetConnected()->EnumMediaTypes( ppEnum );
+ return m_pTIPFilter->m_pOutput->GetConnected()->EnumMediaTypes(ppEnum);
} // EnumMediaTypes
@@ -831,13 +899,13 @@ STDMETHODIMP CTransInPlaceInputPin::EnumMediaTypes( __deref_out IEnumMediaTypes
// otherwise pass through to the downstream filter.
// This assumes that the filter does not change the media type.
-HRESULT CTransInPlaceInputPin::CheckMediaType(const CMediaType *pmt )
+HRESULT CTransInPlaceInputPin::CheckMediaType(const CMediaType *pmt)
{
HRESULT hr = m_pTIPFilter->CheckInputType(pmt);
- if (hr!=S_OK) return hr;
+ if(hr != S_OK) return hr;
- if( m_pTIPFilter->m_pOutput->IsConnected() )
- return m_pTIPFilter->m_pOutput->GetConnected()->QueryAccept( pmt );
+ if(m_pTIPFilter->m_pOutput->IsConnected())
+ return m_pTIPFilter->m_pOutput->GetConnected()->QueryAccept(pmt);
else
return S_OK;
@@ -850,9 +918,9 @@ STDMETHODIMP
CTransInPlaceInputPin::GetAllocatorRequirements(__out ALLOCATOR_PROPERTIES *pProps)
{
- if( m_pTIPFilter->m_pOutput->IsConnected() )
+ if(m_pTIPFilter->m_pOutput->IsConnected())
return m_pTIPFilter->OutputPin()
- ->ConnectedIMemInputPin()->GetAllocatorRequirements( pProps );
+ ->ConnectedIMemInputPin()->GetAllocatorRequirements(pProps);
else
return E_NOTIMPL;
@@ -860,18 +928,19 @@ CTransInPlaceInputPin::GetAllocatorRequirements(__out ALLOCATOR_PROPERTIES *pPro
// CTransInPlaceInputPin::CompleteConnect() calls CBaseInputPin::CompleteConnect()
-// and then calls CTransInPlaceFilter::CompleteConnect(). It does this because
+// and then calls CTransInPlaceFilter::CompleteConnect(). It does this because
// CTransInPlaceFilter::CompleteConnect() can reconnect a pin and we do not
// want to reconnect a pin if CBaseInputPin::CompleteConnect() fails.
HRESULT
CTransInPlaceInputPin::CompleteConnect(IPin *pReceivePin)
{
HRESULT hr = CBaseInputPin::CompleteConnect(pReceivePin);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
- return m_pTransformFilter->CompleteConnect(PINDIR_INPUT,pReceivePin);
+ return m_pTransformFilter->CompleteConnect(PINDIR_INPUT, pReceivePin);
} // CompleteConnect
@@ -887,27 +956,27 @@ CTransInPlaceOutputPin::CTransInPlaceOutputPin(
__inout CTransInPlaceFilter *pFilter,
__inout HRESULT * phr,
__in_opt LPCWSTR pPinName)
- : CTransformOutputPin( pObjectName
- , pFilter
- , phr
- , pPinName),
- m_pTIPFilter(pFilter)
+ : CTransformOutputPin(pObjectName
+ , pFilter
+ , phr
+ , pPinName),
+ m_pTIPFilter(pFilter)
{
- DbgLog(( LOG_TRACE, 2
- , TEXT("CTransInPlaceOutputPin::CTransInPlaceOutputPin")));
+ DbgLog((LOG_TRACE, 2
+ , TEXT("CTransInPlaceOutputPin::CTransInPlaceOutputPin")));
} // constructor
// EnumMediaTypes
// - pass through to our upstream filter
-STDMETHODIMP CTransInPlaceOutputPin::EnumMediaTypes( __deref_out IEnumMediaTypes **ppEnum )
+STDMETHODIMP CTransInPlaceOutputPin::EnumMediaTypes(__deref_out IEnumMediaTypes **ppEnum)
{
// Can only pass through if connected.
- if( ! m_pTIPFilter->m_pInput->IsConnected() )
+ if(! m_pTIPFilter->m_pInput->IsConnected())
return VFW_E_NOT_CONNECTED;
- return m_pTIPFilter->m_pInput->GetConnected()->EnumMediaTypes( ppEnum );
+ return m_pTIPFilter->m_pInput->GetConnected()->EnumMediaTypes(ppEnum);
} // EnumMediaTypes
@@ -917,15 +986,19 @@ STDMETHODIMP CTransInPlaceOutputPin::EnumMediaTypes( __deref_out IEnumMediaTypes
// - agree to anything if not connected,
// otherwise pass through to the upstream filter.
-HRESULT CTransInPlaceOutputPin::CheckMediaType(const CMediaType *pmt )
+HRESULT CTransInPlaceOutputPin::CheckMediaType(const CMediaType *pmt)
{
// Don't accept any output pin type changes if we're copying
// between allocators - it's too late to change the input
// allocator size.
- if (m_pTIPFilter->UsingDifferentAllocators() && !m_pFilter->IsStopped()) {
- if (*pmt == m_mt) {
+ if(m_pTIPFilter->UsingDifferentAllocators() && !m_pFilter->IsStopped())
+ {
+ if(*pmt == m_mt)
+ {
return S_OK;
- } else {
+ }
+ else
+ {
return VFW_E_TYPE_NOT_ACCEPTED;
}
}
@@ -933,10 +1006,10 @@ HRESULT CTransInPlaceOutputPin::CheckMediaType(const CMediaType *pmt )
// Assumes the type does not change. That's why we're calling
// CheckINPUTType here on the OUTPUT pin.
HRESULT hr = m_pTIPFilter->CheckInputType(pmt);
- if (hr!=S_OK) return hr;
+ if(hr != S_OK) return hr;
- if( m_pTIPFilter->m_pInput->IsConnected() )
- return m_pTIPFilter->m_pInput->GetConnected()->QueryAccept( pmt );
+ if(m_pTIPFilter->m_pInput->IsConnected())
+ return m_pTIPFilter->m_pInput->GetConnected()->QueryAccept(pmt);
else
return S_OK;
@@ -949,7 +1022,8 @@ void
CTransInPlaceOutputPin::SetAllocator(IMemAllocator * pAllocator)
{
pAllocator->AddRef();
- if (m_pAllocator) {
+ if(m_pAllocator)
+ {
m_pAllocator->Release();
}
m_pAllocator = pAllocator;
@@ -957,18 +1031,19 @@ CTransInPlaceOutputPin::SetAllocator(IMemAllocator * pAllocator)
// CTransInPlaceOutputPin::CompleteConnect() calls CBaseOutputPin::CompleteConnect()
-// and then calls CTransInPlaceFilter::CompleteConnect(). It does this because
-// CTransInPlaceFilter::CompleteConnect() can reconnect a pin and we do not want to
-// reconnect a pin if CBaseOutputPin::CompleteConnect() fails.
-// CBaseOutputPin::CompleteConnect() often fails when our output pin is being connected
+// and then calls CTransInPlaceFilter::CompleteConnect(). It does this because
+// CTransInPlaceFilter::CompleteConnect() can reconnect a pin and we do not want to
+// reconnect a pin if CBaseOutputPin::CompleteConnect() fails.
+// CBaseOutputPin::CompleteConnect() often fails when our output pin is being connected
// to the Video Mixing Renderer.
HRESULT
CTransInPlaceOutputPin::CompleteConnect(IPin *pReceivePin)
{
HRESULT hr = CBaseOutputPin::CompleteConnect(pReceivePin);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
- return m_pTransformFilter->CompleteConnect(PINDIR_OUTPUT,pReceivePin);
+ return m_pTransformFilter->CompleteConnect(PINDIR_OUTPUT, pReceivePin);
} // CompleteConnect
diff --git a/src/filters/BaseClasses/transip.h b/src/filters/BaseClasses/transip.h
index 3fc335eff..cf91e6c3d 100644
--- a/src/filters/BaseClasses/transip.h
+++ b/src/filters/BaseClasses/transip.h
@@ -57,7 +57,7 @@ public:
// --- IMemInputPin -----
// Provide an enumerator for media types by getting one from downstream
- STDMETHODIMP EnumMediaTypes( __deref_out IEnumMediaTypes **ppEnum );
+ STDMETHODIMP EnumMediaTypes(__deref_out IEnumMediaTypes **ppEnum);
// Say whether media type is acceptable.
HRESULT CheckMediaType(const CMediaType* pmt);
@@ -73,14 +73,19 @@ public:
// Allow the filter to see what allocator we have
// N.B. This does NOT AddRef
__out IMemAllocator * PeekAllocator() const
- { return m_pAllocator; }
+ {
+ return m_pAllocator;
+ }
// Pass this on downstream if it ever gets called.
STDMETHODIMP GetAllocatorRequirements(__out ALLOCATOR_PROPERTIES *pProps);
HRESULT CompleteConnect(IPin *pReceivePin);
- inline const BOOL ReadOnly() { return m_bReadOnly ; }
+ inline const BOOL ReadOnly()
+ {
+ return m_bReadOnly ;
+ }
}; // CTransInPlaceInputPin
@@ -113,7 +118,7 @@ public:
// virtual HRESULT DecideAllocator(IMemInputPin * pPin, IMemAllocator ** pAlloc);
// Provide a media type enumerator. Get it from upstream.
- STDMETHODIMP EnumMediaTypes( __deref_out IEnumMediaTypes **ppEnum );
+ STDMETHODIMP EnumMediaTypes(__deref_out IEnumMediaTypes **ppEnum);
// Say whether media type is acceptable.
HRESULT CheckMediaType(const CMediaType* pmt);
@@ -123,12 +128,16 @@ public:
void SetAllocator(IMemAllocator * pAllocator);
__out_opt IMemInputPin * ConnectedIMemInputPin()
- { return m_pInputPin; }
+ {
+ return m_pInputPin;
+ }
// Allow the filter to see what allocator we have
// N.B. This does NOT AddRef
__out IMemAllocator * PeekAllocator() const
- { return m_pAllocator; }
+ {
+ return m_pAllocator;
+ }
HRESULT CompleteConnect(IPin *pReceivePin);
@@ -163,9 +172,10 @@ public:
// We override EnumMediaTypes to bypass the transform class enumerator
// which would otherwise call this.
HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType)
- { DbgBreak("CTransInPlaceFilter::GetMediaType should never be called");
- return E_UNEXPECTED;
- }
+ {
+ DbgBreak("CTransInPlaceFilter::GetMediaType should never be called");
+ return E_UNEXPECTED;
+ }
// This is called when we actually have to provide our own allocator.
HRESULT DecideBufferSize(IMemAllocator*, __inout ALLOCATOR_PROPERTIES *);
@@ -184,7 +194,7 @@ public:
// ----- You may want to override this -----------------------------
// =================================================================
- HRESULT CompleteConnect(PIN_DIRECTION dir,IPin *pReceivePin);
+ HRESULT CompleteConnect(PIN_DIRECTION dir, IPin *pReceivePin);
// chance to customize the transform process
virtual HRESULT Receive(IMediaSample *pSample);
@@ -203,7 +213,9 @@ public:
// Override to register performance measurement with a less generic string
// You should do this to avoid confusion with other filters
virtual void RegisterPerfId()
- {m_idTransInPlace = MSR_REGISTER(TEXT("TransInPlace"));}
+ {
+ m_idTransInPlace = MSR_REGISTER(TEXT("TransInPlace"));
+ }
#endif // PERF
diff --git a/src/filters/BaseClasses/videoctl.cpp b/src/filters/BaseClasses/videoctl.cpp
index b12ccbd37..655b8db1e 100644
--- a/src/filters/BaseClasses/videoctl.cpp
+++ b/src/filters/BaseClasses/videoctl.cpp
@@ -17,7 +17,8 @@
LPTSTR WINAPI StringFromResource(__out_ecount(STR_MAX_LENGTH) LPTSTR pBuffer, int iResourceID)
{
- if (LoadString(g_hInst,iResourceID,pBuffer,STR_MAX_LENGTH) == 0) {
+ if(LoadString(g_hInst, iResourceID, pBuffer, STR_MAX_LENGTH) == 0)
+ {
return TEXT("");
}
return pBuffer;
@@ -26,7 +27,8 @@ LPTSTR WINAPI StringFromResource(__out_ecount(STR_MAX_LENGTH) LPTSTR pBuffer, in
#ifdef UNICODE
LPSTR WINAPI StringFromResource(__out_ecount(STR_MAX_LENGTH) LPSTR pBuffer, int iResourceID)
{
- if (LoadStringA(g_hInst,iResourceID,pBuffer,STR_MAX_LENGTH) == 0) {
+ if(LoadStringA(g_hInst, iResourceID, pBuffer, STR_MAX_LENGTH) == 0)
+ {
return "";
}
return pBuffer;
@@ -48,17 +50,21 @@ LPWSTR WINAPI WideStringFromResource(__out_ecount(STR_MAX_LENGTH) LPWSTR pBuffer
{
*pBuffer = 0;
- if (g_amPlatform == VER_PLATFORM_WIN32_NT) {
- LoadStringW(g_hInst,iResourceID,pBuffer,STR_MAX_LENGTH);
- } else {
-
- CHAR szBuffer[STR_MAX_LENGTH];
- DWORD dwStringLength = LoadString(g_hInst,iResourceID,szBuffer,STR_MAX_LENGTH);
- // if we loaded a string convert it to wide characters, ensuring
- // that we also null terminate the result.
- if (dwStringLength++) {
- MultiByteToWideChar(CP_ACP,0,szBuffer,dwStringLength,pBuffer,STR_MAX_LENGTH);
- }
+ if(g_amPlatform == VER_PLATFORM_WIN32_NT)
+ {
+ LoadStringW(g_hInst, iResourceID, pBuffer, STR_MAX_LENGTH);
+ }
+ else
+ {
+
+ CHAR szBuffer[STR_MAX_LENGTH];
+ DWORD dwStringLength = LoadString(g_hInst, iResourceID, szBuffer, STR_MAX_LENGTH);
+ // if we loaded a string convert it to wide characters, ensuring
+ // that we also null terminate the result.
+ if(dwStringLength++)
+ {
+ MultiByteToWideChar(CP_ACP, 0, szBuffer, dwStringLength, pBuffer, STR_MAX_LENGTH);
+ }
}
return pBuffer;
}
@@ -83,7 +89,8 @@ BOOL WINAPI GetDialogSize(int iResourceID,
GetDesktopWindow(),
pDlgProc,
lParam);
- if (hwnd == NULL) {
+ if(hwnd == NULL)
+ {
return FALSE;
}
@@ -110,10 +117,13 @@ STDMETHODIMP CAggDirectDraw::NonDelegatingQueryInterface(REFIID riid, __deref_ou
// Do we have this interface
- if (riid == IID_IDirectDraw) {
- return GetInterface((IDirectDraw *)this,ppv);
- } else {
- return CUnknown::NonDelegatingQueryInterface(riid,ppv);
+ if(riid == IID_IDirectDraw)
+ {
+ return GetInterface((IDirectDraw *)this, ppv);
+ }
+ else
+ {
+ return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -128,54 +138,54 @@ STDMETHODIMP CAggDirectDraw::Compact()
STDMETHODIMP CAggDirectDraw::CreateClipper(DWORD dwFlags, __deref_out LPDIRECTDRAWCLIPPER *lplpDDClipper, __inout_opt IUnknown *pUnkOuter)
{
ASSERT(m_pDirectDraw);
- return m_pDirectDraw->CreateClipper(dwFlags,lplpDDClipper,pUnkOuter);
+ return m_pDirectDraw->CreateClipper(dwFlags, lplpDDClipper, pUnkOuter);
}
STDMETHODIMP CAggDirectDraw::CreatePalette(DWORD dwFlags,
- __in LPPALETTEENTRY lpColorTable,
- __deref_out LPDIRECTDRAWPALETTE *lplpDDPalette,
- __inout_opt IUnknown *pUnkOuter)
+ __in LPPALETTEENTRY lpColorTable,
+ __deref_out LPDIRECTDRAWPALETTE *lplpDDPalette,
+ __inout_opt IUnknown *pUnkOuter)
{
ASSERT(m_pDirectDraw);
- return m_pDirectDraw->CreatePalette(dwFlags,lpColorTable,lplpDDPalette,pUnkOuter);
+ return m_pDirectDraw->CreatePalette(dwFlags, lpColorTable, lplpDDPalette, pUnkOuter);
}
STDMETHODIMP CAggDirectDraw::CreateSurface(__in LPDDSURFACEDESC lpDDSurfaceDesc,
- __deref_out LPDIRECTDRAWSURFACE *lplpDDSurface,
- __inout_opt IUnknown *pUnkOuter)
+ __deref_out LPDIRECTDRAWSURFACE *lplpDDSurface,
+ __inout_opt IUnknown *pUnkOuter)
{
ASSERT(m_pDirectDraw);
- return m_pDirectDraw->CreateSurface(lpDDSurfaceDesc,lplpDDSurface,pUnkOuter);
+ return m_pDirectDraw->CreateSurface(lpDDSurfaceDesc, lplpDDSurface, pUnkOuter);
}
STDMETHODIMP CAggDirectDraw::DuplicateSurface(__in LPDIRECTDRAWSURFACE lpDDSurface,
- __deref_out LPDIRECTDRAWSURFACE *lplpDupDDSurface)
+ __deref_out LPDIRECTDRAWSURFACE *lplpDupDDSurface)
{
ASSERT(m_pDirectDraw);
- return m_pDirectDraw->DuplicateSurface(lpDDSurface,lplpDupDDSurface);
+ return m_pDirectDraw->DuplicateSurface(lpDDSurface, lplpDupDDSurface);
}
STDMETHODIMP CAggDirectDraw::EnumDisplayModes(DWORD dwSurfaceDescCount,
- __in LPDDSURFACEDESC lplpDDSurfaceDescList,
- __in LPVOID lpContext,
- __in LPDDENUMMODESCALLBACK lpEnumCallback)
+ __in LPDDSURFACEDESC lplpDDSurfaceDescList,
+ __in LPVOID lpContext,
+ __in LPDDENUMMODESCALLBACK lpEnumCallback)
{
ASSERT(m_pDirectDraw);
- return m_pDirectDraw->EnumDisplayModes(dwSurfaceDescCount,lplpDDSurfaceDescList,lpContext,lpEnumCallback);
+ return m_pDirectDraw->EnumDisplayModes(dwSurfaceDescCount, lplpDDSurfaceDescList, lpContext, lpEnumCallback);
}
STDMETHODIMP CAggDirectDraw::EnumSurfaces(DWORD dwFlags,
- __in LPDDSURFACEDESC lpDDSD,
- __in LPVOID lpContext,
- __in LPDDENUMSURFACESCALLBACK lpEnumCallback)
+ __in LPDDSURFACEDESC lpDDSD,
+ __in LPVOID lpContext,
+ __in LPDDENUMSURFACESCALLBACK lpEnumCallback)
{
ASSERT(m_pDirectDraw);
- return m_pDirectDraw->EnumSurfaces(dwFlags,lpDDSD,lpContext,lpEnumCallback);
+ return m_pDirectDraw->EnumSurfaces(dwFlags, lpDDSD, lpContext, lpEnumCallback);
}
@@ -186,10 +196,10 @@ STDMETHODIMP CAggDirectDraw::FlipToGDISurface()
}
-STDMETHODIMP CAggDirectDraw::GetCaps(__out LPDDCAPS lpDDDriverCaps,__out LPDDCAPS lpDDHELCaps)
+STDMETHODIMP CAggDirectDraw::GetCaps(__out LPDDCAPS lpDDDriverCaps, __out LPDDCAPS lpDDHELCaps)
{
ASSERT(m_pDirectDraw);
- return m_pDirectDraw->GetCaps(lpDDDriverCaps,lpDDHELCaps);
+ return m_pDirectDraw->GetCaps(lpDDDriverCaps, lpDDHELCaps);
}
@@ -200,10 +210,10 @@ STDMETHODIMP CAggDirectDraw::GetDisplayMode(__out LPDDSURFACEDESC lpDDSurfaceDes
}
-STDMETHODIMP CAggDirectDraw::GetFourCCCodes(__inout LPDWORD lpNumCodes,__out_ecount(*lpNumCodes) LPDWORD lpCodes)
+STDMETHODIMP CAggDirectDraw::GetFourCCCodes(__inout LPDWORD lpNumCodes, __out_ecount(*lpNumCodes) LPDWORD lpCodes)
{
ASSERT(m_pDirectDraw);
- return m_pDirectDraw->GetFourCCCodes(lpNumCodes,lpCodes);
+ return m_pDirectDraw->GetFourCCCodes(lpNumCodes, lpCodes);
}
@@ -249,24 +259,24 @@ STDMETHODIMP CAggDirectDraw::RestoreDisplayMode()
}
-STDMETHODIMP CAggDirectDraw::SetCooperativeLevel(HWND hWnd,DWORD dwFlags)
+STDMETHODIMP CAggDirectDraw::SetCooperativeLevel(HWND hWnd, DWORD dwFlags)
{
ASSERT(m_pDirectDraw);
- return m_pDirectDraw->SetCooperativeLevel(hWnd,dwFlags);
+ return m_pDirectDraw->SetCooperativeLevel(hWnd, dwFlags);
}
-STDMETHODIMP CAggDirectDraw::SetDisplayMode(DWORD dwWidth,DWORD dwHeight,DWORD dwBpp)
+STDMETHODIMP CAggDirectDraw::SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBpp)
{
ASSERT(m_pDirectDraw);
- return m_pDirectDraw->SetDisplayMode(dwWidth,dwHeight,dwBpp);
+ return m_pDirectDraw->SetDisplayMode(dwWidth, dwHeight, dwBpp);
}
-STDMETHODIMP CAggDirectDraw::WaitForVerticalBlank(DWORD dwFlags,HANDLE hEvent)
+STDMETHODIMP CAggDirectDraw::WaitForVerticalBlank(DWORD dwFlags, HANDLE hEvent)
{
ASSERT(m_pDirectDraw);
- return m_pDirectDraw->WaitForVerticalBlank(dwFlags,hEvent);
+ return m_pDirectDraw->WaitForVerticalBlank(dwFlags, hEvent);
}
@@ -284,10 +294,13 @@ STDMETHODIMP CAggDrawSurface::NonDelegatingQueryInterface(REFIID riid, __deref_o
// Do we have this interface
- if (riid == IID_IDirectDrawSurface) {
- return GetInterface((IDirectDrawSurface *)this,ppv);
- } else {
- return CUnknown::NonDelegatingQueryInterface(riid,ppv);
+ if(riid == IID_IDirectDrawSurface)
+ {
+ return GetInterface((IDirectDrawSurface *)this, ppv);
+ }
+ else
+ {
+ return CUnknown::NonDelegatingQueryInterface(riid, ppv);
}
}
@@ -313,64 +326,64 @@ STDMETHODIMP CAggDrawSurface::Blt(__in LPRECT lpDestRect,
__in LPDDBLTFX lpDDBltFx)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->Blt(lpDestRect,lpDDSrcSurface,lpSrcRect,dwFlags,lpDDBltFx);
+ return m_pDirectDrawSurface->Blt(lpDestRect, lpDDSrcSurface, lpSrcRect, dwFlags, lpDDBltFx);
}
-STDMETHODIMP CAggDrawSurface::BltBatch(__in_ecount(dwCount) LPDDBLTBATCH lpDDBltBatch,DWORD dwCount,DWORD dwFlags)
+STDMETHODIMP CAggDrawSurface::BltBatch(__in_ecount(dwCount) LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->BltBatch(lpDDBltBatch,dwCount,dwFlags);
+ return m_pDirectDrawSurface->BltBatch(lpDDBltBatch, dwCount, dwFlags);
}
-STDMETHODIMP CAggDrawSurface::BltFast(DWORD dwX,DWORD dwY,
+STDMETHODIMP CAggDrawSurface::BltFast(DWORD dwX, DWORD dwY,
__in LPDIRECTDRAWSURFACE lpDDSrcSurface,
__in LPRECT lpSrcRect,
DWORD dwTrans)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->BltFast(dwX,dwY,lpDDSrcSurface,lpSrcRect,dwTrans);
+ return m_pDirectDrawSurface->BltFast(dwX, dwY, lpDDSrcSurface, lpSrcRect, dwTrans);
}
STDMETHODIMP CAggDrawSurface::DeleteAttachedSurface(DWORD dwFlags,
- __in LPDIRECTDRAWSURFACE lpDDSAttachedSurface)
+ __in LPDIRECTDRAWSURFACE lpDDSAttachedSurface)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->DeleteAttachedSurface(dwFlags,lpDDSAttachedSurface);
+ return m_pDirectDrawSurface->DeleteAttachedSurface(dwFlags, lpDDSAttachedSurface);
}
STDMETHODIMP CAggDrawSurface::EnumAttachedSurfaces(__in LPVOID lpContext,
- __in LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
+ __in LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->EnumAttachedSurfaces(lpContext,lpEnumSurfacesCallback);
+ return m_pDirectDrawSurface->EnumAttachedSurfaces(lpContext, lpEnumSurfacesCallback);
}
STDMETHODIMP CAggDrawSurface::EnumOverlayZOrders(DWORD dwFlags,
- __in LPVOID lpContext,
- __in LPDDENUMSURFACESCALLBACK lpfnCallback)
+ __in LPVOID lpContext,
+ __in LPDDENUMSURFACESCALLBACK lpfnCallback)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->EnumOverlayZOrders(dwFlags,lpContext,lpfnCallback);
+ return m_pDirectDrawSurface->EnumOverlayZOrders(dwFlags, lpContext, lpfnCallback);
}
-STDMETHODIMP CAggDrawSurface::Flip(__in LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride,DWORD dwFlags)
+STDMETHODIMP CAggDrawSurface::Flip(__in LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride, DWORD dwFlags)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->Flip(lpDDSurfaceTargetOverride,dwFlags);
+ return m_pDirectDrawSurface->Flip(lpDDSurfaceTargetOverride, dwFlags);
}
STDMETHODIMP CAggDrawSurface::GetAttachedSurface(__in LPDDSCAPS lpDDSCaps,
- __deref_out LPDIRECTDRAWSURFACE *lplpDDAttachedSurface)
+ __deref_out LPDIRECTDRAWSURFACE *lplpDDAttachedSurface)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->GetAttachedSurface(lpDDSCaps,lplpDDAttachedSurface);
+ return m_pDirectDrawSurface->GetAttachedSurface(lpDDSCaps, lplpDDAttachedSurface);
}
@@ -395,10 +408,10 @@ STDMETHODIMP CAggDrawSurface::GetClipper(__deref_out LPDIRECTDRAWCLIPPER *lplpDD
}
-STDMETHODIMP CAggDrawSurface::GetColorKey(DWORD dwFlags,__out LPDDCOLORKEY lpDDColorKey)
+STDMETHODIMP CAggDrawSurface::GetColorKey(DWORD dwFlags, __out LPDDCOLORKEY lpDDColorKey)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->GetColorKey(dwFlags,lpDDColorKey);
+ return m_pDirectDrawSurface->GetColorKey(dwFlags, lpDDColorKey);
}
@@ -416,10 +429,10 @@ STDMETHODIMP CAggDrawSurface::GetFlipStatus(DWORD dwFlags)
}
-STDMETHODIMP CAggDrawSurface::GetOverlayPosition(__out LPLONG lpdwX,__out LPLONG lpdwY)
+STDMETHODIMP CAggDrawSurface::GetOverlayPosition(__out LPLONG lpdwX, __out LPLONG lpdwY)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->GetOverlayPosition(lpdwX,lpdwY);
+ return m_pDirectDrawSurface->GetOverlayPosition(lpdwX, lpdwY);
}
@@ -454,7 +467,8 @@ STDMETHODIMP CAggDrawSurface::GetSurfaceDesc(__out LPDDSURFACEDESC lpDDSurfaceDe
// First call down to the underlying DirectDraw
HRESULT hr = m_pDirectDrawSurface->GetSurfaceDesc(lpDDSurfaceDesc);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -464,10 +478,10 @@ STDMETHODIMP CAggDrawSurface::GetSurfaceDesc(__out LPDDSURFACEDESC lpDDSurfaceDe
}
-STDMETHODIMP CAggDrawSurface::Initialize(__in LPDIRECTDRAW lpDD,__in LPDDSURFACEDESC lpDDSurfaceDesc)
+STDMETHODIMP CAggDrawSurface::Initialize(__in LPDIRECTDRAW lpDD, __in LPDDSURFACEDESC lpDDSurfaceDesc)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->Initialize(lpDD,lpDDSurfaceDesc);
+ return m_pDirectDrawSurface->Initialize(lpDD, lpDDSurfaceDesc);
}
@@ -484,7 +498,7 @@ STDMETHODIMP CAggDrawSurface::Lock(__in LPRECT lpDestRect,
HANDLE hEvent)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->Lock(lpDestRect,lpDDSurfaceDesc,dwFlags,hEvent);
+ return m_pDirectDrawSurface->Lock(lpDestRect, lpDDSurfaceDesc, dwFlags, hEvent);
}
@@ -509,17 +523,17 @@ STDMETHODIMP CAggDrawSurface::SetClipper(__in LPDIRECTDRAWCLIPPER lpDDClipper)
}
-STDMETHODIMP CAggDrawSurface::SetColorKey(DWORD dwFlags,__in LPDDCOLORKEY lpDDColorKey)
+STDMETHODIMP CAggDrawSurface::SetColorKey(DWORD dwFlags, __in LPDDCOLORKEY lpDDColorKey)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->SetColorKey(dwFlags,lpDDColorKey);
+ return m_pDirectDrawSurface->SetColorKey(dwFlags, lpDDColorKey);
}
-STDMETHODIMP CAggDrawSurface::SetOverlayPosition(LONG dwX,LONG dwY)
+STDMETHODIMP CAggDrawSurface::SetOverlayPosition(LONG dwX, LONG dwY)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->SetOverlayPosition(dwX,dwY);
+ return m_pDirectDrawSurface->SetOverlayPosition(dwX, dwY);
}
@@ -538,13 +552,13 @@ STDMETHODIMP CAggDrawSurface::Unlock(__in LPVOID lpSurfaceData)
STDMETHODIMP CAggDrawSurface::UpdateOverlay(__in LPRECT lpSrcRect,
- __in LPDIRECTDRAWSURFACE lpDDDestSurface,
- __in LPRECT lpDestRect,
- DWORD dwFlags,
- __in LPDDOVERLAYFX lpDDOverlayFX)
+ __in LPDIRECTDRAWSURFACE lpDDDestSurface,
+ __in LPRECT lpDestRect,
+ DWORD dwFlags,
+ __in LPDDOVERLAYFX lpDDOverlayFX)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->UpdateOverlay(lpSrcRect,lpDDDestSurface,lpDestRect,dwFlags,lpDDOverlayFX);
+ return m_pDirectDrawSurface->UpdateOverlay(lpSrcRect, lpDDDestSurface, lpDestRect, dwFlags, lpDDOverlayFX);
}
@@ -555,10 +569,10 @@ STDMETHODIMP CAggDrawSurface::UpdateOverlayDisplay(DWORD dwFlags)
}
-STDMETHODIMP CAggDrawSurface::UpdateOverlayZOrder(DWORD dwFlags,__in LPDIRECTDRAWSURFACE lpDDSReference)
+STDMETHODIMP CAggDrawSurface::UpdateOverlayZOrder(DWORD dwFlags, __in LPDIRECTDRAWSURFACE lpDDSReference)
{
ASSERT(m_pDirectDrawSurface);
- return m_pDirectDrawSurface->UpdateOverlayZOrder(dwFlags,lpDDSReference);
+ return m_pDirectDrawSurface->UpdateOverlayZOrder(dwFlags, lpDDSReference);
}
@@ -581,7 +595,8 @@ CLoadDirectDraw::~CLoadDirectDraw()
{
ReleaseDirectDraw();
- if (m_hDirectDraw) {
+ if(m_hDirectDraw)
+ {
NOTE("Unloading library");
FreeLibrary(m_hDirectDraw);
}
@@ -609,7 +624,8 @@ HRESULT CLoadDirectDraw::LoadDirectDraw(__in LPSTR szDevice)
// Is DirectDraw already loaded
- if (m_pDirectDraw) {
+ if(m_pDirectDraw)
+ {
NOTE("Already loaded");
ASSERT(m_hDirectDraw);
return NOERROR;
@@ -623,8 +639,9 @@ HRESULT CLoadDirectDraw::LoadDirectDraw(__in LPSTR szDevice)
m_hDirectDraw = LoadLibrary(TEXT("DDRAW.DLL"));
SetErrorMode(ErrorMode);
- if (m_hDirectDraw == NULL) {
- DbgLog((LOG_ERROR,1,TEXT("Can't load DDRAW.DLL")));
+ if(m_hDirectDraw == NULL)
+ {
+ DbgLog((LOG_ERROR, 1, TEXT("Can't load DDRAW.DLL")));
NOTE("No library");
return E_NOINTERFACE;
}
@@ -632,38 +649,40 @@ HRESULT CLoadDirectDraw::LoadDirectDraw(__in LPSTR szDevice)
// Get the DLL address for the creator function
- pDrawCreate = (PDRAWCREATE)GetProcAddress(m_hDirectDraw,"DirectDrawCreate");
+ pDrawCreate = (PDRAWCREATE)GetProcAddress(m_hDirectDraw, "DirectDrawCreate");
// force ANSI, we assume it
- pDrawEnum = (PDRAWENUM)GetProcAddress(m_hDirectDraw,"DirectDrawEnumerateA");
+ pDrawEnum = (PDRAWENUM)GetProcAddress(m_hDirectDraw, "DirectDrawEnumerateA");
pDrawEnumEx = (LPDIRECTDRAWENUMERATEEXA)GetProcAddress(m_hDirectDraw,
- "DirectDrawEnumerateExA");
+ "DirectDrawEnumerateExA");
// We don't NEED DirectDrawEnumerateEx, that's just for multimon stuff
- if (pDrawCreate == NULL || pDrawEnum == NULL) {
- DbgLog((LOG_ERROR,1,TEXT("Can't get functions: Create=%x Enum=%x"),
- pDrawCreate, pDrawEnum));
+ if(pDrawCreate == NULL || pDrawEnum == NULL)
+ {
+ DbgLog((LOG_ERROR, 1, TEXT("Can't get functions: Create=%x Enum=%x"),
+ pDrawCreate, pDrawEnum));
NOTE("No entry point");
ReleaseDirectDraw();
return E_NOINTERFACE;
}
- DbgLog((LOG_TRACE,3,TEXT("Creating DDraw for device %s"),
- szDevice ? szDevice : "<NULL>"));
+ DbgLog((LOG_TRACE, 3, TEXT("Creating DDraw for device %s"),
+ szDevice ? szDevice : "<NULL>"));
// Create a DirectDraw display provider for this device, using the fancy
// multimon-aware version, if it exists
- if (pDrawEnumEx)
+ if(pDrawEnumEx)
m_pDirectDraw = DirectDrawCreateFromDeviceEx(szDevice, pDrawCreate,
- pDrawEnumEx);
+ pDrawEnumEx);
else
m_pDirectDraw = DirectDrawCreateFromDevice(szDevice, pDrawCreate,
- pDrawEnum);
+ pDrawEnum);
- if (m_pDirectDraw == NULL) {
- DbgLog((LOG_ERROR,1,TEXT("Can't create DDraw")));
- NOTE("No instance");
- ReleaseDirectDraw();
- return E_NOINTERFACE;
+ if(m_pDirectDraw == NULL)
+ {
+ DbgLog((LOG_ERROR, 1, TEXT("Can't create DDraw")));
+ NOTE("No instance");
+ ReleaseDirectDraw();
+ return E_NOINTERFACE;
}
return NOERROR;
}
@@ -681,7 +700,8 @@ void CLoadDirectDraw::ReleaseDirectDraw()
// Release any DirectDraw provider interface
- if (m_pDirectDraw) {
+ if(m_pDirectDraw)
+ {
NOTE("Releasing instance");
m_pDirectDraw->Release();
m_pDirectDraw = NULL;
@@ -696,7 +716,8 @@ HRESULT CLoadDirectDraw::IsDirectDrawLoaded()
{
NOTE("Entering IsDirectDrawLoaded");
- if (m_pDirectDraw == NULL) {
+ if(m_pDirectDraw == NULL)
+ {
NOTE("DirectDraw not loaded");
return S_FALSE;
}
@@ -710,7 +731,8 @@ LPDIRECTDRAW CLoadDirectDraw::GetDirectDraw()
{
NOTE("Entering GetDirectDraw");
- if (m_pDirectDraw == NULL) {
+ if(m_pDirectDraw == NULL)
+ {
NOTE("No DirectDraw");
return NULL;
}
@@ -729,18 +751,21 @@ LPDIRECTDRAW CLoadDirectDraw::GetDirectDraw()
BOOL CLoadDirectDraw::IsDirectDrawVersion1()
{
- if (m_pDirectDraw == NULL)
- return FALSE;
+ if(m_pDirectDraw == NULL)
+ return FALSE;
IDirectDraw2 *p = NULL;
HRESULT hr = m_pDirectDraw->QueryInterface(IID_IDirectDraw2, (void **)&p);
- if (p)
- p->Release();
- if (hr == NOERROR) {
- DbgLog((LOG_TRACE,3,TEXT("Direct Draw Version 2 or greater")));
- return FALSE;
- } else {
- DbgLog((LOG_TRACE,3,TEXT("Direct Draw Version 1")));
- return TRUE;
+ if(p)
+ p->Release();
+ if(hr == NOERROR)
+ {
+ DbgLog((LOG_TRACE, 3, TEXT("Direct Draw Version 2 or greater")));
+ return FALSE;
+ }
+ else
+ {
+ DbgLog((LOG_TRACE, 3, TEXT("Direct Draw Version 1")));
+ return TRUE;
}
}
diff --git a/src/filters/BaseClasses/videoctl.h b/src/filters/BaseClasses/videoctl.h
index 30c377834..27bc1ce07 100644
--- a/src/filters/BaseClasses/videoctl.h
+++ b/src/filters/BaseClasses/videoctl.h
@@ -43,43 +43,44 @@ protected:
public:
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,__deref_out void **ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
// Constructor and destructor
- CAggDirectDraw(__in_opt LPCTSTR pName,__inout_opt LPUNKNOWN pUnk) :
- CUnknown(pName,pUnk),
+ CAggDirectDraw(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk) :
+ CUnknown(pName, pUnk),
m_pDirectDraw(NULL) { };
virtual CAggDirectDraw::~CAggDirectDraw() { };
// Set the object we should be aggregating
- void SetDirectDraw(__inout LPDIRECTDRAW pDirectDraw) {
+ void SetDirectDraw(__inout LPDIRECTDRAW pDirectDraw)
+ {
m_pDirectDraw = pDirectDraw;
}
// IDirectDraw methods
STDMETHODIMP Compact();
- STDMETHODIMP CreateClipper(DWORD dwFlags,__deref_out LPDIRECTDRAWCLIPPER *lplpDDClipper,__inout_opt IUnknown *pUnkOuter);
- STDMETHODIMP CreatePalette(DWORD dwFlags,__in LPPALETTEENTRY lpColorTable,__deref_out LPDIRECTDRAWPALETTE *lplpDDPalette,__inout_opt IUnknown *pUnkOuter);
- STDMETHODIMP CreateSurface(__in LPDDSURFACEDESC lpDDSurfaceDesc,__deref_out LPDIRECTDRAWSURFACE *lplpDDSurface,__inout_opt IUnknown *pUnkOuter);
- STDMETHODIMP DuplicateSurface(__in LPDIRECTDRAWSURFACE lpDDSurface,__deref_out LPDIRECTDRAWSURFACE *lplpDupDDSurface);
- STDMETHODIMP EnumDisplayModes(DWORD dwSurfaceDescCount,__in LPDDSURFACEDESC lplpDDSurfaceDescList,__in LPVOID lpContext,__in LPDDENUMMODESCALLBACK lpEnumCallback);
- STDMETHODIMP EnumSurfaces(DWORD dwFlags,__in LPDDSURFACEDESC lpDDSD,__in LPVOID lpContext,__in LPDDENUMSURFACESCALLBACK lpEnumCallback);
+ STDMETHODIMP CreateClipper(DWORD dwFlags, __deref_out LPDIRECTDRAWCLIPPER *lplpDDClipper, __inout_opt IUnknown *pUnkOuter);
+ STDMETHODIMP CreatePalette(DWORD dwFlags, __in LPPALETTEENTRY lpColorTable, __deref_out LPDIRECTDRAWPALETTE *lplpDDPalette, __inout_opt IUnknown *pUnkOuter);
+ STDMETHODIMP CreateSurface(__in LPDDSURFACEDESC lpDDSurfaceDesc, __deref_out LPDIRECTDRAWSURFACE *lplpDDSurface, __inout_opt IUnknown *pUnkOuter);
+ STDMETHODIMP DuplicateSurface(__in LPDIRECTDRAWSURFACE lpDDSurface, __deref_out LPDIRECTDRAWSURFACE *lplpDupDDSurface);
+ STDMETHODIMP EnumDisplayModes(DWORD dwSurfaceDescCount, __in LPDDSURFACEDESC lplpDDSurfaceDescList, __in LPVOID lpContext, __in LPDDENUMMODESCALLBACK lpEnumCallback);
+ STDMETHODIMP EnumSurfaces(DWORD dwFlags, __in LPDDSURFACEDESC lpDDSD, __in LPVOID lpContext, __in LPDDENUMSURFACESCALLBACK lpEnumCallback);
STDMETHODIMP FlipToGDISurface();
- STDMETHODIMP GetCaps(__out LPDDCAPS lpDDDriverCaps,__out LPDDCAPS lpDDHELCaps);
+ STDMETHODIMP GetCaps(__out LPDDCAPS lpDDDriverCaps, __out LPDDCAPS lpDDHELCaps);
STDMETHODIMP GetDisplayMode(__out LPDDSURFACEDESC lpDDSurfaceDesc);
- STDMETHODIMP GetFourCCCodes(__inout LPDWORD lpNumCodes,__out_ecount(*lpNumCodes) LPDWORD lpCodes);
+ STDMETHODIMP GetFourCCCodes(__inout LPDWORD lpNumCodes, __out_ecount(*lpNumCodes) LPDWORD lpCodes);
STDMETHODIMP GetGDISurface(__deref_out LPDIRECTDRAWSURFACE *lplpGDIDDSurface);
STDMETHODIMP GetMonitorFrequency(__out LPDWORD lpdwFrequency);
STDMETHODIMP GetScanLine(__out LPDWORD lpdwScanLine);
STDMETHODIMP GetVerticalBlankStatus(__out LPBOOL lpblsInVB);
STDMETHODIMP Initialize(__in GUID *lpGUID);
STDMETHODIMP RestoreDisplayMode();
- STDMETHODIMP SetCooperativeLevel(HWND hWnd,DWORD dwFlags);
- STDMETHODIMP SetDisplayMode(DWORD dwWidth,DWORD dwHeight,DWORD dwBpp);
- STDMETHODIMP WaitForVerticalBlank(DWORD dwFlags,HANDLE hEvent);
+ STDMETHODIMP SetCooperativeLevel(HWND hWnd, DWORD dwFlags);
+ STDMETHODIMP SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBpp);
+ STDMETHODIMP WaitForVerticalBlank(DWORD dwFlags, HANDLE hEvent);
};
@@ -94,18 +95,19 @@ protected:
public:
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,__deref_out void **ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
// Constructor and destructor
- CAggDrawSurface(__in_opt LPCTSTR pName,__inout_opt LPUNKNOWN pUnk) :
- CUnknown(pName,pUnk),
+ CAggDrawSurface(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk) :
+ CUnknown(pName, pUnk),
m_pDirectDrawSurface(NULL) { };
virtual ~CAggDrawSurface() { };
// Set the object we should be aggregating
- void SetDirectDrawSurface(__inout LPDIRECTDRAWSURFACE pDirectDrawSurface) {
+ void SetDirectDrawSurface(__inout LPDIRECTDRAWSURFACE pDirectDrawSurface)
+ {
m_pDirectDrawSurface = pDirectDrawSurface;
}
@@ -113,37 +115,37 @@ public:
STDMETHODIMP AddAttachedSurface(__in LPDIRECTDRAWSURFACE lpDDSAttachedSurface);
STDMETHODIMP AddOverlayDirtyRect(__in LPRECT lpRect);
- STDMETHODIMP Blt(__in LPRECT lpDestRect,__in LPDIRECTDRAWSURFACE lpDDSrcSurface,__in LPRECT lpSrcRect,DWORD dwFlags,__in LPDDBLTFX lpDDBltFx);
- STDMETHODIMP BltBatch(__in_ecount(dwCount) LPDDBLTBATCH lpDDBltBatch,DWORD dwCount,DWORD dwFlags);
- STDMETHODIMP BltFast(DWORD dwX,DWORD dwY,__in LPDIRECTDRAWSURFACE lpDDSrcSurface,__in LPRECT lpSrcRect,DWORD dwTrans);
- STDMETHODIMP DeleteAttachedSurface(DWORD dwFlags,__in LPDIRECTDRAWSURFACE lpDDSAttachedSurface);
- STDMETHODIMP EnumAttachedSurfaces(__in LPVOID lpContext,__in LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback);
- STDMETHODIMP EnumOverlayZOrders(DWORD dwFlags,__in LPVOID lpContext,__in LPDDENUMSURFACESCALLBACK lpfnCallback);
- STDMETHODIMP Flip(__in LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride,DWORD dwFlags);
- STDMETHODIMP GetAttachedSurface(__in LPDDSCAPS lpDDSCaps,__deref_out LPDIRECTDRAWSURFACE *lplpDDAttachedSurface);
+ STDMETHODIMP Blt(__in LPRECT lpDestRect, __in LPDIRECTDRAWSURFACE lpDDSrcSurface, __in LPRECT lpSrcRect, DWORD dwFlags, __in LPDDBLTFX lpDDBltFx);
+ STDMETHODIMP BltBatch(__in_ecount(dwCount) LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags);
+ STDMETHODIMP BltFast(DWORD dwX, DWORD dwY, __in LPDIRECTDRAWSURFACE lpDDSrcSurface, __in LPRECT lpSrcRect, DWORD dwTrans);
+ STDMETHODIMP DeleteAttachedSurface(DWORD dwFlags, __in LPDIRECTDRAWSURFACE lpDDSAttachedSurface);
+ STDMETHODIMP EnumAttachedSurfaces(__in LPVOID lpContext, __in LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback);
+ STDMETHODIMP EnumOverlayZOrders(DWORD dwFlags, __in LPVOID lpContext, __in LPDDENUMSURFACESCALLBACK lpfnCallback);
+ STDMETHODIMP Flip(__in LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride, DWORD dwFlags);
+ STDMETHODIMP GetAttachedSurface(__in LPDDSCAPS lpDDSCaps, __deref_out LPDIRECTDRAWSURFACE *lplpDDAttachedSurface);
STDMETHODIMP GetBltStatus(DWORD dwFlags);
STDMETHODIMP GetCaps(__out LPDDSCAPS lpDDSCaps);
STDMETHODIMP GetClipper(__deref_out LPDIRECTDRAWCLIPPER *lplpDDClipper);
- STDMETHODIMP GetColorKey(DWORD dwFlags,__out LPDDCOLORKEY lpDDColorKey);
+ STDMETHODIMP GetColorKey(DWORD dwFlags, __out LPDDCOLORKEY lpDDColorKey);
STDMETHODIMP GetDC(__out HDC *lphDC);
STDMETHODIMP GetFlipStatus(DWORD dwFlags);
- STDMETHODIMP GetOverlayPosition(__out LPLONG lpdwX,__out LPLONG lpdwY);
+ STDMETHODIMP GetOverlayPosition(__out LPLONG lpdwX, __out LPLONG lpdwY);
STDMETHODIMP GetPalette(__deref_out LPDIRECTDRAWPALETTE *lplpDDPalette);
STDMETHODIMP GetPixelFormat(__out LPDDPIXELFORMAT lpDDPixelFormat);
STDMETHODIMP GetSurfaceDesc(__out LPDDSURFACEDESC lpDDSurfaceDesc);
- STDMETHODIMP Initialize(__in LPDIRECTDRAW lpDD,__in LPDDSURFACEDESC lpDDSurfaceDesc);
+ STDMETHODIMP Initialize(__in LPDIRECTDRAW lpDD, __in LPDDSURFACEDESC lpDDSurfaceDesc);
STDMETHODIMP IsLost();
- STDMETHODIMP Lock(__in LPRECT lpDestRect,__inout LPDDSURFACEDESC lpDDSurfaceDesc,DWORD dwFlags,HANDLE hEvent);
+ STDMETHODIMP Lock(__in LPRECT lpDestRect, __inout LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent);
STDMETHODIMP ReleaseDC(HDC hDC);
STDMETHODIMP Restore();
STDMETHODIMP SetClipper(__in LPDIRECTDRAWCLIPPER lpDDClipper);
- STDMETHODIMP SetColorKey(DWORD dwFlags,__in LPDDCOLORKEY lpDDColorKey);
- STDMETHODIMP SetOverlayPosition(LONG dwX,LONG dwY);
+ STDMETHODIMP SetColorKey(DWORD dwFlags, __in LPDDCOLORKEY lpDDColorKey);
+ STDMETHODIMP SetOverlayPosition(LONG dwX, LONG dwY);
STDMETHODIMP SetPalette(__in LPDIRECTDRAWPALETTE lpDDPalette);
STDMETHODIMP Unlock(__in LPVOID lpSurfaceData);
- STDMETHODIMP UpdateOverlay(__in LPRECT lpSrcRect,__in LPDIRECTDRAWSURFACE lpDDDestSurface,__in LPRECT lpDestRect,DWORD dwFlags,__in LPDDOVERLAYFX lpDDOverlayFX);
+ STDMETHODIMP UpdateOverlay(__in LPRECT lpSrcRect, __in LPDIRECTDRAWSURFACE lpDDDestSurface, __in LPRECT lpDestRect, DWORD dwFlags, __in LPDDOVERLAYFX lpDDOverlayFX);
STDMETHODIMP UpdateOverlayDisplay(DWORD dwFlags);
- STDMETHODIMP UpdateOverlayZOrder(DWORD dwFlags,__in LPDIRECTDRAWSURFACE lpDDSReference);
+ STDMETHODIMP UpdateOverlayZOrder(DWORD dwFlags, __in LPDIRECTDRAWSURFACE lpDDSReference);
};
diff --git a/src/filters/BaseClasses/vtrans.cpp b/src/filters/BaseClasses/vtrans.cpp
index 27502970f..750ab85d7 100644
--- a/src/filters/BaseClasses/vtrans.cpp
+++ b/src/filters/BaseClasses/vtrans.cpp
@@ -12,7 +12,7 @@
// #include <vtransfr.h> // now in precomp file streams.h
CVideoTransformFilter::CVideoTransformFilter
- ( __in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, REFCLSID clsid)
+(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, REFCLSID clsid)
: CTransformFilter(pName, pUnk, clsid)
, m_itrLate(0)
, m_nKeyFramePeriod(0) // No QM until we see at least 2 key frames
@@ -30,7 +30,7 @@ CVideoTransformFilter::CVideoTransformFilter
CVideoTransformFilter::~CVideoTransformFilter()
{
- // nothing to do
+ // nothing to do
}
@@ -118,7 +118,7 @@ HRESULT CVideoTransformFilter::Receive(IMediaSample *pSample)
IMediaSample * pOutSample;
// If no output pin to deliver to then no point sending us data
- ASSERT (m_pOutput != NULL) ;
+ ASSERT(m_pOutput != NULL) ;
// The source filter may dynamically ask us to start transforming from a
// different media type than the one we're using now. If we don't, we'll
@@ -130,45 +130,48 @@ HRESULT CVideoTransformFilter::Receive(IMediaSample *pSample)
#define rcT1 ((VIDEOINFOHEADER *)(pmt->pbFormat))->rcTarget
pSample->GetMediaType(&pmt);
- if (pmt != NULL && pmt->pbFormat != NULL) {
+ if(pmt != NULL && pmt->pbFormat != NULL)
+ {
- // spew some debug output
- ASSERT(!IsEqualGUID(pmt->majortype, GUID_NULL));
+ // spew some debug output
+ ASSERT(!IsEqualGUID(pmt->majortype, GUID_NULL));
#ifdef _DEBUG
fccOut.SetFOURCC(&pmt->subtype);
- LONG lCompression = HEADER(pmt->pbFormat)->biCompression;
- LONG lBitCount = HEADER(pmt->pbFormat)->biBitCount;
- LONG lStride = (HEADER(pmt->pbFormat)->biWidth * lBitCount + 7) / 8;
- lStride = (lStride + 3) & ~3;
- DbgLog((LOG_TRACE,3,TEXT("*Changing input type on the fly to")));
- DbgLog((LOG_TRACE,3,TEXT("FourCC: %lx Compression: %lx BitCount: %ld"),
- fccOut.GetFOURCC(), lCompression, lBitCount));
- DbgLog((LOG_TRACE,3,TEXT("biHeight: %ld rcDst: (%ld, %ld, %ld, %ld)"),
- HEADER(pmt->pbFormat)->biHeight,
- rcT1.left, rcT1.top, rcT1.right, rcT1.bottom));
- DbgLog((LOG_TRACE,3,TEXT("rcSrc: (%ld, %ld, %ld, %ld) Stride: %ld"),
- rcS1.left, rcS1.top, rcS1.right, rcS1.bottom,
- lStride));
+ LONG lCompression = HEADER(pmt->pbFormat)->biCompression;
+ LONG lBitCount = HEADER(pmt->pbFormat)->biBitCount;
+ LONG lStride = (HEADER(pmt->pbFormat)->biWidth * lBitCount + 7) / 8;
+ lStride = (lStride + 3) & ~3;
+ DbgLog((LOG_TRACE, 3, TEXT("*Changing input type on the fly to")));
+ DbgLog((LOG_TRACE, 3, TEXT("FourCC: %lx Compression: %lx BitCount: %ld"),
+ fccOut.GetFOURCC(), lCompression, lBitCount));
+ DbgLog((LOG_TRACE, 3, TEXT("biHeight: %ld rcDst: (%ld, %ld, %ld, %ld)"),
+ HEADER(pmt->pbFormat)->biHeight,
+ rcT1.left, rcT1.top, rcT1.right, rcT1.bottom));
+ DbgLog((LOG_TRACE, 3, TEXT("rcSrc: (%ld, %ld, %ld, %ld) Stride: %ld"),
+ rcS1.left, rcS1.top, rcS1.right, rcS1.bottom,
+ lStride));
#endif
- // now switch to using the new format. I am assuming that the
- // derived filter will do the right thing when its media type is
- // switched and streaming is restarted.
-
- StopStreaming();
- m_pInput->CurrentMediaType() = *pmt;
- DeleteMediaType(pmt);
- // if this fails, playback will stop, so signal an error
- hr = StartStreaming();
- if (FAILED(hr)) {
- return AbortPlayback(hr);
- }
+ // now switch to using the new format. I am assuming that the
+ // derived filter will do the right thing when its media type is
+ // switched and streaming is restarted.
+
+ StopStreaming();
+ m_pInput->CurrentMediaType() = *pmt;
+ DeleteMediaType(pmt);
+ // if this fails, playback will stop, so signal an error
+ hr = StartStreaming();
+ if(FAILED(hr))
+ {
+ return AbortPlayback(hr);
+ }
}
// Now that we have noticed any format changes on the input sample, it's
// OK to discard it.
- if (ShouldSkipFrame(pSample)) {
+ if(ShouldSkipFrame(pSample))
+ {
MSR_NOTE(m_idSkip);
m_bSampleSkipped = TRUE;
return NOERROR;
@@ -177,7 +180,8 @@ HRESULT CVideoTransformFilter::Receive(IMediaSample *pSample)
// Set up the output sample
hr = InitializeOutputSample(pSample, &pOutSample);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -190,64 +194,70 @@ HRESULT CVideoTransformFilter::Receive(IMediaSample *pSample)
#define rcT ((VIDEOINFOHEADER *)(pmtOut->pbFormat))->rcTarget
pOutSample->GetMediaType(&pmtOut);
- if (pmtOut != NULL && pmtOut->pbFormat != NULL) {
+ if(pmtOut != NULL && pmtOut->pbFormat != NULL)
+ {
- // spew some debug output
- ASSERT(!IsEqualGUID(pmtOut->majortype, GUID_NULL));
+ // spew some debug output
+ ASSERT(!IsEqualGUID(pmtOut->majortype, GUID_NULL));
#ifdef _DEBUG
fccOut.SetFOURCC(&pmtOut->subtype);
- LONG lCompression = HEADER(pmtOut->pbFormat)->biCompression;
- LONG lBitCount = HEADER(pmtOut->pbFormat)->biBitCount;
- LONG lStride = (HEADER(pmtOut->pbFormat)->biWidth * lBitCount + 7) / 8;
- lStride = (lStride + 3) & ~3;
- DbgLog((LOG_TRACE,3,TEXT("*Changing output type on the fly to")));
- DbgLog((LOG_TRACE,3,TEXT("FourCC: %lx Compression: %lx BitCount: %ld"),
- fccOut.GetFOURCC(), lCompression, lBitCount));
- DbgLog((LOG_TRACE,3,TEXT("biHeight: %ld rcDst: (%ld, %ld, %ld, %ld)"),
- HEADER(pmtOut->pbFormat)->biHeight,
- rcT.left, rcT.top, rcT.right, rcT.bottom));
- DbgLog((LOG_TRACE,3,TEXT("rcSrc: (%ld, %ld, %ld, %ld) Stride: %ld"),
- rcS.left, rcS.top, rcS.right, rcS.bottom,
- lStride));
+ LONG lCompression = HEADER(pmtOut->pbFormat)->biCompression;
+ LONG lBitCount = HEADER(pmtOut->pbFormat)->biBitCount;
+ LONG lStride = (HEADER(pmtOut->pbFormat)->biWidth * lBitCount + 7) / 8;
+ lStride = (lStride + 3) & ~3;
+ DbgLog((LOG_TRACE, 3, TEXT("*Changing output type on the fly to")));
+ DbgLog((LOG_TRACE, 3, TEXT("FourCC: %lx Compression: %lx BitCount: %ld"),
+ fccOut.GetFOURCC(), lCompression, lBitCount));
+ DbgLog((LOG_TRACE, 3, TEXT("biHeight: %ld rcDst: (%ld, %ld, %ld, %ld)"),
+ HEADER(pmtOut->pbFormat)->biHeight,
+ rcT.left, rcT.top, rcT.right, rcT.bottom));
+ DbgLog((LOG_TRACE, 3, TEXT("rcSrc: (%ld, %ld, %ld, %ld) Stride: %ld"),
+ rcS.left, rcS.top, rcS.right, rcS.bottom,
+ lStride));
#endif
- // now switch to using the new format. I am assuming that the
- // derived filter will do the right thing when its media type is
- // switched and streaming is restarted.
+ // now switch to using the new format. I am assuming that the
+ // derived filter will do the right thing when its media type is
+ // switched and streaming is restarted.
- StopStreaming();
- m_pOutput->CurrentMediaType() = *pmtOut;
- DeleteMediaType(pmtOut);
- hr = StartStreaming();
+ StopStreaming();
+ m_pOutput->CurrentMediaType() = *pmtOut;
+ DeleteMediaType(pmtOut);
+ hr = StartStreaming();
- if (SUCCEEDED(hr)) {
- // a new format, means a new empty buffer, so wait for a keyframe
- // before passing anything on to the renderer.
- // !!! a keyframe may never come, so give up after 30 frames
- DbgLog((LOG_TRACE,3,TEXT("Output format change means we must wait for a keyframe")));
- m_nWaitForKey = 30;
+ if(SUCCEEDED(hr))
+ {
+ // a new format, means a new empty buffer, so wait for a keyframe
+ // before passing anything on to the renderer.
+ // !!! a keyframe may never come, so give up after 30 frames
+ DbgLog((LOG_TRACE, 3, TEXT("Output format change means we must wait for a keyframe")));
+ m_nWaitForKey = 30;
- // if this fails, playback will stop, so signal an error
- } else {
+ // if this fails, playback will stop, so signal an error
+ }
+ else
+ {
// Must release the sample before calling AbortPlayback
// because we might be holding the win16 lock or
// ddraw lock
pOutSample->Release();
- AbortPlayback(hr);
+ AbortPlayback(hr);
return hr;
- }
+ }
}
// After a discontinuity, we need to wait for the next key frame
- if (pSample->IsDiscontinuity() == S_OK) {
- DbgLog((LOG_TRACE,3,TEXT("Non-key discontinuity - wait for keyframe")));
- m_nWaitForKey = 30;
+ if(pSample->IsDiscontinuity() == S_OK)
+ {
+ DbgLog((LOG_TRACE, 3, TEXT("Non-key discontinuity - wait for keyframe")));
+ m_nWaitForKey = 30;
}
// Start timing the transform (and log it if PERF is defined)
- if (SUCCEEDED(hr)) {
+ if(SUCCEEDED(hr))
+ {
m_tDecodeStart = timeGetTime();
MSR_START(m_idTransform);
@@ -256,39 +266,47 @@ HRESULT CVideoTransformFilter::Receive(IMediaSample *pSample)
// Stop the clock (and log it if PERF is defined)
MSR_STOP(m_idTransform);
- m_tDecodeStart = timeGetTime()-m_tDecodeStart;
- m_itrAvgDecode = m_tDecodeStart*(10000/16) + 15*(m_itrAvgDecode/16);
+ m_tDecodeStart = timeGetTime() - m_tDecodeStart;
+ m_itrAvgDecode = m_tDecodeStart * (10000 / 16) + 15 * (m_itrAvgDecode / 16);
// Maybe we're waiting for a keyframe still?
- if (m_nWaitForKey)
+ if(m_nWaitForKey)
m_nWaitForKey--;
- if (m_nWaitForKey && pSample->IsSyncPoint() == S_OK)
- m_nWaitForKey = FALSE;
+ if(m_nWaitForKey && pSample->IsSyncPoint() == S_OK)
+ m_nWaitForKey = FALSE;
// if so, then we don't want to pass this on to the renderer
- if (m_nWaitForKey && hr == NOERROR) {
- DbgLog((LOG_TRACE,3,TEXT("still waiting for a keyframe")));
- hr = S_FALSE;
- }
+ if(m_nWaitForKey && hr == NOERROR)
+ {
+ DbgLog((LOG_TRACE, 3, TEXT("still waiting for a keyframe")));
+ hr = S_FALSE;
+ }
}
- if (FAILED(hr)) {
- DbgLog((LOG_TRACE,1,TEXT("Error from video transform")));
- } else {
+ if(FAILED(hr))
+ {
+ DbgLog((LOG_TRACE, 1, TEXT("Error from video transform")));
+ }
+ else
+ {
// the Transform() function can return S_FALSE to indicate that the
// sample should not be delivered; we only deliver the sample if it's
// really S_OK (same as NOERROR, of course.)
// Try not to return S_FALSE to a direct draw buffer (it's wasteful)
// Try to take the decision earlier - before you get it.
- if (hr == NOERROR) {
- hr = m_pOutput->Deliver(pOutSample);
- } else {
+ if(hr == NOERROR)
+ {
+ hr = m_pOutput->Deliver(pOutSample);
+ }
+ else
+ {
// S_FALSE returned from Transform is a PRIVATE agreement
// We should return NOERROR from Receive() in this case because returning S_FALSE
// from Receive() means that this is the end of the stream and no more data should
// be sent.
- if (S_FALSE == hr) {
+ if(S_FALSE == hr)
+ {
// We must Release() the sample before doing anything
// like calling the filter graph because having the
@@ -296,9 +314,10 @@ HRESULT CVideoTransformFilter::Receive(IMediaSample *pSample)
// (== win16 lock on some versions)
pOutSample->Release();
m_bSampleSkipped = TRUE;
- if (!m_bQualityChanged) {
+ if(!m_bQualityChanged)
+ {
m_bQualityChanged = TRUE;
- NotifyEvent(EC_QUALITY_CHANGE,0,0);
+ NotifyEvent(EC_QUALITY_CHANGE, 0, 0);
}
return NOERROR;
}
@@ -315,30 +334,35 @@ HRESULT CVideoTransformFilter::Receive(IMediaSample *pSample)
-BOOL CVideoTransformFilter::ShouldSkipFrame( IMediaSample * pIn)
+BOOL CVideoTransformFilter::ShouldSkipFrame(IMediaSample * pIn)
{
REFERENCE_TIME trStart, trStopAt;
HRESULT hr = pIn->GetTime(&trStart, &trStopAt);
// Don't skip frames with no timestamps
- if (hr != S_OK)
- return FALSE;
+ if(hr != S_OK)
+ return FALSE;
int itrFrame = (int)(trStopAt - trStart); // frame duration
- if(S_OK==pIn->IsSyncPoint()) {
+ if(S_OK == pIn->IsSyncPoint())
+ {
MSR_INTEGER(m_idFrameType, 1);
- if ( m_nKeyFramePeriod < m_nFramesSinceKeyFrame ) {
+ if(m_nKeyFramePeriod < m_nFramesSinceKeyFrame)
+ {
// record the max
m_nKeyFramePeriod = m_nFramesSinceKeyFrame;
}
m_nFramesSinceKeyFrame = 0;
m_bSkipping = FALSE;
- } else {
+ }
+ else
+ {
MSR_INTEGER(m_idFrameType, 2);
- if ( m_nFramesSinceKeyFrame>m_nKeyFramePeriod
- && m_nKeyFramePeriod>0
- ) {
+ if(m_nFramesSinceKeyFrame > m_nKeyFramePeriod
+ && m_nKeyFramePeriod > 0
+ )
+ {
// We haven't seen the key frame yet, but we were clearly being
// overoptimistic about how frequent they are.
m_nKeyFramePeriod = m_nFramesSinceKeyFrame;
@@ -351,11 +375,13 @@ BOOL CVideoTransformFilter::ShouldSkipFrame( IMediaSample * pIn)
// then any quality problems are actually coming from somewhere else.
// Could be a net problem at the source for instance. In this case there's
// no point in us skipping frames here.
- if (m_itrAvgDecode*4>itrFrame) {
+ if(m_itrAvgDecode * 4 > itrFrame)
+ {
// Don't skip unless we are at least a whole frame late.
// (We would skip B frames if more than 1/2 frame late, but they're safe).
- if ( m_itrLate > itrFrame ) {
+ if(m_itrLate > itrFrame)
+ {
// Don't skip unless the anticipated key frame would be no more than
// 1 frame early. If the renderer has not been waiting (we *guess*
@@ -370,13 +396,14 @@ BOOL CVideoTransformFilter::ShouldSkipFrame( IMediaSample * pIn)
// We don't dare skip until we have seen some key frames and have
// some idea how often they occur and they are reasonably frequent.
- if (m_nKeyFramePeriod>0) {
+ if(m_nKeyFramePeriod > 0)
+ {
// It would be crazy - but we could have a stream with key frames
// a very long way apart - and if they are further than about
// 3.5 minutes apart then we could get arithmetic overflow in
// reference time units. Therefore we switch to mSec at this point
- int it = (itrFrame/10000)
- * (m_nKeyFramePeriod-m_nFramesSinceKeyFrame - 1);
+ int it = (itrFrame / 10000)
+ * (m_nKeyFramePeriod - m_nFramesSinceKeyFrame - 1);
MSR_INTEGER(m_idTimeTillKey, it);
// For debug - might want to see the details - dump them as scratch pad
@@ -385,28 +412,37 @@ BOOL CVideoTransformFilter::ShouldSkipFrame( IMediaSample * pIn)
MSR_INTEGER(0, m_nFramesSinceKeyFrame);
MSR_INTEGER(0, m_nKeyFramePeriod);
#endif
- if (m_itrLate/10000 > it) {
+ if(m_itrLate / 10000 > it)
+ {
m_bSkipping = TRUE;
// Now we are committed. Once we start skipping, we
// cannot stop until we hit a key frame.
- } else {
+ }
+ else
+ {
#ifdef VTRANSPERF
MSR_INTEGER(0, 777770); // not near enough to next key
#endif
}
- } else {
+ }
+ else
+ {
#ifdef VTRANSPERF
MSR_INTEGER(0, 777771); // Next key not predictable
#endif
}
- } else {
+ }
+ else
+ {
#ifdef VTRANSPERF
MSR_INTEGER(0, 777772); // Less than one frame late
MSR_INTEGER(0, m_itrLate);
MSR_INTEGER(0, itrFrame);
#endif
}
- } else {
+ }
+ else
+ {
#ifdef VTRANSPERF
MSR_INTEGER(0, 777773); // Decode time short - not not worth skipping
MSR_INTEGER(0, m_itrAvgDecode);
@@ -416,7 +452,8 @@ BOOL CVideoTransformFilter::ShouldSkipFrame( IMediaSample * pIn)
++m_nFramesSinceKeyFrame;
- if (m_bSkipping) {
+ if(m_bSkipping)
+ {
// We will count down the lateness as we skip each frame.
// We re-assess each frame. The key frame might not arrive when expected.
// We reset m_itrLate if we get a new Quality message, but actually that's
@@ -427,11 +464,13 @@ BOOL CVideoTransformFilter::ShouldSkipFrame( IMediaSample * pIn)
m_itrLate = m_itrLate - itrFrame;
}
- MSR_INTEGER(m_idLate, (int)m_itrLate/10000 ); // Note how late we think we are
- if (m_bSkipping) {
- if (!m_bQualityChanged) {
+ MSR_INTEGER(m_idLate, (int)m_itrLate / 10000); // Note how late we think we are
+ if(m_bSkipping)
+ {
+ if(!m_bQualityChanged)
+ {
m_bQualityChanged = TRUE;
- NotifyEvent(EC_QUALITY_CHANGE,0,0);
+ NotifyEvent(EC_QUALITY_CHANGE, 0, 0);
}
}
return m_bSkipping;
@@ -442,10 +481,13 @@ HRESULT CVideoTransformFilter::AlterQuality(Quality q)
{
// to reduce the amount of 64 bit arithmetic, m_itrLate is an int.
// +, -, >, == etc are not too bad, but * and / are painful.
- if (m_itrLate>300000000) {
+ if(m_itrLate > 300000000)
+ {
// Avoid overflow and silliness - more than 30 secs late is already silly
m_itrLate = 300000000;
- } else {
+ }
+ else
+ {
m_itrLate = (int)q.Late;
}
// We ignore the other fields
diff --git a/src/filters/BaseClasses/vtrans.h b/src/filters/BaseClasses/vtrans.h
index 49b1509b1..d8cf55bdf 100644
--- a/src/filters/BaseClasses/vtrans.h
+++ b/src/filters/BaseClasses/vtrans.h
@@ -13,7 +13,7 @@
class CVideoTransformFilter : public CTransformFilter
{
- public:
+public:
CVideoTransformFilter(__in_opt LPCTSTR, __inout_opt LPUNKNOWN, REFCLSID clsid);
~CVideoTransformFilter();
@@ -53,7 +53,8 @@ class CVideoTransformFilter : public CTransformFilter
// If you override this - ensure that you register all these ids
// as well as any of your own,
- virtual void RegisterPerfId() {
+ virtual void RegisterPerfId()
+ {
m_idSkip = MSR_REGISTER(TEXT("Video Transform Skip frame"));
m_idFrameType = MSR_REGISTER(TEXT("Video transform frame type"));
m_idLate = MSR_REGISTER(TEXT("Video Transform Lateness"));
@@ -62,7 +63,7 @@ class CVideoTransformFilter : public CTransformFilter
}
#endif
- protected:
+protected:
// =========== QUALITY MANAGEMENT IMPLEMENTATION ========================
// Frames are assumed to come in three types:
@@ -101,10 +102,10 @@ class CVideoTransformFilter : public CTransformFilter
// the quality management here if you have B-frames.
int m_nKeyFramePeriod; // the largest observed interval between type 1 frames
- // 1 means every frame is type 1, 2 means every other.
+ // 1 means every frame is type 1, 2 means every other.
int m_nFramesSinceKeyFrame; // Used to count frames since the last type 1.
- // becomes the new m_nKeyFramePeriod if greater.
+ // becomes the new m_nKeyFramePeriod if greater.
BOOL m_bSkipping; // we are skipping to the next type 1 frame
@@ -126,7 +127,7 @@ class CVideoTransformFilter : public CTransformFilter
BOOL ShouldSkipFrame(IMediaSample * pIn);
int m_itrLate; // lateness from last Quality message
- // (this overflows at 214 secs late).
+ // (this overflows at 214 secs late).
int m_tDecodeStart; // timeGetTime when decode started.
int m_itrAvgDecode; // Average decode time in reference units.
diff --git a/src/filters/BaseClasses/winctrl.cpp b/src/filters/BaseClasses/winctrl.cpp
index 9b2c0df6d..1c6b3669d 100644
--- a/src/filters/BaseClasses/winctrl.cpp
+++ b/src/filters/BaseClasses/winctrl.cpp
@@ -30,46 +30,46 @@
BOOL WINAPI PossiblyEatMessage(HWND hwndDrain, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- if (hwndDrain != NULL && !InSendMessage())
+ if(hwndDrain != NULL && !InSendMessage())
{
- switch (uMsg)
+ switch(uMsg)
{
- case WM_CHAR:
- case WM_DEADCHAR:
- case WM_KEYDOWN:
- case WM_KEYUP:
- case WM_LBUTTONDBLCLK:
- case WM_LBUTTONDOWN:
- case WM_LBUTTONUP:
- case WM_MBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- case WM_MBUTTONUP:
- case WM_MOUSEACTIVATE:
- case WM_MOUSEMOVE:
+ case WM_CHAR:
+ case WM_DEADCHAR:
+ case WM_KEYDOWN:
+ case WM_KEYUP:
+ case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDOWN:
+ case WM_LBUTTONUP:
+ case WM_MBUTTONDBLCLK:
+ case WM_MBUTTONDOWN:
+ case WM_MBUTTONUP:
+ case WM_MOUSEACTIVATE:
+ case WM_MOUSEMOVE:
// If we pass this on we don't get any mouse clicks
//case WM_NCHITTEST:
- case WM_NCLBUTTONDBLCLK:
- case WM_NCLBUTTONDOWN:
- case WM_NCLBUTTONUP:
- case WM_NCMBUTTONDBLCLK:
- case WM_NCMBUTTONDOWN:
- case WM_NCMBUTTONUP:
- case WM_NCMOUSEMOVE:
- case WM_NCRBUTTONDBLCLK:
- case WM_NCRBUTTONDOWN:
- case WM_NCRBUTTONUP:
- case WM_RBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
- case WM_RBUTTONUP:
- case WM_SYSCHAR:
- case WM_SYSDEADCHAR:
- case WM_SYSKEYDOWN:
- case WM_SYSKEYUP:
-
- DbgLog((LOG_TRACE, 2, TEXT("Forwarding %x to drain")));
- PostMessage(hwndDrain, uMsg, wParam, lParam);
-
- return TRUE;
+ case WM_NCLBUTTONDBLCLK:
+ case WM_NCLBUTTONDOWN:
+ case WM_NCLBUTTONUP:
+ case WM_NCMBUTTONDBLCLK:
+ case WM_NCMBUTTONDOWN:
+ case WM_NCMBUTTONUP:
+ case WM_NCMOUSEMOVE:
+ case WM_NCRBUTTONDBLCLK:
+ case WM_NCRBUTTONDOWN:
+ case WM_NCRBUTTONUP:
+ case WM_RBUTTONDBLCLK:
+ case WM_RBUTTONDOWN:
+ case WM_RBUTTONUP:
+ case WM_SYSCHAR:
+ case WM_SYSDEADCHAR:
+ case WM_SYSKEYDOWN:
+ case WM_SYSKEYUP:
+
+ DbgLog((LOG_TRACE, 2, TEXT("Forwarding %x to drain")));
+ PostMessage(hwndDrain, uMsg, wParam, lParam);
+
+ return TRUE;
}
}
return FALSE;
@@ -84,13 +84,13 @@ BOOL WINAPI PossiblyEatMessage(HWND hwndDrain, UINT uMsg, WPARAM wParam, LPARAM
// more direct and efficient mechanism as many values may be changed in one
CBaseControlWindow::CBaseControlWindow(
- __inout CBaseFilter *pFilter, // Owning filter
- __in CCritSec *pInterfaceLock, // Locking object
- __in_opt LPCTSTR pName, // Object description
- __inout_opt LPUNKNOWN pUnk, // Normal COM ownership
- __inout HRESULT *phr) : // OLE return code
+ __inout CBaseFilter *pFilter, // Owning filter
+ __in CCritSec *pInterfaceLock, // Locking object
+ __in_opt LPCTSTR pName, // Object description
+ __inout_opt LPUNKNOWN pUnk, // Normal COM ownership
+ __inout HRESULT *phr) : // OLE return code
- CBaseVideoWindow(pName,pUnk),
+ CBaseVideoWindow(pName, pUnk),
m_pInterfaceLock(pInterfaceLock),
m_hwndOwner(NULL),
m_hwndDrain(NULL),
@@ -113,14 +113,14 @@ CBaseControlWindow::CBaseControlWindow(
STDMETHODIMP CBaseControlWindow::put_Caption(__in BSTR strCaption)
{
- CheckPointer((PVOID)strCaption,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer((PVOID)strCaption, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
#ifdef UNICODE
SetWindowText(m_hwnd, strCaption);
#else
CHAR Caption[CAPTION];
- WideCharToMultiByte(CP_ACP,0,strCaption,-1,Caption,CAPTION,NULL,NULL);
+ WideCharToMultiByte(CP_ACP, 0, strCaption, -1, Caption, CAPTION, NULL, NULL);
SetWindowText(m_hwnd, Caption);
#endif
return NOERROR;
@@ -135,20 +135,20 @@ STDMETHODIMP CBaseControlWindow::put_Caption(__in BSTR strCaption)
STDMETHODIMP CBaseControlWindow::get_Caption(__out BSTR *pstrCaption)
{
- CheckPointer(pstrCaption,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pstrCaption, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
WCHAR WideCaption[CAPTION];
#ifdef UNICODE
- GetWindowText(m_hwnd,WideCaption,CAPTION);
+ GetWindowText(m_hwnd, WideCaption, CAPTION);
#else
// Convert the ASCII caption to a UNICODE string
TCHAR Caption[CAPTION];
- GetWindowText(m_hwnd,Caption,CAPTION);
- MultiByteToWideChar(CP_ACP,0,Caption,-1,WideCaption,CAPTION);
+ GetWindowText(m_hwnd, Caption, CAPTION);
+ MultiByteToWideChar(CP_ACP, 0, Caption, -1, WideCaption, CAPTION);
#endif
- return WriteBSTR(pstrCaption,WideCaption);
+ return WriteBSTR(pstrCaption, WideCaption);
}
@@ -156,24 +156,27 @@ STDMETHODIMP CBaseControlWindow::get_Caption(__out BSTR *pstrCaption)
STDMETHODIMP CBaseControlWindow::put_WindowStyleEx(long WindowStyleEx)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
// Should we be taking off WS_EX_TOPMOST
- if (GetWindowLong(m_hwnd,GWL_EXSTYLE) & WS_EX_TOPMOST) {
- if ((WindowStyleEx & WS_EX_TOPMOST) == 0) {
- SendMessage(m_hwnd,m_ShowStageTop,(WPARAM) FALSE,(LPARAM) 0);
+ if(GetWindowLong(m_hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
+ {
+ if((WindowStyleEx & WS_EX_TOPMOST) == 0)
+ {
+ SendMessage(m_hwnd, m_ShowStageTop, (WPARAM) FALSE, (LPARAM) 0);
}
}
// Likewise should we be adding WS_EX_TOPMOST
- if (WindowStyleEx & WS_EX_TOPMOST) {
- SendMessage(m_hwnd,m_ShowStageTop,(WPARAM) TRUE,(LPARAM) 0);
+ if(WindowStyleEx & WS_EX_TOPMOST)
+ {
+ SendMessage(m_hwnd, m_ShowStageTop, (WPARAM) TRUE, (LPARAM) 0);
WindowStyleEx &= (~WS_EX_TOPMOST);
- if (WindowStyleEx == 0) return NOERROR;
+ if(WindowStyleEx == 0) return NOERROR;
}
- return DoSetWindowStyle(WindowStyleEx,GWL_EXSTYLE);
+ return DoSetWindowStyle(WindowStyleEx, GWL_EXSTYLE);
}
@@ -181,9 +184,9 @@ STDMETHODIMP CBaseControlWindow::put_WindowStyleEx(long WindowStyleEx)
STDMETHODIMP CBaseControlWindow::get_WindowStyleEx(__out long *pWindowStyleEx)
{
- CheckPointer(pWindowStyleEx,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
- return DoGetWindowStyle(pWindowStyleEx,GWL_EXSTYLE);
+ CheckPointer(pWindowStyleEx, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
+ return DoGetWindowStyle(pWindowStyleEx, GWL_EXSTYLE);
}
@@ -193,18 +196,19 @@ STDMETHODIMP CBaseControlWindow::put_WindowStyle(long WindowStyle)
{
// These styles cannot be changed dynamically
- if ((WindowStyle & WS_DISABLED) ||
- (WindowStyle & WS_ICONIC) ||
- (WindowStyle & WS_MAXIMIZE) ||
- (WindowStyle & WS_MINIMIZE) ||
- (WindowStyle & WS_HSCROLL) ||
- (WindowStyle & WS_VSCROLL)) {
+ if((WindowStyle & WS_DISABLED) ||
+ (WindowStyle & WS_ICONIC) ||
+ (WindowStyle & WS_MAXIMIZE) ||
+ (WindowStyle & WS_MINIMIZE) ||
+ (WindowStyle & WS_HSCROLL) ||
+ (WindowStyle & WS_VSCROLL))
+ {
- return E_INVALIDARG;
+ return E_INVALIDARG;
}
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
- return DoSetWindowStyle(WindowStyle,GWL_STYLE);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
+ return DoSetWindowStyle(WindowStyle, GWL_STYLE);
}
@@ -212,9 +216,9 @@ STDMETHODIMP CBaseControlWindow::put_WindowStyle(long WindowStyle)
STDMETHODIMP CBaseControlWindow::get_WindowStyle(__out long *pWindowStyle)
{
- CheckPointer(pWindowStyle,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
- return DoGetWindowStyle(pWindowStyle,GWL_STYLE);
+ CheckPointer(pWindowStyle, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
+ return DoGetWindowStyle(pWindowStyle, GWL_STYLE);
}
@@ -225,26 +229,27 @@ STDMETHODIMP CBaseControlWindow::get_WindowStyle(__out long *pWindowStyle)
// In most cases the client will call get_WindowStyle before they call this
// and then AND and OR in extra bit settings according to the requirements
-HRESULT CBaseControlWindow::DoSetWindowStyle(long Style,long WindowLong)
+HRESULT CBaseControlWindow::DoSetWindowStyle(long Style, long WindowLong)
{
RECT WindowRect;
// Get the window's visibility before setting the style
BOOL bVisible = IsWindowVisible(m_hwnd);
- EXECUTE_ASSERT(GetWindowRect(m_hwnd,&WindowRect));
+ EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));
// Set the new style flags for the window
- SetWindowLong(m_hwnd,WindowLong,Style);
+ SetWindowLong(m_hwnd, WindowLong, Style);
UINT WindowFlags = SWP_SHOWWINDOW | SWP_FRAMECHANGED | SWP_NOACTIVATE;
WindowFlags |= SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE;
// Show the window again in the current position
- if (bVisible == TRUE) {
+ if(bVisible == TRUE)
+ {
SetWindowPos(m_hwnd, // Base window handle
HWND_TOP, // Just a place holder
- 0,0,0,0, // Leave size and position
+ 0, 0, 0, 0, // Leave size and position
WindowFlags); // Just draw it again
return NOERROR;
@@ -263,12 +268,13 @@ HRESULT CBaseControlWindow::DoSetWindowStyle(long Style,long WindowLong)
SetWindowPos(m_hwnd, // Base window handle
HWND_TOP, // Just a place holder
- 0,0,0,0, // Leave size and position
+ 0, 0, 0, 0, // Leave size and position
WindowFlags); // Just draw it again
- ShowWindow(m_hwnd,SW_HIDE);
+ ShowWindow(m_hwnd, SW_HIDE);
- if (GetParent(m_hwnd)) {
+ if(GetParent(m_hwnd))
+ {
MapWindowPoints(HWND_DESKTOP, GetParent(m_hwnd), (LPPOINT)&WindowRect, 2);
}
@@ -286,9 +292,9 @@ HRESULT CBaseControlWindow::DoSetWindowStyle(long Style,long WindowLong)
// Get the current base window style (either GWL_STYLE or GWL_EXSTYLE)
-HRESULT CBaseControlWindow::DoGetWindowStyle(__out long *pStyle,long WindowLong)
+HRESULT CBaseControlWindow::DoGetWindowStyle(__out long *pStyle, long WindowLong)
{
- *pStyle = GetWindowLong(m_hwnd,WindowLong);
+ *pStyle = GetWindowLong(m_hwnd, WindowLong);
return NOERROR;
}
@@ -300,7 +306,7 @@ HRESULT CBaseControlWindow::DoGetWindowStyle(__out long *pStyle,long WindowLong)
STDMETHODIMP CBaseControlWindow::put_WindowState(long WindowState)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
DoShowWindow(WindowState);
return NOERROR;
}
@@ -314,8 +320,8 @@ STDMETHODIMP CBaseControlWindow::put_WindowState(long WindowState)
STDMETHODIMP CBaseControlWindow::get_WindowState(__out long *pWindowState)
{
- CheckPointer(pWindowState,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pWindowState, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
ASSERT(pWindowState);
*pWindowState = FALSE;
@@ -323,24 +329,30 @@ STDMETHODIMP CBaseControlWindow::get_WindowState(__out long *pWindowState)
// the current desktop even if it is completely obscured by other windows
// so the flag is a style for each window set with the WS_VISIBLE bit
- if (IsWindowVisible(m_hwnd) == TRUE) {
+ if(IsWindowVisible(m_hwnd) == TRUE)
+ {
// Is the base window iconic
- if (IsIconic(m_hwnd) == TRUE) {
+ if(IsIconic(m_hwnd) == TRUE)
+ {
*pWindowState |= SW_MINIMIZE;
}
// Has the window been maximised
- else if (IsZoomed(m_hwnd) == TRUE) {
+ else if(IsZoomed(m_hwnd) == TRUE)
+ {
*pWindowState |= SW_MAXIMIZE;
}
// Window is normal
- else {
+ else
+ {
*pWindowState |= SW_SHOW;
}
- } else {
+ }
+ else
+ {
*pWindowState |= SW_HIDE;
}
return NOERROR;
@@ -355,13 +367,15 @@ STDMETHODIMP CBaseControlWindow::get_WindowState(__out long *pWindowState)
STDMETHODIMP CBaseControlWindow::put_BackgroundPalette(long BackgroundPalette)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cWindowLock(&m_WindowLock);
// Check this is a valid automation boolean type
- if (BackgroundPalette != OATRUE) {
- if (BackgroundPalette != OAFALSE) {
+ if(BackgroundPalette != OATRUE)
+ {
+ if(BackgroundPalette != OAFALSE)
+ {
return E_INVALIDARG;
}
}
@@ -369,7 +383,7 @@ STDMETHODIMP CBaseControlWindow::put_BackgroundPalette(long BackgroundPalette)
// Make sure the window realises any palette it has again
m_bBackground = (BackgroundPalette == OATRUE ? TRUE : FALSE);
- PostMessage(m_hwnd,m_RealizePalette,0,0);
+ PostMessage(m_hwnd, m_RealizePalette, 0, 0);
PaintWindow(FALSE);
return NOERROR;
@@ -381,8 +395,8 @@ STDMETHODIMP CBaseControlWindow::put_BackgroundPalette(long BackgroundPalette)
STDMETHODIMP
CBaseControlWindow::get_BackgroundPalette(__out long *pBackgroundPalette)
{
- CheckPointer(pBackgroundPalette,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pBackgroundPalette, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cWindowLock(&m_WindowLock);
// Get the current background palette setting
@@ -396,12 +410,14 @@ CBaseControlWindow::get_BackgroundPalette(__out long *pBackgroundPalette)
STDMETHODIMP CBaseControlWindow::put_Visible(long Visible)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
// Check this is a valid automation boolean type
- if (Visible != OATRUE) {
- if (Visible != OAFALSE) {
+ if(Visible != OATRUE)
+ {
+ if(Visible != OAFALSE)
+ {
return E_INVALIDARG;
}
}
@@ -418,8 +434,8 @@ STDMETHODIMP CBaseControlWindow::put_Visible(long Visible)
STDMETHODIMP CBaseControlWindow::get_Visible(__out long *pVisible)
{
- CheckPointer(pVisible,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pVisible, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
// See if the base window has a WS_VISIBLE style - this will return TRUE
// even if the window is completely obscured by other desktop windows, we
@@ -437,14 +453,15 @@ STDMETHODIMP CBaseControlWindow::get_Visible(__out long *pVisible)
STDMETHODIMP CBaseControlWindow::put_Left(long Left)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
BOOL bSuccess;
RECT WindowRect;
// Get the current window position in a RECT
- EXECUTE_ASSERT(GetWindowRect(m_hwnd,&WindowRect));
+ EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));
- if (GetParent(m_hwnd)) {
+ if(GetParent(m_hwnd))
+ {
MapWindowPoints(HWND_DESKTOP, GetParent(m_hwnd), (LPPOINT)&WindowRect, 2);
}
@@ -465,7 +482,8 @@ STDMETHODIMP CBaseControlWindow::put_Left(long Left)
WindowRect.bottom, // The HEIGHT (not bottom)
WindowFlags); // Show window options
- if (bSuccess == FALSE) {
+ if(bSuccess == FALSE)
+ {
return E_INVALIDARG;
}
return NOERROR;
@@ -476,11 +494,11 @@ STDMETHODIMP CBaseControlWindow::put_Left(long Left)
STDMETHODIMP CBaseControlWindow::get_Left(__out long *pLeft)
{
- CheckPointer(pLeft,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pLeft, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
RECT WindowRect;
- EXECUTE_ASSERT(GetWindowRect(m_hwnd,&WindowRect));
+ EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));
*pLeft = WindowRect.left;
return NOERROR;
}
@@ -493,7 +511,7 @@ STDMETHODIMP CBaseControlWindow::get_Left(__out long *pLeft)
STDMETHODIMP CBaseControlWindow::put_Width(long Width)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
BOOL bSuccess;
RECT WindowRect;
@@ -501,9 +519,10 @@ STDMETHODIMP CBaseControlWindow::put_Width(long Width)
// get back from GetWindowRect is in left,top,right and bottom while the
// coordinates SetWindowPos wants are left,top,width and height values
- EXECUTE_ASSERT(GetWindowRect(m_hwnd,&WindowRect));
+ EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));
- if (GetParent(m_hwnd)) {
+ if(GetParent(m_hwnd))
+ {
MapWindowPoints(HWND_DESKTOP, GetParent(m_hwnd), (LPPOINT)&WindowRect, 2);
}
@@ -523,7 +542,8 @@ STDMETHODIMP CBaseControlWindow::put_Width(long Width)
WindowRect.bottom, // The HEIGHT (not bottom)
WindowFlags); // Show window options
- if (bSuccess == FALSE) {
+ if(bSuccess == FALSE)
+ {
return E_INVALIDARG;
}
return NOERROR;
@@ -534,11 +554,11 @@ STDMETHODIMP CBaseControlWindow::put_Width(long Width)
STDMETHODIMP CBaseControlWindow::get_Width(__out long *pWidth)
{
- CheckPointer(pWidth,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pWidth, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
RECT WindowRect;
- EXECUTE_ASSERT(GetWindowRect(m_hwnd,&WindowRect));
+ EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));
*pWidth = WindowRect.right - WindowRect.left;
return NOERROR;
}
@@ -550,14 +570,15 @@ STDMETHODIMP CBaseControlWindow::get_Width(__out long *pWidth)
STDMETHODIMP CBaseControlWindow::put_Top(long Top)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
BOOL bSuccess;
RECT WindowRect;
// Get the current window position in a RECT
- EXECUTE_ASSERT(GetWindowRect(m_hwnd,&WindowRect));
+ EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));
- if (GetParent(m_hwnd)) {
+ if(GetParent(m_hwnd))
+ {
MapWindowPoints(HWND_DESKTOP, GetParent(m_hwnd), (LPPOINT)&WindowRect, 2);
}
@@ -578,7 +599,8 @@ STDMETHODIMP CBaseControlWindow::put_Top(long Top)
WindowRect.bottom, // The HEIGHT (not bottom)
WindowFlags); // Show window flags
- if (bSuccess == FALSE) {
+ if(bSuccess == FALSE)
+ {
return E_INVALIDARG;
}
return NOERROR;
@@ -589,11 +611,11 @@ STDMETHODIMP CBaseControlWindow::put_Top(long Top)
STDMETHODIMP CBaseControlWindow::get_Top(long *pTop)
{
- CheckPointer(pTop,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pTop, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
RECT WindowRect;
- EXECUTE_ASSERT(GetWindowRect(m_hwnd,&WindowRect));
+ EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));
*pTop = WindowRect.top;
return NOERROR;
}
@@ -606,7 +628,7 @@ STDMETHODIMP CBaseControlWindow::get_Top(long *pTop)
STDMETHODIMP CBaseControlWindow::put_Height(long Height)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
BOOL bSuccess;
RECT WindowRect;
@@ -614,9 +636,10 @@ STDMETHODIMP CBaseControlWindow::put_Height(long Height)
// get back from GetWindowRect is in left,top,right and bottom while the
// coordinates SetWindowPos wants are left,top,width and height values
- EXECUTE_ASSERT(GetWindowRect(m_hwnd,&WindowRect));
+ EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));
- if (GetParent(m_hwnd)) {
+ if(GetParent(m_hwnd))
+ {
MapWindowPoints(HWND_DESKTOP, GetParent(m_hwnd), (LPPOINT)&WindowRect, 2);
}
@@ -632,7 +655,8 @@ STDMETHODIMP CBaseControlWindow::put_Height(long Height)
Height, // New height dimension
WindowFlags); // Show window flags
- if (bSuccess == FALSE) {
+ if(bSuccess == FALSE)
+ {
return E_INVALIDARG;
}
return NOERROR;
@@ -643,11 +667,11 @@ STDMETHODIMP CBaseControlWindow::put_Height(long Height)
STDMETHODIMP CBaseControlWindow::get_Height(__out long *pHeight)
{
- CheckPointer(pHeight,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pHeight, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
RECT WindowRect;
- EXECUTE_ASSERT(GetWindowRect(m_hwnd,&WindowRect));
+ EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));
*pHeight = WindowRect.bottom - WindowRect.top;
return NOERROR;
}
@@ -668,26 +692,29 @@ STDMETHODIMP CBaseControlWindow::put_Owner(OAHWND Owner)
{
// Check we are connected otherwise reject the call
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
m_hwndOwner = (HWND) Owner;
HWND hwndParent = m_hwndOwner;
// Add or remove WS_CHILD as appropriate
- LONG Style = GetWindowLong(m_hwnd,GWL_STYLE);
- if (Owner == NULL) {
+ LONG Style = GetWindowLong(m_hwnd, GWL_STYLE);
+ if(Owner == NULL)
+ {
Style &= (~WS_CHILD);
- } else {
+ }
+ else
+ {
Style |= (WS_CHILD);
}
- SetWindowLong(m_hwnd,GWL_STYLE,Style);
+ SetWindowLong(m_hwnd, GWL_STYLE, Style);
// Don't call this with the filter locked
- SetParent(m_hwnd,hwndParent);
+ SetParent(m_hwnd, hwndParent);
PaintWindow(TRUE);
- NOTE1("Changed parent %lx",hwndParent);
+ NOTE1("Changed parent %lx", hwndParent);
return NOERROR;
}
@@ -701,8 +728,8 @@ STDMETHODIMP CBaseControlWindow::put_Owner(OAHWND Owner)
STDMETHODIMP CBaseControlWindow::get_Owner(__out OAHWND *Owner)
{
- CheckPointer(Owner,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(Owner, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
*Owner = (OAHWND) m_hwndOwner;
return NOERROR;
}
@@ -717,7 +744,7 @@ STDMETHODIMP CBaseControlWindow::put_MessageDrain(OAHWND Drain)
{
// Check we are connected otherwise reject the call
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
m_hwndDrain = (HWND) Drain;
return NOERROR;
}
@@ -727,8 +754,8 @@ STDMETHODIMP CBaseControlWindow::put_MessageDrain(OAHWND Drain)
STDMETHODIMP CBaseControlWindow::get_MessageDrain(__out OAHWND *Drain)
{
- CheckPointer(Drain,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(Drain, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
*Drain = (OAHWND) m_hwndDrain;
return NOERROR;
}
@@ -747,35 +774,37 @@ CBaseControlWindow::NotifyOwnerMessage(OAHWND hwnd, // Window handle
LONG_PTR wParam, // Parameters
LONG_PTR lParam) // for message
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
// Only interested in these Windows messages
- switch (uMsg) {
+ switch(uMsg)
+ {
- case WM_SYSCOLORCHANGE:
- case WM_PALETTECHANGED:
- case WM_PALETTEISCHANGING:
- case WM_QUERYNEWPALETTE:
- case WM_DEVMODECHANGE:
- case WM_DISPLAYCHANGE:
- case WM_ACTIVATEAPP:
+ case WM_SYSCOLORCHANGE:
+ case WM_PALETTECHANGED:
+ case WM_PALETTEISCHANGING:
+ case WM_QUERYNEWPALETTE:
+ case WM_DEVMODECHANGE:
+ case WM_DISPLAYCHANGE:
+ case WM_ACTIVATEAPP:
- // If we do not have an owner then ignore
+ // If we do not have an owner then ignore
- if (m_hwndOwner == NULL) {
- return NOERROR;
- }
- SendMessage(m_hwnd,uMsg,(WPARAM)wParam,(LPARAM)lParam);
- break;
+ if(m_hwndOwner == NULL)
+ {
+ return NOERROR;
+ }
+ SendMessage(m_hwnd, uMsg, (WPARAM)wParam, (LPARAM)lParam);
+ break;
- // do NOT fwd WM_MOVE. the parameters are the location of the parent
- // window, NOT what the renderer should be looking at. But we need
- // to make sure the overlay is moved with the parent window, so we
- // do this.
- case WM_MOVE:
- PostMessage(m_hwnd,WM_PAINT,0,0);
- break;
+ // do NOT fwd WM_MOVE. the parameters are the location of the parent
+ // window, NOT what the renderer should be looking at. But we need
+ // to make sure the overlay is moved with the parent window, so we
+ // do this.
+ case WM_MOVE:
+ PostMessage(m_hwnd, WM_PAINT, 0, 0);
+ break;
}
return NOERROR;
}
@@ -789,15 +818,17 @@ STDMETHODIMP CBaseControlWindow::SetWindowForeground(long Focus)
{
// Check this is a valid automation boolean type
- if (Focus != OATRUE) {
- if (Focus != OAFALSE) {
+ if(Focus != OATRUE)
+ {
+ if(Focus != OAFALSE)
+ {
return E_INVALIDARG;
}
}
// We shouldn't lock as this sends a message
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
BOOL bFocus = (Focus == OATRUE ? TRUE : FALSE);
DoSetWindowForeground(bFocus);
@@ -811,9 +842,9 @@ STDMETHODIMP CBaseControlWindow::SetWindowForeground(long Focus)
// occur as each of them gets updated (they are better set at design time)
STDMETHODIMP
-CBaseControlWindow::SetWindowPosition(long Left,long Top,long Width,long Height)
+CBaseControlWindow::SetWindowPosition(long Left, long Top, long Width, long Height)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
BOOL bSuccess;
// Set the new size and position
@@ -831,7 +862,8 @@ CBaseControlWindow::SetWindowPosition(long Left,long Top,long Width,long Height)
#ifdef _DEBUG
DbgLog((LOG_TRACE, 1, TEXT("SWP failed error %d"), GetLastError()));
#endif
- if (bSuccess == FALSE) {
+ if(bSuccess == FALSE)
+ {
return E_INVALIDARG;
}
return NOERROR;
@@ -844,20 +876,20 @@ CBaseControlWindow::SetWindowPosition(long Left,long Top,long Width,long Height)
// therefore more suitable to a live environment rather than design time
STDMETHODIMP
-CBaseControlWindow::GetWindowPosition(__out long *pLeft,__out long *pTop,__out long *pWidth,__out long *pHeight)
+CBaseControlWindow::GetWindowPosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight)
{
// Should check the pointers are not NULL
- CheckPointer(pLeft,E_POINTER);
- CheckPointer(pTop,E_POINTER);
- CheckPointer(pWidth,E_POINTER);
- CheckPointer(pHeight,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pLeft, E_POINTER);
+ CheckPointer(pTop, E_POINTER);
+ CheckPointer(pWidth, E_POINTER);
+ CheckPointer(pHeight, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
RECT WindowRect;
// Get the current window coordinates
- EXECUTE_ASSERT(GetWindowRect(m_hwnd,&WindowRect));
+ EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));
// Convert the RECT into left,top,width and height values
@@ -877,28 +909,30 @@ CBaseControlWindow::GetWindowPosition(__out long *pLeft,__out long *pTop,__out l
// maximised) then this returns the same coordinates as GetWindowPosition
STDMETHODIMP
-CBaseControlWindow::GetRestorePosition(__out long *pLeft,__out long *pTop,__out long *pWidth,__out long *pHeight)
+CBaseControlWindow::GetRestorePosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight)
{
// Should check the pointers are not NULL
- CheckPointer(pLeft,E_POINTER);
- CheckPointer(pTop,E_POINTER);
- CheckPointer(pWidth,E_POINTER);
- CheckPointer(pHeight,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pLeft, E_POINTER);
+ CheckPointer(pTop, E_POINTER);
+ CheckPointer(pWidth, E_POINTER);
+ CheckPointer(pHeight, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
// Use GetWindowPlacement to find the restore position
WINDOWPLACEMENT Place;
Place.length = sizeof(WINDOWPLACEMENT);
- EXECUTE_ASSERT(GetWindowPlacement(m_hwnd,&Place));
+ EXECUTE_ASSERT(GetWindowPlacement(m_hwnd, &Place));
RECT WorkArea;
// We must take into account any task bar present
- if (SystemParametersInfo(SPI_GETWORKAREA,0,&WorkArea,FALSE) == TRUE) {
- if (GetParent(m_hwnd) == NULL) {
+ if(SystemParametersInfo(SPI_GETWORKAREA, 0, &WorkArea, FALSE) == TRUE)
+ {
+ if(GetParent(m_hwnd) == NULL)
+ {
Place.rcNormalPosition.top += WorkArea.top;
Place.rcNormalPosition.bottom += WorkArea.top;
Place.rcNormalPosition.left += WorkArea.left;
@@ -924,8 +958,8 @@ CBaseControlWindow::GetRestorePosition(__out long *pLeft,__out long *pTop,__out
STDMETHODIMP CBaseControlWindow::get_BorderColor(__out long *Color)
{
- CheckPointer(Color,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(Color, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
*Color = (long) m_BorderColour;
return NOERROR;
}
@@ -935,7 +969,7 @@ STDMETHODIMP CBaseControlWindow::get_BorderColor(__out long *Color)
STDMETHODIMP CBaseControlWindow::put_BorderColor(long Color)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
// Have the window repainted with the new border colour
@@ -949,8 +983,8 @@ STDMETHODIMP CBaseControlWindow::put_BorderColor(long Color)
STDMETHODIMP CBaseControlWindow::get_FullScreenMode(__out long *FullScreenMode)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
- CheckPointer(FullScreenMode,E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
+ CheckPointer(FullScreenMode, E_POINTER);
return E_NOTIMPL;
}
@@ -970,12 +1004,14 @@ STDMETHODIMP CBaseControlWindow::put_FullScreenMode(long FullScreenMode)
STDMETHODIMP CBaseControlWindow::put_AutoShow(long AutoShow)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
// Check this is a valid automation boolean type
- if (AutoShow != OATRUE) {
- if (AutoShow != OAFALSE) {
+ if(AutoShow != OATRUE)
+ {
+ if(AutoShow != OAFALSE)
+ {
return E_INVALIDARG;
}
}
@@ -991,8 +1027,8 @@ STDMETHODIMP CBaseControlWindow::put_AutoShow(long AutoShow)
STDMETHODIMP CBaseControlWindow::get_AutoShow(__out long *AutoShow)
{
- CheckPointer(AutoShow,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(AutoShow, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
*AutoShow = (m_bAutoShow == TRUE ? OATRUE : OAFALSE);
return NOERROR;
}
@@ -1004,17 +1040,18 @@ STDMETHODIMP CBaseControlWindow::get_AutoShow(__out long *AutoShow)
// cards have a minimum stretch factor depending on the overlay surface size
STDMETHODIMP
-CBaseControlWindow::GetMinIdealImageSize(__out long *pWidth,__out long *pHeight)
+CBaseControlWindow::GetMinIdealImageSize(__out long *pWidth, __out long *pHeight)
{
- CheckPointer(pWidth,E_POINTER);
- CheckPointer(pHeight,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pWidth, E_POINTER);
+ CheckPointer(pHeight, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
FILTER_STATE State;
// Must not be stopped for this to work correctly
- m_pFilter->GetState(0,&State);
- if (State == State_Stopped) {
+ m_pFilter->GetState(0, &State);
+ if(State == State_Stopped)
+ {
return VFW_E_WRONG_STATE;
}
@@ -1031,17 +1068,18 @@ CBaseControlWindow::GetMinIdealImageSize(__out long *pWidth,__out long *pHeight)
// cards have a maximum stretch factor depending on the overlay surface size
STDMETHODIMP
-CBaseControlWindow::GetMaxIdealImageSize(__out long *pWidth,__out long *pHeight)
+CBaseControlWindow::GetMaxIdealImageSize(__out long *pWidth, __out long *pHeight)
{
- CheckPointer(pWidth,E_POINTER);
- CheckPointer(pHeight,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pWidth, E_POINTER);
+ CheckPointer(pHeight, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
FILTER_STATE State;
// Must not be stopped for this to work correctly
- m_pFilter->GetState(0,&State);
- if (State == State_Stopped) {
+ m_pFilter->GetState(0, &State);
+ if(State == State_Stopped)
+ {
return VFW_E_WRONG_STATE;
}
@@ -1057,12 +1095,14 @@ CBaseControlWindow::GetMaxIdealImageSize(__out long *pWidth,__out long *pHeight)
STDMETHODIMP
CBaseControlWindow::HideCursor(long HideCursor)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
// Check this is a valid automation boolean type
- if (HideCursor != OATRUE) {
- if (HideCursor != OAFALSE) {
+ if(HideCursor != OATRUE)
+ {
+ if(HideCursor != OAFALSE)
+ {
return E_INVALIDARG;
}
}
@@ -1076,8 +1116,8 @@ CBaseControlWindow::HideCursor(long HideCursor)
STDMETHODIMP CBaseControlWindow::IsCursorHidden(__out long *CursorHidden)
{
- CheckPointer(CursorHidden,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(CursorHidden, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
*CursorHidden = (m_bCursorHidden == TRUE ? OATRUE : OAFALSE);
return NOERROR;
}
@@ -1091,13 +1131,13 @@ STDMETHODIMP CBaseControlWindow::IsCursorHidden(__out long *CursorHidden)
// more direct and efficient mechanism as many values may be changed in one
CBaseControlVideo::CBaseControlVideo(
- __inout CBaseFilter *pFilter, // Owning filter
- __in CCritSec *pInterfaceLock, // Locking object
- __in_opt LPCTSTR pName, // Object description
- __inout_opt LPUNKNOWN pUnk, // Normal COM ownership
- __inout HRESULT *phr) : // OLE return code
+ __inout CBaseFilter *pFilter, // Owning filter
+ __in CCritSec *pInterfaceLock, // Locking object
+ __in_opt LPCTSTR pName, // Object description
+ __inout_opt LPUNKNOWN pUnk, // Normal COM ownership
+ __inout HRESULT *phr) : // OLE return code
- CBaseBasicVideo(pName,pUnk),
+ CBaseBasicVideo(pName, pUnk),
m_pFilter(pFilter),
m_pInterfaceLock(pInterfaceLock),
m_pPin(NULL)
@@ -1111,13 +1151,13 @@ CBaseControlVideo::CBaseControlVideo(
STDMETHODIMP CBaseControlVideo::get_AvgTimePerFrame(__out REFTIME *pAvgTimePerFrame)
{
- CheckPointer(pAvgTimePerFrame,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pAvgTimePerFrame, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();
- if (pVideoInfo == NULL)
- return E_OUTOFMEMORY;
+ if(pVideoInfo == NULL)
+ return E_OUTOFMEMORY;
COARefTime AvgTime(pVideoInfo->AvgTimePerFrame);
*pAvgTimePerFrame = (REFTIME) AvgTime;
@@ -1129,13 +1169,13 @@ STDMETHODIMP CBaseControlVideo::get_AvgTimePerFrame(__out REFTIME *pAvgTimePerFr
STDMETHODIMP CBaseControlVideo::get_BitRate(__out long *pBitRate)
{
- CheckPointer(pBitRate,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pBitRate, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();
- if (pVideoInfo == NULL)
- return E_OUTOFMEMORY;
+ if(pVideoInfo == NULL)
+ return E_OUTOFMEMORY;
*pBitRate = pVideoInfo->dwBitRate;
return NOERROR;
}
@@ -1145,13 +1185,13 @@ STDMETHODIMP CBaseControlVideo::get_BitRate(__out long *pBitRate)
STDMETHODIMP CBaseControlVideo::get_BitErrorRate(__out long *pBitErrorRate)
{
- CheckPointer(pBitErrorRate,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pBitErrorRate, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();
- if (pVideoInfo == NULL)
- return E_OUTOFMEMORY;
+ if(pVideoInfo == NULL)
+ return E_OUTOFMEMORY;
*pBitErrorRate = pVideoInfo->dwBitErrorRate;
return NOERROR;
}
@@ -1161,13 +1201,13 @@ STDMETHODIMP CBaseControlVideo::get_BitErrorRate(__out long *pBitErrorRate)
STDMETHODIMP CBaseControlVideo::get_VideoWidth(__out long *pVideoWidth)
{
- CheckPointer(pVideoWidth,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pVideoWidth, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();
- if (pVideoInfo == NULL)
- return E_OUTOFMEMORY;
+ if(pVideoInfo == NULL)
+ return E_OUTOFMEMORY;
*pVideoWidth = pVideoInfo->bmiHeader.biWidth;
return NOERROR;
}
@@ -1177,13 +1217,13 @@ STDMETHODIMP CBaseControlVideo::get_VideoWidth(__out long *pVideoWidth)
STDMETHODIMP CBaseControlVideo::get_VideoHeight(__out long *pVideoHeight)
{
- CheckPointer(pVideoHeight,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pVideoHeight, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();
- if (pVideoInfo == NULL)
- return E_OUTOFMEMORY;
+ if(pVideoInfo == NULL)
+ return E_OUTOFMEMORY;
*pVideoHeight = pVideoInfo->bmiHeader.biHeight;
return NOERROR;
}
@@ -1197,39 +1237,42 @@ STDMETHODIMP CBaseControlVideo::get_VideoHeight(__out long *pVideoHeight)
// If the number of entries evaluates to zero then we return an S_FALSE code
STDMETHODIMP CBaseControlVideo::GetVideoPaletteEntries(long StartIndex,
- long Entries,
- __out long *pRetrieved,
- __out_ecount_part(Entries, *pRetrieved) long *pPalette)
+ long Entries,
+ __out long *pRetrieved,
+ __out_ecount_part(Entries, *pRetrieved) long *pPalette)
{
- CheckPointer(pRetrieved,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pRetrieved, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
CMediaType MediaType;
// Get the video format from the derived class
VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();
- if (pVideoInfo == NULL)
- return E_OUTOFMEMORY;
+ if(pVideoInfo == NULL)
+ return E_OUTOFMEMORY;
BITMAPINFOHEADER *pHeader = HEADER(pVideoInfo);
// Is the current format palettised
- if (PALETTISED(pVideoInfo) == FALSE) {
+ if(PALETTISED(pVideoInfo) == FALSE)
+ {
*pRetrieved = 0;
return VFW_E_NO_PALETTE_AVAILABLE;
}
// Do they just want to know how many are available
- if (pPalette == NULL) {
+ if(pPalette == NULL)
+ {
*pRetrieved = pHeader->biClrUsed;
return NOERROR;
}
// Make sure the start position is a valid offset
- if (StartIndex >= (LONG) pHeader->biClrUsed || StartIndex < 0) {
+ if(StartIndex >= (LONG) pHeader->biClrUsed || StartIndex < 0)
+ {
*pRetrieved = 0;
return E_INVALIDARG;
}
@@ -1237,8 +1280,9 @@ STDMETHODIMP CBaseControlVideo::GetVideoPaletteEntries(long StartIndex,
// Correct the number we can retrieve
LONG Available = (LONG) pHeader->biClrUsed - StartIndex;
- *pRetrieved = max(0,min(Available,Entries));
- if (*pRetrieved == 0) {
+ *pRetrieved = max(0, min(Available, Entries));
+ if(*pRetrieved == 0)
+ {
return S_FALSE;
}
@@ -1247,7 +1291,8 @@ STDMETHODIMP CBaseControlVideo::GetVideoPaletteEntries(long StartIndex,
PALETTEENTRY *pEntries = (PALETTEENTRY *) pPalette;
RGBQUAD *pColours = COLORS(pVideoInfo) + StartIndex;
- for (LONG Count = 0;Count < *pRetrieved;Count++) {
+ for(LONG Count = 0; Count < *pRetrieved; Count++)
+ {
pEntries[Count].peRed = pColours[Count].rgbRed;
pEntries[Count].peGreen = pColours[Count].rgbGreen;
pEntries[Count].peBlue = pColours[Count].rgbBlue;
@@ -1262,17 +1307,17 @@ STDMETHODIMP CBaseControlVideo::GetVideoPaletteEntries(long StartIndex,
// cannot access the renderer media type directly as the window object thread
// may be updating it since dynamic format changes may change these values
-STDMETHODIMP CBaseControlVideo::GetVideoSize(__out long *pWidth,__out long *pHeight)
+STDMETHODIMP CBaseControlVideo::GetVideoSize(__out long *pWidth, __out long *pHeight)
{
- CheckPointer(pWidth,E_POINTER);
- CheckPointer(pHeight,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pWidth, E_POINTER);
+ CheckPointer(pHeight, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
// Get the video format from the derived class
VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();
- if (pVideoInfo == NULL)
- return E_OUTOFMEMORY;
+ if(pVideoInfo == NULL)
+ return E_OUTOFMEMORY;
*pWidth = pVideoInfo->bmiHeader.biWidth;
*pHeight = pVideoInfo->bmiHeader.biHeight;
return NOERROR;
@@ -1284,9 +1329,9 @@ STDMETHODIMP CBaseControlVideo::GetVideoSize(__out long *pWidth,__out long *pHei
// Then pass the rectangle on to the window object to set the source
STDMETHODIMP
-CBaseControlVideo::SetSourcePosition(long Left,long Top,long Width,long Height)
+CBaseControlVideo::SetSourcePosition(long Left, long Top, long Width, long Height)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT SourceRect;
SourceRect.left = Left;
@@ -1297,14 +1342,16 @@ CBaseControlVideo::SetSourcePosition(long Left,long Top,long Width,long Height)
// Check the source rectangle is valid
HRESULT hr = CheckSourceRect(&SourceRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
// Now set the source rectangle
hr = SetSourceRect(&SourceRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return OnUpdateRectangles();
@@ -1316,15 +1363,15 @@ CBaseControlVideo::SetSourcePosition(long Left,long Top,long Width,long Height)
// object returns through GetSourceRect) which requires a little work
STDMETHODIMP
-CBaseControlVideo::GetSourcePosition(__out long *pLeft,__out long *pTop,__out long *pWidth,__out long *pHeight)
+CBaseControlVideo::GetSourcePosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight)
{
// Should check the pointers are non NULL
- CheckPointer(pLeft,E_POINTER);
- CheckPointer(pTop,E_POINTER);
- CheckPointer(pWidth,E_POINTER);
- CheckPointer(pHeight,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pLeft, E_POINTER);
+ CheckPointer(pTop, E_POINTER);
+ CheckPointer(pWidth, E_POINTER);
+ CheckPointer(pHeight, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
RECT SourceRect;
CAutoLock cInterfaceLock(m_pInterfaceLock);
@@ -1344,9 +1391,9 @@ CBaseControlVideo::GetSourcePosition(__out long *pLeft,__out long *pTop,__out lo
// Then pass the rectangle on to the window object to set the destination
STDMETHODIMP
-CBaseControlVideo::SetDestinationPosition(long Left,long Top,long Width,long Height)
+CBaseControlVideo::SetDestinationPosition(long Left, long Top, long Width, long Height)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT DestinationRect;
@@ -1358,14 +1405,16 @@ CBaseControlVideo::SetDestinationPosition(long Left,long Top,long Width,long Hei
// Check the target rectangle is valid
HRESULT hr = CheckTargetRect(&DestinationRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
// Now set the new target rectangle
hr = SetTargetRect(&DestinationRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return OnUpdateRectangles();
@@ -1377,15 +1426,15 @@ CBaseControlVideo::SetDestinationPosition(long Left,long Top,long Width,long Hei
// object returns through GetDestinationRect) which requires a little work
STDMETHODIMP
-CBaseControlVideo::GetDestinationPosition(__out long *pLeft,__out long *pTop,__out long *pWidth,__out long *pHeight)
+CBaseControlVideo::GetDestinationPosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight)
{
// Should check the pointers are not NULL
- CheckPointer(pLeft,E_POINTER);
- CheckPointer(pTop,E_POINTER);
- CheckPointer(pWidth,E_POINTER);
- CheckPointer(pHeight,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pLeft, E_POINTER);
+ CheckPointer(pTop, E_POINTER);
+ CheckPointer(pWidth, E_POINTER);
+ CheckPointer(pHeight, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
RECT DestinationRect;
CAutoLock cInterfaceLock(m_pInterfaceLock);
@@ -1407,7 +1456,7 @@ CBaseControlVideo::GetDestinationPosition(__out long *pLeft,__out long *pTop,__o
STDMETHODIMP CBaseControlVideo::put_SourceLeft(long SourceLeft)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT SourceRect;
GetSourceRect(&SourceRect);
@@ -1417,14 +1466,16 @@ STDMETHODIMP CBaseControlVideo::put_SourceLeft(long SourceLeft)
// Check the source rectangle is valid
HRESULT hr = CheckSourceRect(&SourceRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
// Now set the source rectangle
hr = SetSourceRect(&SourceRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return OnUpdateRectangles();
@@ -1435,8 +1486,8 @@ STDMETHODIMP CBaseControlVideo::put_SourceLeft(long SourceLeft)
STDMETHODIMP CBaseControlVideo::get_SourceLeft(__out long *pSourceLeft)
{
- CheckPointer(pSourceLeft,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pSourceLeft, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT SourceRect;
@@ -1452,7 +1503,7 @@ STDMETHODIMP CBaseControlVideo::get_SourceLeft(__out long *pSourceLeft)
STDMETHODIMP CBaseControlVideo::put_SourceWidth(long SourceWidth)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT SourceRect;
GetSourceRect(&SourceRect);
@@ -1461,14 +1512,16 @@ STDMETHODIMP CBaseControlVideo::put_SourceWidth(long SourceWidth)
// Check the source rectangle is valid
HRESULT hr = CheckSourceRect(&SourceRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
// Now set the source rectangle
hr = SetSourceRect(&SourceRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return OnUpdateRectangles();
@@ -1479,8 +1532,8 @@ STDMETHODIMP CBaseControlVideo::put_SourceWidth(long SourceWidth)
STDMETHODIMP CBaseControlVideo::get_SourceWidth(__out long *pSourceWidth)
{
- CheckPointer(pSourceWidth,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pSourceWidth, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT SourceRect;
@@ -1497,7 +1550,7 @@ STDMETHODIMP CBaseControlVideo::get_SourceWidth(__out long *pSourceWidth)
STDMETHODIMP CBaseControlVideo::put_SourceTop(long SourceTop)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT SourceRect;
GetSourceRect(&SourceRect);
@@ -1507,14 +1560,16 @@ STDMETHODIMP CBaseControlVideo::put_SourceTop(long SourceTop)
// Check the source rectangle is valid
HRESULT hr = CheckSourceRect(&SourceRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
// Now set the source rectangle
hr = SetSourceRect(&SourceRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return OnUpdateRectangles();
@@ -1525,8 +1580,8 @@ STDMETHODIMP CBaseControlVideo::put_SourceTop(long SourceTop)
STDMETHODIMP CBaseControlVideo::get_SourceTop(__out long *pSourceTop)
{
- CheckPointer(pSourceTop,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pSourceTop, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT SourceRect;
@@ -1540,7 +1595,7 @@ STDMETHODIMP CBaseControlVideo::get_SourceTop(__out long *pSourceTop)
STDMETHODIMP CBaseControlVideo::put_SourceHeight(long SourceHeight)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT SourceRect;
GetSourceRect(&SourceRect);
@@ -1549,14 +1604,16 @@ STDMETHODIMP CBaseControlVideo::put_SourceHeight(long SourceHeight)
// Check the source rectangle is valid
HRESULT hr = CheckSourceRect(&SourceRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
// Now set the source rectangle
hr = SetSourceRect(&SourceRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return OnUpdateRectangles();
@@ -1567,8 +1624,8 @@ STDMETHODIMP CBaseControlVideo::put_SourceHeight(long SourceHeight)
STDMETHODIMP CBaseControlVideo::get_SourceHeight(__out long *pSourceHeight)
{
- CheckPointer(pSourceHeight,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pSourceHeight, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT SourceRect;
@@ -1585,7 +1642,7 @@ STDMETHODIMP CBaseControlVideo::get_SourceHeight(__out long *pSourceHeight)
STDMETHODIMP CBaseControlVideo::put_DestinationLeft(long DestinationLeft)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT DestinationRect;
GetTargetRect(&DestinationRect);
@@ -1595,14 +1652,16 @@ STDMETHODIMP CBaseControlVideo::put_DestinationLeft(long DestinationLeft)
// Check the target rectangle is valid
HRESULT hr = CheckTargetRect(&DestinationRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
// Now set the new target rectangle
hr = SetTargetRect(&DestinationRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return OnUpdateRectangles();
@@ -1613,8 +1672,8 @@ STDMETHODIMP CBaseControlVideo::put_DestinationLeft(long DestinationLeft)
STDMETHODIMP CBaseControlVideo::get_DestinationLeft(__out long *pDestinationLeft)
{
- CheckPointer(pDestinationLeft,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pDestinationLeft, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT DestinationRect;
@@ -1628,7 +1687,7 @@ STDMETHODIMP CBaseControlVideo::get_DestinationLeft(__out long *pDestinationLeft
STDMETHODIMP CBaseControlVideo::put_DestinationWidth(long DestinationWidth)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT DestinationRect;
GetTargetRect(&DestinationRect);
@@ -1637,14 +1696,16 @@ STDMETHODIMP CBaseControlVideo::put_DestinationWidth(long DestinationWidth)
// Check the target rectangle is valid
HRESULT hr = CheckTargetRect(&DestinationRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
// Now set the new target rectangle
hr = SetTargetRect(&DestinationRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return OnUpdateRectangles();
@@ -1655,8 +1716,8 @@ STDMETHODIMP CBaseControlVideo::put_DestinationWidth(long DestinationWidth)
STDMETHODIMP CBaseControlVideo::get_DestinationWidth(__out long *pDestinationWidth)
{
- CheckPointer(pDestinationWidth,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pDestinationWidth, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT DestinationRect;
@@ -1673,7 +1734,7 @@ STDMETHODIMP CBaseControlVideo::get_DestinationWidth(__out long *pDestinationWid
STDMETHODIMP CBaseControlVideo::put_DestinationTop(long DestinationTop)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT DestinationRect;
GetTargetRect(&DestinationRect);
@@ -1683,14 +1744,16 @@ STDMETHODIMP CBaseControlVideo::put_DestinationTop(long DestinationTop)
// Check the target rectangle is valid
HRESULT hr = CheckTargetRect(&DestinationRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
// Now set the new target rectangle
hr = SetTargetRect(&DestinationRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return OnUpdateRectangles();
@@ -1701,8 +1764,8 @@ STDMETHODIMP CBaseControlVideo::put_DestinationTop(long DestinationTop)
STDMETHODIMP CBaseControlVideo::get_DestinationTop(__out long *pDestinationTop)
{
- CheckPointer(pDestinationTop,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pDestinationTop, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT DestinationRect;
@@ -1716,7 +1779,7 @@ STDMETHODIMP CBaseControlVideo::get_DestinationTop(__out long *pDestinationTop)
STDMETHODIMP CBaseControlVideo::put_DestinationHeight(long DestinationHeight)
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT DestinationRect;
GetTargetRect(&DestinationRect);
@@ -1725,14 +1788,16 @@ STDMETHODIMP CBaseControlVideo::put_DestinationHeight(long DestinationHeight)
// Check the target rectangle is valid
HRESULT hr = CheckTargetRect(&DestinationRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
// Now set the new target rectangle
hr = SetTargetRect(&DestinationRect);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return OnUpdateRectangles();
@@ -1743,8 +1808,8 @@ STDMETHODIMP CBaseControlVideo::put_DestinationHeight(long DestinationHeight)
STDMETHODIMP CBaseControlVideo::get_DestinationHeight(__out long *pDestinationHeight)
{
- CheckPointer(pDestinationHeight,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pDestinationHeight, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
RECT DestinationRect;
@@ -1758,10 +1823,11 @@ STDMETHODIMP CBaseControlVideo::get_DestinationHeight(__out long *pDestinationHe
STDMETHODIMP CBaseControlVideo::SetDefaultSourcePosition()
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
HRESULT hr = SetDefaultSourceRect();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return OnUpdateRectangles();
@@ -1772,7 +1838,7 @@ STDMETHODIMP CBaseControlVideo::SetDefaultSourcePosition()
STDMETHODIMP CBaseControlVideo::IsUsingDefaultSource()
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
return IsDefaultSourceRect();
}
@@ -1782,10 +1848,11 @@ STDMETHODIMP CBaseControlVideo::IsUsingDefaultSource()
STDMETHODIMP CBaseControlVideo::SetDefaultDestinationPosition()
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
HRESULT hr = SetDefaultTargetRect();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return OnUpdateRectangles();
@@ -1796,7 +1863,7 @@ STDMETHODIMP CBaseControlVideo::SetDefaultDestinationPosition()
STDMETHODIMP CBaseControlVideo::IsUsingDefaultDestination()
{
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
return IsDefaultTargetRect();
}
@@ -1805,31 +1872,33 @@ STDMETHODIMP CBaseControlVideo::IsUsingDefaultDestination()
// Return a copy of the current image in the video renderer
STDMETHODIMP
-CBaseControlVideo::GetCurrentImage(__inout long *pBufferSize,__out_bcount_part(*pBufferSize, *pBufferSize) long *pVideoImage)
+CBaseControlVideo::GetCurrentImage(__inout long *pBufferSize, __out_bcount_part(*pBufferSize, *pBufferSize) long *pVideoImage)
{
- CheckPointer(pBufferSize,E_POINTER);
- CheckConnected(m_pPin,VFW_E_NOT_CONNECTED);
+ CheckPointer(pBufferSize, E_POINTER);
+ CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);
CAutoLock cInterfaceLock(m_pInterfaceLock);
FILTER_STATE State;
// Make sure we are in a paused state
- if (pVideoImage != NULL) {
- m_pFilter->GetState(0,&State);
- if (State != State_Paused) {
+ if(pVideoImage != NULL)
+ {
+ m_pFilter->GetState(0, &State);
+ if(State != State_Paused)
+ {
return VFW_E_NOT_PAUSED;
}
- return GetStaticImage(pBufferSize,pVideoImage);
+ return GetStaticImage(pBufferSize, pVideoImage);
}
// Just return the memory required
VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();
- if (pVideoInfo == NULL)
- return E_OUTOFMEMORY;
+ if(pVideoInfo == NULL)
+ return E_OUTOFMEMORY;
RECT SourceRect;
GetSourceRect(&SourceRect);
- return GetImageSize(pVideoInfo,pBufferSize,&SourceRect);
+ return GetImageSize(pVideoInfo, pBufferSize, &SourceRect);
}
@@ -1849,17 +1918,20 @@ HRESULT CBaseControlVideo::GetImageSize(__in VIDEOINFOHEADER *pVideoInfo,
// Check we have the correct input parameters
- if (pSourceRect == NULL ||
- pVideoInfo == NULL ||
- pBufferSize == NULL) {
+ if(pSourceRect == NULL ||
+ pVideoInfo == NULL ||
+ pBufferSize == NULL)
+ {
return E_UNEXPECTED;
}
// Is the data format compatible
- if (pVideoInfo->bmiHeader.biCompression != BI_RGB) {
- if (pVideoInfo->bmiHeader.biCompression != BI_BITFIELDS) {
+ if(pVideoInfo->bmiHeader.biCompression != BI_RGB)
+ {
+ if(pVideoInfo->bmiHeader.biCompression != BI_BITFIELDS)
+ {
return E_INVALIDARG;
}
}
@@ -1897,27 +1969,31 @@ HRESULT CBaseControlVideo::CopyImage(IMediaSample *pMediaSample,
// Check we have an image to copy
- if (pMediaSample == NULL || pSourceRect == NULL ||
- pVideoInfo == NULL || pVideoImage == NULL ||
- pBufferSize == NULL) {
+ if(pMediaSample == NULL || pSourceRect == NULL ||
+ pVideoInfo == NULL || pVideoImage == NULL ||
+ pBufferSize == NULL)
+ {
return E_UNEXPECTED;
}
// Is the data format compatible
- if (pVideoInfo->bmiHeader.biCompression != BI_RGB) {
- if (pVideoInfo->bmiHeader.biCompression != BI_BITFIELDS) {
+ if(pVideoInfo->bmiHeader.biCompression != BI_RGB)
+ {
+ if(pVideoInfo->bmiHeader.biCompression != BI_BITFIELDS)
+ {
return E_INVALIDARG;
}
}
- if (*pBufferSize < 0) {
+ if(*pBufferSize < 0)
+ {
return E_INVALIDARG;
}
// Arbitrarily large size to prevent integer overflow problems
- if (pVideoInfo->bmiHeader.biSize > 4096)
+ if(pVideoInfo->bmiHeader.biSize > 4096)
{
return E_INVALIDARG;
}
@@ -1932,7 +2008,8 @@ HRESULT CBaseControlVideo::CopyImage(IMediaSample *pMediaSample,
DWORD Total;
DWORD dwDibSize;
- if( !ValidateBitmapInfoHeader( HEADER(pVideoInfo), Size)) {
+ if(!ValidateBitmapInfoHeader(HEADER(pVideoInfo), Size))
+ {
return E_INVALIDARG;
}
@@ -1940,17 +2017,20 @@ HRESULT CBaseControlVideo::CopyImage(IMediaSample *pMediaSample,
// tools aren't picking up the annotation
__analysis_assume(Size >= sizeof(BITMAPINFOHEADER));
- if (FAILED(SAFE_DIBSIZE(&bih, &dwDibSize))) {
+ if(FAILED(SAFE_DIBSIZE(&bih, &dwDibSize)))
+ {
return E_INVALIDARG;
}
- if (FAILED(DWordAdd(Size, dwDibSize, &Total))) {
+ if(FAILED(DWordAdd(Size, dwDibSize, &Total)))
+ {
return E_INVALIDARG;
}
// Make sure we have a large enough buffer
- if ((DWORD)*pBufferSize < Total) {
+ if((DWORD)*pBufferSize < Total)
+ {
return E_OUTOFMEMORY;
}
@@ -1965,7 +2045,8 @@ HRESULT CBaseControlVideo::CopyImage(IMediaSample *pMediaSample,
// Get the pointer to it's image data
HRESULT hr = pMediaSample->GetPointer(&pCurrentImage);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -1979,7 +2060,8 @@ HRESULT CBaseControlVideo::CopyImage(IMediaSample *pMediaSample,
// Even money on this GP faulting sometime...
- for (LONG Line = 0;Line < HEIGHT(pSourceRect);Line++) {
+ for(LONG Line = 0; Line < HEIGHT(pSourceRect); Line++)
+ {
CopyMemory((PVOID)pImageData, (PVOID)pCurrentImage, ScanLine);
pImageData += DIBWIDTHBYTES(*(BITMAPINFOHEADER *)pVideoImage);
pCurrentImage += DIBWIDTHBYTES(pVideoInfo->bmiHeader);
@@ -1998,14 +2080,14 @@ HRESULT CBaseControlVideo::OnVideoSizeChange()
// Get the video format from the derived class
VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();
- if (pVideoInfo == NULL)
- return E_OUTOFMEMORY;
+ if(pVideoInfo == NULL)
+ return E_OUTOFMEMORY;
WORD Width = (WORD) pVideoInfo->bmiHeader.biWidth;
WORD Height = (WORD) pVideoInfo->bmiHeader.biHeight;
return m_pFilter->NotifyEvent(EC_VIDEO_SIZE_CHANGED,
- MAKELPARAM(Width,Height),
- MAKEWPARAM(0,0));
+ MAKELPARAM(Width, Height),
+ MAKEWPARAM(0, 0));
}
@@ -2019,25 +2101,27 @@ HRESULT CBaseControlVideo::OnVideoSizeChange()
HRESULT CBaseControlVideo::CheckSourceRect(__in RECT *pSourceRect)
{
- CheckPointer(pSourceRect,E_POINTER);
- LONG Width,Height;
- GetVideoSize(&Width,&Height);
+ CheckPointer(pSourceRect, E_POINTER);
+ LONG Width, Height;
+ GetVideoSize(&Width, &Height);
// Check the coordinates are greater than zero
// and that the rectangle is valid (left<right, top<bottom)
- if ((pSourceRect->left >= pSourceRect->right) ||
+ if((pSourceRect->left >= pSourceRect->right) ||
(pSourceRect->left < 0) ||
(pSourceRect->top >= pSourceRect->bottom) ||
- (pSourceRect->top < 0)) {
+ (pSourceRect->top < 0))
+ {
return E_INVALIDARG;
}
// Check the coordinates are less than the extents
- if ((pSourceRect->right > Width) ||
- (pSourceRect->bottom > Height)) {
+ if((pSourceRect->right > Width) ||
+ (pSourceRect->bottom > Height))
+ {
return E_INVALIDARG;
}
@@ -2058,20 +2142,23 @@ HRESULT CBaseControlVideo::CheckTargetRect(__in RECT *pTargetRect)
{
// Check the pointer is valid
- if (pTargetRect == NULL) {
+ if(pTargetRect == NULL)
+ {
return E_POINTER;
}
// These overflow the WIDTH and HEIGHT checks
- if (pTargetRect->left > pTargetRect->right ||
- pTargetRect->top > pTargetRect->bottom) {
- return E_INVALIDARG;
+ if(pTargetRect->left > pTargetRect->right ||
+ pTargetRect->top > pTargetRect->bottom)
+ {
+ return E_INVALIDARG;
}
// Check the rectangle has valid coordinates
- if (WIDTH(pTargetRect) <= 0 || HEIGHT(pTargetRect) <= 0) {
+ if(WIDTH(pTargetRect) <= 0 || HEIGHT(pTargetRect) <= 0)
+ {
return E_INVALIDARG;
}
diff --git a/src/filters/BaseClasses/winctrl.h b/src/filters/BaseClasses/winctrl.h
index 1080a47c6..b1bcf02b6 100644
--- a/src/filters/BaseClasses/winctrl.h
+++ b/src/filters/BaseClasses/winctrl.h
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// File: WinCtrl.h
//
-// Desc: DirectShow base classes - defines classes for video control
+// Desc: DirectShow base classes - defines classes for video control
// interfaces.
//
// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
@@ -34,12 +34,24 @@ public:
// Internal methods for other objects to get information out
- HRESULT DoSetWindowStyle(long Style,long WindowLong);
- HRESULT DoGetWindowStyle(__out long *pStyle,long WindowLong);
- BOOL IsAutoShowEnabled() { return m_bAutoShow; };
- COLORREF GetBorderColour() { return m_BorderColour; };
- HWND GetOwnerWindow() { return m_hwndOwner; };
- BOOL IsCursorHidden() { return m_bCursorHidden; };
+ HRESULT DoSetWindowStyle(long Style, long WindowLong);
+ HRESULT DoGetWindowStyle(__out long *pStyle, long WindowLong);
+ BOOL IsAutoShowEnabled()
+ {
+ return m_bAutoShow;
+ };
+ COLORREF GetBorderColour()
+ {
+ return m_BorderColour;
+ };
+ HWND GetOwnerWindow()
+ {
+ return m_hwndOwner;
+ };
+ BOOL IsCursorHidden()
+ {
+ return m_bCursorHidden;
+ };
inline BOOL PossiblyEatMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@@ -52,7 +64,8 @@ public:
// pins dynamically when requested in CBaseFilter::GetPin. This can
// not be called from our constructor because is is a virtual method
- void SetControlWindowPin(CBasePin *pPin) {
+ void SetControlWindowPin(CBasePin *pPin)
+ {
m_pPin = pPin;
}
@@ -100,13 +113,13 @@ public:
// And these are the methods
STDMETHODIMP SetWindowForeground(long Focus);
- STDMETHODIMP NotifyOwnerMessage(OAHWND hwnd,long uMsg,LONG_PTR wParam,LONG_PTR lParam);
- STDMETHODIMP GetMinIdealImageSize(__out long *pWidth,__out long *pHeight);
- STDMETHODIMP GetMaxIdealImageSize(__out long *pWidth,__out long *pHeight);
- STDMETHODIMP SetWindowPosition(long Left,long Top,long Width,long Height);
- STDMETHODIMP GetWindowPosition(__out long *pLeft,__out long *pTop,__out long *pWidth,__out long *pHeight);
- STDMETHODIMP GetRestorePosition(__out long *pLeft,__out long *pTop,__out long *pWidth,__out long *pHeight);
- STDMETHODIMP HideCursor(long HideCursor);
+ STDMETHODIMP NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam);
+ STDMETHODIMP GetMinIdealImageSize(__out long *pWidth, __out long *pHeight);
+ STDMETHODIMP GetMaxIdealImageSize(__out long *pWidth, __out long *pHeight);
+ STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetWindowPosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight);
+ STDMETHODIMP GetRestorePosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight);
+ STDMETHODIMP HideCursor(long HideCursor);
STDMETHODIMP IsCursorHidden(__out long *CursorHidden);
};
@@ -132,7 +145,7 @@ public:
virtual HRESULT SetDefaultSourceRect() PURE;
virtual HRESULT SetSourceRect(RECT *pSourceRect) PURE;
virtual HRESULT GetSourceRect(RECT *pSourceRect) PURE;
- virtual HRESULT GetStaticImage(__inout long *pBufferSize,__out_bcount_part(*pBufferSize, *pBufferSize) long *pDIBImage) PURE;
+ virtual HRESULT GetStaticImage(__inout long *pBufferSize, __out_bcount_part(*pBufferSize, *pBufferSize) long *pDIBImage) PURE;
// Derived classes must override this to return a VIDEOINFO representing
// the video format. We cannot call IPin ConnectionMediaType to get this
@@ -156,7 +169,10 @@ public:
__in RECT *pSourceRect);
// Override this if you want notifying when the rectangles change
- virtual HRESULT OnUpdateRectangles() { return NOERROR; };
+ virtual HRESULT OnUpdateRectangles()
+ {
+ return NOERROR;
+ };
virtual HRESULT OnVideoSizeChange();
// Derived classes must call this to set the pin the filter is using
@@ -165,7 +181,8 @@ public:
// pins dynamically when requested in CBaseFilter::GetPin. This can
// not be called from our constructor because is is a virtual method
- void SetControlVideoPin(__inout CBasePin *pPin) {
+ void SetControlVideoPin(__inout CBasePin *pPin)
+ {
m_pPin = pPin;
}
@@ -207,17 +224,17 @@ public:
// And these are the methods
- STDMETHODIMP GetVideoSize(__out long *pWidth,__out long *pHeight);
- STDMETHODIMP SetSourcePosition(long Left,long Top,long Width,long Height);
- STDMETHODIMP GetSourcePosition(__out long *pLeft,__out long *pTop,__out long *pWidth,__out long *pHeight);
- STDMETHODIMP GetVideoPaletteEntries(long StartIndex,long Entries,__out long *pRetrieved,__out_ecount_part(Entries, *pRetrieved) long *pPalette);
+ STDMETHODIMP GetVideoSize(__out long *pWidth, __out long *pHeight);
+ STDMETHODIMP SetSourcePosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetSourcePosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight);
+ STDMETHODIMP GetVideoPaletteEntries(long StartIndex, long Entries, __out long *pRetrieved, __out_ecount_part(Entries, *pRetrieved) long *pPalette);
STDMETHODIMP SetDefaultSourcePosition();
STDMETHODIMP IsUsingDefaultSource();
- STDMETHODIMP SetDestinationPosition(long Left,long Top,long Width,long Height);
- STDMETHODIMP GetDestinationPosition(__out long *pLeft,__out long *pTop,__out long *pWidth,__out long *pHeight);
+ STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
+ STDMETHODIMP GetDestinationPosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight);
STDMETHODIMP SetDefaultDestinationPosition();
STDMETHODIMP IsUsingDefaultDestination();
- STDMETHODIMP GetCurrentImage(__inout long *pBufferSize,__out_bcount_part(*pBufferSize, *pBufferSize) long *pVideoImage);
+ STDMETHODIMP GetCurrentImage(__inout long *pBufferSize, __out_bcount_part(*pBufferSize, *pBufferSize) long *pVideoImage);
};
#endif // __WINCTRL__
diff --git a/src/filters/BaseClasses/winutil.cpp b/src/filters/BaseClasses/winutil.cpp
index e5a63cc02..2c50fc2e2 100644
--- a/src/filters/BaseClasses/winutil.cpp
+++ b/src/filters/BaseClasses/winutil.cpp
@@ -50,7 +50,7 @@ CBaseWindow::CBaseWindow(BOOL bDoGetDC, bool bDoPostToDestroy) :
HRESULT CBaseWindow::PrepareWindow()
{
- if (m_hwnd) return NOERROR;
+ if(m_hwnd) return NOERROR;
ASSERT(m_hwnd == NULL);
ASSERT(m_hdc == NULL);
@@ -59,7 +59,8 @@ HRESULT CBaseWindow::PrepareWindow()
m_pClassName = GetClassWindowStyles(&m_ClassStyles,
&m_WindowStyles,
&m_WindowStylesEx);
- if (m_pClassName == NULL) {
+ if(m_pClassName == NULL)
+ {
return E_FAIL;
}
@@ -67,22 +68,26 @@ HRESULT CBaseWindow::PrepareWindow()
m_ShowStageMessage = RegisterWindowMessage(SHOWSTAGE);
// RegisterWindowMessage() returns 0 if an error occurs.
- if (0 == m_ShowStageMessage) {
+ if(0 == m_ShowStageMessage)
+ {
return AmGetLastErrorToHResult();
}
m_ShowStageTop = RegisterWindowMessage(SHOWSTAGETOP);
- if (0 == m_ShowStageTop) {
+ if(0 == m_ShowStageTop)
+ {
return AmGetLastErrorToHResult();
}
m_RealizePalette = RegisterWindowMessage(REALIZEPALETTE);
- if (0 == m_RealizePalette) {
+ if(0 == m_RealizePalette)
+ {
return AmGetLastErrorToHResult();
}
MsgDestroy = RegisterWindowMessage(TEXT("AM_DESTROY"));
- if (0 == MsgDestroy) {
+ if(0 == MsgDestroy)
+ {
return AmGetLastErrorToHResult();
}
@@ -112,19 +117,23 @@ CBaseWindow::~CBaseWindow()
HRESULT CBaseWindow::DoneWithWindow()
{
- if (!IsWindow(m_hwnd) || (GetWindowThreadProcessId(m_hwnd, NULL) != GetCurrentThreadId())) {
+ if(!IsWindow(m_hwnd) || (GetWindowThreadProcessId(m_hwnd, NULL) != GetCurrentThreadId()))
+ {
- if (IsWindow(m_hwnd)) {
+ if(IsWindow(m_hwnd))
+ {
- // This code should only be executed if the window exists and if the window's
+ // This code should only be executed if the window exists and if the window's
// messages are processed on a different thread.
ASSERT(GetWindowThreadProcessId(m_hwnd, NULL) != GetCurrentThreadId());
- if (m_bDoPostToDestroy) {
+ if(m_bDoPostToDestroy)
+ {
HRESULT hr = S_OK;
CAMEvent m_evDone(FALSE, &hr);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -134,7 +143,9 @@ HRESULT CBaseWindow::DoneWithWindow()
// Sending a message gives less synchronization.
PostMessage(m_hwnd, MsgDestroy, (WPARAM)(HANDLE)m_evDone, 0);
WaitDispatchingMessages(m_evDone, INFINITE);
- } else {
+ }
+ else
+ {
SendMessage(m_hwnd, MsgDestroy, 0, 0);
}
}
@@ -150,7 +161,7 @@ HRESULT CBaseWindow::DoneWithWindow()
// We need to free this DC though because USER32 does not know
// anything about it.
//
- if (m_MemoryDC)
+ if(m_MemoryDC)
{
EXECUTE_ASSERT(DeleteDC(m_MemoryDC));
m_MemoryDC = NULL;
@@ -162,7 +173,8 @@ HRESULT CBaseWindow::DoneWithWindow()
return NOERROR;
}
const HWND hwnd = m_hwnd;
- if (hwnd == NULL) {
+ if(hwnd == NULL)
+ {
return NOERROR;
}
@@ -171,14 +183,15 @@ HRESULT CBaseWindow::DoneWithWindow()
// Reset the window styles before destruction
- SetWindowLong(hwnd,GWL_STYLE,m_WindowStyles);
+ SetWindowLong(hwnd, GWL_STYLE, m_WindowStyles);
ASSERT(GetParent(hwnd) == NULL);
- NOTE1("Reset window styles %d",m_WindowStyles);
+ NOTE1("Reset window styles %d", m_WindowStyles);
// UnintialiseWindow sets m_hwnd to NULL so save a copy
UninitialiseWindow();
DbgLog((LOG_TRACE, 2, TEXT("Destroying 0x%8.8X"), hwnd));
- if (!DestroyWindow(hwnd)) {
+ if(!DestroyWindow(hwnd))
+ {
DbgLog((LOG_TRACE, 0, TEXT("DestroyWindow %8.8X failed code %d"),
hwnd, GetLastError()));
DbgBreak("");
@@ -206,12 +219,13 @@ HRESULT CBaseWindow::DoneWithWindow()
HRESULT CBaseWindow::InactivateWindow()
{
// Has the window been activated
- if (m_bActivated == FALSE) {
+ if(m_bActivated == FALSE)
+ {
return S_FALSE;
}
m_bActivated = FALSE;
- ShowWindow(m_hwnd,SW_HIDE);
+ ShowWindow(m_hwnd, SW_HIDE);
return NOERROR;
}
@@ -233,7 +247,8 @@ HRESULT CBaseWindow::ActivateWindow()
{
// Has the window been sized and positioned already
- if (m_bActivated == TRUE || GetParent(m_hwnd) != NULL) {
+ if(m_bActivated == TRUE || GetParent(m_hwnd) != NULL)
+ {
SetWindowPos(m_hwnd, // Our window handle
HWND_TOP, // Put it at the top
@@ -248,9 +263,9 @@ HRESULT CBaseWindow::ActivateWindow()
// Calculate the desired client rectangle
RECT WindowRect, ClientRect = GetDefaultRect();
- GetWindowRect(m_hwnd,&WindowRect);
- AdjustWindowRectEx(&ClientRect,GetWindowLong(m_hwnd,GWL_STYLE),
- FALSE,GetWindowLong(m_hwnd,GWL_EXSTYLE));
+ GetWindowRect(m_hwnd, &WindowRect);
+ AdjustWindowRectEx(&ClientRect, GetWindowLong(m_hwnd, GWL_STYLE),
+ FALSE, GetWindowLong(m_hwnd, GWL_EXSTYLE));
// Align left and top edges on DWORD boundaries
@@ -275,13 +290,14 @@ HRESULT CBaseWindow::ActivateWindow()
HRESULT CBaseWindow::PerformanceAlignWindow()
{
- RECT ClientRect,WindowRect;
- GetWindowRect(m_hwnd,&WindowRect);
+ RECT ClientRect, WindowRect;
+ GetWindowRect(m_hwnd, &WindowRect);
ASSERT(m_bActivated == TRUE);
// Don't do this if we're owned
- if (GetParent(m_hwnd)) {
+ if(GetParent(m_hwnd))
+ {
return NOERROR;
}
@@ -297,7 +313,7 @@ HRESULT CBaseWindow::PerformanceAlignWindow()
HWND_TOP, // Put it at the top
WindowRect.left, // Align left edge
WindowRect.top, // And also top place
- (int) 0,(int) 0, // Ignore these sizes
+ (int) 0, (int) 0, // Ignore these sizes
WindowFlags); // Don't show window
return NOERROR;
@@ -325,17 +341,20 @@ HRESULT CBaseWindow::SetPalette(HPALETTE hPalette)
HRESULT CBaseWindow::SetPalette()
{
- if (!m_bNoRealize) {
+ if(!m_bNoRealize)
+ {
SendMessage(m_hwnd, m_RealizePalette, 0, 0);
return S_OK;
- } else {
+ }
+ else
+ {
// Just select the palette
ASSERT(m_hdc);
ASSERT(m_MemoryDC);
CAutoLock cPaletteLock(&m_PaletteLock);
- SelectPalette(m_hdc,m_hPalette,m_bBackground);
- SelectPalette(m_MemoryDC,m_hPalette,m_bBackground);
+ SelectPalette(m_hdc, m_hPalette, m_bBackground);
+ SelectPalette(m_MemoryDC, m_hPalette, m_bBackground);
return S_OK;
}
@@ -378,7 +397,8 @@ HRESULT CBaseWindow::DoRealisePalette(BOOL bForceBackground)
{
CAutoLock cPaletteLock(&m_PaletteLock);
- if (m_hPalette == NULL) {
+ if(m_hPalette == NULL)
+ {
return NOERROR;
}
@@ -386,8 +406,8 @@ HRESULT CBaseWindow::DoRealisePalette(BOOL bForceBackground)
ASSERT(m_hdc);
ASSERT(m_MemoryDC);
- SelectPalette(m_hdc,m_hPalette,m_bBackground || bForceBackground);
- SelectPalette(m_MemoryDC,m_hPalette,m_bBackground);
+ SelectPalette(m_hdc, m_hPalette, m_bBackground || bForceBackground);
+ SelectPalette(m_MemoryDC, m_hPalette, m_bBackground);
}
// If we grab a critical section here we can deadlock
@@ -425,9 +445,10 @@ LRESULT CALLBACK WndProc(HWND hwnd, // Window handle
// structure. IF we get any messages before WM_NCCREATE we will
// pass them to DefWindowProc.
- CBaseWindow *pBaseWindow = _GetWindowLongPtr<CBaseWindow*>(hwnd,0);
+ CBaseWindow *pBaseWindow = _GetWindowLongPtr<CBaseWindow*>(hwnd, 0);
- if (pBaseWindow == NULL) {
+ if(pBaseWindow == NULL)
+ {
// Get the structure pointer from the create struct.
// We can only do this for WM_NCCREATE which should be one of
@@ -438,12 +459,13 @@ LRESULT CALLBACK WndProc(HWND hwnd, // Window handle
// and will then place it in the window structure
// turn off WS_EX_LAYOUTRTL style for quartz windows
- if (uMsg == WM_NCCREATE) {
+ if(uMsg == WM_NCCREATE)
+ {
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) & ~0x400000);
}
- if ((uMsg != WM_NCCREATE)
- || (NULL == (pBaseWindow = *(CBaseWindow**) ((LPCREATESTRUCT)lParam)->lpCreateParams)))
+ if((uMsg != WM_NCCREATE)
+ || (NULL == (pBaseWindow = *(CBaseWindow**)((LPCREATESTRUCT)lParam)->lpCreateParams)))
{
return(DefWindowProc(hwnd, uMsg, wParam, lParam));
}
@@ -457,7 +479,8 @@ LRESULT CALLBACK WndProc(HWND hwnd, // Window handle
#ifdef _DEBUG
- if (0 == rc) {
+ if(0 == rc)
+ {
// SetWindowLong MIGHT have failed. (Read the docs which admit
// that it is awkward to work out if you have had an error.)
LONG lasterror = GetLastError();
@@ -469,14 +492,16 @@ LRESULT CALLBACK WndProc(HWND hwnd, // Window handle
}
// See if this is the packet of death
- if (uMsg == MsgDestroy && uMsg != 0) {
+ if(uMsg == MsgDestroy && uMsg != 0)
+ {
pBaseWindow->DoneWithWindow();
- if (pBaseWindow->m_bDoPostToDestroy) {
+ if(pBaseWindow->m_bDoPostToDestroy)
+ {
EXECUTE_ASSERT(SetEvent((HANDLE)wParam));
}
return 0;
}
- return pBaseWindow->OnReceiveMessage(hwnd,uMsg,wParam,lParam);
+ return pBaseWindow->OnReceiveMessage(hwnd, uMsg, wParam, lParam);
}
@@ -496,7 +521,7 @@ BOOL CBaseWindow::OnSize(LONG Width, LONG Height)
BOOL CBaseWindow::OnClose()
{
- ShowWindow(m_hwnd,SW_HIDE);
+ ShowWindow(m_hwnd, SW_HIDE);
return TRUE;
}
@@ -511,7 +536,8 @@ HRESULT CBaseWindow::UninitialiseWindow()
{
// Have we already cleaned up
- if (m_hwnd == NULL) {
+ if(m_hwnd == NULL)
+ {
ASSERT(m_hdc == NULL);
ASSERT(m_MemoryDC == NULL);
return NOERROR;
@@ -521,13 +547,13 @@ HRESULT CBaseWindow::UninitialiseWindow()
EXECUTE_ASSERT(GdiFlush());
- if (m_hdc)
+ if(m_hdc)
{
- EXECUTE_ASSERT(ReleaseDC(m_hwnd,m_hdc));
+ EXECUTE_ASSERT(ReleaseDC(m_hwnd, m_hdc));
m_hdc = NULL;
}
- if (m_MemoryDC)
+ if(m_MemoryDC)
{
EXECUTE_ASSERT(DeleteDC(m_MemoryDC));
m_MemoryDC = NULL;
@@ -554,13 +580,13 @@ HRESULT CBaseWindow::InitialiseWindow(HWND hwnd)
ASSERT(IsWindow(hwnd));
m_hwnd = hwnd;
- if (m_bDoGetDC)
+ if(m_bDoGetDC)
{
EXECUTE_ASSERT(m_hdc = GetDC(hwnd));
EXECUTE_ASSERT(m_MemoryDC = CreateCompatibleDC(m_hdc));
- EXECUTE_ASSERT(SetStretchBltMode(m_hdc,COLORONCOLOR));
- EXECUTE_ASSERT(SetStretchBltMode(m_MemoryDC,COLORONCOLOR));
+ EXECUTE_ASSERT(SetStretchBltMode(m_hdc, COLORONCOLOR));
+ EXECUTE_ASSERT(SetStretchBltMode(m_MemoryDC, COLORONCOLOR));
}
return NOERROR;
@@ -580,12 +606,13 @@ HRESULT CBaseWindow::DoCreateWindow()
// for the entire lifetime of the window then changes the class style to do
// say so. If we don't set this flag then the DC comes from the cache and is
// really bad.
- if (m_bDoGetDC)
+ if(m_bDoGetDC)
{
m_ClassStyles |= CS_OWNDC;
}
- if (bRegistered == FALSE) {
+ if(bRegistered == FALSE)
+ {
// Register the renderer window class
@@ -596,7 +623,7 @@ HRESULT CBaseWindow::DoCreateWindow()
wndclass.cbWndExtra = sizeof(CBaseWindow *);
wndclass.hInstance = m_hInstance;
wndclass.hIcon = NULL;
- wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) NULL;
wndclass.lpszMenuName = NULL;
@@ -625,7 +652,8 @@ HRESULT CBaseWindow::DoCreateWindow()
// last Win32 error on this thread) then signal the constructor thread
// to continue, release the mutex to let others have a go and exit
- if (hwnd == NULL) {
+ if(hwnd == NULL)
+ {
DWORD Error = GetLastError();
return AmHresultFromWin32(Error);
}
@@ -657,7 +685,7 @@ INT_PTR CBaseWindow::OnReceiveMessage(HWND hwnd, // Window handle
{
ASSERT(IsWindow(hwnd));
- if (PossiblyEatMessage(uMsg, wParam, lParam))
+ if(PossiblyEatMessage(uMsg, wParam, lParam))
return 0;
// This is sent by the IVideoWindow SetWindowForeground method. If the
@@ -666,7 +694,8 @@ INT_PTR CBaseWindow::OnReceiveMessage(HWND hwnd, // Window handle
// topmost window without the foreground focus. If wParam is TRUE then
// for both cases the window will be forced into the foreground focus
- if (uMsg == m_ShowStageMessage) {
+ if(uMsg == m_ShowStageMessage)
+ {
BOOL bVisible = IsWindowVisible(hwnd);
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,
@@ -674,7 +703,8 @@ INT_PTR CBaseWindow::OnReceiveMessage(HWND hwnd, // Window handle
(bVisible ? SWP_NOACTIVATE : 0));
// Should we bring the window to the foreground
- if (wParam == TRUE) {
+ if(wParam == TRUE)
+ {
SetForegroundWindow(hwnd);
}
return (LRESULT) 1;
@@ -686,7 +716,8 @@ INT_PTR CBaseWindow::OnReceiveMessage(HWND hwnd, // Window handle
// must be on the same thread as that which created the window. The
// wParam parameter can be TRUE or FALSE to set and reset the topmost
- if (uMsg == m_ShowStageTop) {
+ if(uMsg == m_ShowStageTop)
+ {
HWND HwndTop = (wParam == TRUE ? HWND_TOPMOST : HWND_NOTOPMOST);
BOOL bVisible = IsWindowVisible(hwnd);
SetWindowPos(hwnd, HwndTop, 0, 0, 0, 0,
@@ -697,24 +728,26 @@ INT_PTR CBaseWindow::OnReceiveMessage(HWND hwnd, // Window handle
}
// New palette stuff
- if (uMsg == m_RealizePalette) {
+ if(uMsg == m_RealizePalette)
+ {
ASSERT(m_hwnd == hwnd);
- return OnPaletteChange(m_hwnd,WM_QUERYNEWPALETTE);
+ return OnPaletteChange(m_hwnd, WM_QUERYNEWPALETTE);
}
- switch (uMsg) {
+ switch(uMsg)
+ {
// Repaint the window if the system colours change
case WM_SYSCOLORCHANGE:
- InvalidateRect(hwnd,NULL,FALSE);
+ InvalidateRect(hwnd, NULL, FALSE);
return (LRESULT) 1;
- // Somebody has changed the palette
+ // Somebody has changed the palette
case WM_PALETTECHANGED:
- OnPaletteChange((HWND)wParam,uMsg);
+ OnPaletteChange((HWND)wParam, uMsg);
return (LRESULT) 0;
// We are about to receive the keyboard focus so we ask GDI to realise
@@ -723,33 +756,34 @@ INT_PTR CBaseWindow::OnReceiveMessage(HWND hwnd, // Window handle
case WM_QUERYNEWPALETTE:
ASSERT(m_hwnd == hwnd);
- return OnPaletteChange(m_hwnd,uMsg);
+ return OnPaletteChange(m_hwnd, uMsg);
- // do NOT fwd WM_MOVE. the parameters are the location of the parent
- // window, NOT what the renderer should be looking at. But we need
- // to make sure the overlay is moved with the parent window, so we
- // do this.
+ // do NOT fwd WM_MOVE. the parameters are the location of the parent
+ // window, NOT what the renderer should be looking at. But we need
+ // to make sure the overlay is moved with the parent window, so we
+ // do this.
case WM_MOVE:
- if (IsWindowVisible(m_hwnd)) {
- PostMessage(m_hwnd,WM_PAINT,0,0);
+ if(IsWindowVisible(m_hwnd))
+ {
+ PostMessage(m_hwnd, WM_PAINT, 0, 0);
}
break;
- // Store the width and height as useful base class members
+ // Store the width and height as useful base class members
case WM_SIZE:
OnSize(LOWORD(lParam), HIWORD(lParam));
return (LRESULT) 0;
- // Intercept the WM_CLOSE messages to hide the window
+ // Intercept the WM_CLOSE messages to hide the window
case WM_CLOSE:
OnClose();
return (LRESULT) 0;
}
- return DefWindowProc(hwnd,uMsg,wParam,lParam);
+ return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
@@ -760,23 +794,26 @@ INT_PTR CBaseWindow::OnReceiveMessage(HWND hwnd, // Window handle
// includes the standard VGA colours (at the beginning and end) otherwise
// GDI may have to map from our palette to the device palette while drawing
-LRESULT CBaseWindow::OnPaletteChange(HWND hwnd,UINT Message)
+LRESULT CBaseWindow::OnPaletteChange(HWND hwnd, UINT Message)
{
// First check we are not changing the palette during closedown
- if (m_hwnd == NULL || hwnd == NULL) {
+ if(m_hwnd == NULL || hwnd == NULL)
+ {
return (LRESULT) 0;
}
ASSERT(!m_bRealizing);
// Should we realise our palette again
- if ((Message == WM_QUERYNEWPALETTE || hwnd != m_hwnd)) {
+ if((Message == WM_QUERYNEWPALETTE || hwnd != m_hwnd))
+ {
// It seems that even if we're invisible that we can get asked
// to realize our palette and this can cause really ugly side-effects
// Seems like there's another bug but this masks it a least for the
// shutting down case.
- if (!IsWindowVisible(m_hwnd)) {
+ if(!IsWindowVisible(m_hwnd))
+ {
DbgLog((LOG_TRACE, 1, TEXT("Realizing when invisible!")));
return (LRESULT) 0;
}
@@ -791,8 +828,9 @@ LRESULT CBaseWindow::OnPaletteChange(HWND hwnd,UINT Message)
#endif
// Should we redraw the window with the new palette
- if (Message == WM_PALETTECHANGED) {
- InvalidateRect(m_hwnd,NULL,FALSE);
+ if(Message == WM_PALETTECHANGED)
+ {
+ InvalidateRect(m_hwnd, NULL, FALSE);
}
}
@@ -812,7 +850,7 @@ bool CBaseWindow::WindowExists()
RECT CBaseWindow::GetDefaultRect()
{
- RECT DefaultRect = {0,0,DEFWIDTH,DEFHEIGHT};
+ RECT DefaultRect = {0, 0, DEFWIDTH, DEFHEIGHT};
ASSERT(m_hwnd);
// ASSERT(m_hdc);
return DefaultRect;
@@ -886,7 +924,7 @@ HPALETTE CBaseWindow::GetPalette()
HRESULT CBaseWindow::DoShowWindow(LONG ShowCmd)
{
- ShowWindow(m_hwnd,ShowCmd);
+ ShowWindow(m_hwnd, ShowCmd);
return NOERROR;
}
@@ -895,7 +933,7 @@ HRESULT CBaseWindow::DoShowWindow(LONG ShowCmd)
void CBaseWindow::PaintWindow(BOOL bErase)
{
- InvalidateRect(m_hwnd,NULL,bErase);
+ InvalidateRect(m_hwnd, NULL, bErase);
}
@@ -907,7 +945,7 @@ void CBaseWindow::PaintWindow(BOOL bErase)
void CBaseWindow::DoSetWindowForeground(BOOL bFocus)
{
- SendMessage(m_hwnd,m_ShowStageMessage,(WPARAM) bFocus,(LPARAM) 0);
+ SendMessage(m_hwnd, m_ShowStageMessage, (WPARAM) bFocus, (LPARAM) 0);
}
@@ -946,7 +984,8 @@ void CDrawImage::DisplaySampleTimes(IMediaSample *pSample)
// logging "way up"
//
BOOL bAccept = DbgCheckModuleLevel(LOG_TRACE, 5);
- if (bAccept == FALSE) {
+ if(bAccept == FALSE)
+ {
return;
}
#endif
@@ -960,26 +999,27 @@ void CDrawImage::DisplaySampleTimes(IMediaSample *pSample)
pSample->GetTime((REFERENCE_TIME*)&m_StartSample, (REFERENCE_TIME*)&m_EndSample);
HWND hwnd = m_pBaseWindow->GetWindowHWND();
- EXECUTE_ASSERT(GetClientRect(hwnd,&ClientRect));
+ EXECUTE_ASSERT(GetClientRect(hwnd, &ClientRect));
// Format the sample time stamps
- (void)StringCchPrintf(szTimes,NUMELMS(szTimes),TEXT("%08d : %08d"),
- m_StartSample.Millisecs(),
- m_EndSample.Millisecs());
+ (void)StringCchPrintf(szTimes, NUMELMS(szTimes), TEXT("%08d : %08d"),
+ m_StartSample.Millisecs(),
+ m_EndSample.Millisecs());
ASSERT(lstrlen(szTimes) < TIMELENGTH);
// Put the times in the middle at the bottom of the window
- GetTextExtentPoint32(m_hdc,szTimes,lstrlen(szTimes),&Size);
+ GetTextExtentPoint32(m_hdc, szTimes, lstrlen(szTimes), &Size);
INT XPos = ((ClientRect.right - ClientRect.left) - Size.cx) / 2;
INT YPos = ((ClientRect.bottom - ClientRect.top) - Size.cy) * 4 / 5;
// Check the window is big enough to have sample times displayed
- if ((XPos > 0) && (YPos > 0)) {
- TextOut(m_hdc,XPos,YPos,szTimes,lstrlen(szTimes));
+ if((XPos > 0) && (YPos > 0))
+ {
+ TextOut(m_hdc, XPos, YPos, szTimes, lstrlen(szTimes));
}
}
@@ -988,14 +1028,14 @@ void CDrawImage::DisplaySampleTimes(IMediaSample *pSample)
// palette cookie. We simply call the SetDIBColorTable Windows API with the
// palette that is found after the BITMAPINFOHEADER - we return no errors
-void CDrawImage::UpdateColourTable(HDC hdc,__in BITMAPINFOHEADER *pbmi)
+void CDrawImage::UpdateColourTable(HDC hdc, __in BITMAPINFOHEADER *pbmi)
{
ASSERT(pbmi->biClrUsed);
- RGBQUAD *pColourTable = (RGBQUAD *)(pbmi+1);
+ RGBQUAD *pColourTable = (RGBQUAD *)(pbmi + 1);
// Set the new palette in the device context
- UINT uiReturn = SetDIBColorTable(hdc,(UINT) 0,
+ UINT uiReturn = SetDIBColorTable(hdc, (UINT) 0,
pbmi->biClrUsed,
pColourTable);
@@ -1037,12 +1077,13 @@ void CDrawImage::FastRender(IMediaSample *pMediaSample)
pbmi = HEADER(m_pMediaType->Format());
pSample = (CImageSample *) pMediaSample;
pDibData = pSample->GetDIBData();
- hOldBitmap = (HBITMAP) SelectObject(m_MemoryDC,pDibData->hBitmap);
+ hOldBitmap = (HBITMAP) SelectObject(m_MemoryDC, pDibData->hBitmap);
// Get a pointer to the real image data
HRESULT hr = pMediaSample->GetPointer(&pImage);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return;
}
@@ -1052,9 +1093,10 @@ void CDrawImage::FastRender(IMediaSample *pMediaSample)
// By the time we get to draw the images the format change will be done
// so all we do is ask the renderer for what it's palette version is
- if (pDibData->PaletteVersion < GetPaletteVersion()) {
+ if(pDibData->PaletteVersion < GetPaletteVersion())
+ {
ASSERT(pbmi->biBitCount <= iPALETTE);
- UpdateColourTable(m_MemoryDC,pbmi);
+ UpdateColourTable(m_MemoryDC, pbmi);
pDibData->PaletteVersion = GetPaletteVersion();
}
@@ -1069,7 +1111,8 @@ void CDrawImage::FastRender(IMediaSample *pMediaSample)
// Is the window the same size as the video
- if (m_bStretch == FALSE) {
+ if(m_bStretch == FALSE)
+ {
// Put the image straight into the window
@@ -1084,7 +1127,9 @@ void CDrawImage::FastRender(IMediaSample *pMediaSample)
SourceRect.top, // Y source position
SRCCOPY); // Simple copy
- } else {
+ }
+ else
+ {
// Stretch the image when copying to the window
@@ -1106,12 +1151,12 @@ void CDrawImage::FastRender(IMediaSample *pMediaSample)
// draw the times into the offscreen device context however that actually
// writes the text into the image data buffer which may not be writable
- #ifdef _DEBUG
+#ifdef _DEBUG
DisplaySampleTimes(pMediaSample);
- #endif
+#endif
// Put the old bitmap back into the device context so we don't leak
- SelectObject(m_MemoryDC,hOldBitmap);
+ SelectObject(m_MemoryDC, hOldBitmap);
}
@@ -1134,7 +1179,8 @@ void CDrawImage::SlowRender(IMediaSample *pMediaSample)
// Get the image data buffer
HRESULT hr = pMediaSample->GetPointer(&pImage);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return;
}
@@ -1150,12 +1196,14 @@ void CDrawImage::SlowRender(IMediaSample *pMediaSample)
LONG lAdjustedSourceTop = SourceRect.top;
// if the origin of bitmap is bottom-left, adjust soruce_rect_top
// to be the bottom-left corner instead of the top-left.
- if (pbmi->biHeight > 0) {
- lAdjustedSourceTop = pbmi->biHeight - SourceRect.bottom;
+ if(pbmi->biHeight > 0)
+ {
+ lAdjustedSourceTop = pbmi->biHeight - SourceRect.bottom;
}
// Is the window the same size as the video
- if (m_bStretch == FALSE) {
+ if(m_bStretch == FALSE)
+ {
// Put the image straight into the window
@@ -1173,7 +1221,9 @@ void CDrawImage::SlowRender(IMediaSample *pMediaSample)
(BITMAPINFO *) pbmi, // DIB header
DIB_RGB_COLORS); // Type of palette
- } else {
+ }
+ else
+ {
// Stretch the image when copying to the window
@@ -1201,9 +1251,9 @@ void CDrawImage::SlowRender(IMediaSample *pMediaSample)
// the screen, unfortunately this has considerable performance penalties
// and also means that this code is not executed when compiled retail
- #ifdef _DEBUG
+#ifdef _DEBUG
DisplaySampleTimes(pMediaSample);
- #endif
+#endif
}
@@ -1225,7 +1275,8 @@ BOOL CDrawImage::DrawImage(IMediaSample *pMediaSample)
// use to do faster image rendering, they may optionally also contain a
// DirectDraw surface pointer in which case we do not do the drawing
- if (m_bUsingImageAllocator == FALSE) {
+ if(m_bUsingImageAllocator == FALSE)
+ {
SlowRender(pMediaSample);
EXECUTE_ASSERT(GdiFlush());
NotifyEndDraw();
@@ -1246,7 +1297,7 @@ BOOL CDrawImage::DrawVideoImageHere(
IMediaSample *pMediaSample,
__in LPRECT lprcSrc,
__in LPRECT lprcDst
- )
+)
{
ASSERT(m_pMediaType);
BITMAPINFOHEADER *pbmi = HEADER(m_pMediaType->Format());
@@ -1255,19 +1306,22 @@ BOOL CDrawImage::DrawVideoImageHere(
// Get the image data buffer
HRESULT hr = pMediaSample->GetPointer(&pImage);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return FALSE;
}
RECT SourceRect;
RECT TargetRect;
- if (lprcSrc) {
+ if(lprcSrc)
+ {
SourceRect = *lprcSrc;
}
else SourceRect = ScaleSourceRect(&m_SourceRect);
- if (lprcDst) {
+ if(lprcDst)
+ {
TargetRect = *lprcDst;
}
else TargetRect = m_TargetRect;
@@ -1275,8 +1329,9 @@ BOOL CDrawImage::DrawVideoImageHere(
LONG lAdjustedSourceTop = SourceRect.top;
// if the origin of bitmap is bottom-left, adjust soruce_rect_top
// to be the bottom-left corner instead of the top-left.
- if (pbmi->biHeight > 0) {
- lAdjustedSourceTop = pbmi->biHeight - SourceRect.bottom;
+ if(pbmi->biHeight > 0)
+ {
+ lAdjustedSourceTop = pbmi->biHeight - SourceRect.bottom;
}
@@ -1369,8 +1424,10 @@ void CDrawImage::SetStretchMode()
LONG SinkHeight = m_TargetRect.bottom - m_TargetRect.top;
m_bStretch = TRUE;
- if (SourceWidth == SinkWidth) {
- if (SourceHeight == SinkHeight) {
+ if(SourceWidth == SinkWidth)
+ {
+ if(SourceHeight == SinkHeight)
+ {
m_bStretch = FALSE;
}
}
@@ -1450,7 +1507,7 @@ void CDrawImage::IncrementPaletteVersion()
CImageAllocator::CImageAllocator(__inout CBaseFilter *pFilter,
__in_opt LPCTSTR pName,
__inout HRESULT *phr) :
- CBaseAllocator(pName,NULL,phr,TRUE,TRUE),
+ CBaseAllocator(pName, NULL, phr, TRUE, TRUE),
m_pFilter(pFilter)
{
ASSERT(phr);
@@ -1480,7 +1537,8 @@ void CImageAllocator::Free()
CImageSample *pSample;
DIBDATA *pDibData;
- while (m_lFree.GetCount() != 0) {
+ while(m_lFree.GetCount() != 0)
+ {
pSample = (CImageSample *) m_lFree.RemoveHead();
pDibData = pSample->GetDIBData();
EXECUTE_ASSERT(DeleteObject(pDibData->hBitmap));
@@ -1498,7 +1556,8 @@ STDMETHODIMP CImageAllocator::CheckSizes(__in ALLOCATOR_PROPERTIES *pRequest)
{
// Check we have a valid connection
- if (m_pMediaType == NULL) {
+ if(m_pMediaType == NULL)
+ {
return VFW_E_NOT_CONNECTED;
}
@@ -1514,13 +1573,15 @@ STDMETHODIMP CImageAllocator::CheckSizes(__in ALLOCATOR_PROPERTIES *pRequest)
// for an image smaller than this then we reject the call, if they ask
// for an image larger than this then we return what they can have
- if ((DWORD) pRequest->cbBuffer < pVideoInfo->bmiHeader.biSizeImage) {
+ if((DWORD) pRequest->cbBuffer < pVideoInfo->bmiHeader.biSizeImage)
+ {
return E_INVALIDARG;
}
// Reject buffer prefixes
- if (pRequest->cbPrefix > 0) {
+ if(pRequest->cbPrefix > 0)
+ {
return E_INVALIDARG;
}
@@ -1542,7 +1603,8 @@ STDMETHODIMP CImageAllocator::SetProperties(
// Check the parameters fit with the current connection
HRESULT hr = CheckSizes(&Adjusted);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
return CBaseAllocator::SetProperties(&Adjusted, pActual);
@@ -1566,7 +1628,8 @@ HRESULT CImageAllocator::Alloc(void)
// Check the base allocator says it's ok to continue
HRESULT hr = CBaseAllocator::Alloc();
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
@@ -1576,19 +1639,22 @@ HRESULT CImageAllocator::Alloc(void)
// case the available sample list is left with those already created
ASSERT(m_lAllocated == 0);
- while (m_lAllocated < m_lCount) {
+ while(m_lAllocated < m_lCount)
+ {
// Create and initialise a shared memory GDI buffer
- hr = CreateDIB(m_lSize,DibData);
- if (FAILED(hr)) {
+ hr = CreateDIB(m_lSize, DibData);
+ if(FAILED(hr))
+ {
return hr;
}
// Create the sample object and pass it the DIBDATA
- pSample = CreateImageSample(DibData.pBase,m_lSize);
- if (pSample == NULL) {
+ pSample = CreateImageSample(DibData.pBase, m_lSize);
+ if(pSample == NULL)
+ {
EXECUTE_ASSERT(DeleteObject(DibData.hBitmap));
EXECUTE_ASSERT(CloseHandle(DibData.hMapping));
return E_OUTOFMEMORY;
@@ -1608,7 +1674,7 @@ HRESULT CImageAllocator::Alloc(void)
// may override it and allocate more specialised sample objects. So long as it
// derives its samples from CImageSample then all this code will still work ok
-CImageSample *CImageAllocator::CreateImageSample(__in_bcount(Length) LPBYTE pData,LONG Length)
+CImageSample *CImageAllocator::CreateImageSample(__in_bcount(Length) LPBYTE pData, LONG Length)
{
HRESULT hr = NOERROR;
CImageSample *pSample;
@@ -1621,7 +1687,8 @@ CImageSample *CImageAllocator::CreateImageSample(__in_bcount(Length) LPBYTE pDat
(LPBYTE) pData, // DIB address
(LONG) Length); // Size of DIB
- if (pSample == NULL || FAILED(hr)) {
+ if(pSample == NULL || FAILED(hr))
+ {
delete pSample;
return NULL;
}
@@ -1633,7 +1700,7 @@ CImageSample *CImageAllocator::CreateImageSample(__in_bcount(Length) LPBYTE pDat
// generating DIBs for us to render. The memory block is created in shared
// memory so that GDI doesn't have to copy the memory when we do a BitBlt
-HRESULT CImageAllocator::CreateDIB(LONG InSize,DIBDATA &DibData)
+HRESULT CImageAllocator::CreateDIB(LONG InSize, DIBDATA &DibData)
{
BITMAPINFO *pbmi; // Format information for pin
BYTE *pBase; // Pointer to the actual image
@@ -1648,7 +1715,8 @@ HRESULT CImageAllocator::CreateDIB(LONG InSize,DIBDATA &DibData)
(DWORD) 0, // Less than 4Gb in size
InSize, // Size of buffer
NULL); // No name to section
- if (hMapping == NULL) {
+ if(hMapping == NULL)
+ {
DWORD Error = GetLastError();
return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, Error);
}
@@ -1659,7 +1727,8 @@ HRESULT CImageAllocator::CreateDIB(LONG InSize,DIBDATA &DibData)
// have the focus) in which case GDI will do after the palette mapping
pbmi = (BITMAPINFO *) HEADER(m_pMediaType->Format());
- if (m_pMediaType == NULL) {
+ if(m_pMediaType == NULL)
+ {
DbgBreak("Invalid media type");
}
@@ -1670,7 +1739,8 @@ HRESULT CImageAllocator::CreateDIB(LONG InSize,DIBDATA &DibData)
hMapping, // Mapped memory handle
(DWORD) 0); // Offset into memory
- if (hBitmap == NULL || pBase == NULL) {
+ if(hBitmap == NULL || pBase == NULL)
+ {
EXECUTE_ASSERT(CloseHandle(hMapping));
DWORD Error = GetLastError();
return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, Error);
@@ -1682,7 +1752,7 @@ HRESULT CImageAllocator::CreateDIB(LONG InSize,DIBDATA &DibData)
DibData.hMapping = hMapping;
DibData.pBase = pBase;
DibData.PaletteVersion = PALETTE_VERSION;
- GetObject(hBitmap,sizeof(DIBSECTION),(VOID *)&DibData.DibSection);
+ GetObject(hBitmap, sizeof(DIBSECTION), (VOID *)&DibData.DibSection);
return NOERROR;
}
@@ -1733,7 +1803,7 @@ CImageSample::CImageSample(__inout CBaseAllocator *pAllocator,
__inout HRESULT *phr,
__in_bcount(length) LPBYTE pBuffer,
LONG length) :
- CMediaSample(pName,pAllocator,phr,pBuffer,length),
+ CMediaSample(pName, pAllocator, phr, pBuffer, length),
m_bInit(FALSE)
{
ASSERT(pAllocator);
@@ -1804,14 +1874,17 @@ BOOL CImagePalette::ShouldUpdate(const VIDEOINFOHEADER *pNewInfo,
{
// We may not have a current format yet
- if (pOldInfo == NULL) {
+ if(pOldInfo == NULL)
+ {
return TRUE;
}
// Do both formats not require a palette
- if (ContainsPalette(pNewInfo) == FALSE) {
- if (ContainsPalette(pOldInfo) == FALSE) {
+ if(ContainsPalette(pNewInfo) == FALSE)
+ {
+ if(ContainsPalette(pOldInfo) == FALSE)
+ {
return FALSE;
}
}
@@ -1819,13 +1892,14 @@ BOOL CImagePalette::ShouldUpdate(const VIDEOINFOHEADER *pNewInfo,
// Compare the colours to see if they match
DWORD VideoEntries = pNewInfo->bmiHeader.biClrUsed;
- if (ContainsPalette(pNewInfo) == TRUE)
- if (ContainsPalette(pOldInfo) == TRUE)
- if (pOldInfo->bmiHeader.biClrUsed == VideoEntries)
- if (pOldInfo->bmiHeader.biClrUsed > 0)
- if (memcmp((PVOID) GetBitmapPalette(pNewInfo),
- (PVOID) GetBitmapPalette(pOldInfo),
- VideoEntries * sizeof(RGBQUAD)) == 0) {
+ if(ContainsPalette(pNewInfo) == TRUE)
+ if(ContainsPalette(pOldInfo) == TRUE)
+ if(pOldInfo->bmiHeader.biClrUsed == VideoEntries)
+ if(pOldInfo->bmiHeader.biClrUsed > 0)
+ if(memcmp((PVOID) GetBitmapPalette(pNewInfo),
+ (PVOID) GetBitmapPalette(pOldInfo),
+ VideoEntries * sizeof(RGBQUAD)) == 0)
+ {
return FALSE;
}
@@ -1844,7 +1918,7 @@ BOOL CImagePalette::ShouldUpdate(const VIDEOINFOHEADER *pNewInfo,
HRESULT CImagePalette::PreparePalette(const CMediaType *pmtNew,
const CMediaType *pmtOld,
- __in LPSTR szDevice)
+ __in LPSTR szDevice)
{
const VIDEOINFOHEADER *pNewInfo = (VIDEOINFOHEADER *) pmtNew->Format();
const VIDEOINFOHEADER *pOldInfo = (VIDEOINFOHEADER *) pmtOld->Format();
@@ -1855,7 +1929,8 @@ HRESULT CImagePalette::PreparePalette(const CMediaType *pmtNew,
// when previously we didn't or vica versa then this returns TRUE, if we
// previously needed a palette and we do now it compares their colours
- if (ShouldUpdate(pNewInfo,pOldInfo) == FALSE) {
+ if(ShouldUpdate(pNewInfo, pOldInfo) == FALSE)
+ {
NOTE("No update needed");
return S_FALSE;
}
@@ -1866,16 +1941,18 @@ HRESULT CImagePalette::PreparePalette(const CMediaType *pmtNew,
// or renderer lock will ensure it doesn't get in until we are finished
RemovePalette();
- m_pFilter->NotifyEvent(EC_PALETTE_CHANGED,0,0);
+ m_pFilter->NotifyEvent(EC_PALETTE_CHANGED, 0, 0);
// Do we need a palette for the new format
- if (ContainsPalette(pNewInfo) == FALSE) {
+ if(ContainsPalette(pNewInfo) == FALSE)
+ {
NOTE("New has no palette");
return S_FALSE;
}
- if (m_pBaseWindow) {
+ if(m_pBaseWindow)
+ {
m_pBaseWindow->LockPaletteLock();
}
@@ -1888,7 +1965,8 @@ HRESULT CImagePalette::PreparePalette(const CMediaType *pmtNew,
m_hPalette = MakePalette(pNewInfo, szDevice);
ASSERT(m_hPalette != NULL);
- if (m_pBaseWindow) {
+ if(m_pBaseWindow)
+ {
m_pBaseWindow->UnlockPaletteLock();
}
@@ -1896,13 +1974,13 @@ HRESULT CImagePalette::PreparePalette(const CMediaType *pmtNew,
// pointer to signal that no window is in use, if so we don't call it
// Some filters just want to use this object to create/manage palettes
- if (m_pBaseWindow) m_pBaseWindow->SetPalette(m_hPalette);
+ if(m_pBaseWindow) m_pBaseWindow->SetPalette(m_hPalette);
// This is the only time where we need access to the draw object to say
// to it that a new palette will be arriving on a sample real soon. The
// constructor may take a NULL pointer in which case we don't call this
- if (m_pDrawImage) m_pDrawImage->IncrementPaletteVersion();
+ if(m_pDrawImage) m_pDrawImage->IncrementPaletteVersion();
return NOERROR;
}
@@ -1913,7 +1991,7 @@ HRESULT CImagePalette::PreparePalette(const CMediaType *pmtNew,
// any buffer (eg YUV) and hand it back. We make a new palette out of that
// format and then copy the palette colours into the current connection type
-HRESULT CImagePalette::CopyPalette(const CMediaType *pSrc,__out CMediaType *pDest)
+HRESULT CImagePalette::CopyPalette(const CMediaType *pSrc, __out CMediaType *pDest)
{
// Reset the destination palette before starting
@@ -1923,7 +2001,8 @@ HRESULT CImagePalette::CopyPalette(const CMediaType *pSrc,__out CMediaType *pDes
// Does the destination have a palette
- if (PALETTISED(pDestInfo) == FALSE) {
+ if(PALETTISED(pDestInfo) == FALSE)
+ {
NOTE("No destination palette");
return S_FALSE;
}
@@ -1931,7 +2010,8 @@ HRESULT CImagePalette::CopyPalette(const CMediaType *pSrc,__out CMediaType *pDes
// Does the source contain a palette
const VIDEOINFOHEADER *pSrcInfo = (VIDEOINFOHEADER *) pSrc->Format();
- if (ContainsPalette(pSrcInfo) == FALSE) {
+ if(ContainsPalette(pSrcInfo) == FALSE)
+ {
NOTE("No source palette");
return S_FALSE;
}
@@ -1939,9 +2019,10 @@ HRESULT CImagePalette::CopyPalette(const CMediaType *pSrc,__out CMediaType *pDes
// The number of colours may be zero filled
DWORD PaletteEntries = pSrcInfo->bmiHeader.biClrUsed;
- if (PaletteEntries == 0) {
+ if(PaletteEntries == 0)
+ {
DWORD Maximum = (1 << pSrcInfo->bmiHeader.biBitCount);
- NOTE1("Setting maximum colours (%d)",Maximum);
+ NOTE1("Setting maximum colours (%d)", Maximum);
PaletteEntries = Maximum;
}
@@ -1954,7 +2035,8 @@ HRESULT CImagePalette::CopyPalette(const CMediaType *pSrc,__out CMediaType *pDes
pDestInfo->bmiHeader.biClrImportant = pSrcInfo->bmiHeader.biClrImportant;
ULONG BitmapSize = GetBitmapFormatSize(HEADER(pSrcInfo));
- if (pDest->FormatLength() < BitmapSize) {
+ if(pDest->FormatLength() < BitmapSize)
+ {
NOTE("Reallocating destination");
pDest->ReallocFormatBuffer(BitmapSize);
}
@@ -1976,15 +2058,18 @@ HRESULT CImagePalette::CopyPalette(const CMediaType *pSrc,__out CMediaType *pDes
HRESULT CImagePalette::RemovePalette()
{
- if (m_pBaseWindow) {
+ if(m_pBaseWindow)
+ {
m_pBaseWindow->LockPaletteLock();
}
// Do we have a palette to remove
- if (m_hPalette != NULL) {
+ if(m_hPalette != NULL)
+ {
- if (m_pBaseWindow) {
+ if(m_pBaseWindow)
+ {
// Make sure that the window's palette handle matches
// our palette handle.
ASSERT(m_hPalette == m_pBaseWindow->GetPalette());
@@ -1996,7 +2081,8 @@ HRESULT CImagePalette::RemovePalette()
m_hPalette = NULL;
}
- if (m_pBaseWindow) {
+ if(m_pBaseWindow)
+ {
m_pBaseWindow->UnlockPaletteLock();
}
@@ -2024,7 +2110,8 @@ HPALETTE CImagePalette::MakePalette(const VIDEOINFOHEADER *pVideoInfo, __in LPST
HPALETTE hPalette; // Logical palette object
lp = (LOGPALETTE *) new BYTE[sizeof(LOGPALETTE) + SIZE_PALETTE];
- if (lp == NULL) {
+ if(lp == NULL)
+ {
return NULL;
}
@@ -2036,10 +2123,11 @@ HPALETTE CImagePalette::MakePalette(const VIDEOINFOHEADER *pVideoInfo, __in LPST
lp->palVersion = PALVERSION;
lp->palNumEntries = (USHORT) pHeader->biClrUsed;
- if (lp->palNumEntries == 0) lp->palNumEntries = (1 << pHeader->biBitCount);
+ if(lp->palNumEntries == 0) lp->palNumEntries = (1 << pHeader->biBitCount);
pColours = GetBitmapPalette(pVideoInfo);
- for (DWORD dwCount = 0;dwCount < lp->palNumEntries;dwCount++) {
+ for(DWORD dwCount = 0; dwCount < lp->palNumEntries; dwCount++)
+ {
lp->palPalEntry[dwCount].peRed = pColours[dwCount].rgbRed;
lp->palPalEntry[dwCount].peGreen = pColours[dwCount].rgbGreen;
lp->palPalEntry[dwCount].peBlue = pColours[dwCount].rgbBlue;
@@ -2067,7 +2155,7 @@ HPALETTE CImagePalette::MakePalette(const VIDEOINFOHEADER *pVideoInfo, __in LPST
// We can be passed an optional device name if we wish to prepare a palette
// for a specific monitor on a multi monitor system
-HRESULT CImagePalette::MakeIdentityPalette(__inout_ecount_full(iColours) PALETTEENTRY *pEntry,INT iColours, __in LPSTR szDevice)
+HRESULT CImagePalette::MakeIdentityPalette(__inout_ecount_full(iColours) PALETTEENTRY *pEntry, INT iColours, __in LPSTR szDevice)
{
PALETTEENTRY SystemEntries[10]; // System palette entries
BOOL bIdentityPalette = TRUE; // Is an identity palette
@@ -2077,7 +2165,8 @@ HRESULT CImagePalette::MakeIdentityPalette(__inout_ecount_full(iColours) PALETTE
// Does this have the full colour range
- if (iColours < 10) {
+ if(iColours < 10)
+ {
return S_FALSE;
}
@@ -2086,15 +2175,17 @@ HRESULT CImagePalette::MakeIdentityPalette(__inout_ecount_full(iColours) PALETTE
// Get a DC on the right monitor - it's ugly, but this is the way you have
// to do it
HDC hdc;
- if (szDevice == NULL || lstrcmpiLocaleIndependentA(szDevice, "DISPLAY") == 0)
+ if(szDevice == NULL || lstrcmpiLocaleIndependentA(szDevice, "DISPLAY") == 0)
hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
else
hdc = CreateDCA(NULL, szDevice, NULL, NULL);
- if (NULL == hdc) {
+ if(NULL == hdc)
+ {
return E_OUTOFMEMORY;
}
- INT Reserved = GetDeviceCaps(hdc,NUMRESERVED);
- if (Reserved != 20) {
+ INT Reserved = GetDeviceCaps(hdc, NUMRESERVED);
+ if(Reserved != 20)
+ {
DeleteDC(hdc);
return S_FALSE;
}
@@ -2103,24 +2194,29 @@ HRESULT CImagePalette::MakeIdentityPalette(__inout_ecount_full(iColours) PALETTE
// don't do a memory compare between our two arrays of colours is because
// I am not sure what will be in the flags fields for the system entries
- UINT Result = GetSystemPaletteEntries(hdc,0,PalLoCount,SystemEntries);
- for (UINT Count = 0;Count < Result;Count++) {
- if (SystemEntries[Count].peRed != pEntry[Count].peRed ||
- SystemEntries[Count].peGreen != pEntry[Count].peGreen ||
- SystemEntries[Count].peBlue != pEntry[Count].peBlue) {
- bIdentityPalette = FALSE;
+ UINT Result = GetSystemPaletteEntries(hdc, 0, PalLoCount, SystemEntries);
+ for(UINT Count = 0; Count < Result; Count++)
+ {
+ if(SystemEntries[Count].peRed != pEntry[Count].peRed ||
+ SystemEntries[Count].peGreen != pEntry[Count].peGreen ||
+ SystemEntries[Count].peBlue != pEntry[Count].peBlue)
+ {
+ bIdentityPalette = FALSE;
}
}
// And likewise compare against the last ten entries
- Result = GetSystemPaletteEntries(hdc,PalHiStart,PalLoCount,SystemEntries);
- for (UINT Count = 0;Count < Result;Count++) {
- if (INT(Count) + PalHiStart < iColours) {
- if (SystemEntries[Count].peRed != pEntry[PalHiStart + Count].peRed ||
- SystemEntries[Count].peGreen != pEntry[PalHiStart + Count].peGreen ||
- SystemEntries[Count].peBlue != pEntry[PalHiStart + Count].peBlue) {
- bIdentityPalette = FALSE;
+ Result = GetSystemPaletteEntries(hdc, PalHiStart, PalLoCount, SystemEntries);
+ for(UINT Count = 0; Count < Result; Count++)
+ {
+ if(INT(Count) + PalHiStart < iColours)
+ {
+ if(SystemEntries[Count].peRed != pEntry[PalHiStart + Count].peRed ||
+ SystemEntries[Count].peGreen != pEntry[PalHiStart + Count].peGreen ||
+ SystemEntries[Count].peBlue != pEntry[PalHiStart + Count].peBlue)
+ {
+ bIdentityPalette = FALSE;
}
}
}
@@ -2128,13 +2224,15 @@ HRESULT CImagePalette::MakeIdentityPalette(__inout_ecount_full(iColours) PALETTE
// If not an identity palette then return S_FALSE
DeleteDC(hdc);
- if (bIdentityPalette == FALSE) {
+ if(bIdentityPalette == FALSE)
+ {
return S_FALSE;
}
// Set the non VGA entries so that GDI doesn't map them
- for (UINT Count = PalLoCount;INT(Count) < min(PalHiStart,iColours);Count++) {
+ for(UINT Count = PalLoCount; INT(Count) < min(PalHiStart, iColours); Count++)
+ {
pEntry[Count].peFlags = PC_NOCOLLAPSE;
}
return NOERROR;
@@ -2169,7 +2267,7 @@ HRESULT CImageDisplay::RefreshDisplayType(__in_opt LPSTR szDeviceName)
// Set the preferred format type
- ZeroMemory((PVOID)&m_Display,sizeof(VIDEOINFOHEADER)+sizeof(TRUECOLORINFO));
+ ZeroMemory((PVOID)&m_Display, sizeof(VIDEOINFOHEADER) + sizeof(TRUECOLORINFO));
m_Display.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
m_Display.bmiHeader.biBitCount = FALSE;
@@ -2178,26 +2276,29 @@ HRESULT CImageDisplay::RefreshDisplayType(__in_opt LPSTR szDeviceName)
// get caps of whichever monitor they are interested in (multi monitor)
HDC hdcDisplay;
// it's ugly, but this is the way you have to do it
- if (szDeviceName == NULL || lstrcmpiLocaleIndependentA(szDeviceName, "DISPLAY") == 0)
+ if(szDeviceName == NULL || lstrcmpiLocaleIndependentA(szDeviceName, "DISPLAY") == 0)
hdcDisplay = CreateDCA("DISPLAY", NULL, NULL, NULL);
else
hdcDisplay = CreateDCA(NULL, szDeviceName, NULL, NULL);
- if (hdcDisplay == NULL) {
- ASSERT(FALSE);
- DbgLog((LOG_ERROR,1,TEXT("ACK! Can't get a DC for %hs"),
+ if(hdcDisplay == NULL)
+ {
+ ASSERT(FALSE);
+ DbgLog((LOG_ERROR, 1, TEXT("ACK! Can't get a DC for %hs"),
szDeviceName ? szDeviceName : "<NULL>"));
- return E_FAIL;
- } else {
- DbgLog((LOG_TRACE,3,TEXT("Created a DC for %s"),
+ return E_FAIL;
+ }
+ else
+ {
+ DbgLog((LOG_TRACE, 3, TEXT("Created a DC for %s"),
szDeviceName ? szDeviceName : "<NULL>"));
}
- HBITMAP hbm = CreateCompatibleBitmap(hdcDisplay,1,1);
- if ( hbm )
+ HBITMAP hbm = CreateCompatibleBitmap(hdcDisplay, 1, 1);
+ if(hbm)
{
- GetDIBits(hdcDisplay,hbm,0,1,NULL,(BITMAPINFO *)&m_Display.bmiHeader,DIB_RGB_COLORS);
+ GetDIBits(hdcDisplay, hbm, 0, 1, NULL, (BITMAPINFO *)&m_Display.bmiHeader, DIB_RGB_COLORS);
// This call will get the colour table or the proper bitfields
- GetDIBits(hdcDisplay,hbm,0,1,NULL,(BITMAPINFO *)&m_Display.bmiHeader,DIB_RGB_COLORS);
+ GetDIBits(hdcDisplay, hbm, 0, 1, NULL, (BITMAPINFO *)&m_Display.bmiHeader, DIB_RGB_COLORS);
DeleteObject(hbm);
}
DeleteDC(hdcDisplay);
@@ -2206,8 +2307,8 @@ HRESULT CImageDisplay::RefreshDisplayType(__in_opt LPSTR szDeviceName)
ASSERT(CheckHeaderValidity(&m_Display));
UpdateFormat(&m_Display);
- DbgLog((LOG_TRACE,3,TEXT("New DISPLAY bit depth =%d"),
- m_Display.bmiHeader.biBitCount));
+ DbgLog((LOG_TRACE, 3, TEXT("New DISPLAY bit depth =%d"),
+ m_Display.bmiHeader.biBitCount));
return NOERROR;
}
@@ -2221,13 +2322,15 @@ BOOL CImageDisplay::CheckBitFields(const VIDEOINFO *pInput)
{
DWORD *pBitFields = (DWORD *) BITMASKS(pInput);
- for (INT iColour = iRED;iColour <= iBLUE;iColour++) {
+ for(INT iColour = iRED; iColour <= iBLUE; iColour++)
+ {
// First of all work out how many bits are set
DWORD SetBits = CountSetBits(pBitFields[iColour]);
- if (SetBits > iMAXBITS || SetBits == 0) {
- NOTE1("Bit fields for component %d invalid",iColour);
+ if(SetBits > iMAXBITS || SetBits == 0)
+ {
+ NOTE1("Bit fields for component %d invalid", iColour);
return FALSE;
}
@@ -2243,8 +2346,9 @@ BOOL CImageDisplay::CheckBitFields(const VIDEOINFO *pInput)
DWORD TestField = pBitFields[iColour] >> PrefixBits;
DWORD Mask = ULONG_MAX << SetBits;
- if (TestField & Mask) {
- NOTE1("Bit fields for component %d not contiguous",iColour);
+ if(TestField & Mask)
+ {
+ NOTE1("Bit fields for component %d not contiguous", iColour);
return FALSE;
}
}
@@ -2263,7 +2367,8 @@ DWORD CImageDisplay::CountSetBits(DWORD Field)
// Until the input is exhausted, count the number of bits
- while (init) {
+ while(init)
+ {
init = init & (init - 1); // Turn off the bottommost bit
Count++;
}
@@ -2280,14 +2385,17 @@ DWORD CImageDisplay::CountPrefixBits(DWORD Field)
DWORD Mask = 1;
DWORD Count = 0;
- while (TRUE) {
- if (Field & Mask) {
+ while(TRUE)
+ {
+ if(Field & Mask)
+ {
return Count;
}
Count++;
ASSERT(Mask != 0x80000000);
- if (Mask == 0x80000000) {
+ if(Mask == 0x80000000)
+ {
return Count;
}
Mask <<= 1;
@@ -2306,16 +2414,19 @@ BOOL CImageDisplay::CheckHeaderValidity(const VIDEOINFO *pInput)
{
// Check the bitmap width and height are not negative.
- if (pInput->bmiHeader.biWidth <= 0 ||
- pInput->bmiHeader.biHeight <= 0) {
+ if(pInput->bmiHeader.biWidth <= 0 ||
+ pInput->bmiHeader.biHeight <= 0)
+ {
NOTE("Invalid bitmap dimensions");
return FALSE;
}
// Check the compression is either BI_RGB or BI_BITFIELDS
- if (pInput->bmiHeader.biCompression != BI_RGB) {
- if (pInput->bmiHeader.biCompression != BI_BITFIELDS) {
+ if(pInput->bmiHeader.biCompression != BI_RGB)
+ {
+ if(pInput->bmiHeader.biCompression != BI_BITFIELDS)
+ {
NOTE("Invalid compression format");
return FALSE;
}
@@ -2323,9 +2434,12 @@ BOOL CImageDisplay::CheckHeaderValidity(const VIDEOINFO *pInput)
// If BI_BITFIELDS compression format check the colour depth
- if (pInput->bmiHeader.biCompression == BI_BITFIELDS) {
- if (pInput->bmiHeader.biBitCount != 16) {
- if (pInput->bmiHeader.biBitCount != 32) {
+ if(pInput->bmiHeader.biCompression == BI_BITFIELDS)
+ {
+ if(pInput->bmiHeader.biBitCount != 16)
+ {
+ if(pInput->bmiHeader.biBitCount != 32)
+ {
NOTE("BI_BITFIELDS not 16/32 bit depth");
return FALSE;
}
@@ -2334,8 +2448,10 @@ BOOL CImageDisplay::CheckHeaderValidity(const VIDEOINFO *pInput)
// Check the assumptions about the layout of the bit fields
- if (pInput->bmiHeader.biCompression == BI_BITFIELDS) {
- if (CheckBitFields(pInput) == FALSE) {
+ if(pInput->bmiHeader.biCompression == BI_BITFIELDS)
+ {
+ if(CheckBitFields(pInput) == FALSE)
+ {
NOTE("Bit fields are not valid");
return FALSE;
}
@@ -2343,15 +2459,18 @@ BOOL CImageDisplay::CheckHeaderValidity(const VIDEOINFO *pInput)
// Are the number of planes equal to one
- if (pInput->bmiHeader.biPlanes != 1) {
+ if(pInput->bmiHeader.biPlanes != 1)
+ {
NOTE("Number of planes not one");
return FALSE;
}
// Check the image size is consistent (it can be zero)
- if (pInput->bmiHeader.biSizeImage != GetBitmapSize(&pInput->bmiHeader)) {
- if (pInput->bmiHeader.biSizeImage) {
+ if(pInput->bmiHeader.biSizeImage != GetBitmapSize(&pInput->bmiHeader))
+ {
+ if(pInput->bmiHeader.biSizeImage)
+ {
NOTE("Image size incorrectly set");
return FALSE;
}
@@ -2359,7 +2478,8 @@ BOOL CImageDisplay::CheckHeaderValidity(const VIDEOINFO *pInput)
// Check the size of the structure
- if (pInput->bmiHeader.biSize != sizeof(BITMAPINFOHEADER)) {
+ if(pInput->bmiHeader.biSize != sizeof(BITMAPINFOHEADER))
+ {
NOTE("Size of BITMAPINFOHEADER wrong");
return FALSE;
}
@@ -2376,8 +2496,10 @@ BOOL CImageDisplay::CheckPaletteHeader(const VIDEOINFO *pInput)
{
// The checks here are for palettised videos only
- if (PALETTISED(pInput) == FALSE) {
- if (pInput->bmiHeader.biClrUsed) {
+ if(PALETTISED(pInput) == FALSE)
+ {
+ if(pInput->bmiHeader.biClrUsed)
+ {
NOTE("Invalid palette entries");
return FALSE;
}
@@ -2386,21 +2508,24 @@ BOOL CImageDisplay::CheckPaletteHeader(const VIDEOINFO *pInput)
// Compression type of BI_BITFIELDS is meaningless for palette video
- if (pInput->bmiHeader.biCompression != BI_RGB) {
+ if(pInput->bmiHeader.biCompression != BI_RGB)
+ {
NOTE("Palettised video must be BI_RGB");
return FALSE;
}
// Check the number of palette colours is correct
- if (pInput->bmiHeader.biClrUsed > PALETTE_ENTRIES(pInput)) {
+ if(pInput->bmiHeader.biClrUsed > PALETTE_ENTRIES(pInput))
+ {
NOTE("Too many colours in palette");
return FALSE;
}
// The number of important colours shouldn't exceed the number used
- if (pInput->bmiHeader.biClrImportant > pInput->bmiHeader.biClrUsed) {
+ if(pInput->bmiHeader.biClrImportant > pInput->bmiHeader.biClrUsed)
+ {
NOTE("Too many important colours");
return FALSE;
}
@@ -2450,8 +2575,10 @@ HRESULT CImageDisplay::UpdateFormat(__inout VIDEOINFO *pVideoInfo)
// Set the number of colours explicitly
- if (PALETTISED(pVideoInfo)) {
- if (pVideoInfo->bmiHeader.biClrUsed == 0) {
+ if(PALETTISED(pVideoInfo))
+ {
+ if(pVideoInfo->bmiHeader.biClrUsed == 0)
+ {
pVideoInfo->bmiHeader.biClrUsed = PALETTE_ENTRIES(pVideoInfo);
}
}
@@ -2460,13 +2587,15 @@ HRESULT CImageDisplay::UpdateFormat(__inout VIDEOINFO *pVideoInfo)
// some displays the number of important colours is not initialised when
// retrieving the display type so we set the colours used correctly
- if (pVideoInfo->bmiHeader.biClrImportant > pVideoInfo->bmiHeader.biClrUsed) {
+ if(pVideoInfo->bmiHeader.biClrImportant > pVideoInfo->bmiHeader.biClrUsed)
+ {
pVideoInfo->bmiHeader.biClrImportant = PALETTE_ENTRIES(pVideoInfo);
}
// Change the image size field to be explicit
- if (pVideoInfo->bmiHeader.biSizeImage == 0) {
+ if(pVideoInfo->bmiHeader.biSizeImage == 0)
+ {
pVideoInfo->bmiHeader.biSizeImage = GetBitmapSize(&pVideoInfo->bmiHeader);
}
return NOERROR;
@@ -2485,14 +2614,17 @@ HRESULT CImageDisplay::CheckVideoType(const VIDEOINFO *pInput)
{
// First of all check the VIDEOINFOHEADER looks correct
- if (CheckHeaderValidity(pInput) == FALSE) {
+ if(CheckHeaderValidity(pInput) == FALSE)
+ {
return E_INVALIDARG;
}
// Virtually all devices support palettised images efficiently
- if (m_Display.bmiHeader.biBitCount == pInput->bmiHeader.biBitCount) {
- if (PALETTISED(pInput) == TRUE) {
+ if(m_Display.bmiHeader.biBitCount == pInput->bmiHeader.biBitCount)
+ {
+ if(PALETTISED(pInput) == TRUE)
+ {
ASSERT(PALETTISED(&m_Display) == TRUE);
NOTE("(Video) Type connection ACCEPTED");
return NOERROR;
@@ -2502,14 +2634,16 @@ HRESULT CImageDisplay::CheckVideoType(const VIDEOINFO *pInput)
// Is the display depth greater than the input format
- if (m_Display.bmiHeader.biBitCount > pInput->bmiHeader.biBitCount) {
+ if(m_Display.bmiHeader.biBitCount > pInput->bmiHeader.biBitCount)
+ {
NOTE("(Video) Mismatch agreed");
return NOERROR;
}
// Is the display depth less than the input format
- if (m_Display.bmiHeader.biBitCount < pInput->bmiHeader.biBitCount) {
+ if(m_Display.bmiHeader.biBitCount < pInput->bmiHeader.biBitCount)
+ {
NOTE("(Video) Format mismatch");
return E_INVALIDARG;
}
@@ -2529,9 +2663,10 @@ HRESULT CImageDisplay::CheckVideoType(const VIDEOINFO *pInput)
const DWORD *pInputMask = GetBitMasks(pInput);
const DWORD *pDisplayMask = GetBitMasks((VIDEOINFO *)&m_Display);
- if (pInputMask[iRED] != pDisplayMask[iRED] ||
- pInputMask[iGREEN] != pDisplayMask[iGREEN] ||
- pInputMask[iBLUE] != pDisplayMask[iBLUE]) {
+ if(pInputMask[iRED] != pDisplayMask[iRED] ||
+ pInputMask[iGREEN] != pDisplayMask[iGREEN] ||
+ pInputMask[iBLUE] != pDisplayMask[iBLUE])
+ {
NOTE("(Video) Bit field mismatch");
return E_INVALIDARG;
@@ -2546,19 +2681,25 @@ HRESULT CImageDisplay::CheckVideoType(const VIDEOINFO *pInput)
const DWORD *CImageDisplay::GetBitMasks(const VIDEOINFO *pVideoInfo)
{
- static const DWORD FailMasks[] = {0,0,0};
+ static const DWORD FailMasks[] = {0, 0, 0};
- if (pVideoInfo->bmiHeader.biCompression == BI_BITFIELDS) {
+ if(pVideoInfo->bmiHeader.biCompression == BI_BITFIELDS)
+ {
return BITMASKS(pVideoInfo);
}
ASSERT(pVideoInfo->bmiHeader.biCompression == BI_RGB);
- switch (pVideoInfo->bmiHeader.biBitCount) {
- case 16: return bits555;
- case 24: return bits888;
- case 32: return bits888;
- default: return FailMasks;
+ switch(pVideoInfo->bmiHeader.biBitCount)
+ {
+ case 16:
+ return bits555;
+ case 24:
+ return bits888;
+ case 32:
+ return bits888;
+ default:
+ return FailMasks;
}
}
@@ -2574,7 +2715,8 @@ HRESULT CImageDisplay::CheckMediaType(const CMediaType *pmtIn)
// Does this have a VIDEOINFOHEADER format block
const GUID *pFormatType = pmtIn->FormatType();
- if (*pFormatType != FORMAT_VideoInfo) {
+ if(*pFormatType != FORMAT_VideoInfo)
+ {
NOTE("Format GUID not a VIDEOINFOHEADER");
return E_INVALIDARG;
}
@@ -2583,7 +2725,8 @@ HRESULT CImageDisplay::CheckMediaType(const CMediaType *pmtIn)
// Check the format looks reasonably ok
ULONG Length = pmtIn->FormatLength();
- if (Length < SIZE_VIDEOHEADER) {
+ if(Length < SIZE_VIDEOHEADER)
+ {
NOTE("Format smaller than a VIDEOHEADER");
return E_FAIL;
}
@@ -2593,7 +2736,8 @@ HRESULT CImageDisplay::CheckMediaType(const CMediaType *pmtIn)
// Check the major type is MEDIATYPE_Video
const GUID *pMajorType = pmtIn->Type();
- if (*pMajorType != MEDIATYPE_Video) {
+ if(*pMajorType != MEDIATYPE_Video)
+ {
NOTE("Major type not MEDIATYPE_Video");
return E_INVALIDARG;
}
@@ -2601,7 +2745,8 @@ HRESULT CImageDisplay::CheckMediaType(const CMediaType *pmtIn)
// Check we can identify the media subtype
const GUID *pSubType = pmtIn->Subtype();
- if (GetBitCount(pSubType) == USHRT_MAX) {
+ if(GetBitCount(pSubType) == USHRT_MAX)
+ {
NOTE("Invalid video media subtype");
return E_INVALIDARG;
}
@@ -2626,7 +2771,8 @@ BOOL CImageDisplay::GetColourMask(__out DWORD *pMaskRed,
// If this format is palettised then it doesn't have bit fields
- if (m_Display.bmiHeader.biBitCount < 16) {
+ if(m_Display.bmiHeader.biBitCount < 16)
+ {
return FALSE;
}
@@ -2634,7 +2780,8 @@ BOOL CImageDisplay::GetColourMask(__out DWORD *pMaskRed,
// possible colour component ranges described by a byte. It is never
// allowed for a 24 bit colour depth image to have BI_BITFIELDS set
- if (m_Display.bmiHeader.biBitCount == 24) {
+ if(m_Display.bmiHeader.biBitCount == 24)
+ {
ASSERT(m_Display.bmiHeader.biCompression == BI_RGB);
return TRUE;
}
@@ -2648,7 +2795,8 @@ BOOL CImageDisplay::GetColourMask(__out DWORD *pMaskRed,
// bits set in the mask and that they are all contiguous. All that
// therefore remains is to shift them into the correct position
- for (INT iColour = iRED;iColour <= iBLUE;iColour++) {
+ for(INT iColour = iRED; iColour <= iBLUE; iColour++)
+ {
// This works out how many bits there are and where they live
@@ -2670,20 +2818,24 @@ BOOL CImageDisplay::GetColourMask(__out DWORD *pMaskRed,
*/
STDAPI ConvertVideoInfoToVideoInfo2(__inout AM_MEDIA_TYPE *pmt)
{
- if (pmt->formattype != FORMAT_VideoInfo) {
+ if(pmt->formattype != FORMAT_VideoInfo)
+ {
return E_INVALIDARG;
}
- if (NULL == pmt->pbFormat || pmt->cbFormat < sizeof(VIDEOINFOHEADER)) {
+ if(NULL == pmt->pbFormat || pmt->cbFormat < sizeof(VIDEOINFOHEADER))
+ {
return E_INVALIDARG;
}
VIDEOINFO *pVideoInfo = (VIDEOINFO *)pmt->pbFormat;
DWORD dwNewSize;
HRESULT hr = DWordAdd(pmt->cbFormat, sizeof(VIDEOINFOHEADER2) - sizeof(VIDEOINFOHEADER), &dwNewSize);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
PVOID pvNew = CoTaskMemAlloc(dwNewSize);
- if (pvNew == NULL) {
+ if(pvNew == NULL)
+ {
return E_OUTOFMEMORY;
}
CopyMemory(pvNew, pmt->pbFormat, FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader));
@@ -2706,18 +2858,21 @@ STDAPI ConvertVideoInfoToVideoInfo2(__inout AM_MEDIA_TYPE *pmt)
// Check a media type containing VIDEOINFOHEADER
STDAPI CheckVideoInfoType(const AM_MEDIA_TYPE *pmt)
{
- if (NULL == pmt || NULL == pmt->pbFormat) {
+ if(NULL == pmt || NULL == pmt->pbFormat)
+ {
return E_POINTER;
}
- if (pmt->majortype != MEDIATYPE_Video ||
- pmt->formattype != FORMAT_VideoInfo ||
- pmt->cbFormat < sizeof(VIDEOINFOHEADER)) {
+ if(pmt->majortype != MEDIATYPE_Video ||
+ pmt->formattype != FORMAT_VideoInfo ||
+ pmt->cbFormat < sizeof(VIDEOINFOHEADER))
+ {
return VFW_E_TYPE_NOT_ACCEPTED;
}
const VIDEOINFOHEADER *pHeader = (const VIDEOINFOHEADER *)pmt->pbFormat;
- if (!ValidateBitmapInfoHeader(
- &pHeader->bmiHeader,
- pmt->cbFormat - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader))) {
+ if(!ValidateBitmapInfoHeader(
+ &pHeader->bmiHeader,
+ pmt->cbFormat - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader)))
+ {
return VFW_E_TYPE_NOT_ACCEPTED;
}
@@ -2727,18 +2882,21 @@ STDAPI CheckVideoInfoType(const AM_MEDIA_TYPE *pmt)
// Check a media type containing VIDEOINFOHEADER2
STDAPI CheckVideoInfo2Type(const AM_MEDIA_TYPE *pmt)
{
- if (NULL == pmt || NULL == pmt->pbFormat) {
+ if(NULL == pmt || NULL == pmt->pbFormat)
+ {
return E_POINTER;
- }
- if (pmt->majortype != MEDIATYPE_Video ||
- pmt->formattype != FORMAT_VideoInfo2 ||
- pmt->cbFormat < sizeof(VIDEOINFOHEADER2)) {
+ }
+ if(pmt->majortype != MEDIATYPE_Video ||
+ pmt->formattype != FORMAT_VideoInfo2 ||
+ pmt->cbFormat < sizeof(VIDEOINFOHEADER2))
+ {
return VFW_E_TYPE_NOT_ACCEPTED;
}
const VIDEOINFOHEADER2 *pHeader = (const VIDEOINFOHEADER2 *)pmt->pbFormat;
- if (!ValidateBitmapInfoHeader(
- &pHeader->bmiHeader,
- pmt->cbFormat - FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader))) {
+ if(!ValidateBitmapInfoHeader(
+ &pHeader->bmiHeader,
+ pmt->cbFormat - FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader)))
+ {
return VFW_E_TYPE_NOT_ACCEPTED;
}
diff --git a/src/filters/BaseClasses/winutil.h b/src/filters/BaseClasses/winutil.h
index 27358f9fd..e277ac458 100644
--- a/src/filters/BaseClasses/winutil.h
+++ b/src/filters/BaseClasses/winutil.h
@@ -25,7 +25,7 @@ const int PROFILESTR = 128; // Normal profile string
const WORD PALVERSION = 0x300; // GDI palette version
const LONG PALETTE_VERSION = (LONG) 1; // Initial palette version
const COLORREF VIDEO_COLOUR = 0; // Defaults to black background
-const HANDLE hMEMORY = (HANDLE) (-1); // Says to open as memory file
+const HANDLE hMEMORY = (HANDLE)(-1); // Says to open as memory file
#define WIDTH(x) ((*(x)).right - (*(x)).left)
#define HEIGHT(x) ((*(x)).bottom - (*(x)).top)
@@ -59,8 +59,8 @@ protected:
BOOL m_bDoGetDC; // Should this window get a DC
bool m_bDoPostToDestroy; // Use PostMessage to destroy
CCritSec m_PaletteLock; // This lock protects m_hPalette.
- // It should be held anytime the
- // program use the value of m_hPalette.
+ // It should be held anytime the
+ // program use the value of m_hPalette.
// Maps windows message procedure into C++ methods
friend LRESULT CALLBACK WndProc(HWND hwnd, // Window handle
@@ -110,7 +110,9 @@ public:
void UnlockPaletteLock();
virtual BOOL PossiblyEatMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
- { return FALSE; };
+ {
+ return FALSE;
+ };
// Access our window information
@@ -121,9 +123,9 @@ public:
HDC GetMemoryHDC();
HDC GetWindowHDC();
- #ifdef _DEBUG
+#ifdef _DEBUG
HPALETTE GetPalette();
- #endif // DEBUG
+#endif // DEBUG
// This is the window procedure the derived object should override
@@ -135,9 +137,9 @@ public:
// Must be overriden to return class and window styles
virtual LPTSTR GetClassWindowStyles(
- __out DWORD *pClassStyles, // Class styles
- __out DWORD *pWindowStyles, // Window styles
- __out DWORD *pWindowStylesEx) PURE; // Extended styles
+ __out DWORD *pClassStyles, // Class styles
+ __out DWORD *pWindowStyles, // Window styles
+ __out DWORD *pWindowStylesEx) PURE; // Extended styles
};
@@ -180,7 +182,7 @@ protected:
void SlowRender(IMediaSample *pMediaSample);
void FastRender(IMediaSample *pMediaSample);
void DisplaySampleTimes(IMediaSample *pSample);
- void UpdateColourTable(HDC hdc,__in BITMAPINFOHEADER *pbmi);
+ void UpdateColourTable(HDC hdc, __in BITMAPINFOHEADER *pbmi);
void SetStretchMode();
public:
@@ -212,13 +214,15 @@ public:
// Called when we are about to draw an image
- void NotifyStartDraw() {
+ void NotifyStartDraw()
+ {
MSR_START(m_perfidRenderTime);
};
// Called when we complete an image rendering
- void NotifyEndDraw() {
+ void NotifyEndDraw()
+ {
MSR_STOP(m_perfidRenderTime);
};
};
@@ -228,7 +232,8 @@ public:
// samples we create from our allocator will have a DIBSECTION allocated to
// them. When we receive the sample we know we can BitBlt straight to an HDC
-typedef struct tagDIBDATA {
+typedef struct tagDIBDATA
+{
LONG PaletteVersion; // Current palette version in use
DIBSECTION DibSection; // Details of DIB section allocated
@@ -290,15 +295,15 @@ protected:
// Manage the shared DIBSECTION and DCI/DirectDraw buffers
- HRESULT CreateDIB(LONG InSize,DIBDATA &DibData);
+ HRESULT CreateDIB(LONG InSize, DIBDATA &DibData);
STDMETHODIMP CheckSizes(__in ALLOCATOR_PROPERTIES *pRequest);
- virtual CImageSample *CreateImageSample(__in_bcount(Length) LPBYTE pData,LONG Length);
+ virtual CImageSample *CreateImageSample(__in_bcount(Length) LPBYTE pData, LONG Length);
public:
// Constructor and destructor
- CImageAllocator(__inout CBaseFilter *pFilter,__in_opt LPCTSTR pName,__inout HRESULT *phr);
+ CImageAllocator(__inout CBaseFilter *pFilter, __in_opt LPCTSTR pName, __inout HRESULT *phr);
#ifdef _DEBUG
~CImageAllocator();
#endif
@@ -345,14 +350,14 @@ public:
static HPALETTE MakePalette(const VIDEOINFOHEADER *pVideoInfo, __in LPSTR szDevice);
HRESULT RemovePalette();
- static HRESULT MakeIdentityPalette(__inout_ecount_full(iColours) PALETTEENTRY *pEntry,INT iColours, __in LPSTR szDevice);
- HRESULT CopyPalette(const CMediaType *pSrc,__out CMediaType *pDest);
- BOOL ShouldUpdate(const VIDEOINFOHEADER *pNewInfo,const VIDEOINFOHEADER *pOldInfo);
- HRESULT PreparePalette(const CMediaType *pmtNew,const CMediaType *pmtOld,__in LPSTR szDevice);
+ static HRESULT MakeIdentityPalette(__inout_ecount_full(iColours) PALETTEENTRY *pEntry, INT iColours, __in LPSTR szDevice);
+ HRESULT CopyPalette(const CMediaType *pSrc, __out CMediaType *pDest);
+ BOOL ShouldUpdate(const VIDEOINFOHEADER *pNewInfo, const VIDEOINFOHEADER *pOldInfo);
+ HRESULT PreparePalette(const CMediaType *pmtNew, const CMediaType *pmtOld, __in LPSTR szDevice);
BOOL DrawVideoImageHere(HDC hdc, IMediaSample *pMediaSample, __in LPRECT lprcSrc, __in LPRECT lprcDst)
{
- return m_pDrawImage->DrawVideoImageHere(hdc, pMediaSample, lprcSrc,lprcDst);
+ return m_pDrawImage->DrawVideoImageHere(hdc, pMediaSample, lprcSrc, lprcDst);
}
};
diff --git a/src/filters/BaseClasses/wxdebug.cpp b/src/filters/BaseClasses/wxdebug.cpp
index d6aa59802..5ac541b87 100644
--- a/src/filters/BaseClasses/wxdebug.cpp
+++ b/src/filters/BaseClasses/wxdebug.cpp
@@ -41,7 +41,8 @@ const INT iDEBUGINFO = 1024; // Used to format strings
HKEY_LOCAL_MACHINE\SOFTWARE\Debug\<Module Name>\<KeyName> key values
NOTE these must be in the same order as their enumeration definition */
-const LPCTSTR pKeyNames[] = {
+const LPCTSTR pKeyNames[] =
+{
TEXT("TIMING"), // Timing and performance measurements
TEXT("TRACE"), // General step point call tracing
TEXT("MEMORY"), // Memory and object allocation/destruction
@@ -52,7 +53,7 @@ const LPCTSTR pKeyNames[] = {
TEXT("CUSTOM3"),
TEXT("CUSTOM4"),
TEXT("CUSTOM5")
- };
+};
const TCHAR CAutoTrace::_szEntering[] = TEXT("->: %s");
const TCHAR CAutoTrace::_szLeaving[] = TEXT("<-: %s");
@@ -90,8 +91,8 @@ void WINAPI DbgInitialise(HINSTANCE hInst)
m_hInst = hInst;
DbgInitModuleName();
- if (GetProfileInt(m_ModuleName, TEXT("BreakOnLoad"), 0))
- DebugBreak();
+ if(GetProfileInt(m_ModuleName, TEXT("BreakOnLoad"), 0))
+ DebugBreak();
DbgInitModuleSettings(false);
DbgInitGlobalSettings(true);
dwTimeOffset = timeGetTime();
@@ -106,9 +107,10 @@ void WINAPI DbgInitialise(HINSTANCE hInst)
void WINAPI DbgTerminate()
{
- if (m_hOutput != INVALID_HANDLE_VALUE) {
- EXECUTE_ASSERT(CloseHandle(m_hOutput));
- m_hOutput = INVALID_HANDLE_VALUE;
+ if(m_hOutput != INVALID_HANDLE_VALUE)
+ {
+ EXECUTE_ASSERT(CloseHandle(m_hOutput));
+ m_hOutput = INVALID_HANDLE_VALUE;
}
DeleteCriticalSection(&m_CSDebug);
m_bInit = FALSE;
@@ -127,44 +129,48 @@ void WINAPI DbgInitKeyLevels(HKEY hKey, bool fTakeMax)
DWORD dwKeyValue; // This fields value
/* Try and read a value for each key position in turn */
- for (lKeyPos = 0;lKeyPos < iMAXLEVELS;lKeyPos++) {
+ for(lKeyPos = 0; lKeyPos < iMAXLEVELS; lKeyPos++)
+ {
dwKeySize = sizeof(DWORD);
lReturn = RegQueryValueEx(
- hKey, // Handle to an open key
- pKeyNames[lKeyPos], // Subkey name derivation
- NULL, // Reserved field
- &dwKeyType, // Returns the field type
- (LPBYTE) &dwKeyValue, // Returns the field's value
- &dwKeySize ); // Number of bytes transferred
+ hKey, // Handle to an open key
+ pKeyNames[lKeyPos], // Subkey name derivation
+ NULL, // Reserved field
+ &dwKeyType, // Returns the field type
+ (LPBYTE) &dwKeyValue, // Returns the field's value
+ &dwKeySize); // Number of bytes transferred
/* If either the key was not available or it was not a DWORD value
then we ensure only the high priority debug logging is output
but we try and update the field to a zero filled DWORD value */
- if (lReturn != ERROR_SUCCESS || dwKeyType != REG_DWORD) {
+ if(lReturn != ERROR_SUCCESS || dwKeyType != REG_DWORD)
+ {
dwKeyValue = 0;
lReturn = RegSetValueEx(
- hKey, // Handle of an open key
- pKeyNames[lKeyPos], // Address of subkey name
- (DWORD) 0, // Reserved field
- REG_DWORD, // Type of the key field
- (PBYTE) &dwKeyValue, // Value for the field
- sizeof(DWORD)); // Size of the field buffer
-
- if (lReturn != ERROR_SUCCESS) {
- DbgLog((LOG_ERROR,1,TEXT("Could not create subkey %s"),pKeyNames[lKeyPos]));
+ hKey, // Handle of an open key
+ pKeyNames[lKeyPos], // Address of subkey name
+ (DWORD) 0, // Reserved field
+ REG_DWORD, // Type of the key field
+ (PBYTE) &dwKeyValue, // Value for the field
+ sizeof(DWORD)); // Size of the field buffer
+
+ if(lReturn != ERROR_SUCCESS)
+ {
+ DbgLog((LOG_ERROR, 1, TEXT("Could not create subkey %s"), pKeyNames[lKeyPos]));
dwKeyValue = 0;
}
}
if(fTakeMax)
{
- m_Levels[lKeyPos] = max(dwKeyValue,m_Levels[lKeyPos]);
+ m_Levels[lKeyPos] = max(dwKeyValue, m_Levels[lKeyPos]);
}
else
{
- if((m_Levels[lKeyPos] & LOG_FORCIBLY_SET) == 0) {
+ if((m_Levels[lKeyPos] & LOG_FORCIBLY_SET) == 0)
+ {
m_Levels[lKeyPos] = dwKeyValue;
}
}
@@ -173,30 +179,32 @@ void WINAPI DbgInitKeyLevels(HKEY hKey, bool fTakeMax)
/* Read the timeout value for catching hangs */
dwKeySize = sizeof(DWORD);
lReturn = RegQueryValueEx(
- hKey, // Handle to an open key
- TimeoutName, // Subkey name derivation
- NULL, // Reserved field
- &dwKeyType, // Returns the field type
- (LPBYTE) &dwWaitTimeout, // Returns the field's value
- &dwKeySize ); // Number of bytes transferred
+ hKey, // Handle to an open key
+ TimeoutName, // Subkey name derivation
+ NULL, // Reserved field
+ &dwKeyType, // Returns the field type
+ (LPBYTE) &dwWaitTimeout, // Returns the field's value
+ &dwKeySize); // Number of bytes transferred
/* If either the key was not available or it was not a DWORD value
then we ensure only the high priority debug logging is output
but we try and update the field to a zero filled DWORD value */
- if (lReturn != ERROR_SUCCESS || dwKeyType != REG_DWORD) {
+ if(lReturn != ERROR_SUCCESS || dwKeyType != REG_DWORD)
+ {
dwWaitTimeout = INFINITE;
lReturn = RegSetValueEx(
- hKey, // Handle of an open key
- TimeoutName, // Address of subkey name
- (DWORD) 0, // Reserved field
- REG_DWORD, // Type of the key field
- (PBYTE) &dwWaitTimeout, // Value for the field
- sizeof(DWORD)); // Size of the field buffer
-
- if (lReturn != ERROR_SUCCESS) {
- DbgLog((LOG_ERROR,1,TEXT("Could not create subkey %s"),pKeyNames[lKeyPos]));
+ hKey, // Handle of an open key
+ TimeoutName, // Address of subkey name
+ (DWORD) 0, // Reserved field
+ REG_DWORD, // Type of the key field
+ (PBYTE) &dwWaitTimeout, // Value for the field
+ sizeof(DWORD)); // Size of the field buffer
+
+ if(lReturn != ERROR_SUCCESS)
+ {
+ DbgLog((LOG_ERROR, 1, TEXT("Could not create subkey %s"), pKeyNames[lKeyPos]));
dwWaitTimeout = INFINITE;
}
}
@@ -204,18 +212,21 @@ void WINAPI DbgInitKeyLevels(HKEY hKey, bool fTakeMax)
void WINAPI DbgOutString(LPCTSTR psz)
{
- if (m_hOutput != INVALID_HANDLE_VALUE) {
+ if(m_hOutput != INVALID_HANDLE_VALUE)
+ {
UINT cb = lstrlen(psz);
DWORD dw;
#ifdef UNICODE
CHAR szDest[2048];
WideCharToMultiByte(CP_ACP, 0, psz, -1, szDest, NUMELMS(szDest), 0, 0);
- WriteFile (m_hOutput, szDest, cb, &dw, NULL);
+ WriteFile(m_hOutput, szDest, cb, &dw, NULL);
#else
- WriteFile (m_hOutput, psz, cb, &dw, NULL);
+ WriteFile(m_hOutput, psz, cb, &dw, NULL);
#endif
- } else {
- OutputDebugString (psz);
+ }
+ else
+ {
+ OutputDebugString(psz);
}
}
@@ -229,19 +240,19 @@ HRESULT DbgUniqueProcessName(LPCTSTR inName, LPTSTR outName)
int dotPos = -1;
//scan the input and record the last '.' position
- while (*pIn && (pIn - inName) < MAX_PATH)
+ while(*pIn && (pIn - inName) < MAX_PATH)
{
- if ( TEXT('.') == *pIn )
- dotPos = (int)(pIn-inName);
+ if(TEXT('.') == *pIn)
+ dotPos = (int)(pIn - inName);
++pIn;
}
- if (*pIn) //input should be zero-terminated within MAX_PATH
+ if(*pIn) //input should be zero-terminated within MAX_PATH
return E_INVALIDARG;
DWORD dwProcessId = GetCurrentProcessId();
- if (dotPos < 0)
+ if(dotPos < 0)
{
//no extension in the input, appending process id to the input
hr = StringCchPrintf(outName, MAX_PATH, TEXT("%s_%d"), inName, dwProcessId);
@@ -249,12 +260,12 @@ HRESULT DbgUniqueProcessName(LPCTSTR inName, LPTSTR outName)
else
{
TCHAR pathAndBasename[_MAX_PATH] = {0};
-
+
//there's an extension - zero-terminate the path and basename first by copying
hr = StringCchCopyN(pathAndBasename, MAX_PATH, inName, (size_t)dotPos);
//re-combine path, basename and extension with processId appended to a basename
- if (SUCCEEDED(hr))
+ if(SUCCEEDED(hr))
hr = StringCchPrintf(outName, MAX_PATH, TEXT("%s_%d%s"), pathAndBasename, dwProcessId, inName + dotPos);
}
@@ -265,7 +276,7 @@ HRESULT DbgUniqueProcessName(LPCTSTR inName, LPTSTR outName)
/* Called by DbgInitGlobalSettings to setup alternate logging destinations
*/
-void WINAPI DbgInitLogTo (
+void WINAPI DbgInitLogTo(
HKEY hKey)
{
LONG lReturn;
@@ -276,75 +287,79 @@ void WINAPI DbgInitLogTo (
dwKeySize = MAX_PATH;
lReturn = RegQueryValueEx(
- hKey, // Handle to an open key
- cszKey, // Subkey name derivation
- NULL, // Reserved field
- &dwKeyType, // Returns the field type
- (LPBYTE) szFile, // Returns the field's value
- &dwKeySize); // Number of bytes transferred
+ hKey, // Handle to an open key
+ cszKey, // Subkey name derivation
+ NULL, // Reserved field
+ &dwKeyType, // Returns the field type
+ (LPBYTE) szFile, // Returns the field's value
+ &dwKeySize); // Number of bytes transferred
// create an empty key if it does not already exist
//
- if (lReturn != ERROR_SUCCESS || dwKeyType != REG_SZ)
- {
- dwKeySize = sizeof(TCHAR);
- lReturn = RegSetValueEx(
- hKey, // Handle of an open key
- cszKey, // Address of subkey name
- (DWORD) 0, // Reserved field
- REG_SZ, // Type of the key field
- (PBYTE)szFile, // Value for the field
- dwKeySize); // Size of the field buffer
- }
+ if(lReturn != ERROR_SUCCESS || dwKeyType != REG_SZ)
+ {
+ dwKeySize = sizeof(TCHAR);
+ lReturn = RegSetValueEx(
+ hKey, // Handle of an open key
+ cszKey, // Address of subkey name
+ (DWORD) 0, // Reserved field
+ REG_SZ, // Type of the key field
+ (PBYTE)szFile, // Value for the field
+ dwKeySize); // Size of the field buffer
+ }
// if an output-to was specified. try to open it.
//
- if (m_hOutput != INVALID_HANDLE_VALUE) {
- EXECUTE_ASSERT(CloseHandle (m_hOutput));
- m_hOutput = INVALID_HANDLE_VALUE;
- }
- if (szFile[0] != 0)
- {
- if (!lstrcmpi(szFile, TEXT("Console"))) {
- m_hOutput = GetStdHandle (STD_OUTPUT_HANDLE);
- if (m_hOutput == INVALID_HANDLE_VALUE) {
- AllocConsole ();
- m_hOutput = GetStdHandle (STD_OUTPUT_HANDLE);
- }
- SetConsoleTitle (TEXT("ActiveX Debug Output"));
- } else if (szFile[0] &&
+ if(m_hOutput != INVALID_HANDLE_VALUE)
+ {
+ EXECUTE_ASSERT(CloseHandle(m_hOutput));
+ m_hOutput = INVALID_HANDLE_VALUE;
+ }
+ if(szFile[0] != 0)
+ {
+ if(!lstrcmpi(szFile, TEXT("Console")))
+ {
+ m_hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
+ if(m_hOutput == INVALID_HANDLE_VALUE)
+ {
+ AllocConsole();
+ m_hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
+ }
+ SetConsoleTitle(TEXT("ActiveX Debug Output"));
+ }
+ else if(szFile[0] &&
lstrcmpi(szFile, TEXT("Debug")) &&
lstrcmpi(szFile, TEXT("Debugger")) &&
lstrcmpi(szFile, TEXT("Deb")))
- {
+ {
m_hOutput = CreateFile(szFile, GENERIC_WRITE,
- FILE_SHARE_READ,
- NULL, OPEN_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
+ FILE_SHARE_READ,
+ NULL, OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
- if (INVALID_HANDLE_VALUE == m_hOutput &&
- GetLastError() == ERROR_SHARING_VIOLATION)
+ if(INVALID_HANDLE_VALUE == m_hOutput &&
+ GetLastError() == ERROR_SHARING_VIOLATION)
{
- TCHAR uniqueName[_MAX_PATH] = {0};
- if (SUCCEEDED(DbgUniqueProcessName(szFile, uniqueName)))
- {
+ TCHAR uniqueName[_MAX_PATH] = {0};
+ if(SUCCEEDED(DbgUniqueProcessName(szFile, uniqueName)))
+ {
m_hOutput = CreateFile(uniqueName, GENERIC_WRITE,
- FILE_SHARE_READ,
- NULL, OPEN_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
- }
+ FILE_SHARE_READ,
+ NULL, OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ }
}
-
- if (INVALID_HANDLE_VALUE != m_hOutput)
+
+ if(INVALID_HANDLE_VALUE != m_hOutput)
{
- static const TCHAR cszBar[] = TEXT("\r\n\r\n=====DbgInitialize()=====\r\n\r\n");
- SetFilePointer (m_hOutput, 0, NULL, FILE_END);
- DbgOutString (cszBar);
+ static const TCHAR cszBar[] = TEXT("\r\n\r\n=====DbgInitialize()=====\r\n\r\n");
+ SetFilePointer(m_hOutput, 0, NULL, FILE_END);
+ DbgOutString(cszBar);
}
- }
- }
+ }
+ }
}
@@ -361,7 +376,7 @@ void WINAPI DbgInitGlobalSettings(bool fTakeMax)
HKEY hGlobalKey; // Global override key
/* Construct the global base key name */
- (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("%s\\%s"),pBaseKey,pGlobalKey);
+ (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("%s\\%s"), pBaseKey, pGlobalKey);
/* Create or open the key for this module */
lReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Handle of an open key
@@ -374,7 +389,8 @@ void WINAPI DbgInitGlobalSettings(bool fTakeMax)
&hGlobalKey, // Opened handle buffer
NULL); // What really happened
- if (lReturn != ERROR_SUCCESS) {
+ if(lReturn != ERROR_SUCCESS)
+ {
lReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Handle of an open key
szInfo, // Address of subkey name
(DWORD) 0, // Reserved value
@@ -384,8 +400,9 @@ void WINAPI DbgInitGlobalSettings(bool fTakeMax)
NULL, // Key security descriptor
&hGlobalKey, // Opened handle buffer
NULL); // What really happened
- if (lReturn != ERROR_SUCCESS) {
- DbgLog((LOG_ERROR,1,TEXT("Could not access GLOBAL module key")));
+ if(lReturn != ERROR_SUCCESS)
+ {
+ DbgLog((LOG_ERROR, 1, TEXT("Could not access GLOBAL module key")));
}
return;
}
@@ -408,7 +425,7 @@ void WINAPI DbgInitModuleSettings(bool fTakeMax)
HKEY hModuleKey; // Module key handle
/* Construct the base key name */
- (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("%s\\%s"),pBaseKey,m_ModuleName);
+ (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("%s\\%s"), pBaseKey, m_ModuleName);
/* Create or open the key for this module */
lReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Handle of an open key
@@ -421,7 +438,8 @@ void WINAPI DbgInitModuleSettings(bool fTakeMax)
&hModuleKey, // Opened handle buffer
NULL); // What really happened
- if (lReturn != ERROR_SUCCESS) {
+ if(lReturn != ERROR_SUCCESS)
+ {
lReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Handle of an open key
szInfo, // Address of subkey name
(DWORD) 0, // Reserved value
@@ -431,8 +449,9 @@ void WINAPI DbgInitModuleSettings(bool fTakeMax)
NULL, // Key security descriptor
&hModuleKey, // Opened handle buffer
NULL); // What really happened
- if (lReturn != ERROR_SUCCESS) {
- DbgLog((LOG_ERROR,1,TEXT("Could not access module key")));
+ if(lReturn != ERROR_SUCCESS)
+ {
+ DbgLog((LOG_ERROR, 1, TEXT("Could not access module key")));
}
return;
}
@@ -450,14 +469,17 @@ void WINAPI DbgInitModuleName()
TCHAR FullName[iDEBUGINFO]; // Load the full path and module name
LPTSTR pName; // Searches from the end for a backslash
- GetModuleFileName(m_hInst,FullName,iDEBUGINFO);
- pName = _tcsrchr(FullName,'\\');
- if (pName == NULL) {
+ GetModuleFileName(m_hInst, FullName, iDEBUGINFO);
+ pName = _tcsrchr(FullName, '\\');
+ if(pName == NULL)
+ {
pName = FullName;
- } else {
+ }
+ else
+ {
pName++;
}
- (void)StringCchCopy(m_ModuleName,NUMELMS(m_ModuleName), pName);
+ (void)StringCchCopy(m_ModuleName, NUMELMS(m_ModuleName), pName);
}
struct MsgBoxMsg
@@ -474,15 +496,15 @@ struct MsgBoxMsg
// random threads at bad times can confuse the host (eg IE).
//
DWORD WINAPI MsgBoxThread(
- __inout LPVOID lpParameter // thread data
- )
+ __inout LPVOID lpParameter // thread data
+)
{
MsgBoxMsg *pmsg = (MsgBoxMsg *)lpParameter;
pmsg->iResult = MessageBox(
- pmsg->hwnd,
- pmsg->szTitle,
- pmsg->szMessage,
- pmsg->dwFlags);
+ pmsg->hwnd,
+ pmsg->szTitle,
+ pmsg->szMessage,
+ pmsg->dwFlags);
return 0;
}
@@ -506,12 +528,12 @@ INT MessageBoxOtherThread(
MsgBoxMsg msg = {hwnd, szTitle, szMessage, dwFlags, 0};
DWORD dwid;
HANDLE hThread = CreateThread(
- 0, // security
- 0, // stack size
- MsgBoxThread,
- (void *)&msg, // arg
- 0, // flags
- &dwid);
+ 0, // security
+ 0, // stack size
+ MsgBoxThread,
+ (void *)&msg, // arg
+ 0, // flags
+ &dwid);
if(hThread)
{
WaitForSingleObject(hThread, INFINITE);
@@ -526,7 +548,7 @@ INT MessageBoxOtherThread(
/* Displays a message box if the condition evaluated to FALSE */
-void WINAPI DbgAssert(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine)
+void WINAPI DbgAssert(LPCTSTR pCondition, LPCTSTR pFileName, INT iLine)
{
if(g_fUseKASSERT)
{
@@ -537,35 +559,35 @@ void WINAPI DbgAssert(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine)
TCHAR szInfo[iDEBUGINFO];
- (void)StringCchPrintf(szInfo, NUMELMS(szInfo),TEXT("%s \nAt line %d of %s\nContinue? (Cancel to debug)"),
- pCondition, iLine, pFileName);
+ (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("%s \nAt line %d of %s\nContinue? (Cancel to debug)"),
+ pCondition, iLine, pFileName);
- INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("ASSERT Failed"),
+ INT MsgId = MessageBoxOtherThread(NULL, szInfo, TEXT("ASSERT Failed"),
MB_SYSTEMMODAL |
MB_ICONHAND |
MB_YESNOCANCEL |
MB_SETFOREGROUND);
- switch (MsgId)
+ switch(MsgId)
{
- case IDNO: /* Kill the application */
+ case IDNO: /* Kill the application */
- FatalAppExit(FALSE, TEXT("Application terminated"));
- break;
+ FatalAppExit(FALSE, TEXT("Application terminated"));
+ break;
- case IDCANCEL: /* Break into the debugger */
+ case IDCANCEL: /* Break into the debugger */
- DebugBreak();
- break;
+ DebugBreak();
+ break;
- case IDYES: /* Ignore assertion continue execution */
- break;
+ case IDYES: /* Ignore assertion continue execution */
+ break;
}
}
}
/* Displays a message box at a break point */
-void WINAPI DbgBreakPoint(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine)
+void WINAPI DbgBreakPoint(LPCTSTR pCondition, LPCTSTR pFileName, INT iLine)
{
if(g_fUseKASSERT)
{
@@ -575,33 +597,33 @@ void WINAPI DbgBreakPoint(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine)
{
TCHAR szInfo[iDEBUGINFO];
- (void)StringCchPrintf(szInfo, NUMELMS(szInfo),TEXT("%s \nAt line %d of %s\nContinue? (Cancel to debug)"),
- pCondition, iLine, pFileName);
+ (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("%s \nAt line %d of %s\nContinue? (Cancel to debug)"),
+ pCondition, iLine, pFileName);
- INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("Hard coded break point"),
+ INT MsgId = MessageBoxOtherThread(NULL, szInfo, TEXT("Hard coded break point"),
MB_SYSTEMMODAL |
MB_ICONHAND |
MB_YESNOCANCEL |
MB_SETFOREGROUND);
- switch (MsgId)
+ switch(MsgId)
{
- case IDNO: /* Kill the application */
+ case IDNO: /* Kill the application */
- FatalAppExit(FALSE, TEXT("Application terminated"));
- break;
+ FatalAppExit(FALSE, TEXT("Application terminated"));
+ break;
- case IDCANCEL: /* Break into the debugger */
+ case IDCANCEL: /* Break into the debugger */
- DebugBreak();
- break;
+ DebugBreak();
+ break;
- case IDYES: /* Ignore break point continue execution */
- break;
+ case IDYES: /* Ignore break point continue execution */
+ break;
}
}
}
-void WINAPI DbgBreakPoint(LPCTSTR pFileName,INT iLine,__format_string LPCTSTR szFormatString,...)
+void WINAPI DbgBreakPoint(LPCTSTR pFileName, INT iLine, __format_string LPCTSTR szFormatString, ...)
{
// A debug break point message can have at most 2000 characters if
// ANSI or UNICODE characters are being used. A debug break point message
@@ -613,18 +635,19 @@ void WINAPI DbgBreakPoint(LPCTSTR pFileName,INT iLine,__format_string LPCTSTR sz
TCHAR szBreakPointMessage[MAX_BREAK_POINT_MESSAGE_SIZE];
va_list va;
- va_start( va, szFormatString );
+ va_start(va, szFormatString);
- HRESULT hr = StringCchVPrintf( szBreakPointMessage, NUMELMS(szBreakPointMessage), szFormatString, va );
+ HRESULT hr = StringCchVPrintf(szBreakPointMessage, NUMELMS(szBreakPointMessage), szFormatString, va);
va_end(va);
- if( FAILED(hr) ) {
- DbgBreak( "ERROR in DbgBreakPoint(). The variable length debug message could not be displayed because StringCchVPrintf() failed." );
+ if(FAILED(hr))
+ {
+ DbgBreak("ERROR in DbgBreakPoint(). The variable length debug message could not be displayed because StringCchVPrintf() failed.");
return;
}
- ::DbgBreakPoint( szBreakPointMessage, pFileName, iLine );
+ ::DbgBreakPoint(szBreakPointMessage, pFileName, iLine);
}
@@ -641,7 +664,7 @@ void WINAPI DbgBreakPoint(LPCTSTR pFileName,INT iLine,__format_string LPCTSTR sz
*/
-BOOL WINAPI DbgCheckModuleLevel(DWORD Type,DWORD Level)
+BOOL WINAPI DbgCheckModuleLevel(DWORD Type, DWORD Level)
{
if(g_fAutoRefreshLevels)
{
@@ -649,7 +672,8 @@ BOOL WINAPI DbgCheckModuleLevel(DWORD Type,DWORD Level)
// notice registry changes because it's not available on win9x.
static DWORD g_dwLastRefresh = 0;
DWORD dwTime = timeGetTime();
- if(dwTime - g_dwLastRefresh > 1000) {
+ if(dwTime - g_dwLastRefresh > 1000)
+ {
g_dwLastRefresh = dwTime;
// there's a race condition: multiple threads could update the
@@ -663,15 +687,19 @@ BOOL WINAPI DbgCheckModuleLevel(DWORD Type,DWORD Level)
DWORD Mask = 0x01;
// If no valid bits are set return FALSE
- if ((Type & ((1<<iMAXLEVELS)-1))) {
-
- // speed up unconditional output.
- if (0==Level)
- return(TRUE);
-
- for (LONG lKeyPos = 0;lKeyPos < iMAXLEVELS;lKeyPos++) {
- if (Type & Mask) {
- if (Level <= (m_Levels[lKeyPos] & ~LOG_FORCIBLY_SET)) {
+ if((Type & ((1 << iMAXLEVELS) - 1)))
+ {
+
+ // speed up unconditional output.
+ if(0 == Level)
+ return(TRUE);
+
+ for(LONG lKeyPos = 0; lKeyPos < iMAXLEVELS; lKeyPos++)
+ {
+ if(Type & Mask)
+ {
+ if(Level <= (m_Levels[lKeyPos] & ~LOG_FORCIBLY_SET))
+ {
return TRUE;
}
}
@@ -688,8 +716,10 @@ void WINAPI DbgSetModuleLevel(DWORD Type, DWORD Level)
{
DWORD Mask = 0x01;
- for (LONG lKeyPos = 0;lKeyPos < iMAXLEVELS;lKeyPos++) {
- if (Type & Mask) {
+ for(LONG lKeyPos = 0; lKeyPos < iMAXLEVELS; lKeyPos++)
+ {
+ if(Type & Mask)
+ {
m_Levels[lKeyPos] = Level | LOG_FORCIBLY_SET;
}
Mask <<= 1;
@@ -708,12 +738,13 @@ void WINAPI DbgSetAutoRefreshLevels(bool fAuto)
// warning -- this function is implemented twice for ansi applications
// linking to the unicode library
//
-void WINAPI DbgLogInfo(DWORD Type,DWORD Level,__format_string LPCSTR pFormat,...)
+void WINAPI DbgLogInfo(DWORD Type, DWORD Level, __format_string LPCSTR pFormat, ...)
{
/* Check the current level for this type combination */
- BOOL bAccept = DbgCheckModuleLevel(Type,Level);
- if (bAccept == FALSE) {
+ BOOL bAccept = DbgCheckModuleLevel(Type, Level);
+ if(bAccept == FALSE)
+ {
return;
}
@@ -725,9 +756,9 @@ void WINAPI DbgLogInfo(DWORD Type,DWORD Level,__format_string LPCSTR pFormat,...
va_start(va, pFormat);
(void)StringCchPrintf(szInfo, NUMELMS(szInfo),
- TEXT("%s(tid %x) %8d : "),
- m_ModuleName,
- GetCurrentThreadId(), timeGetTime() - dwTimeOffset);
+ TEXT("%s(tid %x) %8d : "),
+ m_ModuleName,
+ GetCurrentThreadId(), timeGetTime() - dwTimeOffset);
CHAR szInfoA[2000];
WideCharToMultiByte(CP_ACP, 0, szInfo, -1, szInfoA, NUMELMS(szInfoA), 0, 0);
@@ -742,7 +773,7 @@ void WINAPI DbgLogInfo(DWORD Type,DWORD Level,__format_string LPCSTR pFormat,...
va_end(va);
}
-void WINAPI DbgAssert(LPCSTR pCondition,LPCSTR pFileName,INT iLine)
+void WINAPI DbgAssert(LPCSTR pCondition, LPCSTR pFileName, INT iLine)
{
if(g_fUseKASSERT)
{
@@ -754,34 +785,34 @@ void WINAPI DbgAssert(LPCSTR pCondition,LPCSTR pFileName,INT iLine)
TCHAR szInfo[iDEBUGINFO];
(void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("%hs \nAt line %d of %hs\nContinue? (Cancel to debug)"),
- pCondition, iLine, pFileName);
+ pCondition, iLine, pFileName);
- INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("ASSERT Failed"),
+ INT MsgId = MessageBoxOtherThread(NULL, szInfo, TEXT("ASSERT Failed"),
MB_SYSTEMMODAL |
MB_ICONHAND |
MB_YESNOCANCEL |
MB_SETFOREGROUND);
- switch (MsgId)
+ switch(MsgId)
{
- case IDNO: /* Kill the application */
+ case IDNO: /* Kill the application */
- FatalAppExit(FALSE, TEXT("Application terminated"));
- break;
+ FatalAppExit(FALSE, TEXT("Application terminated"));
+ break;
- case IDCANCEL: /* Break into the debugger */
+ case IDCANCEL: /* Break into the debugger */
- DebugBreak();
- break;
+ DebugBreak();
+ break;
- case IDYES: /* Ignore assertion continue execution */
- break;
+ case IDYES: /* Ignore assertion continue execution */
+ break;
}
}
}
/* Displays a message box at a break point */
-void WINAPI DbgBreakPoint(LPCSTR pCondition,LPCSTR pFileName,INT iLine)
+void WINAPI DbgBreakPoint(LPCSTR pCondition, LPCSTR pFileName, INT iLine)
{
if(g_fUseKASSERT)
{
@@ -791,36 +822,36 @@ void WINAPI DbgBreakPoint(LPCSTR pCondition,LPCSTR pFileName,INT iLine)
{
TCHAR szInfo[iDEBUGINFO];
- (void)StringCchPrintf(szInfo, NUMELMS(szInfo),TEXT("%hs \nAt line %d of %hs\nContinue? (Cancel to debug)"),
- pCondition, iLine, pFileName);
+ (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("%hs \nAt line %d of %hs\nContinue? (Cancel to debug)"),
+ pCondition, iLine, pFileName);
- INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("Hard coded break point"),
+ INT MsgId = MessageBoxOtherThread(NULL, szInfo, TEXT("Hard coded break point"),
MB_SYSTEMMODAL |
MB_ICONHAND |
MB_YESNOCANCEL |
MB_SETFOREGROUND);
- switch (MsgId)
+ switch(MsgId)
{
- case IDNO: /* Kill the application */
+ case IDNO: /* Kill the application */
- FatalAppExit(FALSE, TEXT("Application terminated"));
- break;
+ FatalAppExit(FALSE, TEXT("Application terminated"));
+ break;
- case IDCANCEL: /* Break into the debugger */
+ case IDCANCEL: /* Break into the debugger */
- DebugBreak();
- break;
+ DebugBreak();
+ break;
- case IDYES: /* Ignore break point continue execution */
- break;
+ case IDYES: /* Ignore break point continue execution */
+ break;
}
}
}
-void WINAPI DbgKernelAssert(LPCSTR pCondition,LPCSTR pFileName,INT iLine)
+void WINAPI DbgKernelAssert(LPCSTR pCondition, LPCSTR pFileName, INT iLine)
{
- DbgLog((LOG_ERROR,0,TEXT("Assertion FAILED (%hs) at line %d in file %hs"),
- pCondition, iLine, pFileName));
+ DbgLog((LOG_ERROR, 0, TEXT("Assertion FAILED (%hs) at line %d in file %hs"),
+ pCondition, iLine, pFileName));
DebugBreak();
}
@@ -835,13 +866,14 @@ void WINAPI DbgKernelAssert(LPCSTR pCondition,LPCSTR pFileName,INT iLine)
// warning -- this function is implemented twice for ansi applications
// linking to the unicode library
//
-void WINAPI DbgLogInfo(DWORD Type,DWORD Level,LPCTSTR pFormat,...)
+void WINAPI DbgLogInfo(DWORD Type, DWORD Level, LPCTSTR pFormat, ...)
{
/* Check the current level for this type combination */
- BOOL bAccept = DbgCheckModuleLevel(Type,Level);
- if (bAccept == FALSE) {
+ BOOL bAccept = DbgCheckModuleLevel(Type, Level);
+ if(bAccept == FALSE)
+ {
return;
}
@@ -853,9 +885,9 @@ void WINAPI DbgLogInfo(DWORD Type,DWORD Level,LPCTSTR pFormat,...)
va_start(va, pFormat);
(void)StringCchPrintf(szInfo, NUMELMS(szInfo),
- TEXT("%s(tid %x) %8d : "),
- m_ModuleName,
- GetCurrentThreadId(), timeGetTime() - dwTimeOffset);
+ TEXT("%s(tid %x) %8d : "),
+ m_ModuleName,
+ GetCurrentThreadId(), timeGetTime() - dwTimeOffset);
(void)StringCchVPrintf(szInfo + lstrlen(szInfo), NUMELMS(szInfo) - lstrlen(szInfo), pFormat, va);
(void)StringCchCat(szInfo, NUMELMS(szInfo), TEXT("\r\n"));
@@ -869,10 +901,10 @@ void WINAPI DbgLogInfo(DWORD Type,DWORD Level,LPCTSTR pFormat,...)
boxes to the user, this provides an alternative which puts the error
condition on the debugger output with a suitable eye catching message */
-void WINAPI DbgKernelAssert(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine)
+void WINAPI DbgKernelAssert(LPCTSTR pCondition, LPCTSTR pFileName, INT iLine)
{
- DbgLog((LOG_ERROR,0,TEXT("Assertion FAILED (%s) at line %d in file %s"),
- pCondition, iLine, pFileName));
+ DbgLog((LOG_ERROR, 0, TEXT("Assertion FAILED (%s) at line %d in file %s"),
+ pCondition, iLine, pFileName));
DebugBreak();
}
@@ -897,7 +929,8 @@ DWORD WINAPI DbgRegisterObjectCreation(LPCSTR szObjectName,
ASSERT(pObject);
/* It is valid to pass a NULL object name */
- if (pObject == NULL) {
+ if(pObject == NULL)
+ {
return FALSE;
}
@@ -905,7 +938,8 @@ DWORD WINAPI DbgRegisterObjectCreation(LPCSTR szObjectName,
being pulled in from an executable which has globally defined objects
as they are created by the C++ run time before WinMain is called */
- if (m_bInit == FALSE) {
+ if(m_bInit == FALSE)
+ {
DbgInitialise(GetModuleHandle(NULL));
}
@@ -913,7 +947,8 @@ DWORD WINAPI DbgRegisterObjectCreation(LPCSTR szObjectName,
EnterCriticalSection(&m_CSDebug);
/* If no name then default to UNKNOWN */
- if (!szObjectName && !wszObjectName) {
+ if(!szObjectName && !wszObjectName)
+ {
szObjectName = pUnknownName;
}
@@ -930,11 +965,14 @@ DWORD WINAPI DbgRegisterObjectCreation(LPCSTR szObjectName,
DWORD ObjectCookie = pObject->m_dwCookie;
ASSERT(ObjectCookie);
- if(wszObjectName) {
- DbgLog((LOG_MEMORY,2,TEXT("Object created %d (%ls) %d Active"),
+ if(wszObjectName)
+ {
+ DbgLog((LOG_MEMORY, 2, TEXT("Object created %d (%ls) %d Active"),
pObject->m_dwCookie, wszObjectName, m_dwObjectCount));
- } else {
- DbgLog((LOG_MEMORY,2,TEXT("Object created %d (%hs) %d Active"),
+ }
+ else
+ {
+ DbgLog((LOG_MEMORY, 2, TEXT("Object created %d (%hs) %d Active"),
pObject->m_dwCookie, szObjectName, m_dwObjectCount));
}
@@ -958,15 +996,18 @@ BOOL WINAPI DbgRegisterObjectDestruction(DWORD dwCookie)
/* Scan the object list looking for a cookie match */
- while (pObject) {
- if (pObject->m_dwCookie == dwCookie) {
+ while(pObject)
+ {
+ if(pObject->m_dwCookie == dwCookie)
+ {
break;
}
pPrevious = pObject;
pObject = pObject->m_pNext;
}
- if (pObject == NULL) {
+ if(pObject == NULL)
+ {
DbgBreak("Apparently destroying a bogus object");
LeaveCriticalSection(&m_CSDebug);
return FALSE;
@@ -974,9 +1015,12 @@ BOOL WINAPI DbgRegisterObjectDestruction(DWORD dwCookie)
/* Is the object at the head of the list */
- if (pPrevious == NULL) {
+ if(pPrevious == NULL)
+ {
pListHead = pObject->m_pNext;
- } else {
+ }
+ else
+ {
pPrevious->m_pNext = pObject->m_pNext;
}
@@ -984,11 +1028,14 @@ BOOL WINAPI DbgRegisterObjectDestruction(DWORD dwCookie)
m_dwObjectCount--;
- if(pObject->m_wszName) {
- DbgLog((LOG_MEMORY,2,TEXT("Object destroyed %d (%ls) %d Active"),
+ if(pObject->m_wszName)
+ {
+ DbgLog((LOG_MEMORY, 2, TEXT("Object destroyed %d (%ls) %d Active"),
pObject->m_dwCookie, pObject->m_wszName, m_dwObjectCount));
- } else {
- DbgLog((LOG_MEMORY,2,TEXT("Object destroyed %d (%hs) %d Active"),
+ }
+ else
+ {
+ DbgLog((LOG_MEMORY, 2, TEXT("Object destroyed %d (%hs) %d Active"),
pObject->m_dwCookie, pObject->m_szName, m_dwObjectCount));
}
@@ -1011,23 +1058,27 @@ void WINAPI DbgDumpObjectRegister()
/* Scan the object list displaying the name and cookie */
- DbgLog((LOG_MEMORY,2,TEXT("")));
- DbgLog((LOG_MEMORY,2,TEXT(" ID Object Description")));
- DbgLog((LOG_MEMORY,2,TEXT("")));
+ DbgLog((LOG_MEMORY, 2, TEXT("")));
+ DbgLog((LOG_MEMORY, 2, TEXT(" ID Object Description")));
+ DbgLog((LOG_MEMORY, 2, TEXT("")));
- while (pObject) {
- if(pObject->m_wszName) {
- (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("%5d (%p) %30ls"),pObject->m_dwCookie, &pObject, pObject->m_wszName);
- } else {
- (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("%5d (%p) %30hs"),pObject->m_dwCookie, &pObject, pObject->m_szName);
+ while(pObject)
+ {
+ if(pObject->m_wszName)
+ {
+ (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("%5d (%p) %30ls"), pObject->m_dwCookie, &pObject, pObject->m_wszName);
}
- DbgLog((LOG_MEMORY,2,szInfo));
+ else
+ {
+ (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("%5d (%p) %30hs"), pObject->m_dwCookie, &pObject, pObject->m_szName);
+ }
+ DbgLog((LOG_MEMORY, 2, szInfo));
pObject = pObject->m_pNext;
}
- (void)StringCchPrintf(szInfo,NUMELMS(szInfo),TEXT("Total object count %5d"),m_dwObjectCount);
- DbgLog((LOG_MEMORY,2,TEXT("")));
- DbgLog((LOG_MEMORY,1,szInfo));
+ (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT("Total object count %5d"), m_dwObjectCount);
+ DbgLog((LOG_MEMORY, 2, TEXT("")));
+ DbgLog((LOG_MEMORY, 1, szInfo));
LeaveCriticalSection(&m_CSDebug);
}
@@ -1035,24 +1086,28 @@ void WINAPI DbgDumpObjectRegister()
DWORD WINAPI DbgWaitForSingleObject(HANDLE h)
{
DWORD dwWaitResult;
- do {
+ do
+ {
dwWaitResult = WaitForSingleObject(h, dwWaitTimeout);
ASSERT(dwWaitResult == WAIT_OBJECT_0);
- } while (dwWaitResult == WAIT_TIMEOUT);
+ }
+ while(dwWaitResult == WAIT_TIMEOUT);
return dwWaitResult;
}
DWORD WINAPI DbgWaitForMultipleObjects(DWORD nCount,
- __in_ecount(nCount) CONST HANDLE *lpHandles,
- BOOL bWaitAll)
+ __in_ecount(nCount) CONST HANDLE *lpHandles,
+ BOOL bWaitAll)
{
DWORD dwWaitResult;
- do {
+ do
+ {
dwWaitResult = WaitForMultipleObjects(nCount,
lpHandles,
bWaitAll,
dwWaitTimeout);
ASSERT((DWORD)(dwWaitResult - WAIT_OBJECT_0) < MAXIMUM_WAIT_OBJECTS);
- } while (dwWaitResult == WAIT_TIMEOUT);
+ }
+ while(dwWaitResult == WAIT_TIMEOUT);
return dwWaitResult;
}
@@ -1065,33 +1120,37 @@ void WINAPI DbgSetWaitTimeout(DWORD dwTimeout)
#ifdef _OBJBASE_H_
- /* Stuff for printing out our GUID names */
+/* Stuff for printing out our GUID names */
- GUID_STRING_ENTRY g_GuidNames[] = {
- #define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+GUID_STRING_ENTRY g_GuidNames[] =
+{
+#define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
{ #name, { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } },
- #include <uuids.h>
- };
+#include <uuids.h>
+};
- CGuidNameList GuidNames;
- int g_cGuidNames = sizeof(g_GuidNames) / sizeof(g_GuidNames[0]);
+CGuidNameList GuidNames;
+int g_cGuidNames = sizeof(g_GuidNames) / sizeof(g_GuidNames[0]);
- char *CGuidNameList::operator [] (const GUID &guid)
+char *CGuidNameList::operator [](const GUID &guid)
+{
+ for(int i = 0; i < g_cGuidNames; i++)
{
- for (int i = 0; i < g_cGuidNames; i++) {
- if (g_GuidNames[i].guid == guid) {
- return g_GuidNames[i].szName;
- }
- }
- if (guid == GUID_NULL) {
- return "GUID_NULL";
+ if(g_GuidNames[i].guid == guid)
+ {
+ return g_GuidNames[i].szName;
}
-
- // !!! add something to print FOURCC guids?
-
- // shouldn't this print the hex CLSID?
- return "Unknown GUID Name";
}
+ if(guid == GUID_NULL)
+ {
+ return "GUID_NULL";
+ }
+
+ // !!! add something to print FOURCC guids?
+
+ // shouldn't this print the hex CLSID?
+ return "Unknown GUID Name";
+}
#endif /* _OBJBASE_H_ */
@@ -1104,32 +1163,35 @@ CDisp::CDisp(LONGLONG ll, int Format)
// introducing a default format of CDISP_REFTIME
LARGE_INTEGER li;
li.QuadPart = ll;
- switch (Format) {
- case CDISP_DEC:
- {
- TCHAR temp[20];
- int pos=20;
- temp[--pos] = 0;
- int digit;
- // always output at least one digit
- do {
- // Get the rightmost digit - we only need the low word
- digit = li.LowPart % 10;
- li.QuadPart /= 10;
- temp[--pos] = (TCHAR) digit+L'0';
- } while (li.QuadPart);
- (void)StringCchCopy(m_String, NUMELMS(m_String), temp+pos);
- break;
- }
- case CDISP_HEX:
- default:
- (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("0x%X%8.8X"), li.HighPart, li.LowPart);
+ switch(Format)
+ {
+ case CDISP_DEC:
+ {
+ TCHAR temp[20];
+ int pos = 20;
+ temp[--pos] = 0;
+ int digit;
+ // always output at least one digit
+ do
+ {
+ // Get the rightmost digit - we only need the low word
+ digit = li.LowPart % 10;
+ li.QuadPart /= 10;
+ temp[--pos] = (TCHAR) digit + L'0';
+ }
+ while(li.QuadPart);
+ (void)StringCchCopy(m_String, NUMELMS(m_String), temp + pos);
+ break;
+ }
+ case CDISP_HEX:
+ default:
+ (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("0x%X%8.8X"), li.HighPart, li.LowPart);
}
};
CDisp::CDisp(REFCLSID clsid)
{
-#ifdef UNICODE
+#ifdef UNICODE
(void)StringFromGUID2(clsid, m_String, NUMELMS(m_String));
#else
WCHAR wszTemp[50];
@@ -1143,28 +1205,32 @@ CDisp::CDisp(REFCLSID clsid)
CDisp::CDisp(CRefTime llTime)
{
LONGLONG llDiv;
- if (llTime < 0) {
+ if(llTime < 0)
+ {
llTime = -llTime;
(void)StringCchCopy(m_String, NUMELMS(m_String), TEXT("-"));
}
llDiv = (LONGLONG)24 * 3600 * 10000000;
- if (llTime >= llDiv) {
+ if(llTime >= llDiv)
+ {
(void)StringCchPrintf(m_String + lstrlen(m_String), NUMELMS(m_String) - lstrlen(m_String), TEXT("%d days "), (LONG)(llTime / llDiv));
llTime = llTime % llDiv;
}
llDiv = (LONGLONG)3600 * 10000000;
- if (llTime >= llDiv) {
+ if(llTime >= llDiv)
+ {
(void)StringCchPrintf(m_String + lstrlen(m_String), NUMELMS(m_String) - lstrlen(m_String), TEXT("%d hrs "), (LONG)(llTime / llDiv));
llTime = llTime % llDiv;
}
llDiv = (LONGLONG)60 * 10000000;
- if (llTime >= llDiv) {
+ if(llTime >= llDiv)
+ {
(void)StringCchPrintf(m_String + lstrlen(m_String), NUMELMS(m_String) - lstrlen(m_String), TEXT("%d mins "), (LONG)(llTime / llDiv));
llTime = llTime % llDiv;
}
(void)StringCchPrintf(m_String + lstrlen(m_String), NUMELMS(m_String) - lstrlen(m_String), TEXT("%d.%3.3d sec"),
- (LONG)llTime / 10000000,
- (LONG)((llTime % 10000000) / 10000));
+ (LONG)llTime / 10000000,
+ (LONG)((llTime % 10000000) / 10000));
};
#endif // __STREAMS__
@@ -1177,23 +1243,27 @@ CDisp::CDisp(IPin *pPin)
TCHAR str[MAX_PIN_NAME];
CLSID clsid;
- if (pPin) {
- pPin->QueryPinInfo(&pi);
- pi.pFilter->GetClassID(&clsid);
- QueryPinInfoReleaseFilter(pi);
- #ifndef UNICODE
- WideCharToMultiByte(GetACP(), 0, pi.achName, lstrlenW(pi.achName) + 1,
- str, MAX_PIN_NAME, NULL, NULL);
- #else
- (void)StringCchCopy(str, NUMELMS(str), pi.achName);
- #endif
- } else {
- (void)StringCchCopy(str, NUMELMS(str), TEXT("NULL IPin"));
+ if(pPin)
+ {
+ pPin->QueryPinInfo(&pi);
+ pi.pFilter->GetClassID(&clsid);
+ QueryPinInfoReleaseFilter(pi);
+#ifndef UNICODE
+ WideCharToMultiByte(GetACP(), 0, pi.achName, lstrlenW(pi.achName) + 1,
+ str, MAX_PIN_NAME, NULL, NULL);
+#else
+ (void)StringCchCopy(str, NUMELMS(str), pi.achName);
+#endif
+ }
+ else
+ {
+ (void)StringCchCopy(str, NUMELMS(str), TEXT("NULL IPin"));
}
m_pString = (PTCHAR) new TCHAR[lstrlen(str)+64];
- if (!m_pString) {
- return;
+ if(!m_pString)
+ {
+ return;
}
(void)StringCchPrintf(m_pString, lstrlen(str) + 64, TEXT("%hs(%s)"), GuidNames[clsid], str);
@@ -1247,14 +1317,15 @@ CDisp::~CDisp()
CDispBasic::~CDispBasic()
{
- if (m_pString != m_String) {
- delete [] m_pString;
+ if(m_pString != m_String)
+ {
+ delete [] m_pString;
}
}
CDisp::CDisp(double d)
{
- (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%d.%03d"), (int) d, (int) ((d - (int) d) * 1000));
+ (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT("%d.%03d"), (int) d, (int)((d - (int) d) * 1000));
}
@@ -1270,103 +1341,122 @@ void WINAPI DisplayType(LPCTSTR label, const AM_MEDIA_TYPE *pmtIn)
/* Dump the GUID types and a short description */
- DbgLog((LOG_TRACE,5,TEXT("")));
- DbgLog((LOG_TRACE,2,TEXT("%s M type %hs S type %hs"), label,
- GuidNames[pmtIn->majortype],
- GuidNames[pmtIn->subtype]));
- DbgLog((LOG_TRACE,5,TEXT("Subtype description %s"),GetSubtypeName(&pmtIn->subtype)));
+ DbgLog((LOG_TRACE, 5, TEXT("")));
+ DbgLog((LOG_TRACE, 2, TEXT("%s M type %hs S type %hs"), label,
+ GuidNames[pmtIn->majortype],
+ GuidNames[pmtIn->subtype]));
+ DbgLog((LOG_TRACE, 5, TEXT("Subtype description %s"), GetSubtypeName(&pmtIn->subtype)));
/* Dump the generic media types */
- if (pmtIn->bTemporalCompression) {
- DbgLog((LOG_TRACE,5,TEXT("Temporally compressed")));
- } else {
- DbgLog((LOG_TRACE,5,TEXT("Not temporally compressed")));
+ if(pmtIn->bTemporalCompression)
+ {
+ DbgLog((LOG_TRACE, 5, TEXT("Temporally compressed")));
+ }
+ else
+ {
+ DbgLog((LOG_TRACE, 5, TEXT("Not temporally compressed")));
}
- if (pmtIn->bFixedSizeSamples) {
- DbgLog((LOG_TRACE,5,TEXT("Sample size %d"),pmtIn->lSampleSize));
- } else {
- DbgLog((LOG_TRACE,5,TEXT("Variable size samples")));
+ if(pmtIn->bFixedSizeSamples)
+ {
+ DbgLog((LOG_TRACE, 5, TEXT("Sample size %d"), pmtIn->lSampleSize));
+ }
+ else
+ {
+ DbgLog((LOG_TRACE, 5, TEXT("Variable size samples")));
}
- if (pmtIn->formattype == FORMAT_VideoInfo) {
+ if(pmtIn->formattype == FORMAT_VideoInfo)
+ {
VIDEOINFOHEADER *pVideoInfo = (VIDEOINFOHEADER *)pmtIn->pbFormat;
- DisplayRECT(TEXT("Source rectangle"),pVideoInfo->rcSource);
- DisplayRECT(TEXT("Target rectangle"),pVideoInfo->rcTarget);
+ DisplayRECT(TEXT("Source rectangle"), pVideoInfo->rcSource);
+ DisplayRECT(TEXT("Target rectangle"), pVideoInfo->rcTarget);
DisplayBITMAPINFO(HEADER(pmtIn->pbFormat));
- } if (pmtIn->formattype == FORMAT_VideoInfo2) {
+ }
+ if(pmtIn->formattype == FORMAT_VideoInfo2)
+ {
VIDEOINFOHEADER2 *pVideoInfo2 = (VIDEOINFOHEADER2 *)pmtIn->pbFormat;
- DisplayRECT(TEXT("Source rectangle"),pVideoInfo2->rcSource);
- DisplayRECT(TEXT("Target rectangle"),pVideoInfo2->rcTarget);
+ DisplayRECT(TEXT("Source rectangle"), pVideoInfo2->rcSource);
+ DisplayRECT(TEXT("Target rectangle"), pVideoInfo2->rcTarget);
DbgLog((LOG_TRACE, 5, TEXT("Aspect Ratio: %d:%d"),
- pVideoInfo2->dwPictAspectRatioX,
- pVideoInfo2->dwPictAspectRatioY));
+ pVideoInfo2->dwPictAspectRatioX,
+ pVideoInfo2->dwPictAspectRatioY));
DisplayBITMAPINFO(&pVideoInfo2->bmiHeader);
- } else if (pmtIn->majortype == MEDIATYPE_Audio) {
- DbgLog((LOG_TRACE,2,TEXT(" Format type %hs"),
- GuidNames[pmtIn->formattype]));
- DbgLog((LOG_TRACE,2,TEXT(" Subtype %hs"),
- GuidNames[pmtIn->subtype]));
+ }
+ else if(pmtIn->majortype == MEDIATYPE_Audio)
+ {
+ DbgLog((LOG_TRACE, 2, TEXT(" Format type %hs"),
+ GuidNames[pmtIn->formattype]));
+ DbgLog((LOG_TRACE, 2, TEXT(" Subtype %hs"),
+ GuidNames[pmtIn->subtype]));
- if ((pmtIn->subtype != MEDIASUBTYPE_MPEG1Packet)
- && (pmtIn->cbFormat >= sizeof(PCMWAVEFORMAT)))
+ if((pmtIn->subtype != MEDIASUBTYPE_MPEG1Packet)
+ && (pmtIn->cbFormat >= sizeof(PCMWAVEFORMAT)))
{
/* Dump the contents of the WAVEFORMATEX type-specific format structure */
WAVEFORMATEX *pwfx = (WAVEFORMATEX *) pmtIn->pbFormat;
- DbgLog((LOG_TRACE,2,TEXT("wFormatTag %u"), pwfx->wFormatTag));
- DbgLog((LOG_TRACE,2,TEXT("nChannels %u"), pwfx->nChannels));
- DbgLog((LOG_TRACE,2,TEXT("nSamplesPerSec %lu"), pwfx->nSamplesPerSec));
- DbgLog((LOG_TRACE,2,TEXT("nAvgBytesPerSec %lu"), pwfx->nAvgBytesPerSec));
- DbgLog((LOG_TRACE,2,TEXT("nBlockAlign %u"), pwfx->nBlockAlign));
- DbgLog((LOG_TRACE,2,TEXT("wBitsPerSample %u"), pwfx->wBitsPerSample));
+ DbgLog((LOG_TRACE, 2, TEXT("wFormatTag %u"), pwfx->wFormatTag));
+ DbgLog((LOG_TRACE, 2, TEXT("nChannels %u"), pwfx->nChannels));
+ DbgLog((LOG_TRACE, 2, TEXT("nSamplesPerSec %lu"), pwfx->nSamplesPerSec));
+ DbgLog((LOG_TRACE, 2, TEXT("nAvgBytesPerSec %lu"), pwfx->nAvgBytesPerSec));
+ DbgLog((LOG_TRACE, 2, TEXT("nBlockAlign %u"), pwfx->nBlockAlign));
+ DbgLog((LOG_TRACE, 2, TEXT("wBitsPerSample %u"), pwfx->wBitsPerSample));
/* PCM uses a WAVEFORMAT and does not have the extra size field */
- if (pmtIn->cbFormat >= sizeof(WAVEFORMATEX)) {
- DbgLog((LOG_TRACE,2,TEXT("cbSize %u"), pwfx->cbSize));
+ if(pmtIn->cbFormat >= sizeof(WAVEFORMATEX))
+ {
+ DbgLog((LOG_TRACE, 2, TEXT("cbSize %u"), pwfx->cbSize));
}
- } else {
+ }
+ else
+ {
}
- } else {
- DbgLog((LOG_TRACE,2,TEXT(" Format type %hs"),
- GuidNames[pmtIn->formattype]));
+ }
+ else
+ {
+ DbgLog((LOG_TRACE, 2, TEXT(" Format type %hs"),
+ GuidNames[pmtIn->formattype]));
}
}
void DisplayBITMAPINFO(const BITMAPINFOHEADER* pbmi)
{
- DbgLog((LOG_TRACE,5,TEXT("Size of BITMAPINFO structure %d"),pbmi->biSize));
- if (pbmi->biCompression < 256) {
- DbgLog((LOG_TRACE,2,TEXT("%dx%dx%d bit (%d)"),
+ DbgLog((LOG_TRACE, 5, TEXT("Size of BITMAPINFO structure %d"), pbmi->biSize));
+ if(pbmi->biCompression < 256)
+ {
+ DbgLog((LOG_TRACE, 2, TEXT("%dx%dx%d bit (%d)"),
pbmi->biWidth, pbmi->biHeight,
pbmi->biBitCount, pbmi->biCompression));
- } else {
- DbgLog((LOG_TRACE,2,TEXT("%dx%dx%d bit '%4.4hs'"),
+ }
+ else
+ {
+ DbgLog((LOG_TRACE, 2, TEXT("%dx%dx%d bit '%4.4hs'"),
pbmi->biWidth, pbmi->biHeight,
pbmi->biBitCount, &pbmi->biCompression));
}
- DbgLog((LOG_TRACE,2,TEXT("Image size %d"),pbmi->biSizeImage));
- DbgLog((LOG_TRACE,5,TEXT("Planes %d"),pbmi->biPlanes));
- DbgLog((LOG_TRACE,5,TEXT("X Pels per metre %d"),pbmi->biXPelsPerMeter));
- DbgLog((LOG_TRACE,5,TEXT("Y Pels per metre %d"),pbmi->biYPelsPerMeter));
- DbgLog((LOG_TRACE,5,TEXT("Colours used %d"),pbmi->biClrUsed));
+ DbgLog((LOG_TRACE, 2, TEXT("Image size %d"), pbmi->biSizeImage));
+ DbgLog((LOG_TRACE, 5, TEXT("Planes %d"), pbmi->biPlanes));
+ DbgLog((LOG_TRACE, 5, TEXT("X Pels per metre %d"), pbmi->biXPelsPerMeter));
+ DbgLog((LOG_TRACE, 5, TEXT("Y Pels per metre %d"), pbmi->biYPelsPerMeter));
+ DbgLog((LOG_TRACE, 5, TEXT("Colours used %d"), pbmi->biClrUsed));
}
void DisplayRECT(LPCTSTR szLabel, const RECT& rc)
{
- DbgLog((LOG_TRACE,5,TEXT("%s (Left %d Top %d Right %d Bottom %d)"),
+ DbgLog((LOG_TRACE, 5, TEXT("%s (Left %d Top %d Right %d Bottom %d)"),
szLabel,
rc.left,
rc.top,
@@ -1377,93 +1467,110 @@ void DisplayRECT(LPCTSTR szLabel, const RECT& rc)
void WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel)
{
- if( !pGraph )
+ if(!pGraph)
{
return;
}
IEnumFilters *pFilters;
- DbgLog((LOG_TRACE,dwLevel,TEXT("DumpGraph [%x]"), pGraph));
+ DbgLog((LOG_TRACE, dwLevel, TEXT("DumpGraph [%x]"), pGraph));
- if (FAILED(pGraph->EnumFilters(&pFilters))) {
- DbgLog((LOG_TRACE,dwLevel,TEXT("EnumFilters failed!")));
+ if(FAILED(pGraph->EnumFilters(&pFilters)))
+ {
+ DbgLog((LOG_TRACE, dwLevel, TEXT("EnumFilters failed!")));
}
IBaseFilter *pFilter;
ULONG n;
- while (pFilters->Next(1, &pFilter, &n) == S_OK) {
- FILTER_INFO info;
-
- if (FAILED(pFilter->QueryFilterInfo(&info))) {
- DbgLog((LOG_TRACE,dwLevel,TEXT(" Filter [%p] -- failed QueryFilterInfo"), pFilter));
- } else {
- QueryFilterInfoReleaseGraph(info);
-
- // !!! should QueryVendorInfo here!
-
- DbgLog((LOG_TRACE,dwLevel,TEXT(" Filter [%p] '%ls'"), pFilter, info.achName));
-
- IEnumPins *pins;
-
- if (FAILED(pFilter->EnumPins(&pins))) {
- DbgLog((LOG_TRACE,dwLevel,TEXT("EnumPins failed!")));
- } else {
-
- IPin *pPin;
- while (pins->Next(1, &pPin, &n) == S_OK) {
- PIN_INFO pinInfo;
-
- if (FAILED(pPin->QueryPinInfo(&pinInfo))) {
- DbgLog((LOG_TRACE,dwLevel,TEXT(" Pin [%x] -- failed QueryPinInfo"), pPin));
- } else {
- QueryPinInfoReleaseFilter(pinInfo);
-
- IPin *pPinConnected = NULL;
-
- HRESULT hr = pPin->ConnectedTo(&pPinConnected);
-
- if (pPinConnected) {
- DbgLog((LOG_TRACE,dwLevel,TEXT(" Pin [%p] '%ls' [%sput]")
- TEXT(" Connected to pin [%p]"),
- pPin, pinInfo.achName,
- pinInfo.dir == PINDIR_INPUT ? TEXT("In") : TEXT("Out"),
- pPinConnected));
+ while(pFilters->Next(1, &pFilter, &n) == S_OK)
+ {
+ FILTER_INFO info;
- pPinConnected->Release();
+ if(FAILED(pFilter->QueryFilterInfo(&info)))
+ {
+ DbgLog((LOG_TRACE, dwLevel, TEXT(" Filter [%p] -- failed QueryFilterInfo"), pFilter));
+ }
+ else
+ {
+ QueryFilterInfoReleaseGraph(info);
- // perhaps we should really dump the type both ways as a sanity
- // check?
- if (pinInfo.dir == PINDIR_OUTPUT) {
- AM_MEDIA_TYPE mt;
+ // !!! should QueryVendorInfo here!
- hr = pPin->ConnectionMediaType(&mt);
+ DbgLog((LOG_TRACE, dwLevel, TEXT(" Filter [%p] '%ls'"), pFilter, info.achName));
- if (SUCCEEDED(hr)) {
- DisplayType(TEXT("Connection type"), &mt);
+ IEnumPins *pins;
- FreeMediaType(mt);
- }
- }
- } else {
- DbgLog((LOG_TRACE,dwLevel,
- TEXT(" Pin [%x] '%ls' [%sput]"),
- pPin, pinInfo.achName,
- pinInfo.dir == PINDIR_INPUT ? TEXT("In") : TEXT("Out")));
+ if(FAILED(pFilter->EnumPins(&pins)))
+ {
+ DbgLog((LOG_TRACE, dwLevel, TEXT("EnumPins failed!")));
+ }
+ else
+ {
- }
- }
+ IPin *pPin;
+ while(pins->Next(1, &pPin, &n) == S_OK)
+ {
+ PIN_INFO pinInfo;
+
+ if(FAILED(pPin->QueryPinInfo(&pinInfo)))
+ {
+ DbgLog((LOG_TRACE, dwLevel, TEXT(" Pin [%x] -- failed QueryPinInfo"), pPin));
+ }
+ else
+ {
+ QueryPinInfoReleaseFilter(pinInfo);
+
+ IPin *pPinConnected = NULL;
+
+ HRESULT hr = pPin->ConnectedTo(&pPinConnected);
+
+ if(pPinConnected)
+ {
+ DbgLog((LOG_TRACE, dwLevel, TEXT(" Pin [%p] '%ls' [%sput]")
+ TEXT(" Connected to pin [%p]"),
+ pPin, pinInfo.achName,
+ pinInfo.dir == PINDIR_INPUT ? TEXT("In") : TEXT("Out"),
+ pPinConnected));
+
+ pPinConnected->Release();
+
+ // perhaps we should really dump the type both ways as a sanity
+ // check?
+ if(pinInfo.dir == PINDIR_OUTPUT)
+ {
+ AM_MEDIA_TYPE mt;
+
+ hr = pPin->ConnectionMediaType(&mt);
+
+ if(SUCCEEDED(hr))
+ {
+ DisplayType(TEXT("Connection type"), &mt);
+
+ FreeMediaType(mt);
+ }
+ }
+ }
+ else
+ {
+ DbgLog((LOG_TRACE, dwLevel,
+ TEXT(" Pin [%x] '%ls' [%sput]"),
+ pPin, pinInfo.achName,
+ pinInfo.dir == PINDIR_INPUT ? TEXT("In") : TEXT("Out")));
+
+ }
+ }
+
+ pPin->Release();
- pPin->Release();
+ }
- }
+ pins->Release();
+ }
- pins->Release();
- }
+ }
- }
-
- pFilter->Release();
+ pFilter->Release();
}
pFilters->Release();
diff --git a/src/filters/BaseClasses/wxdebug.h b/src/filters/BaseClasses/wxdebug.h
index 34ceefeec..be2959c2c 100644
--- a/src/filters/BaseClasses/wxdebug.h
+++ b/src/filters/BaseClasses/wxdebug.h
@@ -51,19 +51,21 @@ enum { LOG_TIMING = 0x01, // Timing and performance measurements
LOG_CUSTOM3 = 0x80,
LOG_CUSTOM4 = 0x100,
LOG_CUSTOM5 = 0x200,
-};
+ };
#define LOG_FORCIBLY_SET 0x80000000
enum { CDISP_HEX = 0x01,
- CDISP_DEC = 0x02};
+ CDISP_DEC = 0x02
+ };
// For each object created derived from CBaseObject (in debug builds) we
// create a descriptor that holds it's name (statically allocated memory)
// and a cookie we assign it. We keep a list of all the active objects
// we have registered so that we can dump a list of remaining objects
-typedef struct tag_ObjectDesc {
+typedef struct tag_ObjectDesc
+{
LPCSTR m_szName;
LPCWSTR m_wszName;
DWORD m_dwCookie;
@@ -75,148 +77,148 @@ typedef struct tag_ObjectDesc {
#ifdef _DEBUG
- #define NAME(x) TEXT(x)
+#define NAME(x) TEXT(x)
- // These are used internally by the debug library (PRIVATE)
+// These are used internally by the debug library (PRIVATE)
- void WINAPI DbgInitKeyLevels(HKEY hKey, bool fTakeMax);
- void WINAPI DbgInitGlobalSettings(bool fTakeMax);
- void WINAPI DbgInitModuleSettings(bool fTakeMax);
- void WINAPI DbgInitModuleName();
- DWORD WINAPI DbgRegisterObjectCreation(
- LPCSTR szObjectName, LPCWSTR wszObjectName);
+void WINAPI DbgInitKeyLevels(HKEY hKey, bool fTakeMax);
+void WINAPI DbgInitGlobalSettings(bool fTakeMax);
+void WINAPI DbgInitModuleSettings(bool fTakeMax);
+void WINAPI DbgInitModuleName();
+DWORD WINAPI DbgRegisterObjectCreation(
+ LPCSTR szObjectName, LPCWSTR wszObjectName);
- BOOL WINAPI DbgRegisterObjectDestruction(DWORD dwCookie);
+BOOL WINAPI DbgRegisterObjectDestruction(DWORD dwCookie);
- // These are the PUBLIC entry points
+// These are the PUBLIC entry points
- BOOL WINAPI DbgCheckModuleLevel(DWORD Type,DWORD Level);
- void WINAPI DbgSetModuleLevel(DWORD Type,DWORD Level);
- void WINAPI DbgSetAutoRefreshLevels(bool fAuto);
+BOOL WINAPI DbgCheckModuleLevel(DWORD Type, DWORD Level);
+void WINAPI DbgSetModuleLevel(DWORD Type, DWORD Level);
+void WINAPI DbgSetAutoRefreshLevels(bool fAuto);
- // Initialise the library with the module handle
+// Initialise the library with the module handle
- void WINAPI DbgInitialise(HINSTANCE hInst);
- void WINAPI DbgTerminate();
+void WINAPI DbgInitialise(HINSTANCE hInst);
+void WINAPI DbgTerminate();
- void WINAPI DbgDumpObjectRegister();
+void WINAPI DbgDumpObjectRegister();
- // Display error and logging to the user
+// Display error and logging to the user
- void WINAPI DbgAssert(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine);
- void WINAPI DbgBreakPoint(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine);
- void WINAPI DbgBreakPoint(LPCTSTR pFileName,INT iLine,__format_string LPCTSTR szFormatString,...);
+void WINAPI DbgAssert(LPCTSTR pCondition, LPCTSTR pFileName, INT iLine);
+void WINAPI DbgBreakPoint(LPCTSTR pCondition, LPCTSTR pFileName, INT iLine);
+void WINAPI DbgBreakPoint(LPCTSTR pFileName, INT iLine, __format_string LPCTSTR szFormatString, ...);
- void WINAPI DbgKernelAssert(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine);
- void WINAPI DbgLogInfo(DWORD Type,DWORD Level,__format_string LPCTSTR pFormat,...);
+void WINAPI DbgKernelAssert(LPCTSTR pCondition, LPCTSTR pFileName, INT iLine);
+void WINAPI DbgLogInfo(DWORD Type, DWORD Level, __format_string LPCTSTR pFormat, ...);
#ifdef UNICODE
- void WINAPI DbgLogInfo(DWORD Type,DWORD Level,__format_string LPCSTR pFormat,...);
- void WINAPI DbgAssert(LPCSTR pCondition,LPCSTR pFileName,INT iLine);
- void WINAPI DbgBreakPoint(LPCSTR pCondition,LPCSTR pFileName,INT iLine);
- void WINAPI DbgKernelAssert(LPCSTR pCondition,LPCSTR pFileName,INT iLine);
+void WINAPI DbgLogInfo(DWORD Type, DWORD Level, __format_string LPCSTR pFormat, ...);
+void WINAPI DbgAssert(LPCSTR pCondition, LPCSTR pFileName, INT iLine);
+void WINAPI DbgBreakPoint(LPCSTR pCondition, LPCSTR pFileName, INT iLine);
+void WINAPI DbgKernelAssert(LPCSTR pCondition, LPCSTR pFileName, INT iLine);
#endif
- void WINAPI DbgOutString(LPCTSTR psz);
+void WINAPI DbgOutString(LPCTSTR psz);
- // Debug infinite wait stuff
- DWORD WINAPI DbgWaitForSingleObject(HANDLE h);
- DWORD WINAPI DbgWaitForMultipleObjects(DWORD nCount,
- __in_ecount(nCount) CONST HANDLE *lpHandles,
- BOOL bWaitAll);
- void WINAPI DbgSetWaitTimeout(DWORD dwTimeout);
+// Debug infinite wait stuff
+DWORD WINAPI DbgWaitForSingleObject(HANDLE h);
+DWORD WINAPI DbgWaitForMultipleObjects(DWORD nCount,
+ __in_ecount(nCount) CONST HANDLE *lpHandles,
+ BOOL bWaitAll);
+void WINAPI DbgSetWaitTimeout(DWORD dwTimeout);
#ifdef __strmif_h__
- // Display a media type: Terse at level 2, verbose at level 5
- void WINAPI DisplayType(LPCTSTR label, const AM_MEDIA_TYPE *pmtIn);
+// Display a media type: Terse at level 2, verbose at level 5
+void WINAPI DisplayType(LPCTSTR label, const AM_MEDIA_TYPE *pmtIn);
- // Dump lots of information about a filter graph
- void WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel);
+// Dump lots of information about a filter graph
+void WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel);
#endif
- #define KASSERT(_x_) if (!(_x_)) \
+#define KASSERT(_x_) if (!(_x_)) \
DbgKernelAssert(TEXT(#_x_),TEXT(__FILE__),__LINE__)
- // Break on the debugger without putting up a message box
- // message goes to debugger instead
+// Break on the debugger without putting up a message box
+// message goes to debugger instead
- #define KDbgBreak(_x_) \
+#define KDbgBreak(_x_) \
DbgKernelAssert(TEXT(#_x_),TEXT(__FILE__),__LINE__)
- // We chose a common name for our ASSERT macro, MFC also uses this name
- // So long as the implementation evaluates the condition and handles it
- // then we will be ok. Rather than override the behaviour expected we
- // will leave whatever first defines ASSERT as the handler (i.e. MFC)
- #ifndef ASSERT
- #define ASSERT(_x_) if (!(_x_)) \
+// We chose a common name for our ASSERT macro, MFC also uses this name
+// So long as the implementation evaluates the condition and handles it
+// then we will be ok. Rather than override the behaviour expected we
+// will leave whatever first defines ASSERT as the handler (i.e. MFC)
+#ifndef ASSERT
+#define ASSERT(_x_) if (!(_x_)) \
DbgAssert(TEXT(#_x_),TEXT(__FILE__),__LINE__)
- #endif
+#endif
- #define DbgAssertAligned( _ptr_, _alignment_ ) ASSERT( ((DWORD_PTR) (_ptr_)) % (_alignment_) == 0)
+#define DbgAssertAligned( _ptr_, _alignment_ ) ASSERT( ((DWORD_PTR) (_ptr_)) % (_alignment_) == 0)
- // Put up a message box informing the user of a halt
- // condition in the program
+// Put up a message box informing the user of a halt
+// condition in the program
- #define DbgBreak(_x_) \
+#define DbgBreak(_x_) \
DbgBreakPoint(TEXT(#_x_),TEXT(__FILE__),__LINE__)
- #define EXECUTE_ASSERT(_x_) ASSERT(_x_)
- #define DbgLog(_x_) DbgLogInfo _x_
- // MFC style trace macros
+#define EXECUTE_ASSERT(_x_) ASSERT(_x_)
+#define DbgLog(_x_) DbgLogInfo _x_
+// MFC style trace macros
- #define NOTE(_x_) DbgLog((LOG_TRACE,5,TEXT(_x_)))
- #define NOTE1(_x_,a) DbgLog((LOG_TRACE,5,TEXT(_x_),a))
- #define NOTE2(_x_,a,b) DbgLog((LOG_TRACE,5,TEXT(_x_),a,b))
- #define NOTE3(_x_,a,b,c) DbgLog((LOG_TRACE,5,TEXT(_x_),a,b,c))
- #define NOTE4(_x_,a,b,c,d) DbgLog((LOG_TRACE,5,TEXT(_x_),a,b,c,d))
- #define NOTE5(_x_,a,b,c,d,e) DbgLog((LOG_TRACE,5,TEXT(_x_),a,b,c,d,e))
+#define NOTE(_x_) DbgLog((LOG_TRACE,5,TEXT(_x_)))
+#define NOTE1(_x_,a) DbgLog((LOG_TRACE,5,TEXT(_x_),a))
+#define NOTE2(_x_,a,b) DbgLog((LOG_TRACE,5,TEXT(_x_),a,b))
+#define NOTE3(_x_,a,b,c) DbgLog((LOG_TRACE,5,TEXT(_x_),a,b,c))
+#define NOTE4(_x_,a,b,c,d) DbgLog((LOG_TRACE,5,TEXT(_x_),a,b,c,d))
+#define NOTE5(_x_,a,b,c,d,e) DbgLog((LOG_TRACE,5,TEXT(_x_),a,b,c,d,e))
#else
- // Retail builds make public debug functions inert - WARNING the source
- // files do not define or build any of the entry points in debug builds
- // (public entry points compile to nothing) so if you go trying to call
- // any of the private entry points in your source they won't compile
+// Retail builds make public debug functions inert - WARNING the source
+// files do not define or build any of the entry points in debug builds
+// (public entry points compile to nothing) so if you go trying to call
+// any of the private entry points in your source they won't compile
- #define NAME(_x_) ((LPTSTR) NULL)
+#define NAME(_x_) ((LPTSTR) NULL)
- #define DbgInitialise(hInst)
- #define DbgTerminate()
- #define DbgLog(_x_) 0
- #define DbgOutString(psz)
- #define DbgAssertAligned( _ptr_, _alignment_ ) 0
+#define DbgInitialise(hInst)
+#define DbgTerminate()
+#define DbgLog(_x_) 0
+#define DbgOutString(psz)
+#define DbgAssertAligned( _ptr_, _alignment_ ) 0
- #define DbgRegisterObjectCreation(pObjectName)
- #define DbgRegisterObjectDestruction(dwCookie)
- #define DbgDumpObjectRegister()
+#define DbgRegisterObjectCreation(pObjectName)
+#define DbgRegisterObjectDestruction(dwCookie)
+#define DbgDumpObjectRegister()
- #define DbgCheckModuleLevel(Type,Level)
- #define DbgSetModuleLevel(Type,Level)
- #define DbgSetAutoRefreshLevels(fAuto)
+#define DbgCheckModuleLevel(Type,Level)
+#define DbgSetModuleLevel(Type,Level)
+#define DbgSetAutoRefreshLevels(fAuto)
- #define DbgWaitForSingleObject(h) WaitForSingleObject(h, INFINITE)
- #define DbgWaitForMultipleObjects(nCount, lpHandles, bWaitAll) \
+#define DbgWaitForSingleObject(h) WaitForSingleObject(h, INFINITE)
+#define DbgWaitForMultipleObjects(nCount, lpHandles, bWaitAll) \
WaitForMultipleObjects(nCount, lpHandles, bWaitAll, INFINITE)
- #define DbgSetWaitTimeout(dwTimeout)
+#define DbgSetWaitTimeout(dwTimeout)
- #define KDbgBreak(_x_)
- #define DbgBreak(_x_)
+#define KDbgBreak(_x_)
+#define DbgBreak(_x_)
- #define KASSERT(_x_) ((void)0)
- #ifndef ASSERT
- #define ASSERT(_x_) ((void)0)
- #endif
- #define EXECUTE_ASSERT(_x_) ((void)(_x_))
+#define KASSERT(_x_) ((void)0)
+#ifndef ASSERT
+#define ASSERT(_x_) ((void)0)
+#endif
+#define EXECUTE_ASSERT(_x_) ((void)(_x_))
- // MFC style trace macros
+// MFC style trace macros
- #define NOTE(_x_) ((void)0)
- #define NOTE1(_x_,a) ((void)0)
- #define NOTE2(_x_,a,b) ((void)0)
- #define NOTE3(_x_,a,b,c) ((void)0)
- #define NOTE4(_x_,a,b,c,d) ((void)0)
- #define NOTE5(_x_,a,b,c,d,e) ((void)0)
+#define NOTE(_x_) ((void)0)
+#define NOTE1(_x_,a) ((void)0)
+#define NOTE2(_x_,a,b) ((void)0)
+#define NOTE3(_x_,a,b,c) ((void)0)
+#define NOTE4(_x_,a,b,c,d) ((void)0)
+#define NOTE5(_x_,a,b,c,d,e) ((void)0)
- #define DisplayType(label, pmtIn) ((void)0)
- #define DumpGraph(pGraph, label) ((void)0)
+#define DisplayType(label, pmtIn) ((void)0)
+#define DumpGraph(pGraph, label) ((void)0)
#endif
@@ -246,37 +248,39 @@ typedef struct tag_ObjectDesc {
#ifdef _OBJBASE_H_
- // Outputting GUID names. If you want to include the name
- // associated with a GUID (eg CLSID_...) then
- //
- // GuidNames[yourGUID]
- //
- // Returns the name defined in uuids.h as a string
-
- typedef struct {
- CHAR *szName;
- GUID guid;
- } GUID_STRING_ENTRY;
-
- class CGuidNameList {
- public:
- CHAR *operator [] (const GUID& guid);
- };
+// Outputting GUID names. If you want to include the name
+// associated with a GUID (eg CLSID_...) then
+//
+// GuidNames[yourGUID]
+//
+// Returns the name defined in uuids.h as a string
+
+typedef struct
+{
+ CHAR *szName;
+ GUID guid;
+} GUID_STRING_ENTRY;
- extern CGuidNameList GuidNames;
+class CGuidNameList
+{
+public:
+ CHAR *operator [](const GUID& guid);
+};
+
+extern CGuidNameList GuidNames;
#endif
#ifndef REMIND
- // REMIND macro - generates warning as reminder to complete coding
- // (eg) usage:
- //
- // #pragma message (REMIND("Add automation support"))
+// REMIND macro - generates warning as reminder to complete coding
+// (eg) usage:
+//
+// #pragma message (REMIND("Add automation support"))
- #define QUOTE(x) #x
- #define QQUOTE(y) QUOTE(y)
- #define REMIND(str) __FILE__ "(" QQUOTE(__LINE__) ") : " str
+#define QUOTE(x) #x
+#define QQUOTE(y) QUOTE(y)
+#define REMIND(str) __FILE__ "(" QQUOTE(__LINE__) ") : " str
#endif
// Method to display objects in a useful format
@@ -289,7 +293,10 @@ typedef struct tag_ObjectDesc {
class CDispBasic
{
public:
- CDispBasic() { m_pString = m_String; };
+ CDispBasic()
+ {
+ m_pString = m_String;
+ };
~CDispBasic();
protected:
PTCHAR m_pString; // normally points to m_String... unless too much data
@@ -329,10 +336,14 @@ private:
public:
CAutoTrace(LPCTSTR szBlkName, const int level = 15)
: _szBlkName(szBlkName), _level(level)
- {DbgLog((LOG_TRACE, _level, _szEntering, _szBlkName));}
+ {
+ DbgLog((LOG_TRACE, _level, _szEntering, _szBlkName));
+ }
~CAutoTrace()
- {DbgLog((LOG_TRACE, _level, _szLeaving, _szBlkName));}
+ {
+ DbgLog((LOG_TRACE, _level, _szLeaving, _szBlkName));
+ }
};
#if defined (__FUNCTION__)
diff --git a/src/filters/BaseClasses/wxlist.cpp b/src/filters/BaseClasses/wxlist.cpp
index e8fda9d6c..d44282426 100644
--- a/src/filters/BaseClasses/wxlist.cpp
+++ b/src/filters/BaseClasses/wxlist.cpp
@@ -155,7 +155,8 @@ void CBaseList::RemoveAll()
which point the cache will be deleted anway */
CNode *pn = m_pFirst;
- while (pn) {
+ while(pn)
+ {
CNode *op = pn;
pn = pn->Next();
delete op;
@@ -218,7 +219,8 @@ __out void *CBaseList::GetNextI(__inout POSITION& rp) const
{
/* have we reached the end of the list */
- if (rp == NULL) {
+ if(rp == NULL)
+ {
return NULL;
}
@@ -250,7 +252,8 @@ __out void *CBaseList::GetNextI(__inout POSITION& rp) const
*/
__out_opt void *CBaseList::GetI(__in_opt POSITION p) const
{
- if (p == NULL) {
+ if(p == NULL)
+ {
return NULL;
}
@@ -272,11 +275,13 @@ __out void *CBaseList::GetValidI(__in POSITION p) const
/* Return the first position in the list which holds the given pointer.
Return NULL if it's not found.
*/
-__out_opt POSITION CBaseList::FindI( __in void * pObj) const
+__out_opt POSITION CBaseList::FindI(__in void * pObj) const
{
POSITION pn;
- INTERNALTRAVERSELIST(*this, pn){
- if (GetI(pn)==pObj) {
+ INTERNALTRAVERSELIST(*this, pn)
+ {
+ if(GetI(pn) == pObj)
+ {
return pn;
}
}
@@ -334,7 +339,7 @@ __out_opt void *CBaseList::RemoveI(__in_opt POSITION pos)
/* Lock the critical section before continuing */
// ASSERT (pos!=NULL); // Removing NULL is to be harmless!
- if (pos==NULL) return NULL;
+ if(pos == NULL) return NULL;
CNode *pCurrent = (CNode *) pos;
@@ -343,18 +348,24 @@ __out_opt void *CBaseList::RemoveI(__in_opt POSITION pos)
/* Update the previous node */
CNode *pNode = pCurrent->Prev();
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
m_pFirst = pCurrent->Next();
- } else {
+ }
+ else
+ {
pNode->SetNext(pCurrent->Next());
}
/* Update the following node */
pNode = pCurrent->Next();
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
m_pLast = pCurrent->Prev();
- } else {
+ }
+ else
+ {
pNode->SetPrev(pCurrent->Prev());
}
@@ -401,13 +412,15 @@ __out_opt POSITION CBaseList::AddTailI(__in void *pObject)
that otherwise we will have to create a new one */
pNode = (CNode *) m_Cache.RemoveFromCache();
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
pNode = new CNode;
}
/* Check we have a valid object */
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
return NULL;
}
@@ -419,9 +432,12 @@ __out_opt POSITION CBaseList::AddTailI(__in void *pObject)
pNode->SetNext(NULL);
pNode->SetPrev(m_pLast);
- if (m_pLast == NULL) {
+ if(m_pLast == NULL)
+ {
m_pFirst = pNode;
- } else {
+ }
+ else
+ {
m_pLast->SetNext(pNode);
}
@@ -450,13 +466,15 @@ __out_opt POSITION CBaseList::AddHeadI(__in void *pObject)
that otherwise we will have to create a new one */
pNode = (CNode *) m_Cache.RemoveFromCache();
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
pNode = new CNode;
}
/* Check we have a valid object */
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
return NULL;
}
@@ -470,9 +488,12 @@ __out_opt POSITION CBaseList::AddHeadI(__in void *pObject)
pNode->SetPrev(NULL);
pNode->SetNext(m_pFirst);
- if (m_pFirst == NULL) {
+ if(m_pFirst == NULL)
+ {
m_pLast = pNode;
- } else {
+ }
+ else
+ {
m_pFirst->SetPrev(pNode);
}
m_pFirst = pNode;
@@ -497,10 +518,12 @@ BOOL CBaseList::AddTail(__in CBaseList *pList)
*/
POSITION pos = pList->GetHeadPositionI();
- while (pos) {
- if (NULL == AddTailI(pList->GetNextI(pos))) {
- return FALSE;
- }
+ while(pos)
+ {
+ if(NULL == AddTailI(pList->GetNextI(pos)))
+ {
+ return FALSE;
+ }
}
return TRUE;
} // AddTail(list)
@@ -523,8 +546,10 @@ BOOL CBaseList::AddHead(__in CBaseList *pList)
POSITION pos;
- INTERNALREVERSETRAVERSELIST(*pList, pos) {
- if (NULL== AddHeadI(pList->GetValidI(pos))){
+ INTERNALREVERSETRAVERSELIST(*pList, pos)
+ {
+ if(NULL == AddHeadI(pList->GetValidI(pos)))
+ {
return FALSE;
}
}
@@ -540,7 +565,7 @@ BOOL CBaseList::AddHead(__in CBaseList *pList)
*/
__out_opt POSITION CBaseList::AddAfterI(__in_opt POSITION pos, __in void * pObj)
{
- if (pos==NULL)
+ if(pos == NULL)
return AddHeadI(pObj);
/* As someone else might be furkling with the list -
@@ -548,19 +573,21 @@ __out_opt POSITION CBaseList::AddAfterI(__in_opt POSITION pos, __in void * pObj
*/
CNode *pAfter = (CNode *) pos;
ASSERT(pAfter != NULL);
- if (pAfter==m_pLast)
+ if(pAfter == m_pLast)
return AddTailI(pObj);
/* set pnode to point to a new node, preferably from the cache */
CNode *pNode = (CNode *) m_Cache.RemoveFromCache();
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
pNode = new CNode;
}
/* Check we have a valid object */
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
return NULL;
}
@@ -593,10 +620,11 @@ __out_opt POSITION CBaseList::AddAfterI(__in_opt POSITION pos, __in void * pObj
BOOL CBaseList::AddAfter(__in_opt POSITION p, __in CBaseList *pList)
{
POSITION pos;
- INTERNALTRAVERSELIST(*pList, pos) {
+ INTERNALTRAVERSELIST(*pList, pos)
+ {
/* p follows along the elements being added */
p = AddAfterI(p, pList->GetValidI(pos));
- if (p==NULL) return FALSE;
+ if(p == NULL) return FALSE;
}
return TRUE;
} // AddAfter(list)
@@ -610,24 +638,26 @@ BOOL CBaseList::AddAfter(__in_opt POSITION p, __in CBaseList *pList)
*/
__out_opt POSITION CBaseList::AddBeforeI(__in_opt POSITION pos, __in void * pObj)
{
- if (pos==NULL)
+ if(pos == NULL)
return AddTailI(pObj);
/* set pnode to point to a new node, preferably from the cache */
CNode *pBefore = (CNode *) pos;
ASSERT(pBefore != NULL);
- if (pBefore==m_pFirst)
+ if(pBefore == m_pFirst)
return AddHeadI(pObj);
CNode * pNode = (CNode *) m_Cache.RemoveFromCache();
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
pNode = new CNode;
}
/* Check we have a valid object */
- if (pNode == NULL) {
+ if(pNode == NULL)
+ {
return NULL;
}
@@ -661,10 +691,11 @@ __out_opt POSITION CBaseList::AddBeforeI(__in_opt POSITION pos, __in void * pObj
BOOL CBaseList::AddBefore(__in_opt POSITION p, __in CBaseList *pList)
{
POSITION pos;
- INTERNALREVERSETRAVERSELIST(*pList, pos) {
+ INTERNALREVERSETRAVERSELIST(*pList, pos)
+ {
/* p follows along the elements being added */
p = AddBeforeI(p, pList->GetValidI(pos));
- if (p==NULL) return FALSE;
+ if(p == NULL) return FALSE;
}
return TRUE;
} // AddBefore(list)
@@ -688,7 +719,7 @@ BOOL CBaseList::AddBefore(__in_opt POSITION p, __in CBaseList *pList)
MoveElementsFromHeadThroughPositionToOtherTail
*/
BOOL CBaseList::MoveToTail
- (__in_opt POSITION pos, __in CBaseList *pList)
+(__in_opt POSITION pos, __in CBaseList *pList)
{
/* Algorithm:
Note that the elements (including their order) in the concatenation
@@ -701,38 +732,39 @@ BOOL CBaseList::MoveToTail
6. Set/Reset any events
*/
- if (pos==NULL) return TRUE; // no-op. Eliminates special cases later.
+ if(pos == NULL) return TRUE; // no-op. Eliminates special cases later.
/* Make cMove the number of nodes to move */
CNode * p = (CNode *)pos;
int cMove = 0; // number of nodes to move
- while(p!=NULL) {
- p = p->Prev();
- ++cMove;
+ while(p != NULL)
+ {
+ p = p->Prev();
+ ++cMove;
}
/* Join the two chains together */
- if (pList->m_pLast!=NULL)
+ if(pList->m_pLast != NULL)
pList->m_pLast->SetNext(m_pFirst);
- if (m_pFirst!=NULL)
+ if(m_pFirst != NULL)
m_pFirst->SetPrev(pList->m_pLast);
/* set first and last pointers */
p = (CNode *)pos;
- if (pList->m_pFirst==NULL)
+ if(pList->m_pFirst == NULL)
pList->m_pFirst = m_pFirst;
m_pFirst = p->Next();
- if (m_pFirst==NULL)
+ if(m_pFirst == NULL)
m_pLast = NULL;
pList->m_pLast = p;
/* Break the chain after p to create the new pieces */
- if (m_pFirst!=NULL)
+ if(m_pFirst != NULL)
m_pFirst->SetPrev(NULL);
p->SetNext(NULL);
@@ -762,26 +794,27 @@ BOOL CBaseList::MoveToTail
concatenates foo onto the start of bar and empties foo.
*/
BOOL CBaseList::MoveToHead
- (__in_opt POSITION pos, __in CBaseList *pList)
+(__in_opt POSITION pos, __in CBaseList *pList)
{
/* See the comments on the algorithm in MoveToTail */
- if (pos==NULL) return TRUE; // no-op. Eliminates special cases later.
+ if(pos == NULL) return TRUE; // no-op. Eliminates special cases later.
/* Make cMove the number of nodes to move */
CNode * p = (CNode *)pos;
int cMove = 0; // number of nodes to move
- while(p!=NULL) {
- p = p->Next();
- ++cMove;
+ while(p != NULL)
+ {
+ p = p->Next();
+ ++cMove;
}
/* Join the two chains together */
- if (pList->m_pFirst!=NULL)
+ if(pList->m_pFirst != NULL)
pList->m_pFirst->SetPrev(m_pLast);
- if (m_pLast!=NULL)
+ if(m_pLast != NULL)
m_pLast->SetNext(pList->m_pFirst);
@@ -789,17 +822,17 @@ BOOL CBaseList::MoveToHead
p = (CNode *)pos;
- if (pList->m_pLast==NULL)
+ if(pList->m_pLast == NULL)
pList->m_pLast = m_pLast;
m_pLast = p->Prev();
- if (m_pLast==NULL)
+ if(m_pLast == NULL)
m_pFirst = NULL;
pList->m_pFirst = p;
/* Break the chain after p to create the new pieces */
- if (m_pLast!=NULL)
+ if(m_pLast != NULL)
m_pLast->SetNext(NULL);
p->SetPrev(NULL);
@@ -840,7 +873,8 @@ void CBaseList::Reverse()
// Yes we COULD use a traverse, but it would look funny!
p = m_pFirst;
- while (p!=NULL) {
+ while(p != NULL)
+ {
CNode * q;
q = p->Next();
p->SetNext(p->Prev());
@@ -855,15 +889,16 @@ void CBaseList::Reverse()
#if 0 // old version
- if (m_pFirst==NULL) return; // empty list
- if (m_pFirst->Next()==NULL) return; // single node list
+ if(m_pFirst == NULL) return; // empty list
+ if(m_pFirst->Next() == NULL) return; // single node list
/* run along forward chain */
- for ( p = m_pFirst
- ; p!=NULL
+ for(p = m_pFirst
+ ; p != NULL
; p = p->Next()
- ){
+ )
+ {
p->SetPrev(p->Next());
}
@@ -873,10 +908,11 @@ void CBaseList::Reverse()
/* run along new reverse chain i.e. old forward chain again */
- for ( p = m_pFirst // start at the old first element
- ; p->Prev()!=NULL // while there's a node still to be set
+ for(p = m_pFirst // start at the old first element
+ ; p->Prev() != NULL // while there's a node still to be set
; p = p->Prev() // work in the same direction as before
- ){
+ )
+ {
p->Prev()->SetNext(p);
}
diff --git a/src/filters/BaseClasses/wxlist.h b/src/filters/BaseClasses/wxlist.h
index 900792883..560c1841f 100644
--- a/src/filters/BaseClasses/wxlist.h
+++ b/src/filters/BaseClasses/wxlist.h
@@ -27,30 +27,33 @@
#ifndef __WXLIST__
#define __WXLIST__
- /* A POSITION represents (in some fashion that's opaque) a cursor
- on the list that can be set to identify any element. NULL is
- a valid value and several operations regard NULL as the position
- "one step off the end of the list". (In an n element list there
- are n+1 places to insert and NULL is that "n+1-th" value).
- The POSITION of an element in the list is only invalidated if
- that element is deleted. Move operations may mean that what
- was a valid POSITION in one list is now a valid POSITION in
- a different list.
-
- Some operations which at first sight are illegal are allowed as
- harmless no-ops. For instance RemoveHead is legal on an empty
- list and it returns NULL. This allows an atomic way to test if
- there is an element there, and if so, get it. The two operations
- AddTail and RemoveHead thus implement a MONITOR (See Hoare's paper).
-
- Single element operations return POSITIONs, non-NULL means it worked.
- whole list operations return a BOOL. TRUE means it all worked.
-
- This definition is the same as the POSITION type for MFCs, so we must
- avoid defining it twice.
- */
+/* A POSITION represents (in some fashion that's opaque) a cursor
+ on the list that can be set to identify any element. NULL is
+ a valid value and several operations regard NULL as the position
+ "one step off the end of the list". (In an n element list there
+ are n+1 places to insert and NULL is that "n+1-th" value).
+ The POSITION of an element in the list is only invalidated if
+ that element is deleted. Move operations may mean that what
+ was a valid POSITION in one list is now a valid POSITION in
+ a different list.
+
+ Some operations which at first sight are illegal are allowed as
+ harmless no-ops. For instance RemoveHead is legal on an empty
+ list and it returns NULL. This allows an atomic way to test if
+ there is an element there, and if so, get it. The two operations
+ AddTail and RemoveHead thus implement a MONITOR (See Hoare's paper).
+
+ Single element operations return POSITIONs, non-NULL means it worked.
+ whole list operations return a BOOL. TRUE means it all worked.
+
+ This definition is the same as the POSITION type for MFCs, so we must
+ avoid defining it twice.
+*/
#ifndef __AFX_H__
-struct __POSITION { int unused; };
+struct __POSITION
+{
+ int unused;
+};
typedef __POSITION* POSITION;
#endif
@@ -61,22 +64,24 @@ const int DEFAULTCACHE = 10; /* Default node object cache size */
to the object that it looks after.
All of these pointers can be retrieved or set through member functions.
*/
-class CBaseList
+class CBaseList
#ifdef _DEBUG
: public CBaseObject
#endif
{
/* Making these classes inherit from CBaseObject does nothing
functionally but it allows us to check there are no memory
- leaks in debug builds.
+ leaks in debug builds.
*/
public:
#ifdef _DEBUG
- class CNode : public CBaseObject {
+ class CNode : public CBaseObject
+ {
#else
- class CNode {
+ class CNode
+ {
#endif
CNode *m_pPrev; /* Previous node in the list */
@@ -95,39 +100,59 @@ public:
/* Return the previous node before this one */
- __out CNode *Prev() const { return m_pPrev; };
+ __out CNode *Prev() const
+ {
+ return m_pPrev;
+ };
/* Return the next node after this one */
- __out CNode *Next() const { return m_pNext; };
+ __out CNode *Next() const
+ {
+ return m_pNext;
+ };
/* Set the previous node before this one */
- void SetPrev(__in_opt CNode *p) { m_pPrev = p; };
+ void SetPrev(__in_opt CNode *p)
+ {
+ m_pPrev = p;
+ };
/* Set the next node after this one */
- void SetNext(__in_opt CNode *p) { m_pNext = p; };
+ void SetNext(__in_opt CNode *p)
+ {
+ m_pNext = p;
+ };
/* Get the pointer to the object for this node */
- __out void *GetData() const { return m_pObject; };
+ __out void *GetData() const
+ {
+ return m_pObject;
+ };
/* Set the pointer to the object for this node */
- void SetData(__in void *p) { m_pObject = p; };
+ void SetData(__in void *p)
+ {
+ m_pObject = p;
+ };
};
class CNodeCache
{
public:
CNodeCache(INT iCacheSize) : m_iCacheSize(iCacheSize),
- m_pHead(NULL),
- m_iUsed(0)
- {};
- ~CNodeCache() {
+ m_pHead(NULL),
+ m_iUsed(0)
+ {};
+ ~CNodeCache()
+ {
CNode *pNode = m_pHead;
- while (pNode) {
+ while(pNode)
+ {
CNode *pCurrent = pNode;
pNode = pNode->Next();
delete pCurrent;
@@ -135,22 +160,28 @@ public:
};
void AddToCache(__inout CNode *pNode)
{
- if (m_iUsed < m_iCacheSize) {
+ if(m_iUsed < m_iCacheSize)
+ {
pNode->SetNext(m_pHead);
m_pHead = pNode;
m_iUsed++;
- } else {
+ }
+ else
+ {
delete pNode;
}
};
CNode *RemoveFromCache()
{
CNode *pNode = m_pHead;
- if (pNode != NULL) {
+ if(pNode != NULL)
+ {
m_pHead = pNode->Next();
m_iUsed--;
ASSERT(m_iUsed >= 0);
- } else {
+ }
+ else
+ {
ASSERT(m_iUsed == 0);
}
return pNode;
@@ -260,7 +291,8 @@ public:
*/
__out_opt POSITION Next(__in_opt POSITION pos) const
{
- if (pos == NULL) {
+ if(pos == NULL)
+ {
return (POSITION) m_pFirst;
}
CNode *pn = (CNode *) pos;
@@ -270,7 +302,8 @@ public:
// See Next
__out_opt POSITION Prev(__in_opt POSITION pos) const
{
- if (pos == NULL) {
+ if(pos == NULL)
+ {
return (POSITION) m_pLast;
}
CNode *pn = (CNode *) pos;
@@ -282,7 +315,7 @@ public:
pointer. Return NULL if the pointer was not not found.
*/
protected:
- __out_opt POSITION FindI( __in void * pObj) const;
+ __out_opt POSITION FindI(__in void * pObj) const;
// ??? Should there be (or even should there be only)
// ??? POSITION FindNextAfter(void * pObj, POSITION p)
@@ -380,9 +413,9 @@ public:
Return the position of the new object, NULL if it fails
Existing POSITIONs in *this are undisturbed, including p.
*/
- protected:
+protected:
__out_opt POSITION AddBeforeI(__in_opt POSITION p, __in void * pObj);
- public:
+public:
/* Add the list *pList to *this before position p in *this
AddAfter(NULL,x) adds x to the start - equivalent to AddHead
@@ -479,7 +512,7 @@ public:
/* set cursor to the position of each element of list in turn */
- #define TRAVERSELIST(list, cursor) \
+#define TRAVERSELIST(list, cursor) \
for ( cursor = (list).GetHeadPosition() \
; cursor!=NULL \
; cursor = (list).Next(cursor) \
@@ -489,7 +522,7 @@ public:
/* set cursor to the position of each element of list in turn
in reverse order
*/
- #define REVERSETRAVERSELIST(list, cursor) \
+#define REVERSETRAVERSELIST(list, cursor) \
for ( cursor = (list).GetTailPosition() \
; cursor!=NULL \
; cursor = (list).Prev(cursor) \
@@ -504,42 +537,97 @@ public:
INT iItems,
BOOL bLock = TRUE,
BOOL bAlert = FALSE) :
- CBaseList(pName, iItems) {
+ CBaseList(pName, iItems)
+ {
UNREFERENCED_PARAMETER(bAlert);
UNREFERENCED_PARAMETER(bLock);
};
CGenericList(__in_opt LPCTSTR pName) :
- CBaseList(pName) {
+ CBaseList(pName)
+ {
};
- __out_opt POSITION GetHeadPosition() const { return (POSITION)m_pFirst; }
- __out_opt POSITION GetTailPosition() const { return (POSITION)m_pLast; }
- int GetCount() const { return m_Count; }
+ __out_opt POSITION GetHeadPosition() const
+ {
+ return (POSITION)m_pFirst;
+ }
+ __out_opt POSITION GetTailPosition() const
+ {
+ return (POSITION)m_pLast;
+ }
+ int GetCount() const
+ {
+ return m_Count;
+ }
- __out OBJECT *GetNext(__inout POSITION& rp) const { return (OBJECT *) GetNextI(rp); }
+ __out OBJECT *GetNext(__inout POSITION& rp) const
+ {
+ return (OBJECT *) GetNextI(rp);
+ }
- __out_opt OBJECT *Get(__in_opt POSITION p) const { return (OBJECT *) GetI(p); }
- __out OBJECT *GetValid(__in POSITION p) const { return (OBJECT *) GetValidI(p); }
- __out_opt OBJECT *GetHead() const { return Get(GetHeadPosition()); }
+ __out_opt OBJECT *Get(__in_opt POSITION p) const
+ {
+ return (OBJECT *) GetI(p);
+ }
+ __out OBJECT *GetValid(__in POSITION p) const
+ {
+ return (OBJECT *) GetValidI(p);
+ }
+ __out_opt OBJECT *GetHead() const
+ {
+ return Get(GetHeadPosition());
+ }
- __out_opt OBJECT *RemoveHead() { return (OBJECT *) RemoveHeadI(); }
+ __out_opt OBJECT *RemoveHead()
+ {
+ return (OBJECT *) RemoveHeadI();
+ }
- __out_opt OBJECT *RemoveTail() { return (OBJECT *) RemoveTailI(); }
+ __out_opt OBJECT *RemoveTail()
+ {
+ return (OBJECT *) RemoveTailI();
+ }
- __out_opt OBJECT *Remove(__in_opt POSITION p) { return (OBJECT *) RemoveI(p); }
- __out_opt POSITION AddBefore(__in_opt POSITION p, __in OBJECT * pObj) { return AddBeforeI(p, pObj); }
- __out_opt POSITION AddAfter(__in_opt POSITION p, __in OBJECT * pObj) { return AddAfterI(p, pObj); }
- __out_opt POSITION AddHead(__in OBJECT * pObj) { return AddHeadI(pObj); }
- __out_opt POSITION AddTail(__in OBJECT * pObj) { return AddTailI(pObj); }
+ __out_opt OBJECT *Remove(__in_opt POSITION p)
+ {
+ return (OBJECT *) RemoveI(p);
+ }
+ __out_opt POSITION AddBefore(__in_opt POSITION p, __in OBJECT * pObj)
+ {
+ return AddBeforeI(p, pObj);
+ }
+ __out_opt POSITION AddAfter(__in_opt POSITION p, __in OBJECT * pObj)
+ {
+ return AddAfterI(p, pObj);
+ }
+ __out_opt POSITION AddHead(__in OBJECT * pObj)
+ {
+ return AddHeadI(pObj);
+ }
+ __out_opt POSITION AddTail(__in OBJECT * pObj)
+ {
+ return AddTailI(pObj);
+ }
BOOL AddTail(__in CGenericList<OBJECT> *pList)
- { return CBaseList::AddTail((CBaseList *) pList); }
+ {
+ return CBaseList::AddTail((CBaseList *) pList);
+ }
BOOL AddHead(__in CGenericList<OBJECT> *pList)
- { return CBaseList::AddHead((CBaseList *) pList); }
+ {
+ return CBaseList::AddHead((CBaseList *) pList);
+ }
BOOL AddAfter(__in_opt POSITION p, __in CGenericList<OBJECT> *pList)
- { return CBaseList::AddAfter(p, (CBaseList *) pList); };
+ {
+ return CBaseList::AddAfter(p, (CBaseList *) pList);
+ };
BOOL AddBefore(__in_opt POSITION p, __in CGenericList<OBJECT> *pList)
- { return CBaseList::AddBefore(p, (CBaseList *) pList); };
- __out_opt POSITION Find( __in OBJECT * pObj) const { return FindI(pObj); }
+ {
+ return CBaseList::AddBefore(p, (CBaseList *) pList);
+ };
+ __out_opt POSITION Find(__in OBJECT * pObj) const
+ {
+ return FindI(pObj);
+ }
}; // end of class declaration
diff --git a/src/filters/BaseClasses/wxutil.cpp b/src/filters/BaseClasses/wxutil.cpp
index 271f68da0..65e3c904a 100644
--- a/src/filters/BaseClasses/wxutil.cpp
+++ b/src/filters/BaseClasses/wxutil.cpp
@@ -17,8 +17,10 @@
CAMEvent::CAMEvent(BOOL fManualReset, __inout_opt HRESULT *phr)
{
m_hEvent = CreateEvent(NULL, fManualReset, FALSE, NULL);
- if (NULL == m_hEvent) {
- if (NULL != phr && SUCCEEDED(*phr)) {
+ if(NULL == m_hEvent)
+ {
+ if(NULL != phr && SUCCEEDED(*phr))
+ {
*phr = E_OUTOFMEMORY;
}
}
@@ -27,8 +29,10 @@ CAMEvent::CAMEvent(BOOL fManualReset, __inout_opt HRESULT *phr)
CAMEvent::CAMEvent(__inout_opt HRESULT *phr)
{
m_hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (NULL == m_hEvent) {
- if (NULL != phr && SUCCEEDED(*phr)) {
+ if(NULL == m_hEvent)
+ {
+ if(NULL != phr && SUCCEEDED(*phr))
+ {
*phr = E_OUTOFMEMORY;
}
}
@@ -36,8 +40,9 @@ CAMEvent::CAMEvent(__inout_opt HRESULT *phr)
CAMEvent::~CAMEvent()
{
- if (m_hEvent) {
- EXECUTE_ASSERT(CloseHandle(m_hEvent));
+ if(m_hEvent)
+ {
+ EXECUTE_ASSERT(CloseHandle(m_hEvent));
}
}
@@ -63,30 +68,35 @@ BOOL CAMMsgEvent::WaitMsg(DWORD dwTimeout)
// the timeout will eventually run down as we iterate
// processing messages. grab the start time so that
// we can calculate elapsed times.
- if (dwWaitTime != INFINITE) {
+ if(dwWaitTime != INFINITE)
+ {
dwStartTime = timeGetTime();
}
- do {
- dwWait = MsgWaitForMultipleObjects(1,&m_hEvent,FALSE, dwWaitTime, QS_SENDMESSAGE);
- if (dwWait == WAIT_OBJECT_0 + 1) {
- MSG Message;
- PeekMessage(&Message,NULL,0,0,PM_NOREMOVE);
+ do
+ {
+ dwWait = MsgWaitForMultipleObjects(1, &m_hEvent, FALSE, dwWaitTime, QS_SENDMESSAGE);
+ if(dwWait == WAIT_OBJECT_0 + 1)
+ {
+ MSG Message;
+ PeekMessage(&Message, NULL, 0, 0, PM_NOREMOVE);
- // If we have an explicit length of time to wait calculate
- // the next wake up point - which might be now.
- // If dwTimeout is INFINITE, it stays INFINITE
- if (dwWaitTime != INFINITE) {
+ // If we have an explicit length of time to wait calculate
+ // the next wake up point - which might be now.
+ // If dwTimeout is INFINITE, it stays INFINITE
+ if(dwWaitTime != INFINITE)
+ {
- DWORD dwElapsed = timeGetTime()-dwStartTime;
+ DWORD dwElapsed = timeGetTime() - dwStartTime;
- dwWaitTime =
- (dwElapsed >= dwTimeout)
- ? 0 // wake up with WAIT_TIMEOUT
- : dwTimeout-dwElapsed;
- }
+ dwWaitTime =
+ (dwElapsed >= dwTimeout)
+ ? 0 // wake up with WAIT_TIMEOUT
+ : dwTimeout - dwElapsed;
+ }
}
- } while (dwWait == WAIT_OBJECT_0 + 1);
+ }
+ while(dwWait == WAIT_OBJECT_0 + 1);
// return TRUE if we woke on the event handle,
// FALSE if we timed out.
@@ -103,7 +113,8 @@ CAMThread::CAMThread(__inout_opt HRESULT *phr)
m_hThread = NULL;
}
-CAMThread::~CAMThread() {
+CAMThread::~CAMThread()
+{
Close();
}
@@ -114,7 +125,8 @@ DWORD WINAPI
CAMThread::InitialThreadProc(__inout LPVOID pv)
{
HRESULT hrCoInit = CAMThread::CoInitializeHelper();
- if(FAILED(hrCoInit)) {
+ if(FAILED(hrCoInit))
+ {
DbgLog((LOG_ERROR, 1, TEXT("CoInitializeEx failed.")));
}
@@ -122,7 +134,8 @@ CAMThread::InitialThreadProc(__inout LPVOID pv)
HRESULT hr = pThread->ThreadProc();
- if(SUCCEEDED(hrCoInit)) {
+ if(SUCCEEDED(hrCoInit))
+ {
CoUninitialize();
}
@@ -136,20 +149,22 @@ CAMThread::Create()
CAutoLock lock(&m_AccessLock);
- if (ThreadExists()) {
- return FALSE;
+ if(ThreadExists())
+ {
+ return FALSE;
}
m_hThread = CreateThread(
- NULL,
- 0,
- CAMThread::InitialThreadProc,
- this,
- 0,
- &threadid);
-
- if (!m_hThread) {
- return FALSE;
+ NULL,
+ 0,
+ CAMThread::InitialThreadProc,
+ this,
+ 0,
+ &threadid);
+
+ if(!m_hThread)
+ {
+ return FALSE;
}
return TRUE;
@@ -161,8 +176,9 @@ 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;
+ if(!ThreadExists())
+ {
+ return (DWORD) E_FAIL;
}
// set the parameter
@@ -190,13 +206,17 @@ CAMThread::GetRequest()
BOOL
CAMThread::CheckRequest(__out_opt DWORD * pParam)
{
- if (!m_EventSend.Check()) {
- return FALSE;
- } else {
- if (pParam) {
- *pParam = m_dwParam;
- }
- return TRUE;
+ if(!m_EventSend.Check())
+ {
+ return FALSE;
+ }
+ else
+ {
+ if(pParam)
+ {
+ *pParam = m_dwParam;
+ }
+ return TRUE;
}
}
@@ -238,13 +258,13 @@ HRESULT CAMThread::CoInitializeHelper()
HINSTANCE hOle = GetModuleHandle(TEXT("ole32.dll"));
if(hOle)
{
- typedef HRESULT (STDAPICALLTYPE *PCoInitializeEx)(
+ typedef HRESULT(STDAPICALLTYPE * PCoInitializeEx)(
LPVOID pvReserved, DWORD dwCoInit);
PCoInitializeEx pCoInitializeEx =
(PCoInitializeEx)(GetProcAddress(hOle, "CoInitializeEx"));
if(pCoInitializeEx)
{
- hr = (*pCoInitializeEx)(0, COINIT_DISABLE_OLE1DDE );
+ hr = (*pCoInitializeEx)(0, COINIT_DISABLE_OLE1DDE);
}
}
else
@@ -261,34 +281,38 @@ HRESULT CAMThread::CoInitializeHelper()
// queue when the thread exited
CMsgThread::~CMsgThread()
{
- if (m_hThread != NULL) {
+ if(m_hThread != NULL)
+ {
WaitForSingleObject(m_hThread, INFINITE);
EXECUTE_ASSERT(CloseHandle(m_hThread));
}
POSITION pos = m_ThreadQueue.GetHeadPosition();
- while (pos) {
+ while(pos)
+ {
CMsg * pMsg = m_ThreadQueue.GetNext(pos);
delete pMsg;
}
m_ThreadQueue.RemoveAll();
- if (m_hSem != NULL) {
+ if(m_hSem != NULL)
+ {
EXECUTE_ASSERT(CloseHandle(m_hSem));
}
}
BOOL
CMsgThread::CreateThread(
- )
+)
{
m_hSem = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL);
- if (m_hSem == NULL) {
+ if(m_hSem == NULL)
+ {
return FALSE;
}
m_hThread = ::CreateThread(NULL, 0, DefaultThreadProc,
- (LPVOID)this, 0, &m_ThreadId);
+ (LPVOID)this, 0, &m_ThreadId);
return m_hThread != NULL;
}
@@ -301,7 +325,7 @@ CMsgThread::CreateThread(
DWORD WINAPI
CMsgThread::DefaultThreadProc(
__inout LPVOID lpParam
- )
+)
{
CMsgThread *lpThis = (CMsgThread *)lpParam;
CMsg msg;
@@ -313,11 +337,13 @@ CMsgThread::DefaultThreadProc(
// allow a derived class to handle thread startup
lpThis->OnThreadInit();
- do {
- lpThis->GetThreadMsg(&msg);
- lResult = lpThis->ThreadMessageProc(msg.uMsg,msg.dwFlags,
- msg.lpParam, msg.pEvent);
- } while (lResult == 0L);
+ do
+ {
+ lpThis->GetThreadMsg(&msg);
+ lResult = lpThis->ThreadMessageProc(msg.uMsg, msg.dwFlags,
+ msg.lpParam, msg.pEvent);
+ }
+ while(lResult == 0L);
// !!!
CoUninitialize();
@@ -334,13 +360,17 @@ CMsgThread::GetThreadMsg(__out CMsg *msg)
CMsg * pmsg = NULL;
// keep trying until a message appears
- while (TRUE) {
+ while(TRUE)
+ {
{
CAutoLock lck(&m_Lock);
pmsg = m_ThreadQueue.RemoveHead();
- if (pmsg == NULL) {
+ if(pmsg == NULL)
+ {
m_lWaiting++;
- } else {
+ }
+ else
+ {
break;
}
}
@@ -359,14 +389,18 @@ CMsgThread::GetThreadMsg(__out CMsg *msg)
void WINAPI IntToWstr(int i, __out_ecount(12) LPWSTR wstr)
{
#ifdef UNICODE
- if (FAILED(StringCchPrintf(wstr, 12, L"%d", i))) {
+ if(FAILED(StringCchPrintf(wstr, 12, L"%d", i)))
+ {
wstr[0] = 0;
}
#else
TCHAR temp[12];
- if (FAILED(StringCchPrintf(temp, NUMELMS(temp), "%d", i))) {
+ if(FAILED(StringCchPrintf(temp, NUMELMS(temp), "%d", i)))
+ {
wstr[0] = 0;
- } else {
+ }
+ else
+ {
MultiByteToWideChar(CP_ACP, 0, temp, -1, wstr, 12);
}
#endif
@@ -382,40 +416,44 @@ void * __stdcall memmoveInternal(void * dst, const void * src, size_t count)
void * ret = dst;
#ifdef _X86_
- if (dst <= src || (char *)dst >= ((char *)src + count)) {
+ if(dst <= src || (char *)dst >= ((char *)src + count))
+ {
/*
* Non-Overlapping Buffers
* copy from lower addresses to higher addresses
*/
- _asm {
- mov esi,src
- mov edi,dst
- mov ecx,count
+ _asm
+ {
+ mov esi, src
+ mov edi, dst
+ mov ecx, count
cld
- mov edx,ecx
- and edx,MEMORY_ALIGNMENT_MASK
- shr ecx,MEMORY_ALIGNMENT_LOG2
+ mov edx, ecx
+ and edx, MEMORY_ALIGNMENT_MASK
+ shr ecx, MEMORY_ALIGNMENT_LOG2
rep movsd
- or ecx,edx
+ or ecx, edx
jz memmove_done
rep movsb
-memmove_done:
+ memmove_done:
}
}
- else {
+ else
+ {
/*
* Overlapping Buffers
* copy from higher addresses to lower addresses
*/
- _asm {
- mov esi,src
- mov edi,dst
- mov ecx,count
+ _asm
+ {
+ mov esi, src
+ mov edi, dst
+ mov ecx, count
std
- add esi,ecx
- add edi,ecx
+ add esi, ecx
+ add edi, ecx
dec esi
dec edi
rep movsb
@@ -439,20 +477,20 @@ HRESULT AMSafeMemMoveOffset(
__in size_t count)
{
// prevent read overruns
- if( count + cb_src_offset < count || // prevent integer overflow
- count + cb_src_offset > src_size) // prevent read overrun
+ if(count + cb_src_offset < count || // prevent integer overflow
+ count + cb_src_offset > src_size) // prevent read overrun
{
return E_INVALIDARG;
}
// prevent write overruns
- if( count + cb_dst_offset < count || // prevent integer overflow
- count + cb_dst_offset > dst_size) // prevent write overrun
+ if(count + cb_dst_offset < count || // prevent integer overflow
+ count + cb_dst_offset > dst_size) // prevent write overrun
{
return E_INVALIDARG;
}
- memmoveInternal( (BYTE *)dst+cb_dst_offset, (BYTE *)src+cb_src_offset, count);
+ memmoveInternal((BYTE *)dst + cb_dst_offset, (BYTE *)src + cb_src_offset, count);
return S_OK;
}
@@ -483,26 +521,30 @@ CCritSec::~CCritSec()
void CCritSec::Lock()
{
- UINT tracelevel=3;
+ UINT tracelevel = 3;
DWORD us = GetCurrentThreadId();
DWORD currentOwner = m_currentOwner;
- if (currentOwner && (currentOwner != us)) {
+ if(currentOwner && (currentOwner != us))
+ {
// already owned, but not by us
- if (m_fTrace) {
+ if(m_fTrace)
+ {
DbgLog((LOG_LOCKING, 2, TEXT("Thread %d about to wait for lock %x owned by %d"),
- GetCurrentThreadId(), &m_CritSec, currentOwner));
- tracelevel=2;
- // if we saw the message about waiting for the critical
- // section we ensure we see the message when we get the
- // critical section
+ GetCurrentThreadId(), &m_CritSec, currentOwner));
+ tracelevel = 2;
+ // if we saw the message about waiting for the critical
+ // section we ensure we see the message when we get the
+ // critical section
}
}
EnterCriticalSection(&m_CritSec);
- if (0 == m_lockCount++) {
+ if(0 == m_lockCount++)
+ {
// we now own it for the first time. Set owner information
m_currentOwner = us;
- if (m_fTrace) {
+ if(m_fTrace)
+ {
DbgLog((LOG_LOCKING, tracelevel, TEXT("Thread %d now owns lock %x"), m_currentOwner, &m_CritSec));
}
}
@@ -510,28 +552,33 @@ void CCritSec::Lock()
bool CCritSec::TryLock()
{
- UINT tracelevel=3;
+ UINT tracelevel = 3;
DWORD us = GetCurrentThreadId();
DWORD currentOwner = m_currentOwner;
BOOL bSuccess = TryEnterCriticalSection(&m_CritSec);
- if (bSuccess)
- {
- if (0 == m_lockCount++) {
- // we now own it for the first time. Set owner information
- m_currentOwner = us;
-
- if (m_fTrace) {
- DbgLog((LOG_LOCKING, tracelevel, TEXT("Thread %d now owns lock %x"), m_currentOwner, &m_CritSec));
- }
- }
- }
- return bSuccess != 0;
-}
-
-void CCritSec::Unlock() {
- if (0 == --m_lockCount) {
+ if(bSuccess)
+ {
+ if(0 == m_lockCount++)
+ {
+ // we now own it for the first time. Set owner information
+ m_currentOwner = us;
+
+ if(m_fTrace)
+ {
+ DbgLog((LOG_LOCKING, tracelevel, TEXT("Thread %d now owns lock %x"), m_currentOwner, &m_CritSec));
+ }
+ }
+ }
+ return bSuccess != 0;
+}
+
+void CCritSec::Unlock()
+{
+ if(0 == --m_lockCount)
+ {
// about to be unowned
- if (m_fTrace) {
+ if(m_fTrace)
+ {
DbgLog((LOG_LOCKING, 3, TEXT("Thread %d releasing lock %x"), m_currentOwner, &m_CritSec));
}
@@ -569,16 +616,16 @@ BOOL WINAPI CritCheckOut(const CCritSec * pcCrit)
STDAPI WriteBSTR(__deref_out BSTR *pstrDest, LPCWSTR szSrc)
{
- *pstrDest = SysAllocString( szSrc );
- if( !(*pstrDest) ) return E_OUTOFMEMORY;
+ *pstrDest = SysAllocString(szSrc);
+ if(!(*pstrDest)) return E_OUTOFMEMORY;
return NOERROR;
}
STDAPI FreeBSTR(__deref_in BSTR* pstr)
{
- if( (PVOID)*pstr == NULL ) return S_FALSE;
- SysFreeString( *pstr );
+ if((PVOID)*pstr == NULL) return S_FALSE;
+ SysFreeString(*pstr);
return NOERROR;
}
@@ -595,12 +642,14 @@ STDAPI AMGetWideString(LPCWSTR psz, __deref_out LPWSTR *ppszReturn)
*ppszReturn = NULL;
size_t nameLen;
HRESULT hr = StringCbLengthW(psz, 100000, &nameLen);
- if (FAILED(hr)) {
+ if(FAILED(hr))
+ {
return hr;
}
*ppszReturn = (LPWSTR)CoTaskMemAlloc(nameLen + sizeof(WCHAR));
- if (*ppszReturn == NULL) {
- return E_OUTOFMEMORY;
+ if(*ppszReturn == NULL)
+ {
+ return E_OUTOFMEMORY;
}
CopyMemory(*ppszReturn, psz, nameLen + sizeof(WCHAR));
return NOERROR;
@@ -626,35 +675,42 @@ DWORD WINAPI WaitDispatchingMessages(
static UINT uMsgId = 0;
HANDLE hObjects[2] = { hObject, hEvent };
- if (dwWait != INFINITE && dwWait != 0) {
+ if(dwWait != INFINITE && dwWait != 0)
+ {
dwStart = GetTickCount();
}
- for (; ; ) {
+ for(; ;)
+ {
DWORD nCount = NULL != hEvent ? 2 : 1;
// Minimize the chance of actually dispatching any messages
// by seeing if we can lock immediately.
dwResult = WaitForMultipleObjects(nCount, hObjects, FALSE, 0);
- if (dwResult < WAIT_OBJECT_0 + nCount) {
+ if(dwResult < WAIT_OBJECT_0 + nCount)
+ {
break;
}
DWORD dwTimeOut = dwWait;
- if (dwTimeOut > 10) {
+ if(dwTimeOut > 10)
+ {
dwTimeOut = 10;
}
dwResult = MsgWaitForMultipleObjects(
- nCount,
- hObjects,
- FALSE,
- dwTimeOut,
- hwnd == NULL ? QS_SENDMESSAGE :
- QS_SENDMESSAGE + QS_POSTMESSAGE);
- if (dwResult == WAIT_OBJECT_0 + nCount ||
- dwResult == WAIT_TIMEOUT && dwTimeOut != dwWait) {
+ nCount,
+ hObjects,
+ FALSE,
+ dwTimeOut,
+ hwnd == NULL ? QS_SENDMESSAGE :
+ QS_SENDMESSAGE + QS_POSTMESSAGE);
+ if(dwResult == WAIT_OBJECT_0 + nCount ||
+ dwResult == WAIT_TIMEOUT && dwTimeOut != dwWait)
+ {
MSG msg;
- if (hwnd != NULL) {
- while (PeekMessage(&msg, hwnd, uMsg, uMsg, PM_REMOVE)) {
+ if(hwnd != NULL)
+ {
+ while(PeekMessage(&msg, hwnd, uMsg, uMsg, PM_REMOVE))
+ {
DispatchMessage(&msg);
}
}
@@ -662,41 +718,54 @@ DWORD WINAPI WaitDispatchingMessages(
// messages
PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
- if (dwWait != INFINITE && dwWait != 0) {
+ if(dwWait != INFINITE && dwWait != 0)
+ {
DWORD dwNow = GetTickCount();
// Working with differences handles wrap-around
DWORD dwDiff = dwNow - dwStart;
- if (dwDiff > dwWait) {
+ if(dwDiff > dwWait)
+ {
dwWait = 0;
- } else {
+ }
+ else
+ {
dwWait -= dwDiff;
}
dwStart = dwNow;
}
- if (!bPeeked) {
+ if(!bPeeked)
+ {
// Raise our priority to prevent our message queue
// building up
dwThreadPriority = GetThreadPriority(GetCurrentThread());
- if (dwThreadPriority < THREAD_PRIORITY_HIGHEST) {
+ if(dwThreadPriority < THREAD_PRIORITY_HIGHEST)
+ {
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
}
bPeeked = TRUE;
}
- } else {
+ }
+ else
+ {
break;
}
}
- if (bPeeked) {
+ if(bPeeked)
+ {
SetThreadPriority(GetCurrentThread(), dwThreadPriority);
- if (HIWORD(GetQueueStatus(QS_POSTMESSAGE)) & QS_POSTMESSAGE) {
- if (uMsgId == 0) {
+ if(HIWORD(GetQueueStatus(QS_POSTMESSAGE)) & QS_POSTMESSAGE)
+ {
+ if(uMsgId == 0)
+ {
uMsgId = RegisterWindowMessage(TEXT("AMUnblock"));
}
- if (uMsgId != 0) {
+ if(uMsgId != 0)
+ {
MSG msg;
// Remove old ones
- while (PeekMessage(&msg, (HWND)-1, uMsgId, uMsgId, PM_REMOVE)) {
+ while(PeekMessage(&msg, (HWND) - 1, uMsgId, uMsgId, PM_REMOVE))
+ {
}
}
PostThreadMessage(GetCurrentThreadId(), uMsgId, 0, 0);
@@ -720,9 +789,9 @@ HRESULT AmGetLastErrorToHResult()
IUnknown* QzAtlComPtrAssign(__deref_inout_opt IUnknown** pp, __in_opt IUnknown* lp)
{
- if (lp != NULL)
+ if(lp != NULL)
lp->AddRef();
- if (*pp)
+ if(*pp)
(*pp)->Release();
*pp = lp;
return lp;
@@ -737,48 +806,52 @@ timeSetEvent() if the current operating system supports it. TIME_KILL_SYNCHRONO
is supported on Windows XP and later operating systems.
Parameters:
-- The same parameters as timeSetEvent(). See timeSetEvent()'s documentation in
+- The same parameters as timeSetEvent(). See timeSetEvent()'s documentation in
the Platform SDK for more information.
Return Value:
-- The same return value as timeSetEvent(). See timeSetEvent()'s documentation in
+- The same return value as timeSetEvent(). See timeSetEvent()'s documentation in
the Platform SDK for more information.
******************************************************************************/
-MMRESULT CompatibleTimeSetEvent( UINT uDelay, UINT uResolution, __in LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent )
+MMRESULT CompatibleTimeSetEvent(UINT uDelay, UINT uResolution, __in LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent)
{
- #if WINVER >= 0x0501
+#if WINVER >= 0x0501
{
static bool fCheckedVersion = false;
- static bool fTimeKillSynchronousFlagAvailable = false;
+ static bool fTimeKillSynchronousFlagAvailable = false;
- if( !fCheckedVersion ) {
+ if(!fCheckedVersion)
+ {
fTimeKillSynchronousFlagAvailable = TimeKillSynchronousFlagAvailable();
fCheckedVersion = true;
}
- if( fTimeKillSynchronousFlagAvailable ) {
+ if(fTimeKillSynchronousFlagAvailable)
+ {
fuEvent = fuEvent | TIME_KILL_SYNCHRONOUS;
}
}
- #endif // WINVER >= 0x0501
+#endif // WINVER >= 0x0501
- return timeSetEvent( uDelay, uResolution, lpTimeProc, dwUser, fuEvent );
+ return timeSetEvent(uDelay, uResolution, lpTimeProc, dwUser, fuEvent);
}
-bool TimeKillSynchronousFlagAvailable( void )
+bool TimeKillSynchronousFlagAvailable(void)
{
OSVERSIONINFO osverinfo;
osverinfo.dwOSVersionInfoSize = sizeof(osverinfo);
- if( GetVersionEx( &osverinfo ) ) {
-
+ if(GetVersionEx(&osverinfo))
+ {
+
// Windows XP's major version is 5 and its' minor version is 1.
// timeSetEvent() started supporting the TIME_KILL_SYNCHRONOUS flag
// in Windows XP.
- if( (osverinfo.dwMajorVersion > 5) ||
- ( (osverinfo.dwMajorVersion == 5) && (osverinfo.dwMinorVersion >= 1) ) ) {
+ if((osverinfo.dwMajorVersion > 5) ||
+ ((osverinfo.dwMajorVersion == 5) && (osverinfo.dwMinorVersion >= 1)))
+ {
return true;
}
}
diff --git a/src/filters/BaseClasses/wxutil.h b/src/filters/BaseClasses/wxutil.h
index caef83c56..a9e4aa4f0 100644
--- a/src/filters/BaseClasses/wxutil.h
+++ b/src/filters/BaseClasses/wxutil.h
@@ -15,7 +15,8 @@
#pragma warning(disable: 4705)
// wrapper for whatever critical section we have
-class CCritSec {
+class CCritSec
+{
// make copy constructor and assignment operator inaccessible
@@ -38,24 +39,28 @@ public:
#else
public:
- CCritSec() {
+ CCritSec()
+ {
InitializeCriticalSection(&m_CritSec);
};
- ~CCritSec() {
+ ~CCritSec()
+ {
DeleteCriticalSection(&m_CritSec);
};
- void Lock() {
+ void Lock()
+ {
EnterCriticalSection(&m_CritSec);
};
- bool TryLock()
- {
+ bool TryLock()
+ {
return TryEnterCriticalSection(&m_CritSec) != 0;
};
- void Unlock() {
+ void Unlock()
+ {
LeaveCriticalSection(&m_CritSec);
};
#endif
@@ -72,21 +77,22 @@ public:
//
#ifdef _DEBUG
- BOOL WINAPI CritCheckIn(CCritSec * pcCrit);
- BOOL WINAPI CritCheckIn(const CCritSec * pcCrit);
- BOOL WINAPI CritCheckOut(CCritSec * pcCrit);
- BOOL WINAPI CritCheckOut(const CCritSec * pcCrit);
- void WINAPI DbgLockTrace(CCritSec * pcCrit, BOOL fTrace);
+BOOL WINAPI CritCheckIn(CCritSec * pcCrit);
+BOOL WINAPI CritCheckIn(const CCritSec * pcCrit);
+BOOL WINAPI CritCheckOut(CCritSec * pcCrit);
+BOOL WINAPI CritCheckOut(const CCritSec * pcCrit);
+void WINAPI DbgLockTrace(CCritSec * pcCrit, BOOL fTrace);
#else
- #define CritCheckIn(x) TRUE
- #define CritCheckOut(x) TRUE
- #define DbgLockTrace(pc, fT)
+#define CritCheckIn(x) TRUE
+#define CritCheckOut(x) TRUE
+#define DbgLockTrace(pc, fT)
#endif
// locks a critical section, and unlocks it automatically
// when the lock goes out of scope
-class CAutoLock {
+class CAutoLock
+{
// make copy constructor and assignment operator inaccessible
@@ -103,7 +109,8 @@ public:
m_pLock->Lock();
};
- ~CAutoLock() {
+ ~CAutoLock()
+ {
m_pLock->Unlock();
};
};
@@ -127,14 +134,27 @@ public:
~CAMEvent();
// Cast to HANDLE - we don't support this as an lvalue
- operator HANDLE () const { return m_hEvent; };
+ operator HANDLE() const
+ {
+ return m_hEvent;
+ };
- void Set() {EXECUTE_ASSERT(SetEvent(m_hEvent));};
- BOOL Wait(DWORD dwTimeout = INFINITE) {
- return (WaitForSingleObject(m_hEvent, dwTimeout) == WAIT_OBJECT_0);
+ void Set()
+ {
+ EXECUTE_ASSERT(SetEvent(m_hEvent));
+ };
+ BOOL Wait(DWORD dwTimeout = INFINITE)
+ {
+ return (WaitForSingleObject(m_hEvent, dwTimeout) == WAIT_OBJECT_0);
+ };
+ void Reset()
+ {
+ ResetEvent(m_hEvent);
+ };
+ BOOL Check()
+ {
+ return Wait(0);
};
- void Reset() { ResetEvent(m_hEvent); };
- BOOL Check() { return Wait(0); };
};
@@ -161,7 +181,8 @@ public:
#ifdef AM_NOVTABLE
// simple thread class supports creation of worker thread, synchronization
// and communication. Can be derived to simplify parameter passing
-class AM_NOVTABLE CAMThread {
+class AM_NOVTABLE CAMThread
+{
// make copy constructor and assignment operator inaccessible
@@ -201,7 +222,8 @@ public:
// accessor thread calls this when done with thread (having told thread
// to exit)
- void Close() {
+ void Close()
+ {
// Disable warning: Conversion from LONG to PVOID of greater size
#pragma warning(push)
@@ -209,7 +231,8 @@ public:
HANDLE hThread = (HANDLE)InterlockedExchangePointer(&m_hThread, 0);
#pragma warning(pop)
- if (hThread) {
+ if(hThread)
+ {
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
}
@@ -219,9 +242,12 @@ public:
// Return TRUE if the thread exists. FALSE otherwise
BOOL ThreadExists(void) const
{
- if (m_hThread == 0) {
+ if(m_hThread == 0)
+ {
return FALSE;
- } else {
+ }
+ else
+ {
return TRUE;
}
}
@@ -237,10 +263,16 @@ public:
// If you want to do WaitForMultipleObjects you'll need to include
// this handle in your wait list or you won't be responsive
- HANDLE GetRequestHandle() const { return m_EventSend; };
+ HANDLE GetRequestHandle() const
+ {
+ return m_EventSend;
+ };
// Find out what the request was
- DWORD GetRequestParam() const { return m_dwParam; };
+ DWORD GetRequestParam() const
+ {
+ return m_dwParam;
+ };
// call CoInitializeEx (COINIT_DISABLE_OLE1DDE) if
// available. S_FALSE means it's not available.
@@ -264,7 +296,8 @@ public:
#define DEFAULT_QUEUESIZE 2
-template <class T> class CQueue {
+template <class T> class CQueue
+{
private:
HANDLE hSemPut; // Semaphore controlling queue "putting"
HANDLE hSemGet; // Semaphore controlling queue "getting"
@@ -274,7 +307,8 @@ private:
int iNextGet; // Array index of next "GetMsg"
T *QueueObjects; // Array of objects (ptr's to void)
- void Initialize(int n) {
+ void Initialize(int n)
+ {
iNextPut = iNextGet = 0;
nMax = n;
InitializeCriticalSection(&CritSect);
@@ -285,22 +319,26 @@ private:
public:
- CQueue(int n) {
+ CQueue(int n)
+ {
Initialize(n);
}
- CQueue() {
+ CQueue()
+ {
Initialize(DEFAULT_QUEUESIZE);
}
- ~CQueue() {
+ ~CQueue()
+ {
delete [] QueueObjects;
DeleteCriticalSection(&CritSect);
CloseHandle(hSemPut);
CloseHandle(hSemGet);
}
- T GetQueueObject() {
+ T GetQueueObject()
+ {
int iSlot;
T Object;
LONG lPrevious;
@@ -322,7 +360,8 @@ public:
return Object;
}
- void PutQueueObject(T Object) {
+ void PutQueueObject(T Object)
+ {
int iSlot;
LONG lPrevious;
@@ -373,7 +412,8 @@ inline void * __cdecl memchrInternal(const void *buf, int chr, size_t cnt)
#ifdef _X86_
void *pRet = NULL;
- _asm {
+ _asm
+ {
cld // make sure we get the direction right
mov ecx, cnt // num of bytes to scan
mov edi, buf // pointer byte stream
@@ -381,14 +421,15 @@ inline void * __cdecl memchrInternal(const void *buf, int chr, size_t cnt)
repne scasb // look for the byte in the byte stream
jnz exit_memchr // Z flag set if byte found
dec edi // scasb always increments edi even when it
- // finds the required byte
+ // finds the required byte
mov pRet, edi
-exit_memchr:
+ exit_memchr:
}
return pRet;
#else
- while ( cnt && (*(unsigned char *)buf != (unsigned char)chr) ) {
+ while(cnt && (*(unsigned char *)buf != (unsigned char)chr))
+ {
buf = (unsigned char *)buf + 1;
cnt--;
}
@@ -488,42 +529,76 @@ IUnknown* QzAtlComPtrAssign(__deref_inout_opt IUnknown** pp, __in_opt IUnknown*
template <class T>
class QzCComPtr
{
-public:
- typedef T _PtrClass;
- QzCComPtr() {p=NULL;}
- QzCComPtr(T* lp)
- {
- if ((p = lp) != NULL)
- p->AddRef();
- }
- QzCComPtr(const QzCComPtr<T>& lp)
- {
- if ((p = lp.p) != NULL)
- p->AddRef();
- }
- ~QzCComPtr() {if (p) p->Release();}
- void Release() {if (p) p->Release(); p=NULL;}
- operator T*() {return (T*)p;}
- T& operator*() {ASSERT(p!=NULL); return *p; }
- //The assert on operator& usually indicates a bug. If this is really
- //what is needed, however, take the address of the p member explicitly.
- T** operator&() { ASSERT(p==NULL); return &p; }
- T* operator->() { ASSERT(p!=NULL); return p; }
- T* operator=(T* lp){return (T*)QzAtlComPtrAssign((IUnknown**)&p, lp);}
- T* operator=(const QzCComPtr<T>& lp)
- {
- return (T*)QzAtlComPtrAssign((IUnknown**)&p, lp.p);
- }
+ public:
+ typedef T _PtrClass;
+ QzCComPtr()
+ {
+ p = NULL;
+ }
+ QzCComPtr(T* lp)
+ {
+ if((p = lp) != NULL)
+ p->AddRef();
+ }
+ QzCComPtr(const QzCComPtr<T>& lp)
+ {
+ if((p = lp.p) != NULL)
+ p->AddRef();
+ }
+ ~QzCComPtr()
+ {
+ if(p) p->Release();
+ }
+ void Release()
+ {
+ if(p) p->Release();
+ p = NULL;
+ }
+ operator T*()
+ {
+ return (T*)p;
+ }
+ T& operator*()
+ {
+ ASSERT(p != NULL);
+ return *p;
+ }
+ //The assert on operator& usually indicates a bug. If this is really
+ //what is needed, however, take the address of the p member explicitly.
+ T** operator&()
+ {
+ ASSERT(p == NULL);
+ return &p;
+ }
+ T* operator->()
+ {
+ ASSERT(p != NULL);
+ return p;
+ }
+ T* operator=(T* lp)
+ {
+ return (T*)QzAtlComPtrAssign((IUnknown**)&p, lp);
+ }
+ T* operator=(const QzCComPtr<T>& lp)
+ {
+ return (T*)QzAtlComPtrAssign((IUnknown**)&p, lp.p);
+ }
#if _MSC_VER>1020
- bool operator!(){return (p == NULL);}
+ bool operator!()
+ {
+ return (p == NULL);
+ }
#else
- BOOL operator!(){return (p == NULL) ? TRUE : FALSE;}
+ BOOL operator!()
+ {
+ return (p == NULL) ? TRUE : FALSE;
+ }
#endif
- T* p;
+ T* p;
};
-MMRESULT CompatibleTimeSetEvent( UINT uDelay, UINT uResolution, __in LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent );
-bool TimeKillSynchronousFlagAvailable( void );
+MMRESULT CompatibleTimeSetEvent(UINT uDelay, UINT uResolution, __in LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent);
+bool TimeKillSynchronousFlagAvailable(void);
// Helper to replace lstrcpmi
__inline int lstrcmpiLocaleIndependentW(LPCWSTR lpsz1, LPCWSTR lpsz2)