Skip to content

Commit

Permalink
Fix variant crash
Browse files Browse the repository at this point in the history
  • Loading branch information
LAGonauta committed Dec 2, 2023
1 parent dd262cf commit 145b3b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/AudioEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,12 @@ namespace MetaAudio
settings.version = STEAMAUDIO_VERSION;
settings.logCallback = reinterpret_cast<IPLLogFunction>(SteamAudioLog);
auto result = SteamAudio::Context::Create(settings);
if (std::get<1>(result) != IPL_STATUS_SUCCESS) {
SteamAudioLog(IPLLogLevel::IPL_LOGLEVEL_ERROR, "Unable to load SteamAudio");
return;
if (std::holds_alternative<IPLerror>(result)) {
auto& err = std::get<1>(result);
if (err != IPL_STATUS_SUCCESS) {
SteamAudioLog(IPLLogLevel::IPL_LOGLEVEL_ERROR, "Unable to load SteamAudio");
return;
}
}
sa_context = std::get<0>(result);
IPLSimulationSettings simulationSettings{};
Expand Down
2 changes: 1 addition & 1 deletion src/Effects/SteamAudioOcclusionCalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace MetaAudio
IPLSourceSettings sourceSettings{};
sourceSettings.flags = IPLSimulationFlags::IPL_SIMULATIONFLAGS_DIRECT;
auto sourceResult = simulator.SourceCreate(sourceSettings);
if (std::get<1>(sourceResult) != IPLerror::IPL_STATUS_SUCCESS) {
if (std::holds_alternative<IPLerror>(sourceResult) && std::get<1>(sourceResult) != IPLerror::IPL_STATUS_SUCCESS) {
// TODO: LOG
return OcclusionFrequencyGain{ 1.0f, 1.0f, 1.0f };
}
Expand Down
6 changes: 3 additions & 3 deletions src/Loaders/SteamAudioMapMeshLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace MetaAudio
IPLSceneSettings settings{};
settings.type = IPLSceneType::IPL_SCENETYPE_DEFAULT;
auto sceneResult = this->sa_context.CreateScene(settings);
if (std::get<1>(sceneResult) != IPLerror::IPL_STATUS_SUCCESS) {
if (std::holds_alternative<IPLerror>(sceneResult) && std::get<1>(sceneResult) != IPLerror::IPL_STATUS_SUCCESS) {
// TODO: log error and return instead of throw?
throw std::runtime_error("Error creating scene: " + std::to_string(std::get<1>(sceneResult)));
//return;
Expand All @@ -170,15 +170,15 @@ namespace MetaAudio
staticMeshSettings.materialIndices = materialIndices.data();

auto staticMeshResult = scene.StaticMeshCreate(staticMeshSettings);
if (std::get<1>(staticMeshResult) != IPLerror::IPL_STATUS_SUCCESS) {
if (std::holds_alternative<IPLerror>(staticMeshResult) && std::get<1>(staticMeshResult) != IPLerror::IPL_STATUS_SUCCESS) {
throw std::runtime_error("Error creating static mesh: " + std::to_string(std::get<1>(staticMeshResult)));
}
auto& staticMesh = std::get<0>(staticMeshResult);
scene.StaticMeshAdd(staticMesh);
scene.Commit();

auto simulatorResult = sa_context.CreateSimulator(sa_simul_settings);
if (std::get<1>(simulatorResult) != IPLerror::IPL_STATUS_SUCCESS) {
if (std::holds_alternative<IPLerror>(simulatorResult) && std::get<1>(simulatorResult) != IPLerror::IPL_STATUS_SUCCESS) {
throw std::runtime_error("Error creating simulator: " + std::to_string(std::get<1>(simulatorResult)));
}
auto& simulator = std::get<0>(simulatorResult);
Expand Down

0 comments on commit 145b3b3

Please sign in to comment.