Reduce some indentation
This commit is contained in:
parent
52f82f0b94
commit
2235a53824
164
Alc/ALc.c
164
Alc/ALc.c
@ -673,7 +673,7 @@ static ALCvoid ExitContext(ALCcontext *pContext)
|
||||
ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei SampleSize)
|
||||
{
|
||||
ALCboolean DeviceFound = ALC_FALSE;
|
||||
ALCdevice *pDevice = NULL;
|
||||
ALCdevice *device = NULL;
|
||||
ALCint i;
|
||||
|
||||
if(SampleSize <= 0)
|
||||
@ -685,31 +685,32 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName,
|
||||
if(deviceName && !deviceName[0])
|
||||
deviceName = NULL;
|
||||
|
||||
pDevice = malloc(sizeof(ALCdevice));
|
||||
if (pDevice)
|
||||
device = calloc(1, sizeof(ALCdevice));
|
||||
if(!device)
|
||||
{
|
||||
//Initialise device structure
|
||||
memset(pDevice, 0, sizeof(ALCdevice));
|
||||
alcSetError(NULL, ALC_OUT_OF_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Validate device
|
||||
pDevice->Connected = ALC_TRUE;
|
||||
pDevice->IsCaptureDevice = AL_TRUE;
|
||||
device->Connected = ALC_TRUE;
|
||||
device->IsCaptureDevice = AL_TRUE;
|
||||
|
||||
pDevice->szDeviceName = NULL;
|
||||
device->szDeviceName = NULL;
|
||||
|
||||
pDevice->Frequency = frequency;
|
||||
pDevice->Format = format;
|
||||
pDevice->UpdateSize = SampleSize;
|
||||
pDevice->NumUpdates = 1;
|
||||
device->Frequency = frequency;
|
||||
device->Format = format;
|
||||
device->UpdateSize = SampleSize;
|
||||
device->NumUpdates = 1;
|
||||
|
||||
SuspendContext(NULL);
|
||||
for(i = 0;BackendList[i].Init;i++)
|
||||
{
|
||||
pDevice->Funcs = &BackendList[i].Funcs;
|
||||
if(ALCdevice_OpenCapture(pDevice, deviceName))
|
||||
device->Funcs = &BackendList[i].Funcs;
|
||||
if(ALCdevice_OpenCapture(device, deviceName))
|
||||
{
|
||||
pDevice->next = g_pDeviceList;
|
||||
g_pDeviceList = pDevice;
|
||||
device->next = g_pDeviceList;
|
||||
g_pDeviceList = device;
|
||||
g_ulDeviceCount++;
|
||||
|
||||
DeviceFound = ALC_TRUE;
|
||||
@ -721,23 +722,23 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName,
|
||||
if(!DeviceFound)
|
||||
{
|
||||
alcSetError(NULL, ALC_INVALID_VALUE);
|
||||
free(pDevice);
|
||||
pDevice = NULL;
|
||||
free(device);
|
||||
device = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
alcSetError(NULL, ALC_OUT_OF_MEMORY);
|
||||
|
||||
return pDevice;
|
||||
return device;
|
||||
}
|
||||
|
||||
ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *pDevice)
|
||||
{
|
||||
ALCboolean bReturn = ALC_FALSE;
|
||||
ALCdevice **list;
|
||||
|
||||
if(IsDevice(pDevice) && pDevice->IsCaptureDevice)
|
||||
if(!IsDevice(pDevice) || !pDevice->IsCaptureDevice)
|
||||
{
|
||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
SuspendContext(NULL);
|
||||
|
||||
list = &g_pDeviceList;
|
||||
@ -756,48 +757,43 @@ ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *pDevice)
|
||||
|
||||
free(pDevice);
|
||||
|
||||
bReturn = ALC_TRUE;
|
||||
}
|
||||
else
|
||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
||||
|
||||
return bReturn;
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *pDevice)
|
||||
ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device)
|
||||
{
|
||||
if(IsDevice(pDevice) && pDevice->IsCaptureDevice)
|
||||
if(!IsDevice(device) || !device->IsCaptureDevice)
|
||||
{
|
||||
alcSetError(device, ALC_INVALID_DEVICE);
|
||||
return;
|
||||
}
|
||||
SuspendContext(NULL);
|
||||
ALCdevice_StartCapture(pDevice);
|
||||
ALCdevice_StartCapture(device);
|
||||
ProcessContext(NULL);
|
||||
}
|
||||
else
|
||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
||||
}
|
||||
|
||||
ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *pDevice)
|
||||
ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device)
|
||||
{
|
||||
if(IsDevice(pDevice) && pDevice->IsCaptureDevice)
|
||||
if(!IsDevice(device) || !device->IsCaptureDevice)
|
||||
{
|
||||
alcSetError(device, ALC_INVALID_DEVICE);
|
||||
return;
|
||||
}
|
||||
SuspendContext(NULL);
|
||||
ALCdevice_StopCapture(pDevice);
|
||||
ALCdevice_StopCapture(device);
|
||||
ProcessContext(NULL);
|
||||
}
|
||||
else
|
||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
||||
}
|
||||
|
||||
ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCsizei lSamples)
|
||||
ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples)
|
||||
{
|
||||
if(IsDevice(pDevice) && pDevice->IsCaptureDevice)
|
||||
if(!IsDevice(device) || !device->IsCaptureDevice)
|
||||
{
|
||||
SuspendContext(NULL);
|
||||
ALCdevice_CaptureSamples(pDevice, pBuffer, lSamples);
|
||||
ProcessContext(NULL);
|
||||
alcSetError(device, ALC_INVALID_DEVICE);
|
||||
return;
|
||||
}
|
||||
else
|
||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
||||
SuspendContext(NULL);
|
||||
ALCdevice_CaptureSamples(device, buffer, samples);
|
||||
ProcessContext(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1123,12 +1119,15 @@ ALC_API ALCvoid ALC_APIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsi
|
||||
ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extName)
|
||||
{
|
||||
ALCboolean bResult = ALC_FALSE;
|
||||
|
||||
if (extName)
|
||||
{
|
||||
const char *ptr;
|
||||
size_t len;
|
||||
|
||||
if(!extName)
|
||||
{
|
||||
alcSetError(device, ALC_INVALID_VALUE);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
len = strlen(extName);
|
||||
ptr = (IsDevice(device) ? alcExtensionList : alcNoDeviceExtList);
|
||||
while(ptr && *ptr)
|
||||
@ -1146,9 +1145,6 @@ ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const A
|
||||
} while(isspace(*ptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
alcSetError(device, ALC_INVALID_VALUE);
|
||||
|
||||
return bResult;
|
||||
}
|
||||
@ -1161,20 +1157,17 @@ ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const A
|
||||
*/
|
||||
ALC_API ALCvoid* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcName)
|
||||
{
|
||||
ALCvoid *pFunction = NULL;
|
||||
ALsizei i = 0;
|
||||
|
||||
if (funcName)
|
||||
if(!funcName)
|
||||
{
|
||||
while(alcFunctions[i].funcName &&
|
||||
strcmp(alcFunctions[i].funcName,funcName) != 0)
|
||||
i++;
|
||||
pFunction = alcFunctions[i].address;
|
||||
}
|
||||
else
|
||||
alcSetError(device, ALC_INVALID_VALUE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pFunction;
|
||||
while(alcFunctions[i].funcName && strcmp(alcFunctions[i].funcName,funcName) != 0)
|
||||
i++;
|
||||
return alcFunctions[i].address;
|
||||
}
|
||||
|
||||
|
||||
@ -1188,7 +1181,7 @@ ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *e
|
||||
ALsizei i = 0;
|
||||
ALCenum val;
|
||||
|
||||
while ((enumeration[i].enumName)&&(strcmp(enumeration[i].enumName,enumName)))
|
||||
while(enumeration[i].enumName && strcmp(enumeration[i].enumName,enumName) == 0)
|
||||
i++;
|
||||
val = enumeration[i].value;
|
||||
|
||||
@ -1389,12 +1382,17 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
|
||||
*/
|
||||
ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context)
|
||||
{
|
||||
ALCdevice *Device;
|
||||
ALCcontext **list;
|
||||
ALuint i;
|
||||
|
||||
if (IsContext(context))
|
||||
if(!IsContext(context))
|
||||
{
|
||||
ALCdevice *Device = context->Device;
|
||||
alcSetError(NULL, ALC_INVALID_CONTEXT);
|
||||
return;
|
||||
}
|
||||
|
||||
Device = context->Device;
|
||||
|
||||
if(Device->NumContexts == 1)
|
||||
ALCdevice_StopPlayback(Device);
|
||||
@ -1446,9 +1444,6 @@ ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context)
|
||||
memset(context, 0, sizeof(ALCcontext));
|
||||
free(context);
|
||||
}
|
||||
else
|
||||
alcSetError(NULL, ALC_INVALID_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -1698,19 +1693,19 @@ static ALenum GetFormatFromString(const char *str)
|
||||
ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
|
||||
{
|
||||
ALboolean bDeviceFound = AL_FALSE;
|
||||
const ALCchar *fmt;
|
||||
ALCdevice *device;
|
||||
ALint i;
|
||||
|
||||
if(deviceName && !deviceName[0])
|
||||
deviceName = NULL;
|
||||
|
||||
device = malloc(sizeof(ALCdevice));
|
||||
if (device)
|
||||
device = calloc(1, sizeof(ALCdevice));
|
||||
if(!device)
|
||||
{
|
||||
const char *fmt;
|
||||
|
||||
//Initialise device structure
|
||||
memset(device, 0, sizeof(ALCdevice));
|
||||
alcSetError(NULL, ALC_OUT_OF_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Validate device
|
||||
device->Connected = ALC_TRUE;
|
||||
@ -1792,9 +1787,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
|
||||
free(device);
|
||||
device = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
alcSetError(NULL, ALC_OUT_OF_MEMORY);
|
||||
|
||||
return device;
|
||||
}
|
||||
@ -1807,11 +1799,14 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
|
||||
*/
|
||||
ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *pDevice)
|
||||
{
|
||||
ALCboolean bReturn = ALC_FALSE;
|
||||
ALCdevice **list;
|
||||
|
||||
if(IsDevice(pDevice) && !pDevice->IsCaptureDevice)
|
||||
if(!IsDevice(pDevice) || pDevice->IsCaptureDevice)
|
||||
{
|
||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
SuspendContext(NULL);
|
||||
|
||||
list = &g_pDeviceList;
|
||||
@ -1875,12 +1870,7 @@ ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *pDevice)
|
||||
memset(pDevice, 0, sizeof(ALCdevice));
|
||||
free(pDevice);
|
||||
|
||||
bReturn = ALC_TRUE;
|
||||
}
|
||||
else
|
||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
||||
|
||||
return bReturn;
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user