- make OpenAL and the decoder libraries delay loaded so that ZDoom can still start without them being present.

This required the addition of a few exception handlers so to avoid #ifdef overuse I also added some #defines for non-Windows systems that allow using __try and __except directly in the code without #ifdef'ing them out.
This commit is contained in:
Christoph Oelckers 2015-04-25 12:25:10 +02:00
commit d880783784
8 changed files with 151 additions and 89 deletions

View file

@ -52,6 +52,7 @@ extern HWND Window;
#include <malloc.h>
#endif
#include "except.h"
#include "templates.h"
#include "fmodsound.h"
#include "c_cvars.h"
@ -629,30 +630,6 @@ bool FMODSoundRenderer::IsValid()
return InitSuccess;
}
#ifdef _MSC_VER
//==========================================================================
//
// CheckException
//
//==========================================================================
#ifndef FACILITY_VISUALCPP
#define FACILITY_VISUALCPP ((LONG)0x6d)
#endif
#define VcppException(sev,err) ((sev) | (FACILITY_VISUALCPP<<16) | err)
static int CheckException(DWORD code)
{
if (code == VcppException(ERROR_SEVERITY_ERROR,ERROR_MOD_NOT_FOUND) ||
code == VcppException(ERROR_SEVERITY_ERROR,ERROR_PROC_NOT_FOUND))
{
return EXCEPTION_EXECUTE_HANDLER;
}
return EXCEPTION_CONTINUE_SEARCH;
}
#endif
//==========================================================================
//
// FMODSoundRenderer :: Init
@ -690,12 +667,12 @@ bool FMODSoundRenderer::Init()
Printf("I_InitSound: Initializing FMOD\n");
HMODULE a = GetModuleHandle("fmodex.dll");
// Create a System object and initialize.
#ifdef _MSC_VER
__try {
#endif
result = FMOD::System_Create(&Sys);
#ifdef _MSC_VER
__try
{
result = FMOD::System_Create(&Sys);
}
__except(CheckException(GetExceptionCode()))
{
@ -707,7 +684,6 @@ bool FMODSoundRenderer::Init()
".dll\n");
return false;
}
#endif
if (result != FMOD_OK)
{
Sys = NULL;