OpenAL: fix CreativeLab bug. This bug causes hang on my machine.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2864 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hyperiris 2009-04-04 03:48:15 +00:00
parent 0478301c1e
commit 5d72a992bf
1 changed files with 17 additions and 9 deletions

View File

@ -47,30 +47,38 @@ ALDeviceList::ALDeviceList()
// grab function pointers for 1.0-API functions, and if successful proceed to enumerate all devices // grab function pointers for 1.0-API functions, and if successful proceed to enumerate all devices
//if (LoadOAL10Library(NULL, &ALFunction) == TRUE) { //if (LoadOAL10Library(NULL, &ALFunction) == TRUE) {
if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) { if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT"))
{
devices = (char *)alcGetString(NULL, ALC_DEVICE_SPECIFIER); devices = (char *)alcGetString(NULL, ALC_DEVICE_SPECIFIER);
defaultDeviceName = (char *)alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); defaultDeviceName = (char *)alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
index = 0; index = 0;
// go through device list (each device terminated with a single NULL, list terminated with double NULL) // go through device list (each device terminated with a single NULL, list terminated with double NULL)
while (devices != NULL) { while (devices != NULL && strlen(devices) > 0)
if (strcmp(defaultDeviceName, devices) == 0) { {
if (strcmp(defaultDeviceName, devices) == 0)
{
defaultDeviceIndex = index; defaultDeviceIndex = index;
} }
ALCdevice *device = alcOpenDevice(devices); ALCdevice *device = alcOpenDevice(devices);
if (device) { if (device)
{
ALCcontext *context = alcCreateContext(device, NULL); ALCcontext *context = alcCreateContext(device, NULL);
if (context) { if (context)
{
alcMakeContextCurrent(context); alcMakeContextCurrent(context);
// if new actual device name isn't already in the list, then add it... // if new actual device name isn't already in the list, then add it...
actualDeviceName = alcGetString(device, ALC_DEVICE_SPECIFIER); actualDeviceName = alcGetString(device, ALC_DEVICE_SPECIFIER);
bool bNewName = true; bool bNewName = true;
for (s32 i = 0; i < GetNumDevices(); i++) { for (s32 i = 0; i < GetNumDevices(); i++)
if (strcmp(GetDeviceName(i), actualDeviceName) == 0) { {
if (strcmp(GetDeviceName(i), actualDeviceName) == 0)
{
bNewName = false; bNewName = false;
} }
} }
if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) { if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0))
//memset(&ALDeviceInfo, 0, sizeof(ALDEVICEINFO)); // the creative was brain broken. {
memset(&ALDeviceInfo, 0, sizeof(ALDEVICEINFO)); // the creative was brain broken.
ALDeviceInfo.bSelected = true; ALDeviceInfo.bSelected = true;
ALDeviceInfo.strDeviceName = actualDeviceName; ALDeviceInfo.strDeviceName = actualDeviceName;
alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(s32), &ALDeviceInfo.iMajorVersion); alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(s32), &ALDeviceInfo.iMajorVersion);