- [Psy-X] fix shutdown

This commit is contained in:
Ilya Shurumov 2021-02-20 15:15:20 +06:00
parent a299a002a0
commit 54177774a8
5 changed files with 24 additions and 12 deletions

View File

@ -91,9 +91,6 @@ extern void PsyX_EndScene();
/* Explicitly updates emulator input loop */
extern void PsyX_UpdateInput();
/* Usually called at the end if main function */
extern void PsyX_ShutDown();
/* Screen size of emulated PSX viewport with widescreen offsets */
extern void PsyX_GetPSXWidescreenMappedViewport(struct _RECT16* rect);

View File

@ -97,11 +97,14 @@ int g_enableSPUReverb = 0;
int g_ALEffectsSupported = 0;
LPALGENEFFECTS alGenEffects = NULL;
LPALDELETEEFFECTS alDeleteEffects = NULL;
LPALEFFECTI alEffecti = NULL;
LPALEFFECTF alEffectf = NULL;
LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots = NULL;
LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots = NULL;
LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti = NULL;
void InitOpenAlEffects()
{
g_ALEffectsSupported = 0;
@ -113,9 +116,11 @@ void InitOpenAlEffects()
}
alGenEffects = (LPALGENEFFECTS)alGetProcAddress("alGenEffects");
alDeleteEffects = (LPALDELETEEFFECTS)alGetProcAddress("alDeleteEffects");
alEffecti = (LPALEFFECTI)alGetProcAddress("alEffecti");
alEffectf = (LPALEFFECTF)alGetProcAddress("alEffectf");
alGenAuxiliaryEffectSlots = (LPALGENAUXILIARYEFFECTSLOTS)alGetProcAddress("alGenAuxiliaryEffectSlots");
alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)alGetProcAddress("alDeleteAuxiliaryEffectSlots");
alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)alGetProcAddress("alAuxiliaryEffectSloti");
int max_sends = 0;
@ -234,10 +239,18 @@ void PsyX_ShutdownSound()
for (int i = 0; i < SPU_VOICES; i++)
{
SPUVoice& voice = g_SpuVoices[i];
alGenSources(1, &voice.alSource);
alGenBuffers(1, &voice.alBuffer);
alDeleteSources(1, &voice.alSource);
alDeleteBuffers(1, &voice.alBuffer);
}
if (g_ALEffectsSupported)
{
alDeleteEffects(1, &g_nAlReverbEffect);
g_ALEffectsSupported = AL_NONE;
}
alDeleteAuxiliaryEffectSlots(1, g_ALEffectSlots);
alcDestroyContext(g_ALCcontext);
alcCloseDevice(g_ALCdevice);

View File

@ -419,35 +419,35 @@ void PsyX_Initialise(char* appName, int width, int height, int fullscreen)
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
eprinterr("Failed to initialise SDL\n");
PsyX_ShutDown();
PsyX_Shutdown();
return;
}
if (!GR_InitialiseRender(windowNameStr, width, height, fullscreen))
{
eprinterr("Failed to Intialise Window\n");
PsyX_ShutDown();
PsyX_Shutdown();
return;
}
if (!PsyX_Sys_InitialiseCore())
{
eprinterr("Failed to Intialise Psy-X Core.\n");
PsyX_ShutDown();
PsyX_Shutdown();
return;
}
if (!GR_InitialisePSX())
{
eprinterr("Failed to Intialise PSX.\n");
PsyX_ShutDown();
PsyX_Shutdown();
return;
}
PsyX_Sys_InitialiseInput();
// set shutdown function (PSX apps usualy don't exit)
atexit(PsyX_ShutDown);
atexit(PsyX_Shutdown);
}
void PsyX_GetScreenSize(int& screenWidth, int& screenHeight)
@ -722,7 +722,7 @@ void PsyX_Exit()
exit(0);
}
void PsyX_ShutDown()
void PsyX_Shutdown()
{
if (!g_window)
return;

View File

@ -430,7 +430,7 @@ int GR_InitialiseRender(char* windowName, int width, int height, int fullscreen)
if (!GR_InitialiseGLExt())
{
eprinterr("Failed to Intialise GL extensions\n");
PsyX_ShutDown();
return 0;
}
#endif

View File

@ -681,5 +681,7 @@ int main(int argc, char** argv)
DeinitStringMng();
PsyX_Shutdown();
return 0;
}