WwiseSoundBankInfoCache.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. #pragma once
  16. #include "ISoundBankInfoCache.h"
  17. #include "Containers/Map.h"
  18. #include "Misc/Guid.h"
  19. class FArchive;
  20. class WwiseSoundBankInfoCache : public ISoundBankInfoCache
  21. {
  22. public:
  23. bool Load(const FString& Path);
  24. bool IsSoundBankUpToUpdate(const FGuid& Id, const FString& Platform, const FString& Language, const uint32 Hash) const override;
  25. private:
  26. void readString(FArchive& ar, FString& Value);
  27. void readGuid(FArchive& Ar, FGuid& Value);
  28. static void readBool(FArchive& Ar, bool& Value);
  29. private:
  30. enum class CacheType : uint8
  31. {
  32. XML,
  33. JSON,
  34. Bank,
  35. Count
  36. };
  37. enum class SerializeState : uint8
  38. {
  39. None,
  40. Platform,
  41. Language,
  42. BankInfo,
  43. InfoFile,
  44. InfoFileType,
  45. EndOfData
  46. };
  47. struct FileInfo
  48. {
  49. uint32 Hash = 0;
  50. int64 Timestamp = 0;
  51. bool Updated = false;
  52. };
  53. struct MemoryStats
  54. {
  55. int64 Timestamp;
  56. uint32 DataSize;
  57. uint32 FileSize;
  58. uint32 DecodedSize;
  59. uint32 SFXPreFetchSize;
  60. uint32 SFXInMemorySize;
  61. uint32 SFXMissingFiles;
  62. uint32 MusicPreFetchSize;
  63. uint32 MusicInMemorySize;
  64. uint32 MusicMissingFiles;
  65. uint32 VoicePreFetchSize;
  66. uint32 VoiceInMemorySize;
  67. uint32 VoiceMissingFiles;
  68. uint32 ReplacedFiles;
  69. };
  70. struct BankInfo : public FileInfo
  71. {
  72. MemoryStats Stats;
  73. bool IsTemporary = false;
  74. };
  75. struct CacheKey
  76. {
  77. CacheKey() = default;
  78. CacheKey(const FString& InName, const FGuid& InPlatform, uint32 InLanguage)
  79. : Name(InName), Platform(InPlatform), Language(InLanguage)
  80. {}
  81. FString Name;
  82. FGuid Platform;
  83. uint32 Language;
  84. bool operator==(const CacheKey& Right) const
  85. {
  86. return Name == Right.Name
  87. && Platform == Right.Platform
  88. && Language == Right.Language
  89. ;
  90. }
  91. };
  92. friend FArchive& operator<<(FArchive& Ar, WwiseSoundBankInfoCache::FileInfo& Value);
  93. friend FArchive& operator<<(FArchive& Ar, WwiseSoundBankInfoCache::BankInfo& Value);
  94. friend FArchive& operator<<(FArchive& Ar, WwiseSoundBankInfoCache::MemoryStats& Value);
  95. friend uint32 GetTypeHash(const CacheKey& Key);
  96. private:
  97. TMap<FString, FGuid> platformNameToGuidMap;
  98. TMap<CacheKey, BankInfo> bankInfoMap;
  99. };
  100. FArchive& operator<<(FArchive& Ar, WwiseSoundBankInfoCache::FileInfo& Value);
  101. FArchive& operator<<(FArchive& Ar, WwiseSoundBankInfoCache::BankInfo& Value);
  102. FArchive& operator<<(FArchive& Ar, WwiseSoundBankInfoCache::MemoryStats& Value);
  103. uint32 GetTypeHash(const WwiseSoundBankInfoCache::CacheKey& Key);