From f76916b0730994d215ac576a7d731de438b1485f Mon Sep 17 00:00:00 2001 From: Mike Seese Date: Mon, 6 May 2024 17:21:59 -0700 Subject: [PATCH] add support for 5.4 (#417) --- Source/CoreUtility/CoreUtility.Build.cs | 11 +++++++++++ Source/CoreUtility/Private/CUBlueprintLibrary.cpp | 4 ++++ Source/CoreUtility/Private/CUOpusCoder.cpp | 10 ++++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Source/CoreUtility/CoreUtility.Build.cs b/Source/CoreUtility/CoreUtility.Build.cs index b813a637..2cb27e71 100644 --- a/Source/CoreUtility/CoreUtility.Build.cs +++ b/Source/CoreUtility/CoreUtility.Build.cs @@ -46,6 +46,17 @@ public CoreUtility(ReadOnlyTargetRules Target) : base(Target) ); + if (Target.Version.MajorVersion == 5 && Target.Version.MinorVersion >= 4) + { + PrivateDependencyModuleNames.AddRange( + new string[] + { + "OpusAudioDecoder", + } + ); + } + + DynamicallyLoadedModuleNames.AddRange( new string[] { diff --git a/Source/CoreUtility/Private/CUBlueprintLibrary.cpp b/Source/CoreUtility/Private/CUBlueprintLibrary.cpp index ecb29cc4..d3de1d15 100644 --- a/Source/CoreUtility/Private/CUBlueprintLibrary.cpp +++ b/Source/CoreUtility/Private/CUBlueprintLibrary.cpp @@ -10,7 +10,11 @@ #include "HAL/ThreadSafeBool.h" #include "RHI.h" #include "Misc/FileHelper.h" +#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 4 +#include "Decoders/OpusAudioInfo.h" +#else #include "OpusAudioInfo.h" +#endif #include "Runtime/Launch/Resources/Version.h" #include "Developer/TargetPlatform/Public/Interfaces/IAudioFormat.h" #include "CoreMinimal.h" diff --git a/Source/CoreUtility/Private/CUOpusCoder.cpp b/Source/CoreUtility/Private/CUOpusCoder.cpp index 89d3ade6..d7083f50 100644 --- a/Source/CoreUtility/Private/CUOpusCoder.cpp +++ b/Source/CoreUtility/Private/CUOpusCoder.cpp @@ -109,7 +109,7 @@ bool FCUOpusCoder::EncodeStream(const TArray& InPCMBytes, FCUOpusMinimalS if (EncodedBytes < 0) { - UE_LOG(LogTemp, Warning, TEXT("opus_encode err: %s"), opus_strerror(EncodedBytes)); + UE_LOG(LogTemp, Warning, TEXT("opus_encode err: %hs"), opus_strerror(EncodedBytes)); return false; } OutStream.CompressedBytes.Append(TempBuffer.GetData(), EncodedBytes); @@ -164,7 +164,7 @@ bool FCUOpusCoder::DecodeStream(const FCUOpusMinimalStream& InStream, TArray& InPCMFrame, TArray& { #if WITH_OPUS return opus_encode(Encoder, (const opus_int16*)InPCMFrame.GetData(), FrameSize, OutCompressed.GetData(), MaxPacketSize); -#endif +#else return 0; +#endif } int32 FCUOpusCoder::DecodeFrame(const TArray& InCompressedFrame, TArray& OutPCMFrame) { #if WITH_OPUS return opus_decode(Decoder, InCompressedFrame.GetData(), InCompressedFrame.Num(), (opus_int16*)OutPCMFrame.GetData(), FrameSize, 0); -#endif +#else return 0; +#endif }