Skip to content

Commit

Permalink
[EAX] Fix error handling (#953)
Browse files Browse the repository at this point in the history
- Set error on EAX call failure if context is available.
- Reset error on successful retreiving the last error code.

Reference: EAX 4.0 - Programmer's Guide (pg.37)
  • Loading branch information
bibendovsky authored Dec 21, 2023
1 parent 9ccddf8 commit 32dbdd9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions al/eax/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ constexpr auto EAXCONTEXT_MINMACROFXFACTOR = 0.0F;
constexpr auto EAXCONTEXT_MAXMACROFXFACTOR = 1.0F;
constexpr auto EAXCONTEXT_DEFAULTMACROFXFACTOR = 0.0F;

constexpr auto EAXCONTEXT_DEFAULTLASTERROR = EAX_OK;

extern const GUID EAXPROPERTYID_EAX40_FXSlot0;
extern const GUID EAXPROPERTYID_EAX50_FXSlot0;
Expand Down
5 changes: 4 additions & 1 deletion alc/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ void ALCcontext::eax_update_speaker_configuration()

void ALCcontext::eax_set_last_error_defaults() noexcept
{
mEaxLastError = EAX_OK;
mEaxLastError = EAXCONTEXT_DEFAULTLASTERROR;
}

void ALCcontext::eax_session_set_defaults() noexcept
Expand Down Expand Up @@ -675,6 +675,7 @@ void ALCcontext::eax_get_misc(const EaxCall& call)
break;
case EAXCONTEXT_LASTERROR:
call.set_value<ContextException>(mEaxLastError);
mEaxLastError = EAX_OK;
break;
case EAXCONTEXT_SPEAKERCONFIG:
call.set_value<ContextException>(mEaxSpeakerConfig);
Expand Down Expand Up @@ -1045,6 +1046,7 @@ try
}
catch(...)
{
context->eaxSetLastError();
eax_log_exception(__func__);
return AL_INVALID_OPERATION;
}
Expand Down Expand Up @@ -1072,6 +1074,7 @@ try
}
catch(...)
{
context->eaxSetLastError();
eax_log_exception(__func__);
return AL_INVALID_OPERATION;
}
Expand Down

0 comments on commit 32dbdd9

Please sign in to comment.