WwiseProcessingModule.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 "Modules/ModuleManager.h"
  17. #include "Misc/ConfigCacheIni.h"
  18. #include "AkInclude.h"
  19. class FWwiseGlobalCallbacks;
  20. class IWwiseProcessingModule : public IModuleInterface
  21. {
  22. public:
  23. static FName GetModuleName()
  24. {
  25. static const FName ModuleName = GetModuleNameFromConfig();
  26. return ModuleName;
  27. }
  28. /**
  29. * Checks to see if this module is loaded and ready.
  30. *
  31. * @return True if the module is loaded and ready to use
  32. */
  33. static bool IsAvailable()
  34. {
  35. return FModuleManager::Get().IsModuleLoaded(GetModuleName());
  36. }
  37. static IWwiseProcessingModule* GetModule()
  38. {
  39. const auto ModuleName = GetModuleName();
  40. if (ModuleName.IsNone())
  41. {
  42. return nullptr;
  43. }
  44. FModuleManager& ModuleManager = FModuleManager::Get();
  45. IWwiseProcessingModule* Result = ModuleManager.GetModulePtr<IWwiseProcessingModule>(ModuleName);
  46. if (UNLIKELY(!Result))
  47. {
  48. if (UNLIKELY(IsEngineExitRequested()))
  49. {
  50. UE_LOG(LogLoad, Verbose, TEXT("Skipping reloading missing WwiseProcessing module: Exiting."));
  51. }
  52. else if (UNLIKELY(!IsInGameThread()))
  53. {
  54. UE_LOG(LogLoad, Warning, TEXT("Skipping loading missing WwiseProcessing module: Not in game thread"));
  55. }
  56. else
  57. {
  58. UE_LOG(LogLoad, Log, TEXT("Loading WwiseProcessing module: %s"), *ModuleName.GetPlainNameString());
  59. Result = ModuleManager.LoadModulePtr<IWwiseProcessingModule>(ModuleName);
  60. if (UNLIKELY(!Result))
  61. {
  62. UE_LOG(LogLoad, Fatal, TEXT("Could not load WwiseProcessing module: %s not found"), *ModuleName.GetPlainNameString());
  63. }
  64. }
  65. }
  66. return Result;
  67. }
  68. virtual FWwiseGlobalCallbacks* GetGlobalCallbacks() = 0;
  69. private:
  70. static inline FName GetModuleNameFromConfig()
  71. {
  72. FString ModuleName = TEXT("WwiseProcessing");
  73. GConfig->GetString(TEXT("Audio"), TEXT("WwiseProcessingModuleName"), ModuleName, GEngineIni);
  74. return FName(ModuleName);
  75. }
  76. };