mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
Create new MV_CleanupVoice() function to handle most of what was in MV_StopVoice() plus the MV_CallBackFunc() functionality
git-svn-id: https://svn.eduke32.com/eduke32@7307 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
9f3cf8002b
commit
74d766d988
1 changed files with 16 additions and 40 deletions
|
@ -212,15 +212,10 @@ void MV_PlayVoice(VoiceNode *voice)
|
||||||
RestoreInterrupts();
|
RestoreInterrupts();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MV_StopVoice(VoiceNode *voice)
|
static void MV_CleanupVoice(VoiceNode *voice)
|
||||||
{
|
{
|
||||||
DisableInterrupts();
|
if (MV_CallBackFunc)
|
||||||
|
MV_CallBackFunc(voice->callbackval);
|
||||||
// move the voice from the play list to the free list
|
|
||||||
LL_Remove(voice, next, prev);
|
|
||||||
LL_Add((VoiceNode*) &VoicePool, voice, next, prev);
|
|
||||||
|
|
||||||
RestoreInterrupts();
|
|
||||||
|
|
||||||
switch (voice->wavetype)
|
switch (voice->wavetype)
|
||||||
{
|
{
|
||||||
|
@ -240,6 +235,17 @@ static void MV_StopVoice(VoiceNode *voice)
|
||||||
voice->handle = 0;
|
voice->handle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void MV_StopVoice(VoiceNode *voice)
|
||||||
|
{
|
||||||
|
MV_CleanupVoice(voice);
|
||||||
|
|
||||||
|
DisableInterrupts();
|
||||||
|
// move the voice from the play list to the free list
|
||||||
|
LL_Remove(voice, next, prev);
|
||||||
|
LL_Add((VoiceNode*) &VoicePool, voice, next, prev);
|
||||||
|
RestoreInterrupts();
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------
|
/*---------------------------------------------------------------------
|
||||||
JBF: no synchronisation happens inside MV_ServiceVoc nor the
|
JBF: no synchronisation happens inside MV_ServiceVoc nor the
|
||||||
supporting functions it calls. This would cause a deadlock
|
supporting functions it calls. This would cause a deadlock
|
||||||
|
@ -317,30 +323,10 @@ static void MV_ServiceVoc(void)
|
||||||
// Is this voice done?
|
// Is this voice done?
|
||||||
if (!MV_Mix(voice, MV_MixPage))
|
if (!MV_Mix(voice, MV_MixPage))
|
||||||
{
|
{
|
||||||
//JBF: prevent a deadlock caused by MV_StopVoice grabbing the mutex again
|
MV_CleanupVoice(voice);
|
||||||
//MV_StopVoice( voice );
|
|
||||||
LL_Remove(voice, next, prev);
|
LL_Remove(voice, next, prev);
|
||||||
LL_Add((VoiceNode*) &VoicePool, voice, next, prev);
|
LL_Add((VoiceNode*) &VoicePool, voice, next, prev);
|
||||||
|
|
||||||
switch (voice->wavetype)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_VORBIS
|
|
||||||
case FMT_VORBIS: MV_ReleaseVorbisVoice(voice); break;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_FLAC
|
|
||||||
case FMT_FLAC: MV_ReleaseFLACVoice(voice); break;
|
|
||||||
#endif
|
|
||||||
case FMT_XA: MV_ReleaseXAVoice(voice); break;
|
|
||||||
#ifdef HAVE_XMP
|
|
||||||
case FMT_XMP: MV_ReleaseXMPVoice(voice); break;
|
|
||||||
#endif
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
voice->handle = 0;
|
|
||||||
|
|
||||||
if (MV_CallBackFunc)
|
|
||||||
MV_CallBackFunc(voice->callbackval);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ((voice = next) != &VoiceList);
|
while ((voice = next) != &VoiceList);
|
||||||
|
@ -438,15 +424,9 @@ int32_t MV_Kill(int32_t handle)
|
||||||
if (voice == NULL)
|
if (voice == NULL)
|
||||||
return MV_Error;
|
return MV_Error;
|
||||||
|
|
||||||
uint32_t const callbackval = voice->callbackval;
|
|
||||||
|
|
||||||
MV_StopVoice(voice);
|
MV_StopVoice(voice);
|
||||||
|
|
||||||
MV_EndService();
|
MV_EndService();
|
||||||
|
|
||||||
if (MV_CallBackFunc)
|
|
||||||
MV_CallBackFunc(callbackval);
|
|
||||||
|
|
||||||
return MV_Ok;
|
return MV_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,11 +826,7 @@ static void MV_StopPlayback(void)
|
||||||
for (VoiceNode *voice = VoiceList.next, *next; voice != &VoiceList; voice = next)
|
for (VoiceNode *voice = VoiceList.next, *next; voice != &VoiceList; voice = next)
|
||||||
{
|
{
|
||||||
next = voice->next;
|
next = voice->next;
|
||||||
|
|
||||||
MV_StopVoice(voice);
|
MV_StopVoice(voice);
|
||||||
|
|
||||||
if (MV_CallBackFunc)
|
|
||||||
MV_CallBackFunc(voice->callbackval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RestoreInterrupts();
|
RestoreInterrupts();
|
||||||
|
|
Loading…
Reference in a new issue