From d543b80f2e924fbda9ed7f49e0633de3a70679a9 Mon Sep 17 00:00:00 2001 From: Respirant Date: Tue, 29 Dec 2020 17:32:26 +0300 Subject: [PATCH] change destroying sound object --- .../Private/RuntimeAudioImporterBPLibrary.cpp | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/RuntimeAudioImporter/Source/RuntimeAudioImporter/Private/RuntimeAudioImporterBPLibrary.cpp b/RuntimeAudioImporter/Source/RuntimeAudioImporter/Private/RuntimeAudioImporterBPLibrary.cpp index 42a7b9c..11ffb3a 100644 --- a/RuntimeAudioImporter/Source/RuntimeAudioImporter/Private/RuntimeAudioImporterBPLibrary.cpp +++ b/RuntimeAudioImporter/Source/RuntimeAudioImporter/Private/RuntimeAudioImporterBPLibrary.cpp @@ -23,6 +23,34 @@ class USoundWave* URuntimeAudioImporterBPLibrary::GetSoundWaveFromAudioFile(cons return GetUSoundWaveFromAudioFile_Internal(filePath, Format, status, DefineFormatAutomatically); } +/** +* Destroy USoundWave static object +* +* @return Returns true - success, false - failure. +*/ +bool URuntimeAudioImporterBPLibrary::DestroySoundWave(USoundWave* ReadySoundWave) { + + if (IsValid(ReadySoundWave) && ReadySoundWave->IsValidLowLevel()) { + + /* Free memory */ + ReadySoundWave->InvalidateCompressedData(); + FMemory::Free(ReadySoundWave->RawPCMData); + ReadySoundWave->RawData.RemoveBulkData(); + ReadySoundWave->RemoveAudioResource(); + /* Free memory */ + + /* Destroying USoundWave object as UObject */ + ReadySoundWave->ConditionalBeginDestroy(); + ReadySoundWave = NULL; + /* Destroying USoundWave object as UObject */ + + return true; + } + else { + return false; + } +} + /* Get USoundWave static object reference */ class USoundWave* URuntimeAudioImporterBPLibrary::GetSoundWaveObject(const uint8* WaveData, int32 WaveDataSize, TEnumAsByte < TranscodingStatus >& status) { USoundWave* sw = NewObject(USoundWave::StaticClass()); @@ -87,34 +115,6 @@ class USoundWave* URuntimeAudioImporterBPLibrary::GetSoundWaveObject(const uint8 return sw; } -/** -* Destroy USoundWave static object -* -* @return Returns true - success, false - failure. -*/ -bool URuntimeAudioImporterBPLibrary::DestroySoundWave(USoundWave* ReadySoundWave) { - - if (IsValid(ReadySoundWave) && ReadySoundWave->IsValidLowLevel()) { - - /* Free memory */ - ReadySoundWave->InvalidateCompressedData(); - FMemory::Free(ReadySoundWave->RawPCMData); - ReadySoundWave->RawData.RemoveBulkData(); - ReadySoundWave->RemoveAudioResource(); - /* Free memory */ - - /* Destroying USoundWave object as UObject */ - ReadySoundWave->ConditionalBeginDestroy(); - ReadySoundWave = NULL; - /* Destroying USoundWave object as UObject */ - - return true; - } - else { - return false; - } -} - #include "ThirdParty/dr_wav.h" #include "ThirdParty/dr_mp3.h"