Browse Source

Is this... error handling?

master
Thomas Cheyney 4 years ago
parent
commit
a8c49a1199
3 changed files with 37 additions and 27 deletions
  1. +28
    -24
      Plugins/eXiSoundVis/Source/eXiSoundVis/Private/AudioDecompressWorker.cpp
  2. +6
    -2
      Plugins/eXiSoundVis/Source/eXiSoundVis/Private/SoundVisComponent.cpp
  3. +3
    -1
      Plugins/eXiSoundVis/Source/eXiSoundVis/eXiSoundVis.Build.cs

+ 28
- 24
Plugins/eXiSoundVis/Source/eXiSoundVis/Private/AudioDecompressWorker.cpp View File

@ -67,37 +67,41 @@ uint32 FAudioDecompressWorker::Run()
if (AudioInfo != NULL)
{
FSoundQualityInfo QualityInfo = { 0 };
try {
FSoundQualityInfo QualityInfo = { 0 };
// Parse the audio header for the relevant information
if (!(SoundWaveRef->ResourceData))
{
return 0;
}
// Parse the audio header for the relevant information
if (!(SoundWaveRef->ResourceData))
{
return 0;
}
if (AudioInfo->ReadCompressedInfo(SoundWaveRef->ResourceData, SoundWaveRef->ResourceSize, &QualityInfo))
{
FScopeCycleCounterUObject WaveObject(SoundWaveRef);
if (AudioInfo->ReadCompressedInfo(SoundWaveRef->ResourceData, SoundWaveRef->ResourceSize, &QualityInfo))
{
FScopeCycleCounterUObject WaveObject(SoundWaveRef);
// Extract the data
SoundWaveRef->SampleRate = QualityInfo.SampleRate;
SoundWaveRef->NumChannels = QualityInfo.NumChannels;
// Extract the data
SoundWaveRef->SampleRate = QualityInfo.SampleRate;
SoundWaveRef->NumChannels = QualityInfo.NumChannels;
if (QualityInfo.Duration > 0.0f)
{
SoundWaveRef->Duration = QualityInfo.Duration;
}
if (QualityInfo.Duration > 0.0f)
{
SoundWaveRef->Duration = QualityInfo.Duration;
}
const uint32 PCMBufferSize = SoundWaveRef->Duration * SoundWaveRef->SampleRate * SoundWaveRef->NumChannels;
const uint32 PCMBufferSize = SoundWaveRef->Duration * SoundWaveRef->SampleRate * SoundWaveRef->NumChannels;
SoundWaveRef->CachedRealtimeFirstBuffer = new uint8[PCMBufferSize * 2];
SoundWaveRef->CachedRealtimeFirstBuffer = new uint8[PCMBufferSize * 2];
AudioInfo->SeekToTime(0.0f);
AudioInfo->ReadCompressedData(SoundWaveRef->CachedRealtimeFirstBuffer, false, PCMBufferSize * 2);
}
else if (SoundWaveRef->DecompressionType == DTYPE_RealTime || SoundWaveRef->DecompressionType == DTYPE_Native)
{
SoundWaveRef->RemoveAudioResource();
AudioInfo->SeekToTime(0.0f);
AudioInfo->ReadCompressedData(SoundWaveRef->CachedRealtimeFirstBuffer, false, PCMBufferSize * 2);
}
else if (SoundWaveRef->DecompressionType == DTYPE_RealTime || SoundWaveRef->DecompressionType == DTYPE_Native)
{
SoundWaveRef->RemoveAudioResource();
}
} catch (const std::exception&) {
// Yo, bad things happened
}
delete AudioInfo;


+ 6
- 2
Plugins/eXiSoundVis/Source/eXiSoundVis/Private/SoundVisComponent.cpp View File

@ -351,8 +351,12 @@ void USoundVisComponent::Notify_SoundDecompressed()
// ..clear the timer and..
GetWorld()->GetTimerManager().ClearTimer(AudioDecompressTimer);
//..broadcast the result to the Blueprint
OnFileLoadCompleted.Broadcast(FAudioDecompressWorker::Runnable->GetSoundWaveRef());
try {
//..broadcast the result to the Blueprint
OnFileLoadCompleted.Broadcast(FAudioDecompressWorker::Runnable->GetSoundWaveRef());
} catch (const std::exception&) {
// Yo, bad things happened
}
PrintLog(TEXT("Worker finished!"));
}


+ 3
- 1
Plugins/eXiSoundVis/Source/eXiSoundVis/eXiSoundVis.Build.cs View File

@ -5,7 +5,9 @@ public class eXiSoundVis : ModuleRules
{
public eXiSoundVis(ReadOnlyTargetRules Target) : base(Target)
{
PrivateIncludePaths.AddRange(new string[] { "eXiSoundVis/Private" });
this.bEnableExceptions = true;
PrivateIncludePaths.AddRange(new string[] { "eXiSoundVis/Private" });
PublicIncludePaths.AddRange(new string[] { "eXiSoundVis/Public" });
PublicDependencyModuleNames.AddRange(new string[] { "Engine", "Core", "CoreUObject", "InputCore", "RHI", "Kiss_FFT" });


Loading…
Cancel
Save