aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-12-28 23:19:13 -0800
committerChris Robinson <[email protected]>2009-12-28 23:19:13 -0800
commit7ee81eac0fd1ecd719c906cfc8fc9a81fcf0ffbe (patch)
treea3b955467e7d67e7369d6f38b23910cffdbac367
parentc9a08fc7b235425058d3e28ddc46ae56dc726d7d (diff)
Store ALC errors with the device when possible
-rw-r--r--Alc/ALc.c131
-rw-r--r--Alc/alsa.c2
-rw-r--r--Alc/dsound.c2
-rw-r--r--Alc/oss.c2
-rw-r--r--Alc/pulseaudio.c2
-rw-r--r--Alc/winmm.c4
-rw-r--r--OpenAL32/Include/alMain.h4
7 files changed, 74 insertions, 73 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index db63f593..1ee820c6 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -508,9 +508,12 @@ static ALCboolean IsContext(ALCcontext *pContext)
Store latest ALC Error
*/
-ALCvoid alcSetError(ALenum errorCode)
+ALCvoid alcSetError(ALCdevice *device, ALenum errorCode)
{
- g_eLastContextError = errorCode;
+ if(IsDevice(device))
+ device->LastError = errorCode;
+ else
+ g_eLastContextError = errorCode;
}
@@ -637,7 +640,7 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL
if(SampleSize <= 0)
{
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(NULL, ALC_INVALID_VALUE);
return NULL;
}
@@ -679,13 +682,13 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL
if(!DeviceFound)
{
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(NULL, ALC_INVALID_VALUE);
free(pDevice);
pDevice = NULL;
}
}
else
- alcSetError(ALC_OUT_OF_MEMORY);
+ alcSetError(NULL, ALC_OUT_OF_MEMORY);
return pDevice;
}
@@ -718,7 +721,7 @@ ALCAPI ALCboolean ALCAPIENTRY alcCaptureCloseDevice(ALCdevice *pDevice)
bReturn = ALC_TRUE;
}
else
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(pDevice, ALC_INVALID_DEVICE);
return bReturn;
}
@@ -728,7 +731,7 @@ ALCAPI void ALCAPIENTRY alcCaptureStart(ALCdevice *pDevice)
if(IsDevice(pDevice) && pDevice->IsCaptureDevice)
ALCdevice_StartCapture(pDevice);
else
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(pDevice, ALC_INVALID_DEVICE);
}
ALCAPI void ALCAPIENTRY alcCaptureStop(ALCdevice *pDevice)
@@ -736,7 +739,7 @@ ALCAPI void ALCAPIENTRY alcCaptureStop(ALCdevice *pDevice)
if(IsDevice(pDevice) && pDevice->IsCaptureDevice)
ALCdevice_StopCapture(pDevice);
else
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(pDevice, ALC_INVALID_DEVICE);
}
ALCAPI void ALCAPIENTRY alcCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCsizei lSamples)
@@ -744,7 +747,7 @@ ALCAPI void ALCAPIENTRY alcCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer,
if(IsDevice(pDevice) && pDevice->IsCaptureDevice)
ALCdevice_CaptureSamples(pDevice, pBuffer, lSamples);
else
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(pDevice, ALC_INVALID_DEVICE);
}
/*
@@ -754,12 +757,13 @@ ALCAPI void ALCAPIENTRY alcCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer,
*/
ALCAPI ALCenum ALCAPIENTRY alcGetError(ALCdevice *device)
{
- ALCenum errorCode;
-
- (void)device;
+ ALCenum errorCode = ALC_NO_ERROR;
- errorCode = g_eLastContextError;
- g_eLastContextError = ALC_NO_ERROR;
+ if(device)
+ {
+ errorCode = device->LastError;
+ device->LastError = ALC_NO_ERROR;
+ }
return errorCode;
}
@@ -857,7 +861,7 @@ ALCAPI const ALCchar* ALCAPIENTRY alcGetString(ALCdevice *pDevice,ALCenum param)
free(alcDefaultDeviceSpecifier);
alcDefaultDeviceSpecifier = strdup(alcDeviceList ? alcDeviceList : "");
if(!alcDefaultDeviceSpecifier)
- alcSetError(ALC_OUT_OF_MEMORY);
+ alcSetError(pDevice, ALC_OUT_OF_MEMORY);
value = alcDefaultDeviceSpecifier;
break;
@@ -866,7 +870,7 @@ ALCAPI const ALCchar* ALCAPIENTRY alcGetString(ALCdevice *pDevice,ALCenum param)
alcDefaultAllDeviceSpecifier = strdup(alcAllDeviceList ?
alcAllDeviceList : "");
if(!alcDefaultAllDeviceSpecifier)
- alcSetError(ALC_OUT_OF_MEMORY);
+ alcSetError(pDevice, ALC_OUT_OF_MEMORY);
value = alcDefaultAllDeviceSpecifier;
break;
@@ -875,7 +879,7 @@ ALCAPI const ALCchar* ALCAPIENTRY alcGetString(ALCdevice *pDevice,ALCenum param)
alcCaptureDefaultDeviceSpecifier = strdup(alcCaptureDeviceList ?
alcCaptureDeviceList : "");
if(!alcCaptureDefaultDeviceSpecifier)
- alcSetError(ALC_OUT_OF_MEMORY);
+ alcSetError(pDevice, ALC_OUT_OF_MEMORY);
value = alcCaptureDefaultDeviceSpecifier;
break;
@@ -884,7 +888,7 @@ ALCAPI const ALCchar* ALCAPIENTRY alcGetString(ALCdevice *pDevice,ALCenum param)
break;
default:
- alcSetError(ALC_INVALID_ENUM);
+ alcSetError(pDevice, ALC_INVALID_ENUM);
break;
}
@@ -910,18 +914,18 @@ ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsize
if ((size) && (data))
*data = ALCdevice_AvailableSamples(device);
else
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
break;
case ALC_CONNECTED:
if(size <= 0)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
*data = device->Connected;
break;
default:
- alcSetError(ALC_INVALID_ENUM);
+ alcSetError(device, ALC_INVALID_ENUM);
break;
}
@@ -936,53 +940,53 @@ ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsize
{
case ALC_MAJOR_VERSION:
if(size <= 0)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
*data = alcMajorVersion;
break;
case ALC_MINOR_VERSION:
if(size <= 0)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
*data = alcMinorVersion;
break;
case ALC_EFX_MAJOR_VERSION:
if(size <= 0)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
*data = alcEFXMajorVersion;
break;
case ALC_EFX_MINOR_VERSION:
if(size <= 0)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
*data = alcEFXMinorVersion;
break;
case ALC_MAX_AUXILIARY_SENDS:
if(size <= 0)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
*data = (device?device->NumAuxSends:MAX_SENDS);
break;
case ALC_ATTRIBUTES_SIZE:
if(!IsDevice(device))
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(device, ALC_INVALID_DEVICE);
else if(size <= 0)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
*data = 13;
break;
case ALC_ALL_ATTRIBUTES:
if(!IsDevice(device))
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(device, ALC_INVALID_DEVICE);
else if (size < 13)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
{
int i = 0;
@@ -1013,65 +1017,65 @@ ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsize
case ALC_FREQUENCY:
if(!IsDevice(device))
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(device, ALC_INVALID_DEVICE);
else if(size <= 0)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
*data = device->Frequency;
break;
case ALC_REFRESH:
if(!IsDevice(device))
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(device, ALC_INVALID_DEVICE);
else if(size <= 0)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
*data = device->Frequency / device->UpdateSize;
break;
case ALC_SYNC:
if(!IsDevice(device))
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(device, ALC_INVALID_DEVICE);
else if(size <= 0)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
*data = ALC_FALSE;
break;
case ALC_MONO_SOURCES:
if(!IsDevice(device))
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(device, ALC_INVALID_DEVICE);
else if(size <= 0)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
*data = device->lNumMonoSources;
break;
case ALC_STEREO_SOURCES:
if(!IsDevice(device))
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(device, ALC_INVALID_DEVICE);
else if(size <= 0)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
*data = device->lNumStereoSources;
break;
case ALC_CONNECTED:
if(!IsDevice(device))
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(device, ALC_INVALID_DEVICE);
else if(size <= 0)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
else
*data = device->Connected;
break;
default:
- alcSetError(ALC_INVALID_ENUM);
+ alcSetError(device, ALC_INVALID_ENUM);
break;
}
}
else if(size)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
}
return;
@@ -1087,8 +1091,6 @@ ALCAPI ALCboolean ALCAPIENTRY alcIsExtensionPresent(ALCdevice *device, const ALC
{
ALCboolean bResult = ALC_FALSE;
- (void)device;
-
if (extName)
{
const char *ptr;
@@ -1113,7 +1115,7 @@ ALCAPI ALCboolean ALCAPIENTRY alcIsExtensionPresent(ALCdevice *device, const ALC
}
}
else
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
return bResult;
}
@@ -1129,8 +1131,6 @@ ALCAPI ALCvoid * ALCAPIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar
ALCvoid *pFunction = NULL;
ALsizei i = 0;
- (void)device;
-
if (funcName)
{
while(alcFunctions[i].funcName &&
@@ -1139,7 +1139,7 @@ ALCAPI ALCvoid * ALCAPIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar
pFunction = alcFunctions[i].address;
}
else
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
return pFunction;
}
@@ -1155,14 +1155,12 @@ ALCAPI ALCenum ALCAPIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enu
ALsizei i = 0;
ALCenum val;
- (void)device;
-
while ((enumeration[i].enumName)&&(strcmp(enumeration[i].enumName,enumName)))
i++;
val = enumeration[i].value;
if(!enumeration[i].enumName)
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
return val;
}
@@ -1184,13 +1182,13 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
if(!IsDevice(device) || device->IsCaptureDevice || !device->Connected)
{
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(device, ALC_INVALID_DEVICE);
ProcessContext(NULL);
return NULL;
}
// Reset Context Last Error code
- g_eLastContextError = ALC_NO_ERROR;
+ device->LastError = ALC_NO_ERROR;
// If a context is already running on the device, stop playback so the
// device attributes can be updated
@@ -1251,7 +1249,7 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
if(ALCdevice_ResetPlayback(device) == ALC_FALSE)
{
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(device, ALC_INVALID_DEVICE);
aluHandleDisconnect(device);
ProcessContext(NULL);
return NULL;
@@ -1271,7 +1269,7 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
if(ALEffect_DeviceUpdate(slot->EffectState, device) == AL_FALSE)
{
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(device, ALC_INVALID_DEVICE);
aluHandleDisconnect(device);
ProcessContext(context);
ProcessContext(NULL);
@@ -1318,7 +1316,7 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
temp = realloc(device->Contexts, (device->NumContexts+1) * sizeof(*device->Contexts));
if(!temp)
{
- alcSetError(ALC_OUT_OF_MEMORY);
+ alcSetError(device, ALC_OUT_OF_MEMORY);
ProcessContext(NULL);
return NULL;
}
@@ -1327,7 +1325,7 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
ALContext = calloc(1, sizeof(ALCcontext));
if(!ALContext)
{
- alcSetError(ALC_OUT_OF_MEMORY);
+ alcSetError(device, ALC_OUT_OF_MEMORY);
ProcessContext(NULL);
return NULL;
}
@@ -1414,7 +1412,7 @@ ALCAPI ALCvoid ALCAPIENTRY alcDestroyContext(ALCcontext *context)
free(context);
}
else
- alcSetError(ALC_INVALID_CONTEXT);
+ alcSetError(NULL, ALC_INVALID_CONTEXT);
}
@@ -1470,7 +1468,7 @@ ALCAPI ALCdevice* ALCAPIENTRY alcGetContextsDevice(ALCcontext *pContext)
if (IsContext(pContext))
pDevice = pContext->Device;
else
- alcSetError(ALC_INVALID_CONTEXT);
+ alcSetError(NULL, ALC_INVALID_CONTEXT);
ProcessContext(NULL);
return pDevice;
@@ -1509,7 +1507,7 @@ ALCAPI ALCboolean ALCAPIENTRY alcMakeContextCurrent(ALCcontext *context)
}
else
{
- alcSetError(ALC_INVALID_CONTEXT);
+ alcSetError(NULL, ALC_INVALID_CONTEXT);
bReturn = AL_FALSE;
}
@@ -1534,7 +1532,7 @@ ALCboolean ALCAPIENTRY alcMakeCurrent(ALCcontext *context)
tls_set(LocalContext, context);
else
{
- alcSetError(ALC_INVALID_CONTEXT);
+ alcSetError(NULL, ALC_INVALID_CONTEXT);
bReturn = AL_FALSE;
}
@@ -1677,6 +1675,7 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
//Validate device
device->Connected = ALC_TRUE;
device->IsCaptureDevice = AL_FALSE;
+ device->LastError = ALC_NO_ERROR;
device->Bs2b = NULL;
device->szDeviceName = NULL;
@@ -1749,13 +1748,13 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
if (!bDeviceFound)
{
// No suitable output device found
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(NULL, ALC_INVALID_VALUE);
free(device);
device = NULL;
}
}
else
- alcSetError(ALC_OUT_OF_MEMORY);
+ alcSetError(NULL, ALC_OUT_OF_MEMORY);
return device;
}
@@ -1839,7 +1838,7 @@ ALCAPI ALCboolean ALCAPIENTRY alcCloseDevice(ALCdevice *pDevice)
bReturn = ALC_TRUE;
}
else
- alcSetError(ALC_INVALID_DEVICE);
+ alcSetError(pDevice, ALC_INVALID_DEVICE);
return bReturn;
}
diff --git a/Alc/alsa.c b/Alc/alsa.c
index 460a1cd9..cc7bef27 100644
--- a/Alc/alsa.c
+++ b/Alc/alsa.c
@@ -915,7 +915,7 @@ static void alsa_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint l
if(lSamples <= (ALCuint)RingBufferSize(data->ring))
ReadRingBuffer(data->ring, pBuffer, lSamples);
else
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(pDevice, ALC_INVALID_VALUE);
}
static ALCuint alsa_available_samples(ALCdevice *pDevice)
diff --git a/Alc/dsound.c b/Alc/dsound.c
index ac54b487..43935def 100644
--- a/Alc/dsound.c
+++ b/Alc/dsound.c
@@ -233,7 +233,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
pData = calloc(1, sizeof(DSoundData));
if(!pData)
{
- alcSetError(ALC_OUT_OF_MEMORY);
+ alcSetError(device, ALC_OUT_OF_MEMORY);
DSoundUnload();
return ALC_FALSE;
}
diff --git a/Alc/oss.c b/Alc/oss.c
index 64cf23c6..d0dbff80 100644
--- a/Alc/oss.c
+++ b/Alc/oss.c
@@ -457,7 +457,7 @@ static void oss_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lS
if(lSamples <= (ALCuint)RingBufferSize(data->ring))
ReadRingBuffer(data->ring, pBuffer, lSamples);
else
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(pDevice, ALC_INVALID_VALUE);
}
static ALCuint oss_available_samples(ALCdevice *pDevice)
diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c
index 9faead99..c010369e 100644
--- a/Alc/pulseaudio.c
+++ b/Alc/pulseaudio.c
@@ -910,7 +910,7 @@ static void pulse_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint sa
if(available+ppa_stream_readable_size(data->stream) < samples)
{
ppa_threaded_mainloop_unlock(data->loop);
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(device, ALC_INVALID_VALUE);
return;
}
diff --git a/Alc/winmm.c b/Alc/winmm.c
index bf3c1887..6dd88191 100644
--- a/Alc/winmm.c
+++ b/Alc/winmm.c
@@ -202,7 +202,7 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
pData = calloc(1, sizeof(*pData));
if(!pData)
{
- alcSetError(ALC_OUT_OF_MEMORY);
+ alcSetError(pDevice, ALC_OUT_OF_MEMORY);
return ALC_FALSE;
}
@@ -373,7 +373,7 @@ static void WinMMCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lS
frameSize;
if(ulSamples > ulCapturedSamples)
{
- alcSetError(ALC_INVALID_VALUE);
+ alcSetError(pDevice, ALC_INVALID_VALUE);
return;
}
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 87eb2576..c580bf5f 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -257,6 +257,8 @@ struct ALCdevice_struct
ALCchar *szDeviceName;
+ ALCenum LastError;
+
// Maximum number of sources that can be created
ALuint MaxNoOfSources;
// Maximum number of slots that can be created
@@ -359,7 +361,7 @@ void AppendDeviceList(const ALCchar *name);
void AppendAllDeviceList(const ALCchar *name);
void AppendCaptureDeviceList(const ALCchar *name);
-ALCvoid alcSetError(ALenum errorCode);
+ALCvoid alcSetError(ALCdevice *device, ALenum errorCode);
ALCvoid SuspendContext(ALCcontext *context);
ALCvoid ProcessContext(ALCcontext *context);