diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /replay/sv_sessionpublishmanager.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'replay/sv_sessionpublishmanager.cpp')
| -rw-r--r-- | replay/sv_sessionpublishmanager.cpp | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/replay/sv_sessionpublishmanager.cpp b/replay/sv_sessionpublishmanager.cpp new file mode 100644 index 0000000..96921d5 --- /dev/null +++ b/replay/sv_sessionpublishmanager.cpp @@ -0,0 +1,107 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#include "sv_sessionpublishmanager.h" +#include "sv_recordingsession.h" +#include "sv_sessionblockpublisher.h" +#include "sv_sessioninfopublisher.h" +#include "replay_dbg.h" +#include "vprof.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +//---------------------------------------------------------------------------------------- + +CSessionPublishManager::CSessionPublishManager( CServerRecordingSession *pSession ) +: m_pSession( pSession ), + m_pBlockPublisher( NULL ), + m_pSessionInfoPublisher( NULL ) +{ + m_pSessionInfoPublisher = new CSessionInfoPublisher( pSession ); + m_pBlockPublisher = new CSessionBlockPublisher( pSession, m_pSessionInfoPublisher ); +} + +CSessionPublishManager::~CSessionPublishManager() +{ + delete m_pBlockPublisher; + delete m_pSessionInfoPublisher; +} + +void CSessionPublishManager::PublishAllSynchronous() +{ + Msg( "Finishing up replay publish...\n" ); + + m_pBlockPublisher->PublishAllSynchronous(); + m_pSessionInfoPublisher->PublishAllSynchronous(); +} + +void CSessionPublishManager::OnStartRecording() +{ + // Lock the session (which will propagate the lock to all contained blocks) + m_pSession->SetLocked( true ); + + Assert( m_pSession->m_bRecording ); +} + +void CSessionPublishManager::OnStopRecord( bool bAborting ) +{ + // Recording should be turned off on the session by this point + Assert( !m_pSession->m_bRecording ); + + m_pBlockPublisher->OnStopRecord( bAborting ); + m_pSessionInfoPublisher->OnStopRecord( bAborting ); +} + +ReplayHandle_t CSessionPublishManager::GetSessionHandle() const +{ + return m_pSession->GetHandle(); +} + +bool CSessionPublishManager::IsDone() const +{ + return !m_pSession->m_bRecording && + m_pBlockPublisher->IsDone() && + m_pSessionInfoPublisher->IsDone(); +} + +void CSessionPublishManager::Think() +{ + // NOTE: This gets called even if replay is disabled. This is intentional. + VPROF_BUDGET( "CSessionPublishManager::Think", VPROF_BUDGETGROUP_REPLAY ); + + // Call publishers + m_pBlockPublisher->Think(); + m_pSessionInfoPublisher->Think(); + +#ifdef _DEBUG + m_pSession->VerifyLocks(); +#endif +} + +void CSessionPublishManager::UnlockSession() +{ + Assert( !m_pSession->m_bRecording ); + Assert( m_pBlockPublisher->IsDone() ); + Assert( m_pSessionInfoPublisher->IsDone() ); + + IF_REPLAY_DBG( Warning( "Unlocking session %s\n", m_pSession->GetDebugName() ) ); + + m_pSession->SetLocked( false ); +} + +void CSessionPublishManager::AbortPublish() +{ + m_pBlockPublisher->AbortPublish(); + m_pSessionInfoPublisher->AbortPublish(); +} + +#ifdef _DEBUG +void CSessionPublishManager::Validate() +{ + m_pBlockPublisher->Validate(); +} +#endif + +//---------------------------------------------------------------------------------------- |