WwiseConcurrencyModule.h 2.7 KB

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