mirror of
https://github.com/storytold/RuntimeAudioImporter.git
synced 2026-10-09 00:09:48 +00:00
function to destroy audio and change memory deallocation
This commit is contained in:
+19
@@ -79,6 +79,23 @@ class USoundWave* URuntimeAudioImporterBPLibrary::GetSoundWaveObject(const uint8
|
||||
return sw;
|
||||
}
|
||||
|
||||
/* Destroy USoundWave static object */
|
||||
void URuntimeAudioImporterBPLibrary::DestroySoundWave(USoundWave* ReadySoundWave, bool& SuccessfullyDestroyed) {
|
||||
if (IsValid(ReadySoundWave) && ReadySoundWave->IsReadyForFinishDestroy()) {
|
||||
FMemory::Free(ReadySoundWave->RawPCMData);
|
||||
|
||||
ReadySoundWave->RawData.RemoveBulkData();
|
||||
ReadySoundWave->InvalidateCompressedData();
|
||||
ReadySoundWave->FreeResources();
|
||||
ReadySoundWave->RemoveAudioResource();
|
||||
ReadySoundWave->ConditionalBeginDestroy();
|
||||
SuccessfullyDestroyed = true;
|
||||
}
|
||||
else {
|
||||
SuccessfullyDestroyed = false;
|
||||
}
|
||||
}
|
||||
|
||||
#include "ThirdParty/dr_wav.h"
|
||||
|
||||
#include "ThirdParty/dr_mp3.h"
|
||||
@@ -125,7 +142,9 @@ class USoundWave* URuntimeAudioImporterBPLibrary::GetUSoundWaveFromAudioFile_Int
|
||||
|
||||
USoundWave* ReadyUSoundWave = GetSoundWaveObject((const uint8*)pWavFileData, wavFileSize, status); // A ready USoundWave static object
|
||||
|
||||
drwav_free(pSampleData, NULL);
|
||||
drwav_free(pWavFileData, NULL);
|
||||
|
||||
return ReadyUSoundWave;
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
|
||||
#include "Runtime/Engine/Classes/Sound/SoundWave.h"
|
||||
#include "Sound/SoundWave.h"
|
||||
|
||||
#include "Developer/TargetPlatform/Public/Interfaces/IAudioFormat.h"
|
||||
|
||||
@@ -47,6 +47,9 @@ public:
|
||||
UFUNCTION(BlueprintCallable, meta = (Keywords = "Importer, Transcoder, Converter, MP3, FLAC, WAV", ToolTip = "Transcode audio file to USoundWave static object"), Category = "RuntimeAudioImporter")
|
||||
static class USoundWave* GetSoundWaveFromAudioFile(const FString & filePath, TEnumAsByte < AudioFormat > Format, TEnumAsByte < TranscodingStatus > & status, bool DefineFormatAutomatically);
|
||||
|
||||
UFUNCTION(BlueprintCallable, meta = (Keywords = "MP3, FLAC, WAV, Destroy", ToolTip = "After the Soundwave is no longer needed, you need to call this function to free memory"), Category = "RuntimeAudioImporter")
|
||||
static void DestroySoundWave(USoundWave * ReadySoundWave, bool& SuccessfullyDestroyed);
|
||||
|
||||
private:
|
||||
|
||||
/* Main internal get USoundWave from audio file */
|
||||
|
||||
@@ -19,11 +19,7 @@ public class RuntimeAudioImporter : ModuleRules
|
||||
}
|
||||
);
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
// ... add other private include paths required here ...
|
||||
}
|
||||
);
|
||||
//PrivateIncludePaths.Add(Path.Combine(ModuleDirectory, "ThirdParty"));
|
||||
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
|
||||
Reference in New Issue
Block a user