Skip to content

Commit

Permalink
add support for 5.4 (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeseese authored May 7, 2024
1 parent bdd5ed7 commit f76916b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
11 changes: 11 additions & 0 deletions Source/CoreUtility/CoreUtility.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
{
Expand Down
4 changes: 4 additions & 0 deletions Source/CoreUtility/Private/CUBlueprintLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 6 additions & 4 deletions Source/CoreUtility/Private/CUOpusCoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ bool FCUOpusCoder::EncodeStream(const TArray<uint8>& 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);
Expand Down Expand Up @@ -164,7 +164,7 @@ bool FCUOpusCoder::DecodeStream(const FCUOpusMinimalStream& InStream, TArray<uin
}
else if (DecodedSamples < 0)
{
UE_LOG(LogTemp, Log, TEXT("%s"), opus_strerror(DecodedSamples));
UE_LOG(LogTemp, Log, TEXT("%hs"), opus_strerror(DecodedSamples));
return false;
}

Expand Down Expand Up @@ -228,16 +228,18 @@ int32 FCUOpusCoder::EncodeFrame(const TArray<uint8>& InPCMFrame, TArray<uint8>&
{
#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<uint8>& InCompressedFrame, TArray<uint8>& OutPCMFrame)
{
#if WITH_OPUS
return opus_decode(Decoder, InCompressedFrame.GetData(), InCompressedFrame.Num(), (opus_int16*)OutPCMFrame.GetData(), FrameSize, 0);
#endif
#else
return 0;
#endif
}


Expand Down

0 comments on commit f76916b

Please sign in to comment.