Slightly revise multivoc locking logic

git-svn-id: https://svn.eduke32.com/eduke32@7306 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-01-12 00:22:02 +00:00
parent 97c2271b92
commit 9f3cf8002b

View file

@ -98,14 +98,16 @@ static int32_t lockdepth = 0;
static FORCE_INLINE void DisableInterrupts(void)
{
if (lockdepth++ <= 0)
if (!lockdepth++)
SoundDriver_Lock();
}
static FORCE_INLINE void RestoreInterrupts(void)
{
if (--lockdepth <= 0)
if (!--lockdepth)
SoundDriver_Unlock();
else if (lockdepth < 0 && MV_Printf)
MV_Printf("RestoreInterrupts(): lockdepth < 0!\n");
}
const char *MV_ErrorString(int32_t ErrorNumber)
@ -376,17 +378,16 @@ VoiceNode *MV_BeginService(int32_t handle)
if (!MV_Installed)
return NULL;
DisableInterrupts();
VoiceNode *voice = MV_GetVoice(handle);
VoiceNode *voice;
if ((voice = MV_GetVoice(handle)) == NULL)
if (voice == NULL)
{
RestoreInterrupts();
MV_SetErrorCode(MV_VoiceNotFound);
return NULL;
}
DisableInterrupts();
return voice;
}