Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #include "sv_sessionpublishmanager.h"
  5. #include "sv_recordingsession.h"
  6. #include "sv_sessionblockpublisher.h"
  7. #include "sv_sessioninfopublisher.h"
  8. #include "replay_dbg.h"
  9. #include "vprof.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. //----------------------------------------------------------------------------------------
  13. CSessionPublishManager::CSessionPublishManager( CServerRecordingSession *pSession )
  14. : m_pSession( pSession ),
  15. m_pBlockPublisher( NULL ),
  16. m_pSessionInfoPublisher( NULL )
  17. {
  18. m_pSessionInfoPublisher = new CSessionInfoPublisher( pSession );
  19. m_pBlockPublisher = new CSessionBlockPublisher( pSession, m_pSessionInfoPublisher );
  20. }
  21. CSessionPublishManager::~CSessionPublishManager()
  22. {
  23. delete m_pBlockPublisher;
  24. delete m_pSessionInfoPublisher;
  25. }
  26. void CSessionPublishManager::PublishAllSynchronous()
  27. {
  28. Msg( "Finishing up replay publish...\n" );
  29. m_pBlockPublisher->PublishAllSynchronous();
  30. m_pSessionInfoPublisher->PublishAllSynchronous();
  31. }
  32. void CSessionPublishManager::OnStartRecording()
  33. {
  34. // Lock the session (which will propagate the lock to all contained blocks)
  35. m_pSession->SetLocked( true );
  36. Assert( m_pSession->m_bRecording );
  37. }
  38. void CSessionPublishManager::OnStopRecord( bool bAborting )
  39. {
  40. // Recording should be turned off on the session by this point
  41. Assert( !m_pSession->m_bRecording );
  42. m_pBlockPublisher->OnStopRecord( bAborting );
  43. m_pSessionInfoPublisher->OnStopRecord( bAborting );
  44. }
  45. ReplayHandle_t CSessionPublishManager::GetSessionHandle() const
  46. {
  47. return m_pSession->GetHandle();
  48. }
  49. bool CSessionPublishManager::IsDone() const
  50. {
  51. return !m_pSession->m_bRecording &&
  52. m_pBlockPublisher->IsDone() &&
  53. m_pSessionInfoPublisher->IsDone();
  54. }
  55. void CSessionPublishManager::Think()
  56. {
  57. // NOTE: This gets called even if replay is disabled. This is intentional.
  58. VPROF_BUDGET( "CSessionPublishManager::Think", VPROF_BUDGETGROUP_REPLAY );
  59. // Call publishers
  60. m_pBlockPublisher->Think();
  61. m_pSessionInfoPublisher->Think();
  62. #ifdef _DEBUG
  63. m_pSession->VerifyLocks();
  64. #endif
  65. }
  66. void CSessionPublishManager::UnlockSession()
  67. {
  68. Assert( !m_pSession->m_bRecording );
  69. Assert( m_pBlockPublisher->IsDone() );
  70. Assert( m_pSessionInfoPublisher->IsDone() );
  71. IF_REPLAY_DBG( Warning( "Unlocking session %s\n", m_pSession->GetDebugName() ) );
  72. m_pSession->SetLocked( false );
  73. }
  74. void CSessionPublishManager::AbortPublish()
  75. {
  76. m_pBlockPublisher->AbortPublish();
  77. m_pSessionInfoPublisher->AbortPublish();
  78. }
  79. #ifdef _DEBUG
  80. void CSessionPublishManager::Validate()
  81. {
  82. m_pBlockPublisher->Validate();
  83. }
  84. #endif
  85. //----------------------------------------------------------------------------------------