Reduce some indentation
This commit is contained in:
parent
52f82f0b94
commit
2235a53824
606
Alc/ALc.c
606
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)
|
ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei SampleSize)
|
||||||
{
|
{
|
||||||
ALCboolean DeviceFound = ALC_FALSE;
|
ALCboolean DeviceFound = ALC_FALSE;
|
||||||
ALCdevice *pDevice = NULL;
|
ALCdevice *device = NULL;
|
||||||
ALCint i;
|
ALCint i;
|
||||||
|
|
||||||
if(SampleSize <= 0)
|
if(SampleSize <= 0)
|
||||||
@ -685,119 +685,115 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName,
|
|||||||
if(deviceName && !deviceName[0])
|
if(deviceName && !deviceName[0])
|
||||||
deviceName = NULL;
|
deviceName = NULL;
|
||||||
|
|
||||||
pDevice = malloc(sizeof(ALCdevice));
|
device = calloc(1, sizeof(ALCdevice));
|
||||||
if (pDevice)
|
if(!device)
|
||||||
{
|
{
|
||||||
//Initialise device structure
|
alcSetError(NULL, ALC_OUT_OF_MEMORY);
|
||||||
memset(pDevice, 0, sizeof(ALCdevice));
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
//Validate device
|
//Validate device
|
||||||
pDevice->Connected = ALC_TRUE;
|
device->Connected = ALC_TRUE;
|
||||||
pDevice->IsCaptureDevice = AL_TRUE;
|
device->IsCaptureDevice = AL_TRUE;
|
||||||
|
|
||||||
pDevice->szDeviceName = NULL;
|
device->szDeviceName = NULL;
|
||||||
|
|
||||||
pDevice->Frequency = frequency;
|
device->Frequency = frequency;
|
||||||
pDevice->Format = format;
|
device->Format = format;
|
||||||
pDevice->UpdateSize = SampleSize;
|
device->UpdateSize = SampleSize;
|
||||||
pDevice->NumUpdates = 1;
|
device->NumUpdates = 1;
|
||||||
|
|
||||||
SuspendContext(NULL);
|
SuspendContext(NULL);
|
||||||
for(i = 0;BackendList[i].Init;i++)
|
for(i = 0;BackendList[i].Init;i++)
|
||||||
|
{
|
||||||
|
device->Funcs = &BackendList[i].Funcs;
|
||||||
|
if(ALCdevice_OpenCapture(device, deviceName))
|
||||||
{
|
{
|
||||||
pDevice->Funcs = &BackendList[i].Funcs;
|
device->next = g_pDeviceList;
|
||||||
if(ALCdevice_OpenCapture(pDevice, deviceName))
|
g_pDeviceList = device;
|
||||||
{
|
g_ulDeviceCount++;
|
||||||
pDevice->next = g_pDeviceList;
|
|
||||||
g_pDeviceList = pDevice;
|
|
||||||
g_ulDeviceCount++;
|
|
||||||
|
|
||||||
DeviceFound = ALC_TRUE;
|
DeviceFound = ALC_TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
|
||||||
ProcessContext(NULL);
|
|
||||||
|
|
||||||
if(!DeviceFound)
|
|
||||||
{
|
|
||||||
alcSetError(NULL, ALC_INVALID_VALUE);
|
|
||||||
free(pDevice);
|
|
||||||
pDevice = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
ProcessContext(NULL);
|
||||||
alcSetError(NULL, ALC_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
return pDevice;
|
if(!DeviceFound)
|
||||||
|
{
|
||||||
|
alcSetError(NULL, ALC_INVALID_VALUE);
|
||||||
|
free(device);
|
||||||
|
device = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *pDevice)
|
ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *pDevice)
|
||||||
{
|
{
|
||||||
ALCboolean bReturn = ALC_FALSE;
|
|
||||||
ALCdevice **list;
|
ALCdevice **list;
|
||||||
|
|
||||||
if(IsDevice(pDevice) && pDevice->IsCaptureDevice)
|
if(!IsDevice(pDevice) || !pDevice->IsCaptureDevice)
|
||||||
{
|
{
|
||||||
SuspendContext(NULL);
|
|
||||||
|
|
||||||
list = &g_pDeviceList;
|
|
||||||
while(*list != pDevice)
|
|
||||||
list = &(*list)->next;
|
|
||||||
|
|
||||||
*list = (*list)->next;
|
|
||||||
g_ulDeviceCount--;
|
|
||||||
|
|
||||||
ProcessContext(NULL);
|
|
||||||
|
|
||||||
ALCdevice_CloseCapture(pDevice);
|
|
||||||
|
|
||||||
free(pDevice->szDeviceName);
|
|
||||||
pDevice->szDeviceName = NULL;
|
|
||||||
|
|
||||||
free(pDevice);
|
|
||||||
|
|
||||||
bReturn = ALC_TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
||||||
|
return ALC_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
return bReturn;
|
SuspendContext(NULL);
|
||||||
|
|
||||||
|
list = &g_pDeviceList;
|
||||||
|
while(*list != pDevice)
|
||||||
|
list = &(*list)->next;
|
||||||
|
|
||||||
|
*list = (*list)->next;
|
||||||
|
g_ulDeviceCount--;
|
||||||
|
|
||||||
|
ProcessContext(NULL);
|
||||||
|
|
||||||
|
ALCdevice_CloseCapture(pDevice);
|
||||||
|
|
||||||
|
free(pDevice->szDeviceName);
|
||||||
|
pDevice->szDeviceName = NULL;
|
||||||
|
|
||||||
|
free(pDevice);
|
||||||
|
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
SuspendContext(NULL);
|
alcSetError(device, ALC_INVALID_DEVICE);
|
||||||
ALCdevice_StartCapture(pDevice);
|
return;
|
||||||
ProcessContext(NULL);
|
|
||||||
}
|
}
|
||||||
else
|
SuspendContext(NULL);
|
||||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
ALCdevice_StartCapture(device);
|
||||||
|
ProcessContext(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
SuspendContext(NULL);
|
alcSetError(device, ALC_INVALID_DEVICE);
|
||||||
ALCdevice_StopCapture(pDevice);
|
return;
|
||||||
ProcessContext(NULL);
|
|
||||||
}
|
}
|
||||||
else
|
SuspendContext(NULL);
|
||||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
ALCdevice_StopCapture(device);
|
||||||
|
ProcessContext(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
alcSetError(device, ALC_INVALID_DEVICE);
|
||||||
ALCdevice_CaptureSamples(pDevice, pBuffer, lSamples);
|
return;
|
||||||
ProcessContext(NULL);
|
|
||||||
}
|
}
|
||||||
else
|
SuspendContext(NULL);
|
||||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
ALCdevice_CaptureSamples(device, buffer, samples);
|
||||||
|
ProcessContext(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1123,32 +1119,32 @@ ALC_API ALCvoid ALC_APIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsi
|
|||||||
ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extName)
|
ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extName)
|
||||||
{
|
{
|
||||||
ALCboolean bResult = ALC_FALSE;
|
ALCboolean bResult = ALC_FALSE;
|
||||||
|
const char *ptr;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if (extName)
|
if(!extName)
|
||||||
{
|
{
|
||||||
const char *ptr;
|
alcSetError(device, ALC_INVALID_VALUE);
|
||||||
size_t len;
|
return ALC_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
len = strlen(extName);
|
len = strlen(extName);
|
||||||
ptr = (IsDevice(device) ? alcExtensionList : alcNoDeviceExtList);
|
ptr = (IsDevice(device) ? alcExtensionList : alcNoDeviceExtList);
|
||||||
while(ptr && *ptr)
|
while(ptr && *ptr)
|
||||||
|
{
|
||||||
|
if(strncasecmp(ptr, extName, len) == 0 &&
|
||||||
|
(ptr[len] == '\0' || isspace(ptr[len])))
|
||||||
{
|
{
|
||||||
if(strncasecmp(ptr, extName, len) == 0 &&
|
bResult = ALC_TRUE;
|
||||||
(ptr[len] == '\0' || isspace(ptr[len])))
|
break;
|
||||||
{
|
}
|
||||||
bResult = ALC_TRUE;
|
if((ptr=strchr(ptr, ' ')) != NULL)
|
||||||
break;
|
{
|
||||||
}
|
do {
|
||||||
if((ptr=strchr(ptr, ' ')) != NULL)
|
++ptr;
|
||||||
{
|
} while(isspace(*ptr));
|
||||||
do {
|
|
||||||
++ptr;
|
|
||||||
} while(isspace(*ptr));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
alcSetError(device, ALC_INVALID_VALUE);
|
|
||||||
|
|
||||||
return bResult;
|
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)
|
ALC_API ALCvoid* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcName)
|
||||||
{
|
{
|
||||||
ALCvoid *pFunction = NULL;
|
|
||||||
ALsizei i = 0;
|
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);
|
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;
|
ALsizei i = 0;
|
||||||
ALCenum val;
|
ALCenum val;
|
||||||
|
|
||||||
while ((enumeration[i].enumName)&&(strcmp(enumeration[i].enumName,enumName)))
|
while(enumeration[i].enumName && strcmp(enumeration[i].enumName,enumName) == 0)
|
||||||
i++;
|
i++;
|
||||||
val = enumeration[i].value;
|
val = enumeration[i].value;
|
||||||
|
|
||||||
@ -1389,65 +1382,67 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
|
|||||||
*/
|
*/
|
||||||
ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context)
|
ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context)
|
||||||
{
|
{
|
||||||
|
ALCdevice *Device;
|
||||||
ALCcontext **list;
|
ALCcontext **list;
|
||||||
ALuint i;
|
ALuint i;
|
||||||
|
|
||||||
if (IsContext(context))
|
if(!IsContext(context))
|
||||||
{
|
{
|
||||||
ALCdevice *Device = context->Device;
|
|
||||||
|
|
||||||
if(Device->NumContexts == 1)
|
|
||||||
ALCdevice_StopPlayback(Device);
|
|
||||||
|
|
||||||
SuspendContext(NULL);
|
|
||||||
|
|
||||||
for(i = 0;i < Device->NumContexts-1;i++)
|
|
||||||
{
|
|
||||||
if(Device->Contexts[i] == context)
|
|
||||||
{
|
|
||||||
Device->Contexts[i] = Device->Contexts[Device->NumContexts-1];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Device->NumContexts--;
|
|
||||||
|
|
||||||
// Lock context
|
|
||||||
SuspendContext(context);
|
|
||||||
|
|
||||||
if(context->SourceCount > 0)
|
|
||||||
{
|
|
||||||
#ifdef _DEBUG
|
|
||||||
AL_PRINT("alcDestroyContext(): deleting %d Source(s)\n", context->SourceCount);
|
|
||||||
#endif
|
|
||||||
ReleaseALSources(context);
|
|
||||||
}
|
|
||||||
if(context->EffectSlotCount > 0)
|
|
||||||
{
|
|
||||||
#ifdef _DEBUG
|
|
||||||
AL_PRINT("alcDestroyContext(): deleting %d AuxiliaryEffectSlot(s)\n", context->EffectSlotCount);
|
|
||||||
#endif
|
|
||||||
ReleaseALAuxiliaryEffectSlots(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
list = &g_pContextList;
|
|
||||||
while(*list != context)
|
|
||||||
list = &(*list)->next;
|
|
||||||
|
|
||||||
*list = (*list)->next;
|
|
||||||
g_ulContextCount--;
|
|
||||||
|
|
||||||
// Unlock context
|
|
||||||
ProcessContext(context);
|
|
||||||
ProcessContext(NULL);
|
|
||||||
|
|
||||||
ExitContext(context);
|
|
||||||
|
|
||||||
// Free memory (MUST do this after ProcessContext)
|
|
||||||
memset(context, 0, sizeof(ALCcontext));
|
|
||||||
free(context);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
alcSetError(NULL, ALC_INVALID_CONTEXT);
|
alcSetError(NULL, ALC_INVALID_CONTEXT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Device = context->Device;
|
||||||
|
|
||||||
|
if(Device->NumContexts == 1)
|
||||||
|
ALCdevice_StopPlayback(Device);
|
||||||
|
|
||||||
|
SuspendContext(NULL);
|
||||||
|
|
||||||
|
for(i = 0;i < Device->NumContexts-1;i++)
|
||||||
|
{
|
||||||
|
if(Device->Contexts[i] == context)
|
||||||
|
{
|
||||||
|
Device->Contexts[i] = Device->Contexts[Device->NumContexts-1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Device->NumContexts--;
|
||||||
|
|
||||||
|
// Lock context
|
||||||
|
SuspendContext(context);
|
||||||
|
|
||||||
|
if(context->SourceCount > 0)
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
AL_PRINT("alcDestroyContext(): deleting %d Source(s)\n", context->SourceCount);
|
||||||
|
#endif
|
||||||
|
ReleaseALSources(context);
|
||||||
|
}
|
||||||
|
if(context->EffectSlotCount > 0)
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
AL_PRINT("alcDestroyContext(): deleting %d AuxiliaryEffectSlot(s)\n", context->EffectSlotCount);
|
||||||
|
#endif
|
||||||
|
ReleaseALAuxiliaryEffectSlots(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
list = &g_pContextList;
|
||||||
|
while(*list != context)
|
||||||
|
list = &(*list)->next;
|
||||||
|
|
||||||
|
*list = (*list)->next;
|
||||||
|
g_ulContextCount--;
|
||||||
|
|
||||||
|
// Unlock context
|
||||||
|
ProcessContext(context);
|
||||||
|
ProcessContext(NULL);
|
||||||
|
|
||||||
|
ExitContext(context);
|
||||||
|
|
||||||
|
// Free memory (MUST do this after ProcessContext)
|
||||||
|
memset(context, 0, sizeof(ALCcontext));
|
||||||
|
free(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1500,7 +1495,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *pContext)
|
|||||||
ALCdevice *pDevice = NULL;
|
ALCdevice *pDevice = NULL;
|
||||||
|
|
||||||
SuspendContext(NULL);
|
SuspendContext(NULL);
|
||||||
if (IsContext(pContext))
|
if(IsContext(pContext))
|
||||||
pDevice = pContext->Device;
|
pDevice = pContext->Device;
|
||||||
else
|
else
|
||||||
alcSetError(NULL, ALC_INVALID_CONTEXT);
|
alcSetError(NULL, ALC_INVALID_CONTEXT);
|
||||||
@ -1698,103 +1693,100 @@ static ALenum GetFormatFromString(const char *str)
|
|||||||
ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
|
ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
|
||||||
{
|
{
|
||||||
ALboolean bDeviceFound = AL_FALSE;
|
ALboolean bDeviceFound = AL_FALSE;
|
||||||
|
const ALCchar *fmt;
|
||||||
ALCdevice *device;
|
ALCdevice *device;
|
||||||
ALint i;
|
ALint i;
|
||||||
|
|
||||||
if(deviceName && !deviceName[0])
|
if(deviceName && !deviceName[0])
|
||||||
deviceName = NULL;
|
deviceName = NULL;
|
||||||
|
|
||||||
device = malloc(sizeof(ALCdevice));
|
device = calloc(1, sizeof(ALCdevice));
|
||||||
if (device)
|
if(!device)
|
||||||
{
|
{
|
||||||
const char *fmt;
|
alcSetError(NULL, ALC_OUT_OF_MEMORY);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
//Initialise device structure
|
//Validate device
|
||||||
memset(device, 0, sizeof(ALCdevice));
|
device->Connected = ALC_TRUE;
|
||||||
|
device->IsCaptureDevice = AL_FALSE;
|
||||||
|
device->LastError = ALC_NO_ERROR;
|
||||||
|
|
||||||
//Validate device
|
device->Bs2b = NULL;
|
||||||
device->Connected = ALC_TRUE;
|
device->szDeviceName = NULL;
|
||||||
device->IsCaptureDevice = AL_FALSE;
|
|
||||||
device->LastError = ALC_NO_ERROR;
|
|
||||||
|
|
||||||
device->Bs2b = NULL;
|
device->Contexts = NULL;
|
||||||
device->szDeviceName = NULL;
|
device->NumContexts = 0;
|
||||||
|
|
||||||
device->Contexts = NULL;
|
//Set output format
|
||||||
device->NumContexts = 0;
|
device->Frequency = GetConfigValueInt(NULL, "frequency", SWMIXER_OUTPUT_RATE);
|
||||||
|
if(device->Frequency < 8000)
|
||||||
|
device->Frequency = 8000;
|
||||||
|
|
||||||
//Set output format
|
fmt = GetConfigValue(NULL, "format", "AL_FORMAT_STEREO16");
|
||||||
device->Frequency = GetConfigValueInt(NULL, "frequency", SWMIXER_OUTPUT_RATE);
|
device->Format = GetFormatFromString(fmt);
|
||||||
if(device->Frequency < 8000)
|
|
||||||
device->Frequency = 8000;
|
|
||||||
|
|
||||||
fmt = GetConfigValue(NULL, "format", "AL_FORMAT_STEREO16");
|
device->NumUpdates = GetConfigValueInt(NULL, "periods", 4);
|
||||||
device->Format = GetFormatFromString(fmt);
|
if(device->NumUpdates < 2)
|
||||||
|
device->NumUpdates = 4;
|
||||||
|
|
||||||
device->NumUpdates = GetConfigValueInt(NULL, "periods", 4);
|
i = GetConfigValueInt(NULL, "refresh", 4096);
|
||||||
if(device->NumUpdates < 2)
|
if(i <= 0) i = 4096;
|
||||||
device->NumUpdates = 4;
|
|
||||||
|
|
||||||
i = GetConfigValueInt(NULL, "refresh", 4096);
|
device->UpdateSize = GetConfigValueInt(NULL, "period_size", i/device->NumUpdates);
|
||||||
if(i <= 0) i = 4096;
|
if(device->UpdateSize <= 0)
|
||||||
|
device->UpdateSize = i/device->NumUpdates;
|
||||||
|
|
||||||
device->UpdateSize = GetConfigValueInt(NULL, "period_size", i/device->NumUpdates);
|
device->MaxNoOfSources = GetConfigValueInt(NULL, "sources", 256);
|
||||||
if(device->UpdateSize <= 0)
|
if((ALint)device->MaxNoOfSources <= 0)
|
||||||
device->UpdateSize = i/device->NumUpdates;
|
device->MaxNoOfSources = 256;
|
||||||
|
|
||||||
device->MaxNoOfSources = GetConfigValueInt(NULL, "sources", 256);
|
device->AuxiliaryEffectSlotMax = GetConfigValueInt(NULL, "slots", 4);
|
||||||
if((ALint)device->MaxNoOfSources <= 0)
|
if((ALint)device->AuxiliaryEffectSlotMax <= 0)
|
||||||
device->MaxNoOfSources = 256;
|
device->AuxiliaryEffectSlotMax = 4;
|
||||||
|
|
||||||
device->AuxiliaryEffectSlotMax = GetConfigValueInt(NULL, "slots", 4);
|
device->lNumStereoSources = 1;
|
||||||
if((ALint)device->AuxiliaryEffectSlotMax <= 0)
|
device->lNumMonoSources = device->MaxNoOfSources - device->lNumStereoSources;
|
||||||
device->AuxiliaryEffectSlotMax = 4;
|
|
||||||
|
|
||||||
device->lNumStereoSources = 1;
|
device->NumAuxSends = GetConfigValueInt(NULL, "sends", MAX_SENDS);
|
||||||
device->lNumMonoSources = device->MaxNoOfSources - device->lNumStereoSources;
|
if(device->NumAuxSends > MAX_SENDS)
|
||||||
|
device->NumAuxSends = MAX_SENDS;
|
||||||
|
|
||||||
device->NumAuxSends = GetConfigValueInt(NULL, "sends", MAX_SENDS);
|
device->Bs2bLevel = GetConfigValueInt(NULL, "cf_level", 0);
|
||||||
if(device->NumAuxSends > MAX_SENDS)
|
|
||||||
device->NumAuxSends = MAX_SENDS;
|
|
||||||
|
|
||||||
device->Bs2bLevel = GetConfigValueInt(NULL, "cf_level", 0);
|
if(aluChannelsFromFormat(device->Format) <= 2)
|
||||||
|
{
|
||||||
if(aluChannelsFromFormat(device->Format) <= 2)
|
device->HeadDampen = GetConfigValueFloat(NULL, "head_dampen", DEFAULT_HEAD_DAMPEN);
|
||||||
{
|
device->HeadDampen = __min(device->HeadDampen, 1.0f);
|
||||||
device->HeadDampen = GetConfigValueFloat(NULL, "head_dampen", DEFAULT_HEAD_DAMPEN);
|
device->HeadDampen = __max(device->HeadDampen, 0.0f);
|
||||||
device->HeadDampen = __min(device->HeadDampen, 1.0f);
|
|
||||||
device->HeadDampen = __max(device->HeadDampen, 0.0f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
device->HeadDampen = 0.0f;
|
|
||||||
|
|
||||||
// Find a playback device to open
|
|
||||||
SuspendContext(NULL);
|
|
||||||
for(i = 0;BackendList[i].Init;i++)
|
|
||||||
{
|
|
||||||
device->Funcs = &BackendList[i].Funcs;
|
|
||||||
if(ALCdevice_OpenPlayback(device, deviceName))
|
|
||||||
{
|
|
||||||
device->next = g_pDeviceList;
|
|
||||||
g_pDeviceList = device;
|
|
||||||
g_ulDeviceCount++;
|
|
||||||
|
|
||||||
bDeviceFound = AL_TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ProcessContext(NULL);
|
|
||||||
|
|
||||||
if (!bDeviceFound)
|
|
||||||
{
|
|
||||||
// No suitable output device found
|
|
||||||
alcSetError(NULL, ALC_INVALID_VALUE);
|
|
||||||
free(device);
|
|
||||||
device = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
alcSetError(NULL, ALC_OUT_OF_MEMORY);
|
device->HeadDampen = 0.0f;
|
||||||
|
|
||||||
|
// Find a playback device to open
|
||||||
|
SuspendContext(NULL);
|
||||||
|
for(i = 0;BackendList[i].Init;i++)
|
||||||
|
{
|
||||||
|
device->Funcs = &BackendList[i].Funcs;
|
||||||
|
if(ALCdevice_OpenPlayback(device, deviceName))
|
||||||
|
{
|
||||||
|
device->next = g_pDeviceList;
|
||||||
|
g_pDeviceList = device;
|
||||||
|
g_ulDeviceCount++;
|
||||||
|
|
||||||
|
bDeviceFound = AL_TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ProcessContext(NULL);
|
||||||
|
|
||||||
|
if(!bDeviceFound)
|
||||||
|
{
|
||||||
|
// No suitable output device found
|
||||||
|
alcSetError(NULL, ALC_INVALID_VALUE);
|
||||||
|
free(device);
|
||||||
|
device = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
@ -1807,80 +1799,78 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
|
|||||||
*/
|
*/
|
||||||
ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *pDevice)
|
ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *pDevice)
|
||||||
{
|
{
|
||||||
ALCboolean bReturn = ALC_FALSE;
|
|
||||||
ALCdevice **list;
|
ALCdevice **list;
|
||||||
|
|
||||||
if(IsDevice(pDevice) && !pDevice->IsCaptureDevice)
|
if(!IsDevice(pDevice) || pDevice->IsCaptureDevice)
|
||||||
{
|
{
|
||||||
SuspendContext(NULL);
|
|
||||||
|
|
||||||
list = &g_pDeviceList;
|
|
||||||
while(*list != pDevice)
|
|
||||||
list = &(*list)->next;
|
|
||||||
|
|
||||||
*list = (*list)->next;
|
|
||||||
g_ulDeviceCount--;
|
|
||||||
|
|
||||||
ProcessContext(NULL);
|
|
||||||
|
|
||||||
if(pDevice->NumContexts > 0)
|
|
||||||
{
|
|
||||||
#ifdef _DEBUG
|
|
||||||
AL_PRINT("alcCloseDevice(): destroying %u Context(s)\n", pDevice->NumContexts);
|
|
||||||
#endif
|
|
||||||
while(pDevice->NumContexts > 0)
|
|
||||||
alcDestroyContext(pDevice->Contexts[0]);
|
|
||||||
}
|
|
||||||
ALCdevice_ClosePlayback(pDevice);
|
|
||||||
|
|
||||||
if(pDevice->BufferCount > 0)
|
|
||||||
{
|
|
||||||
#ifdef _DEBUG
|
|
||||||
AL_PRINT("alcCloseDevice(): deleting %d Buffer(s)\n", pDevice->BufferCount);
|
|
||||||
#endif
|
|
||||||
ReleaseALBuffers(pDevice);
|
|
||||||
}
|
|
||||||
if(pDevice->EffectCount > 0)
|
|
||||||
{
|
|
||||||
#ifdef _DEBUG
|
|
||||||
AL_PRINT("alcCloseDevice(): deleting %d Effect(s)\n", pDevice->EffectCount);
|
|
||||||
#endif
|
|
||||||
ReleaseALEffects(pDevice);
|
|
||||||
}
|
|
||||||
if(pDevice->FilterCount > 0)
|
|
||||||
{
|
|
||||||
#ifdef _DEBUG
|
|
||||||
AL_PRINT("alcCloseDevice(): deleting %d Filter(s)\n", pDevice->FilterCount);
|
|
||||||
#endif
|
|
||||||
ReleaseALFilters(pDevice);
|
|
||||||
}
|
|
||||||
if(pDevice->DatabufferCount > 0)
|
|
||||||
{
|
|
||||||
#ifdef _DEBUG
|
|
||||||
AL_PRINT("alcCloseDevice(): deleting %d Databuffer(s)\n", pDevice->DatabufferCount);
|
|
||||||
#endif
|
|
||||||
ReleaseALDatabuffers(pDevice);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(pDevice->Bs2b);
|
|
||||||
pDevice->Bs2b = NULL;
|
|
||||||
|
|
||||||
free(pDevice->szDeviceName);
|
|
||||||
pDevice->szDeviceName = NULL;
|
|
||||||
|
|
||||||
free(pDevice->Contexts);
|
|
||||||
pDevice->Contexts = NULL;
|
|
||||||
|
|
||||||
//Release device structure
|
|
||||||
memset(pDevice, 0, sizeof(ALCdevice));
|
|
||||||
free(pDevice);
|
|
||||||
|
|
||||||
bReturn = ALC_TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
||||||
|
return ALC_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
return bReturn;
|
SuspendContext(NULL);
|
||||||
|
|
||||||
|
list = &g_pDeviceList;
|
||||||
|
while(*list != pDevice)
|
||||||
|
list = &(*list)->next;
|
||||||
|
|
||||||
|
*list = (*list)->next;
|
||||||
|
g_ulDeviceCount--;
|
||||||
|
|
||||||
|
ProcessContext(NULL);
|
||||||
|
|
||||||
|
if(pDevice->NumContexts > 0)
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
AL_PRINT("alcCloseDevice(): destroying %u Context(s)\n", pDevice->NumContexts);
|
||||||
|
#endif
|
||||||
|
while(pDevice->NumContexts > 0)
|
||||||
|
alcDestroyContext(pDevice->Contexts[0]);
|
||||||
|
}
|
||||||
|
ALCdevice_ClosePlayback(pDevice);
|
||||||
|
|
||||||
|
if(pDevice->BufferCount > 0)
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
AL_PRINT("alcCloseDevice(): deleting %d Buffer(s)\n", pDevice->BufferCount);
|
||||||
|
#endif
|
||||||
|
ReleaseALBuffers(pDevice);
|
||||||
|
}
|
||||||
|
if(pDevice->EffectCount > 0)
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
AL_PRINT("alcCloseDevice(): deleting %d Effect(s)\n", pDevice->EffectCount);
|
||||||
|
#endif
|
||||||
|
ReleaseALEffects(pDevice);
|
||||||
|
}
|
||||||
|
if(pDevice->FilterCount > 0)
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
AL_PRINT("alcCloseDevice(): deleting %d Filter(s)\n", pDevice->FilterCount);
|
||||||
|
#endif
|
||||||
|
ReleaseALFilters(pDevice);
|
||||||
|
}
|
||||||
|
if(pDevice->DatabufferCount > 0)
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
AL_PRINT("alcCloseDevice(): deleting %d Databuffer(s)\n", pDevice->DatabufferCount);
|
||||||
|
#endif
|
||||||
|
ReleaseALDatabuffers(pDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(pDevice->Bs2b);
|
||||||
|
pDevice->Bs2b = NULL;
|
||||||
|
|
||||||
|
free(pDevice->szDeviceName);
|
||||||
|
pDevice->szDeviceName = NULL;
|
||||||
|
|
||||||
|
free(pDevice->Contexts);
|
||||||
|
pDevice->Contexts = NULL;
|
||||||
|
|
||||||
|
//Release device structure
|
||||||
|
memset(pDevice, 0, sizeof(ALCdevice));
|
||||||
|
free(pDevice);
|
||||||
|
|
||||||
|
return ALC_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user