- 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:
parent
12118550d2
commit
d880783784
8 changed files with 151 additions and 89 deletions
|
|
@ -38,6 +38,7 @@
|
|||
#define USE_WINDOWS_DWORD
|
||||
#endif
|
||||
|
||||
#include "except.h"
|
||||
#include "doomstat.h"
|
||||
#include "templates.h"
|
||||
#include "oalsound.h"
|
||||
|
|
@ -65,19 +66,25 @@ void I_BuildALDeviceList(FOptionValues *opt)
|
|||
opt->mValues[0].Text = "Default";
|
||||
|
||||
#ifndef NO_OPENAL
|
||||
const ALCchar *names = (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") ?
|
||||
alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER) :
|
||||
alcGetString(NULL, ALC_DEVICE_SPECIFIER));
|
||||
if(!names)
|
||||
Printf("Failed to get device list: %s\n", alcGetString(NULL, alcGetError(NULL)));
|
||||
else while(*names)
|
||||
{
|
||||
unsigned int i = opt->mValues.Reserve(1);
|
||||
opt->mValues[i].TextValue = names;
|
||||
opt->mValues[i].Text = names;
|
||||
__try
|
||||
{
|
||||
const ALCchar *names = (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") ?
|
||||
alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER) :
|
||||
alcGetString(NULL, ALC_DEVICE_SPECIFIER));
|
||||
if (!names)
|
||||
Printf("Failed to get device list: %s\n", alcGetString(NULL, alcGetError(NULL)));
|
||||
else while (*names)
|
||||
{
|
||||
unsigned int i = opt->mValues.Reserve(1);
|
||||
opt->mValues[i].TextValue = names;
|
||||
opt->mValues[i].Text = names;
|
||||
|
||||
names += strlen(names)+1;
|
||||
}
|
||||
names += strlen(names) + 1;
|
||||
}
|
||||
}
|
||||
__except (CheckException(GetExceptionCode()))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -588,6 +595,34 @@ static float GetRolloff(const FRolloffInfo *rolloff, float distance)
|
|||
return (powf(10.f, volume) - 1.f) / 9.f;
|
||||
}
|
||||
|
||||
ALCdevice *OpenALSoundRenderer::InitDevice()
|
||||
{
|
||||
ALCdevice *device = NULL;
|
||||
__try
|
||||
{
|
||||
if(strcmp(snd_aldevice, "Default") != 0)
|
||||
{
|
||||
device = alcOpenDevice(*snd_aldevice);
|
||||
if(!device)
|
||||
Printf(TEXTCOLOR_BLUE" Failed to open device "TEXTCOLOR_BOLD"%s"TEXTCOLOR_BLUE". Trying default.\n", *snd_aldevice);
|
||||
}
|
||||
|
||||
if(!device)
|
||||
{
|
||||
device = alcOpenDevice(NULL);
|
||||
if(!device)
|
||||
{
|
||||
Printf(TEXTCOLOR_RED" Could not open audio device\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
__except(CheckException(GetExceptionCode()))
|
||||
{
|
||||
Printf(TEXTCOLOR_ORANGE"Failed to load openal32.dll\n");
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
static void LoadALFunc(const char *name, T *x)
|
||||
|
|
@ -601,22 +636,8 @@ OpenALSoundRenderer::OpenALSoundRenderer()
|
|||
|
||||
Printf("I_InitSound: Initializing OpenAL\n");
|
||||
|
||||
if(strcmp(snd_aldevice, "Default") != 0)
|
||||
{
|
||||
Device = alcOpenDevice(*snd_aldevice);
|
||||
if(!Device)
|
||||
Printf(TEXTCOLOR_BLUE" Failed to open device "TEXTCOLOR_BOLD"%s"TEXTCOLOR_BLUE". Trying default.\n", *snd_aldevice);
|
||||
}
|
||||
|
||||
if(!Device)
|
||||
{
|
||||
Device = alcOpenDevice(NULL);
|
||||
if(!Device)
|
||||
{
|
||||
Printf(TEXTCOLOR_RED" Could not open audio device\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Device = InitDevice();
|
||||
if (Device == NULL) return;
|
||||
|
||||
const ALCchar *current = NULL;
|
||||
if(alcIsExtensionPresent(Device, "ALC_ENUMERATE_ALL_EXT"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue