AkPlatformInfo.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 "Engine/GameEngine.h"
  17. #include "AkAudioDevice.h"
  18. #if WITH_EDITORONLY_DATA
  19. #include "Wwise/WwiseProjectDatabase.h"
  20. #include "Wwise/WwiseSharedPlatformId.h"
  21. #endif
  22. #include "AkPlatformInfo.generated.h"
  23. UCLASS()
  24. class AKAUDIO_API UAkPlatformInfo : public UObject
  25. {
  26. GENERATED_BODY()
  27. public:
  28. #if WITH_EDITORONLY_DATA
  29. static TMap<FString, FWwiseSharedPlatformId> UnrealTargetNameToSharedPlatformId;
  30. static TMap<FString, UAkPlatformInfo*> UnrealNameToPlatformInfo;
  31. virtual FString GetWwiseBankPlatformName(const TArray<FString>& AvailableWwisePlatforms) const
  32. {
  33. if (AvailableWwisePlatforms.Contains(WwisePlatform))
  34. {
  35. return WwisePlatform;
  36. }
  37. return {};
  38. }
  39. static FWwiseSharedPlatformId GetSharedPlatformInfo(const FString& PlatformName)
  40. {
  41. if (UnrealTargetNameToSharedPlatformId.Contains(PlatformName))
  42. {
  43. return UnrealTargetNameToSharedPlatformId[PlatformName];
  44. }
  45. const auto ProjectDatabase = FWwiseProjectDatabase::Get();
  46. if (UNLIKELY(!ProjectDatabase))
  47. {
  48. UE_LOG(LogAkAudio, Warning, TEXT("ProjectDatabase is not initialized"));
  49. return {};
  50. }
  51. const FWwiseDataStructureScopeLock DataStructure(*ProjectDatabase);
  52. auto Platforms = DataStructure.GetPlatforms();
  53. if (const auto* CurrentPlatformInfo = GetAkPlatformInfo(PlatformName))
  54. {
  55. TArray<FString> AvailablePlatforms;
  56. for (auto WwisePlatform : Platforms)
  57. {
  58. AvailablePlatforms.Add(WwisePlatform.GetPlatformName().ToString());
  59. }
  60. const FString WwisePlatformName = CurrentPlatformInfo->GetWwiseBankPlatformName(AvailablePlatforms);
  61. for (auto WwisePlatform : Platforms)
  62. {
  63. if (WwisePlatform.GetPlatformName().ToString() == WwisePlatformName)
  64. {
  65. UnrealTargetNameToSharedPlatformId.Add(PlatformName, WwisePlatform);
  66. return UnrealTargetNameToSharedPlatformId[PlatformName];
  67. }
  68. }
  69. UE_LOG(LogAkAudio, Warning, TEXT("Could not find parsed platform that matches %s"), *CurrentPlatformInfo->WwisePlatform);
  70. return {};
  71. }
  72. UE_LOG(LogAkAudio, Warning, TEXT("Could not find platform info for %s"), *PlatformName)
  73. return {};
  74. }
  75. #endif
  76. static UAkPlatformInfo* GetAkPlatformInfo(const FString& PlatformName)
  77. {
  78. UAkPlatformInfo* RetVal = nullptr;
  79. #if WITH_EDITORONLY_DATA
  80. auto** FoundInfo = UnrealNameToPlatformInfo.Find(PlatformName);
  81. RetVal = FoundInfo ? *FoundInfo : nullptr;
  82. #endif
  83. if (!RetVal)
  84. {
  85. const FString PlatformInfoClassName = FString::Format(TEXT("Ak{0}PlatformInfo"), { *PlatformName });
  86. #if UE_5_1_OR_LATER
  87. auto* PlatformInfoClass = UClass::TryFindTypeSlow<UClass>(*PlatformInfoClassName);
  88. #else
  89. auto* PlatformInfoClass = FindObject<UClass>(ANY_PACKAGE, *PlatformInfoClassName);
  90. #endif
  91. if (PlatformInfoClass)
  92. {
  93. RetVal = PlatformInfoClass->GetDefaultObject<UAkPlatformInfo>();
  94. }
  95. }
  96. return RetVal;
  97. }
  98. FString WwisePlatform;
  99. FString Architecture;
  100. FString LibraryFileNameFormat;
  101. FString DebugFileNameFormat;
  102. bool bSupportsUPL = false;
  103. bool bUsesStaticLibraries = false;
  104. bool bForceReleaseConfig = false;
  105. };