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.

135 lines
4.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Applicaton-level hooks for clients of the audio subsystem
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef SOUNDSERVICE_H
  8. #define SOUNDSERVICE_H
  9. #if defined( _WIN32 )
  10. #pragma once
  11. #endif
  12. class Vector;
  13. class QAngle;
  14. class CAudioSource;
  15. typedef int SoundSource;
  16. struct SpatializationInfo_t;
  17. typedef void *FileNameHandle_t;
  18. struct StartSoundParams_t;
  19. #include "utlrbtree.h"
  20. //-----------------------------------------------------------------------------
  21. // Purpose: Services required by the audio system to function, this facade
  22. // defines the bridge between the audio code and higher level
  23. // systems.
  24. //
  25. // Note that some of these currently suggest that certain
  26. // functionality would like to exist at a deeper layer so
  27. // systems like audio can take advantage of them
  28. // diectly (toml 05-02-02)
  29. //-----------------------------------------------------------------------------
  30. abstract_class ISoundServices
  31. {
  32. public:
  33. //---------------------------------
  34. // Allocate a block of memory that will be automatically
  35. // cleaned up on level change
  36. //---------------------------------
  37. virtual void *LevelAlloc( int nBytes, const char *pszTag ) = 0;
  38. //---------------------------------
  39. // Notification that someone called S_ExtraUpdate()
  40. //---------------------------------
  41. virtual void OnExtraUpdate() = 0;
  42. //---------------------------------
  43. // Return false if the entity doesn't exist or is out of the PVS, in which case the sound shouldn't be heard.
  44. //---------------------------------
  45. virtual bool GetSoundSpatialization( int entIndex, SpatializationInfo_t& info ) = 0;
  46. //---------------------------------
  47. // This is the client's clock, which follows the servers and thus isn't 100% smooth all the time (it is in single player)
  48. //---------------------------------
  49. virtual float GetClientTime() = 0;
  50. //---------------------------------
  51. // This is the engine's filtered timer, it's pretty smooth all the time
  52. //---------------------------------
  53. virtual float GetHostTime() = 0;
  54. //---------------------------------
  55. //---------------------------------
  56. virtual int GetViewEntity() = 0;
  57. //---------------------------------
  58. //---------------------------------
  59. virtual float GetHostFrametime() = 0;
  60. virtual void SetSoundFrametime( float realDt, float hostDt ) = 0;
  61. //---------------------------------
  62. //---------------------------------
  63. virtual int GetServerCount() = 0;
  64. //---------------------------------
  65. //---------------------------------
  66. virtual bool IsPlayer( SoundSource source ) = 0;
  67. //---------------------------------
  68. //---------------------------------
  69. virtual void OnChangeVoiceStatus( int entity, bool status) = 0;
  70. // Is the player fully connected (don't do DSP processing if not)
  71. virtual bool IsConnected() = 0;
  72. // Calls into client .dll with list of close caption tokens to construct a caption out of
  73. virtual void EmitSentenceCloseCaption( char const *tokenstream ) = 0;
  74. // Calls into client .dll with list of close caption tokens to construct a caption out of
  75. virtual void EmitCloseCaption( char const *captionname, float duration ) = 0;
  76. virtual char const *GetGameDir() = 0;
  77. // If the game is paused, certain audio will pause, too (anything with phoneme/sentence data for now)
  78. virtual bool IsGamePaused() = 0;
  79. // If the game is not active, certain audio will pause
  80. virtual bool IsGameActive() = 0;
  81. // restarts the sound system externally
  82. virtual void RestartSoundSystem() = 0;
  83. virtual void GetAllSoundFilesReferencedInReslists( CUtlRBTree< FileNameHandle_t, int >& list ) = 0;
  84. virtual void GetAllManifestFiles( CUtlRBTree< FileNameHandle_t, int >& list ) = 0;
  85. virtual void GetAllSoundFilesInManifest( CUtlRBTree< FileNameHandle_t, int >& list, char const *manifestfile ) = 0;
  86. virtual void CacheBuildingStart() = 0;
  87. virtual void CacheBuildingUpdateProgress( float percent, char const *cachefile ) = 0;
  88. virtual void CacheBuildingFinish() = 0;
  89. // For building sound cache manifests
  90. virtual int GetPrecachedSoundCount() = 0;
  91. virtual char const *GetPrecachedSound( int index ) = 0;
  92. virtual void OnSoundStarted( int guid, StartSoundParams_t& params, char const *soundname ) = 0;
  93. virtual void OnSoundStopped( int guid, int soundsource, int channel, char const *soundname ) = 0;
  94. virtual bool GetToolSpatialization( int iUserData, int guid, SpatializationInfo_t& info ) = 0;
  95. #if defined( _XBOX )
  96. virtual bool ShouldSuppressNonUISounds() = 0;
  97. #endif
  98. virtual char const *GetUILanguage() = 0;
  99. };
  100. //-------------------------------------
  101. extern ISoundServices *g_pSoundServices;
  102. //=============================================================================
  103. #endif // SOUNDSERVICE_H