change destroying sound object

This commit is contained in:
Respirant
2020-12-29 17:32:26 +03:00
parent b68876da8b
commit d543b80f2e
@@ -23,6 +23,34 @@ class USoundWave* URuntimeAudioImporterBPLibrary::GetSoundWaveFromAudioFile(cons
return GetUSoundWaveFromAudioFile_Internal(filePath, Format, status, DefineFormatAutomatically); 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 */ /* Get USoundWave static object reference */
class USoundWave* URuntimeAudioImporterBPLibrary::GetSoundWaveObject(const uint8* WaveData, int32 WaveDataSize, TEnumAsByte < TranscodingStatus >& status) { class USoundWave* URuntimeAudioImporterBPLibrary::GetSoundWaveObject(const uint8* WaveData, int32 WaveDataSize, TEnumAsByte < TranscodingStatus >& status) {
USoundWave* sw = NewObject<USoundWave>(USoundWave::StaticClass()); USoundWave* sw = NewObject<USoundWave>(USoundWave::StaticClass());
@@ -87,34 +115,6 @@ class USoundWave* URuntimeAudioImporterBPLibrary::GetSoundWaveObject(const uint8
return sw; 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_wav.h"
#include "ThirdParty/dr_mp3.h" #include "ThirdParty/dr_mp3.h"