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/strmctl.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/strmctl.cpp')
-rw-r--r-- | src/filters/BaseClasses/strmctl.cpp | 327 |
1 files changed, 176 insertions, 151 deletions
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();
|