WwiseSoundEngineModule.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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/WwiseSoundEngineModule.h"
  16. #include "Wwise/API/WwiseCommAPI.h"
  17. #include "Wwise/API/WwiseMemoryMgrAPI.h"
  18. #include "Wwise/API/WwiseMonitorAPI.h"
  19. #include "Wwise/API/WwiseMusicEngineAPI.h"
  20. #include "Wwise/API/WwiseSoundEngineAPI.h"
  21. #include "Wwise/API/WwiseSpatialAudioAPI.h"
  22. #include "Wwise/API/WwiseStreamMgrAPI.h"
  23. #include "Wwise/API/WwisePlatformAPI.h"
  24. #include "Wwise/API/WAAPI.h"
  25. #include "Wwise/Stats/SoundEngine.h"
  26. #include WWISE_SOUNDENGINE_VERSION_HEADER_PATH
  27. #include "Misc/ScopeLock.h"
  28. IMPLEMENT_MODULE(FWwiseSoundEngineModule, WwiseSoundEngine)
  29. IWwiseCommAPI* IWwiseSoundEngineModule::Comm = nullptr;
  30. IWwiseMemoryMgrAPI* IWwiseSoundEngineModule::MemoryMgr = nullptr;
  31. IWwiseMonitorAPI* IWwiseSoundEngineModule::Monitor = nullptr;
  32. IWwiseMusicEngineAPI* IWwiseSoundEngineModule::MusicEngine = nullptr;
  33. IWwiseSoundEngineAPI* IWwiseSoundEngineModule::SoundEngine = nullptr;
  34. IWwiseSpatialAudioAPI* IWwiseSoundEngineModule::SpatialAudio = nullptr;
  35. IWwiseStreamMgrAPI* IWwiseSoundEngineModule::StreamMgr = nullptr;
  36. IWwisePlatformAPI* IWwiseSoundEngineModule::Platform = nullptr;
  37. IWAAPI* IWwiseSoundEngineModule::WAAPI = nullptr;
  38. IWwiseSoundEngineVersionModule* IWwiseSoundEngineModule::VersionInterface = nullptr;
  39. void FWwiseSoundEngineModule::StartupModule()
  40. {
  41. UE_LOG(LogWwiseSoundEngine, Display, TEXT("Loading Wwise Sound Engine version %s"), TEXT(AK_WWISE_SOUNDENGINE_VERSION));
  42. VersionInterface = new WWISE_SOUNDENGINE_VERSION_CLASS;
  43. Comm = VersionInterface->GetComm();
  44. MemoryMgr = VersionInterface->GetMemoryMgr();
  45. Monitor = VersionInterface->GetMonitor();
  46. MusicEngine = VersionInterface->GetMusicEngine();
  47. SoundEngine = VersionInterface->GetSoundEngine();
  48. SpatialAudio = VersionInterface->GetSpatialAudio();
  49. StreamMgr = VersionInterface->GetStreamMgr();
  50. Platform = VersionInterface->GetPlatform();
  51. WAAPI = VersionInterface->GetWAAPI();
  52. }
  53. void FWwiseSoundEngineModule::ShutdownModule()
  54. {
  55. DeleteInterface();
  56. }
  57. void FWwiseSoundEngineModule::DeleteInterface()
  58. {
  59. static FCriticalSection CriticalSection;
  60. FScopeLock Lock(&CriticalSection);
  61. if (!VersionInterface)
  62. {
  63. return;
  64. }
  65. delete VersionInterface; VersionInterface = nullptr;
  66. if (LIKELY(SoundEngine) && UNLIKELY(SoundEngine->IsInitialized()))
  67. {
  68. UE_LOG(LogWwiseSoundEngine, Error, TEXT("Shutting down Sound Engine module without deinitializing Low-Level Sound Engine"));
  69. SoundEngine->Term();
  70. }
  71. UE_LOG(LogWwiseSoundEngine, Log, TEXT("Unloading Wwise Sound Engine"));
  72. delete Comm; Comm = nullptr;
  73. delete MemoryMgr; MemoryMgr = nullptr;
  74. delete Monitor; Monitor = nullptr;
  75. delete MusicEngine; MusicEngine = nullptr;
  76. delete SoundEngine; SoundEngine = nullptr;
  77. delete SpatialAudio; SpatialAudio = nullptr;
  78. delete StreamMgr; StreamMgr = nullptr;
  79. delete Platform; Platform = nullptr;
  80. delete WAAPI; WAAPI = nullptr;
  81. }