summaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-10-24 19:58:49 -0700
committerChris Robinson <[email protected]>2008-10-24 19:58:49 -0700
commit8fc4a3b724df11ee7a54780d0e5a89d5d91f0fd9 (patch)
tree45168943c71bf836787091cb9455905c14e13a75 /Alc
parentcb6f040005bec32bfa2f3c9e9f1806572de1d936 (diff)
Make sure an appropriate error is set when opening a device fails
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 223a000e..ab0c7921 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -487,44 +487,46 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL
InitAL();
+ if(SampleSize > 0)
+ {
+ SetALCError(ALC_INVALID_VALUE);
+ return NULL;
+ }
+
if(deviceName && !deviceName[0])
deviceName = NULL;
pDevice = malloc(sizeof(ALCdevice));
if (pDevice)
{
- if (SampleSize > 0)
- {
- //Initialise device structure
- memset(pDevice, 0, sizeof(ALCdevice));
+ //Initialise device structure
+ memset(pDevice, 0, sizeof(ALCdevice));
- //Validate device
- pDevice->IsCaptureDevice = AL_TRUE;
+ //Validate device
+ pDevice->IsCaptureDevice = AL_TRUE;
- pDevice->Frequency = frequency;
- pDevice->Format = format;
+ pDevice->Frequency = frequency;
+ pDevice->Format = format;
- for(i = 0;BackendList[i].Init;i++)
+ for(i = 0;BackendList[i].Init;i++)
+ {
+ pDevice->Funcs = &BackendList[i].Funcs;
+ if(ALCdevice_OpenCapture(pDevice, deviceName, frequency, format, SampleSize))
{
- pDevice->Funcs = &BackendList[i].Funcs;
- if(ALCdevice_OpenCapture(pDevice, deviceName, frequency, format, SampleSize))
- {
- SuspendContext(NULL);
- pDevice->next = g_pDeviceList;
- g_pDeviceList = pDevice;
- g_ulDeviceCount++;
- ProcessContext(NULL);
+ SuspendContext(NULL);
+ pDevice->next = g_pDeviceList;
+ g_pDeviceList = pDevice;
+ g_ulDeviceCount++;
+ ProcessContext(NULL);
- DeviceFound = ALC_TRUE;
- break;
- }
+ DeviceFound = ALC_TRUE;
+ break;
}
}
- else
- SetALCError(ALC_INVALID_VALUE);
if(!DeviceFound)
{
+ SetALCError(ALC_INVALID_VALUE);
free(pDevice);
pDevice = NULL;
}
@@ -1249,10 +1251,13 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
if (!bDeviceFound)
{
// No suitable output device found
+ SetALCError(ALC_INVALID_VALUE);
free(device);
device = NULL;
}
}
+ else
+ SetALCError(ALC_OUT_OF_MEMORY);
return device;
}