WwiseFileHandlerModuleImpl.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. #include "Wwise/WwiseFileHandlerModuleImpl.h"
  16. #include "Wwise/WwiseSoundBankManagerImpl.h"
  17. #include "Wwise/WwiseExternalSourceManagerImpl.h"
  18. #include "Wwise/WwiseFileCache.h"
  19. #include "Wwise/WwiseMediaManagerImpl.h"
  20. #include "Wwise/WwiseIOHookImpl.h"
  21. #include "Wwise/Stats/FileHandler.h"
  22. IMPLEMENT_MODULE(FWwiseFileHandlerModule, WwiseFileHandler)
  23. FWwiseFileHandlerModule::FWwiseFileHandlerModule()
  24. {
  25. }
  26. IWwiseSoundBankManager* FWwiseFileHandlerModule::GetSoundBankManager()
  27. {
  28. Lock.ReadLock();
  29. if (LIKELY(SoundBankManager))
  30. {
  31. Lock.ReadUnlock();
  32. }
  33. else
  34. {
  35. Lock.ReadUnlock();
  36. Lock.WriteLock();
  37. if (LIKELY(!SoundBankManager))
  38. {
  39. UE_LOG(LogWwiseFileHandler, Display, TEXT("Initializing default SoundBank Manager."));
  40. SoundBankManager.Reset(InstantiateSoundBankManager());
  41. }
  42. Lock.WriteUnlock();
  43. }
  44. return SoundBankManager.Get();
  45. }
  46. IWwiseExternalSourceManager* FWwiseFileHandlerModule::GetExternalSourceManager()
  47. {
  48. Lock.ReadLock();
  49. if (LIKELY(ExternalSourceManager))
  50. {
  51. Lock.ReadUnlock();
  52. }
  53. else
  54. {
  55. Lock.ReadUnlock();
  56. Lock.WriteLock();
  57. if (LIKELY(!ExternalSourceManager))
  58. {
  59. UE_LOG(LogWwiseFileHandler, Display, TEXT("Initializing default External Source Manager."));
  60. ExternalSourceManager.Reset(InstantiateExternalSourceManager());
  61. }
  62. Lock.WriteUnlock();
  63. }
  64. return ExternalSourceManager.Get();
  65. }
  66. IWwiseMediaManager* FWwiseFileHandlerModule::GetMediaManager()
  67. {
  68. Lock.ReadLock();
  69. if (LIKELY(MediaManager))
  70. {
  71. Lock.ReadUnlock();
  72. }
  73. else
  74. {
  75. Lock.ReadUnlock();
  76. Lock.WriteLock();
  77. if (LIKELY(!MediaManager))
  78. {
  79. UE_LOG(LogWwiseFileHandler, Display, TEXT("Initializing default Media Manager."));
  80. MediaManager.Reset(InstantiateMediaManager());
  81. }
  82. Lock.WriteUnlock();
  83. }
  84. return MediaManager.Get();
  85. }
  86. FWwiseFileCache* FWwiseFileHandlerModule::GetFileCache()
  87. {
  88. Lock.ReadLock();
  89. if (LIKELY(FileCache))
  90. {
  91. Lock.ReadUnlock();
  92. }
  93. else
  94. {
  95. Lock.ReadUnlock();
  96. Lock.WriteLock();
  97. if (LIKELY(!FileCache))
  98. {
  99. UE_LOG(LogWwiseFileHandler, Display, TEXT("Initializing default File Cache."));
  100. FileCache.Reset(InstantiateFileCache());
  101. }
  102. Lock.WriteUnlock();
  103. }
  104. return FileCache.Get();
  105. }
  106. FWwiseIOHook* FWwiseFileHandlerModule::InstantiateIOHook()
  107. {
  108. return new FWwiseIOHookImpl;
  109. }
  110. IWwiseSoundBankManager* FWwiseFileHandlerModule::InstantiateSoundBankManager()
  111. {
  112. return new FWwiseSoundBankManagerImpl;
  113. }
  114. IWwiseExternalSourceManager* FWwiseFileHandlerModule::InstantiateExternalSourceManager()
  115. {
  116. return new FWwiseExternalSourceManagerImpl;
  117. }
  118. IWwiseMediaManager* FWwiseFileHandlerModule::InstantiateMediaManager()
  119. {
  120. return new FWwiseMediaManagerImpl;
  121. }
  122. FWwiseFileCache* FWwiseFileHandlerModule::InstantiateFileCache()
  123. {
  124. return new FWwiseFileCache;
  125. }
  126. void FWwiseFileHandlerModule::StartupModule()
  127. {
  128. IWwiseFileHandlerModule::StartupModule();
  129. }
  130. void FWwiseFileHandlerModule::ShutdownModule()
  131. {
  132. Lock.WriteLock();
  133. if (SoundBankManager.IsValid())
  134. {
  135. UE_LOG(LogWwiseFileHandler, Display, TEXT("Shutting down SoundBank Manager."));
  136. SoundBankManager.Reset();
  137. }
  138. if (ExternalSourceManager.IsValid())
  139. {
  140. UE_LOG(LogWwiseFileHandler, Display, TEXT("Shutting down External Source Manager."));
  141. ExternalSourceManager.Reset();
  142. }
  143. if (MediaManager.IsValid())
  144. {
  145. UE_LOG(LogWwiseFileHandler, Display, TEXT("Shutting down Media Manager."));
  146. MediaManager.Reset();
  147. }
  148. if (FileCache.IsValid())
  149. {
  150. UE_LOG(LogWwiseFileHandler, Display, TEXT("Shutting down File Cache."));
  151. FileCache.Reset();
  152. }
  153. Lock.WriteUnlock();
  154. IWwiseFileHandlerModule::ShutdownModule();
  155. }