diff options
author | tetsuo55 <tetsuo55@users.sourceforge.net> | 2010-04-09 01:14:58 +0400 |
---|---|---|
committer | tetsuo55 <tetsuo55@users.sourceforge.net> | 2010-04-09 01:14:58 +0400 |
commit | a9b7bf3fb3e1334d8defd05ca4cfae870b4912e5 (patch) | |
tree | 2dab453d94d5e003379a6cc895eceb84c80e23ec /src/filters/BaseClasses/schedule.cpp | |
parent | aafd49a91f7c2fa9c7103971c16fa6e1b29e8bfd (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/schedule.cpp')
-rw-r--r-- | src/filters/BaseClasses/schedule.cpp | 138 |
1 files changed, 70 insertions, 68 deletions
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();
}
|