Compare commits
215 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b3c4faa34 | |||
| 847b3e8b61 | |||
| b1bdd7c89f | |||
| ffe7a11866 | |||
| 8c3188bc7d | |||
| 880196e5a8 | |||
| d523b440e3 | |||
| f2875d5d13 | |||
| b0720333cc | |||
| c3446a10fa | |||
| fbc869eed7 | |||
| e3e4dbbccf | |||
| 7fda645b16 | |||
| ec7f20644d | |||
| 3d5fa91703 | |||
| e8acfb069c | |||
| 4c38ed272d | |||
| acbb4f8e6c | |||
| 13a3fe8a7a | |||
| 3dd3cd4ceb | |||
| 80fcbc8adc | |||
| 33680accea | |||
| 081e593e2b | |||
| b4ffdfab81 | |||
| 1ea4aac799 | |||
| 4d6c292757 | |||
| 655a83c5c5 | |||
| e8b576bc25 | |||
| 01404ed7af | |||
| ad6237f6f7 | |||
| d06c64e1c4 | |||
| b4ad3186dd | |||
| 5f1c0450b3 | |||
| 04b62f77e3 | |||
| 029dff3f40 | |||
| 342f639771 | |||
| b5a2baafe5 | |||
| 781e4e5be4 | |||
| f3dddb5e99 | |||
| 9a5e892cad | |||
| 0317362662 | |||
| 6b403a76e8 | |||
| 6bf6c6fb7b | |||
| 29618bee10 | |||
| db80f682c9 | |||
| e1cdbac5a0 | |||
| 543eb9d217 | |||
| bc963463f3 | |||
| 86b7b3d54b | |||
| 799ba1f954 | |||
| 1a3e39e452 | |||
| 7dc73815ae | |||
| 4caf2c7edd | |||
| 1b9d740244 | |||
| 497ada9c77 | |||
| 73e386dc6f | |||
| 43cfc097de | |||
| 6735fc7911 | |||
| be34dbe608 | |||
| 70102e7cd3 | |||
| 8ad16145f6 | |||
| bb7b18d4e1 | |||
| 4742dedb45 | |||
| 10a9bc62bf | |||
| 8cbbf17519 | |||
| 24f433b938 | |||
| abc69dd3d0 | |||
| bf87aed459 | |||
| 42306f93b3 | |||
| 03ca50fa70 | |||
| 7b1b8bd741 | |||
| a11f25e47b | |||
| a6213ebfc7 | |||
| b95fcf5da1 | |||
| 707e596811 | |||
| 5678041b92 | |||
| 7f850d8fb0 | |||
| 7edc576e9c | |||
| 0041a09576 | |||
| 0f06254ecf | |||
| ff5245ca8a | |||
| fe925ada59 | |||
| b6596f38b9 | |||
| 16fb3f6db5 | |||
| a2e2522612 | |||
| df07e8a65b | |||
| 729f076c3b | |||
| dfc0118b8b | |||
| d9ef062caf | |||
| 2b8ce3b4cf | |||
| a27b855a39 | |||
| 1634b69faf | |||
| 59fa1f90d5 | |||
| e519338a2b | |||
| 7a4870bd97 | |||
| a552e32a9a | |||
| 29c6238b52 | |||
| 38db8eb64b | |||
| 3bbbf8a025 | |||
| 978764cb6b | |||
| 893ecf1af2 | |||
| aa453b4e9e | |||
| f8089d2026 | |||
| 40241b4e97 | |||
| f10408739e | |||
| e1d0ad749b | |||
| 2a5a5b5c1b | |||
| a97ecb8690 | |||
| bc56c00a9a | |||
| 1e3ad2f9ce | |||
| 9c97f07ec9 | |||
| f8acdc9497 | |||
| 90d825e7f8 | |||
| 1178e900eb | |||
| 298f6f440a | |||
| 8553fb9e30 | |||
| da3b270488 | |||
| dd60366aec | |||
| 017fc93307 | |||
| 042ec206e7 | |||
| 312108a0d3 | |||
| 5e48be27b8 | |||
| b3badbf97d | |||
| 4d5885e27b | |||
| 8fe39042da | |||
| 9ed574b399 | |||
| 7ef623c71d | |||
| 733cd120b3 | |||
| 4e2f8e305e | |||
| 3d78d93b40 | |||
| 5a2f509104 | |||
| 9382956b0e | |||
| 42027a3f94 | |||
| 1397417fcd | |||
| c9a539eade | |||
| cb1d62f254 | |||
| 1cbd625b4e | |||
| 73678f3b78 | |||
| 79b95da0a3 | |||
| 1c85273662 | |||
| 76dd568971 | |||
| a43868c32b | |||
| 7a99b1fa32 | |||
| e82c27ab04 | |||
| f32098e04d | |||
| 1e0fa58d79 | |||
| f7ef5c169b | |||
| 927763902f | |||
| fcff17c567 | |||
| 2e88a3d03b | |||
| 1061108c61 | |||
| 5f8e65e099 | |||
| d90b36cf11 | |||
| 87615fffc9 | |||
| 8343a98ec6 | |||
| d7bf7a8b0d | |||
| 9eed1e8609 | |||
| 8011ad97b5 | |||
| ab8d342df0 | |||
| dcac0de44c | |||
| 2ee389044b | |||
| a48201ed94 | |||
| e516b3c0d3 | |||
| 51c5fa94aa | |||
| d6288d63c6 | |||
| 96bd020bd3 | |||
| 8dc2aef058 | |||
| d43486f894 | |||
| 229bc0d7e1 | |||
| 5b0514a829 | |||
| 0bef94cb48 | |||
| 44df5c3567 | |||
| 7bf9ebf545 | |||
| 1e9302f564 | |||
| a433ae0ff4 | |||
| e5609279da | |||
| afd3b71849 | |||
| 4cc64fa9a8 | |||
| 7f55372727 | |||
| 919b8c5bd1 | |||
| a281027876 | |||
| 72ce653bcf | |||
| 17c8881444 | |||
| 6aabc837a9 | |||
| 233e6f1765 | |||
| 9adc20e4e7 | |||
| bdf16bf601 | |||
| cf03bfa156 | |||
| d4f556836a | |||
| ebb30ec5b0 | |||
| 168d8e3bee | |||
| 654788f2cf | |||
| 06f2076f04 | |||
| fc43a13927 | |||
| 28f80fa113 | |||
| 9ebf1c1431 | |||
| 8795932420 | |||
| be50a5f992 | |||
| 7086f5f84c | |||
| 670487b4dd | |||
| 0ac746df57 | |||
| 7458273634 | |||
| aa386041e7 | |||
| 44e0fa9325 | |||
| 91d214d713 | |||
| 635f673b95 | |||
| 35a82970a3 | |||
| ac9bef0b31 | |||
| f6bb6cc891 | |||
| 56ff747463 | |||
| d14ea2965d | |||
| e773887b4b | |||
| 5b85067f9c | |||
| 1fa1edf16b | |||
| 19156ab895 |
@@ -26,20 +26,27 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include <ctype.h>
|
||||
#include "alMain.h"
|
||||
#include "alSource.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alThunk.h"
|
||||
#include "alSource.h"
|
||||
#include "alExtension.h"
|
||||
#include "alAuxEffectSlot.h"
|
||||
#include "bs2b.h"
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// DEBUG INFORMATION
|
||||
|
||||
char szDebug[256];
|
||||
char _alDebug[256];
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define EmptyFuncs { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
|
||||
struct {
|
||||
static struct {
|
||||
const char *name;
|
||||
void (*Init)(BackendFuncs*);
|
||||
BackendFuncs Funcs;
|
||||
@@ -57,35 +64,27 @@ struct {
|
||||
{ "winmm", alcWinMMInit, EmptyFuncs },
|
||||
#endif
|
||||
|
||||
{ "wave", alc_wave_init, EmptyFuncs },
|
||||
|
||||
{ NULL, NULL, EmptyFuncs }
|
||||
};
|
||||
#undef EmptyFuncs
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
|
||||
#define ALC_EFX_MAJOR_VERSION 0x20001
|
||||
#define ALC_EFX_MINOR_VERSION 0x20002
|
||||
#define ALC_MAX_AUXILIARY_SENDS 0x20003
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// STRING and EXTENSIONS
|
||||
|
||||
typedef struct ALCextension_struct
|
||||
{
|
||||
ALCchar *extName;
|
||||
ALvoid *address;
|
||||
} ALCextension;
|
||||
|
||||
typedef struct ALCfunction_struct
|
||||
{
|
||||
ALCchar *funcName;
|
||||
ALvoid *address;
|
||||
} ALCfunction;
|
||||
|
||||
static ALCextension alcExtensions[] = {
|
||||
{ "ALC_ENUMERATE_ALL_EXT", (ALvoid *) NULL },
|
||||
{ "ALC_ENUMERATION_EXT", (ALvoid *) NULL },
|
||||
{ "ALC_EXT_CAPTURE", (ALvoid *) NULL },
|
||||
{ NULL, (ALvoid *) NULL }
|
||||
};
|
||||
|
||||
static ALCfunction alcFunctions[] = {
|
||||
{ "alcCreateContext", (ALvoid *) alcCreateContext },
|
||||
{ "alcMakeContextCurrent", (ALvoid *) alcMakeContextCurrent },
|
||||
@@ -132,9 +131,14 @@ static ALenums enumeration[]={
|
||||
{ (ALchar *)"ALC_MONO_SOURCES", ALC_MONO_SOURCES },
|
||||
{ (ALchar *)"ALC_STEREO_SOURCES", ALC_STEREO_SOURCES },
|
||||
{ (ALchar *)"ALC_CAPTURE_DEVICE_SPECIFIER", ALC_CAPTURE_DEVICE_SPECIFIER },
|
||||
{ (ALchar *)"ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER", ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER },
|
||||
{ (ALchar *)"ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER", ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER},
|
||||
{ (ALchar *)"ALC_CAPTURE_SAMPLES", ALC_CAPTURE_SAMPLES },
|
||||
|
||||
// EFX Properties
|
||||
{ (ALchar *)"ALC_EFX_MAJOR_VERSION", ALC_EFX_MAJOR_VERSION },
|
||||
{ (ALchar *)"ALC_EFX_MINOR_VERSION", ALC_EFX_MINOR_VERSION },
|
||||
{ (ALchar *)"ALC_MAX_AUXILIARY_SENDS", ALC_MAX_AUXILIARY_SENDS },
|
||||
|
||||
// ALC Error Message
|
||||
{ (ALchar *)"ALC_NO_ERROR", ALC_NO_ERROR },
|
||||
{ (ALchar *)"ALC_INVALID_DEVICE", ALC_INVALID_DEVICE },
|
||||
@@ -162,16 +166,22 @@ static ALCchar *alcDefaultAllDeviceSpecifier = alcAllDeviceList;
|
||||
static ALCchar *alcCaptureDefaultDeviceSpecifier = alcCaptureDeviceList;
|
||||
|
||||
|
||||
static ALCchar alcExtensionList[] = "ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE";
|
||||
static ALCchar alcExtensionList[] = "ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_EFX";
|
||||
static ALCint alcMajorVersion = 1;
|
||||
static ALCint alcMinorVersion = 1;
|
||||
|
||||
static ALCint alcEFXMajorVersion = 1;
|
||||
static ALCint alcEFXMinorVersion = 0;
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// Global Variables
|
||||
|
||||
static ALCdevice *g_pDeviceList = NULL;
|
||||
static ALCuint g_ulDeviceCount = 0;
|
||||
|
||||
// Context List
|
||||
static ALCcontext *g_pContextList = NULL;
|
||||
static ALCuint g_ulContextCount = 0;
|
||||
@@ -191,9 +201,11 @@ static void InitAL(void)
|
||||
if(!done)
|
||||
{
|
||||
int i;
|
||||
const char *devs;
|
||||
const char *devs, *str;
|
||||
|
||||
InitializeCriticalSection(&g_mutex);
|
||||
done = 1;
|
||||
|
||||
InitializeCriticalSection(&_alMutex);
|
||||
ALTHUNK_INIT();
|
||||
ReadALConfig();
|
||||
|
||||
@@ -239,31 +251,51 @@ static void InitAL(void)
|
||||
|
||||
for(i = 0;BackendList[i].Init;i++)
|
||||
BackendList[i].Init(&BackendList[i].Funcs);
|
||||
done = 1;
|
||||
|
||||
str = GetConfigValue(NULL, "stereodup", "false");
|
||||
DuplicateStereo = (strcasecmp(str, "true") == 0 ||
|
||||
strcasecmp(str, "yes") == 0 ||
|
||||
strcasecmp(str, "on") == 0 ||
|
||||
atoi(str) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
ALCchar *AppendDeviceList(char *name)
|
||||
{
|
||||
static int pos;
|
||||
static size_t pos;
|
||||
ALCchar *ret = alcDeviceList+pos;
|
||||
pos += snprintf(alcDeviceList+pos, sizeof(alcDeviceList)-pos, "%s", name) + 1;
|
||||
if(pos >= sizeof(alcDeviceList))
|
||||
{
|
||||
AL_PRINT("Not enough room to add %s!\n", name);
|
||||
return alcDeviceList + sizeof(alcDeviceList) - 1;
|
||||
}
|
||||
pos += snprintf(alcDeviceList+pos, sizeof(alcDeviceList)-pos-1, "%s", name) + 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ALCchar *AppendAllDeviceList(char *name)
|
||||
{
|
||||
static int pos;
|
||||
static size_t pos;
|
||||
ALCchar *ret = alcAllDeviceList+pos;
|
||||
pos += snprintf(alcAllDeviceList+pos, sizeof(alcAllDeviceList)-pos, "%s", name) + 1;
|
||||
if(pos >= sizeof(alcAllDeviceList))
|
||||
{
|
||||
AL_PRINT("Not enough room to add %s!\n", name);
|
||||
return alcAllDeviceList + sizeof(alcAllDeviceList) - 1;
|
||||
}
|
||||
pos += snprintf(alcAllDeviceList+pos, sizeof(alcAllDeviceList)-pos-1, "%s", name) + 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ALCchar *AppendCaptureDeviceList(char *name)
|
||||
{
|
||||
static int pos;
|
||||
static size_t pos;
|
||||
ALCchar *ret = alcCaptureDeviceList+pos;
|
||||
pos += snprintf(alcCaptureDeviceList+pos, sizeof(alcCaptureDeviceList)-pos, "%s", name) + 1;
|
||||
if(pos >= sizeof(alcCaptureDeviceList))
|
||||
{
|
||||
AL_PRINT("Not enough room to add %s!\n", name);
|
||||
return alcCaptureDeviceList + sizeof(alcCaptureDeviceList) - 1;
|
||||
}
|
||||
pos += snprintf(alcCaptureDeviceList+pos, sizeof(alcCaptureDeviceList)-pos-1, "%s", name) + 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -303,7 +335,7 @@ ALCvoid SetALCError(ALenum errorCode)
|
||||
ALCvoid SuspendContext(ALCcontext *pContext)
|
||||
{
|
||||
(void)pContext;
|
||||
EnterCriticalSection(&g_mutex);
|
||||
EnterCriticalSection(&_alMutex);
|
||||
}
|
||||
|
||||
|
||||
@@ -315,7 +347,7 @@ ALCvoid SuspendContext(ALCcontext *pContext)
|
||||
ALCvoid ProcessContext(ALCcontext *pContext)
|
||||
{
|
||||
(void)pContext;
|
||||
LeaveCriticalSection(&g_mutex);
|
||||
LeaveCriticalSection(&_alMutex);
|
||||
}
|
||||
|
||||
|
||||
@@ -326,8 +358,11 @@ ALCvoid ProcessContext(ALCcontext *pContext)
|
||||
*/
|
||||
static ALvoid InitContext(ALCcontext *pContext)
|
||||
{
|
||||
int level;
|
||||
|
||||
//Initialise listener
|
||||
pContext->Listener.Gain = 1.0f;
|
||||
pContext->Listener.MetersPerUnit = 1.0f;
|
||||
pContext->Listener.Position[0] = 0.0f;
|
||||
pContext->Listener.Position[1] = 0.0f;
|
||||
pContext->Listener.Position[2] = 0.0f;
|
||||
@@ -357,7 +392,15 @@ static ALvoid InitContext(ALCcontext *pContext)
|
||||
pContext->lNumStereoSources = 1;
|
||||
pContext->lNumMonoSources = pContext->Device->MaxNoOfSources - pContext->lNumStereoSources;
|
||||
|
||||
strcpy(pContext->ExtensionList, "AL_EXT_EXPONENT_DISTANCE AL_EXT_LINEAR_DISTANCE AL_EXT_OFFSET");
|
||||
strcpy(pContext->ExtensionList, "AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_OFFSET AL_LOKI_quadriphonic");
|
||||
|
||||
level = GetConfigValueInt(NULL, "cf_level", 0);
|
||||
if(level > 0 && level <= 6)
|
||||
{
|
||||
pContext->bs2b = calloc(1, sizeof(*pContext->bs2b));
|
||||
bs2b_set_srate(pContext->bs2b, pContext->Frequency);
|
||||
bs2b_set_level(pContext->bs2b, level);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -368,29 +411,12 @@ static ALvoid InitContext(ALCcontext *pContext)
|
||||
*/
|
||||
static ALCvoid ExitContext(ALCcontext *pContext)
|
||||
{
|
||||
unsigned int i;
|
||||
ALsource *ALSource;
|
||||
ALsource *ALTempSource;
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (pContext->SourceCount>0)
|
||||
AL_PRINT("alcDestroyContext() %d Source(s) NOT deleted\n", pContext->SourceCount);
|
||||
#endif
|
||||
|
||||
// Free all the Sources still remaining
|
||||
ALSource = pContext->Source;
|
||||
for (i = 0; i < pContext->SourceCount; i++)
|
||||
{
|
||||
ALTempSource = ALSource->next;
|
||||
ALTHUNK_REMOVEENTRY(ALSource->source);
|
||||
memset(ALSource, 0, sizeof(ALsource));
|
||||
free(ALSource);
|
||||
ALSource = ALTempSource;
|
||||
}
|
||||
|
||||
//Invalidate context
|
||||
pContext->LastError = AL_NO_ERROR;
|
||||
pContext->InUse = AL_FALSE;
|
||||
|
||||
free(pContext->bs2b);
|
||||
pContext->bs2b = NULL;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
@@ -409,6 +435,9 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL
|
||||
|
||||
InitAL();
|
||||
|
||||
if(deviceName && !deviceName[0])
|
||||
deviceName = NULL;
|
||||
|
||||
pDevice = malloc(sizeof(ALCdevice));
|
||||
if (pDevice)
|
||||
{
|
||||
@@ -418,20 +447,22 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL
|
||||
memset(pDevice, 0, sizeof(ALCdevice));
|
||||
|
||||
//Validate device
|
||||
pDevice->InUse = AL_TRUE;
|
||||
pDevice->IsCaptureDevice = AL_TRUE;
|
||||
|
||||
pDevice->Frequency = frequency;
|
||||
pDevice->Format = format;
|
||||
pDevice->Channels = aluChannelsFromFormat(format);
|
||||
pDevice->FrameSize = aluBytesFromFormat(format) *
|
||||
pDevice->Channels;
|
||||
|
||||
for(i = 0;BackendList[i].Init;i++)
|
||||
{
|
||||
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);
|
||||
|
||||
DeviceFound = ALC_TRUE;
|
||||
break;
|
||||
}
|
||||
@@ -455,9 +486,21 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL
|
||||
ALCAPI ALCboolean ALCAPIENTRY alcCaptureCloseDevice(ALCdevice *pDevice)
|
||||
{
|
||||
ALCboolean bReturn = ALC_FALSE;
|
||||
ALCdevice **list;
|
||||
|
||||
if ((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);
|
||||
|
||||
@@ -665,13 +708,34 @@ ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsize
|
||||
*data = alcMinorVersion;
|
||||
break;
|
||||
|
||||
case ALC_EFX_MAJOR_VERSION:
|
||||
if(!size)
|
||||
SetALCError(ALC_INVALID_VALUE);
|
||||
else
|
||||
*data = alcEFXMajorVersion;
|
||||
break;
|
||||
|
||||
case ALC_EFX_MINOR_VERSION:
|
||||
if(!size)
|
||||
SetALCError(ALC_INVALID_VALUE);
|
||||
else
|
||||
*data = alcEFXMinorVersion;
|
||||
break;
|
||||
|
||||
case ALC_MAX_AUXILIARY_SENDS:
|
||||
if(!size)
|
||||
SetALCError(ALC_INVALID_VALUE);
|
||||
else
|
||||
*data = MAX_SENDS;
|
||||
break;
|
||||
|
||||
case ALC_ATTRIBUTES_SIZE:
|
||||
if(!device)
|
||||
SetALCError(ALC_INVALID_DEVICE);
|
||||
else if(!size)
|
||||
SetALCError(ALC_INVALID_VALUE);
|
||||
else
|
||||
*data = 11;
|
||||
*data = 12;
|
||||
break;
|
||||
|
||||
case ALC_ALL_ATTRIBUTES:
|
||||
@@ -687,19 +751,22 @@ ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsize
|
||||
data[i++] = device->Frequency;
|
||||
|
||||
data[i++] = ALC_REFRESH;
|
||||
data[i++] = device->UpdateFreq;
|
||||
data[i++] = device->Frequency / device->UpdateSize;
|
||||
|
||||
data[i++] = ALC_SYNC;
|
||||
data[i++] = ALC_FALSE;
|
||||
|
||||
SuspendContext(NULL);
|
||||
if(device->Context && size >= 11)
|
||||
if(device->Context && size >= 12)
|
||||
{
|
||||
data[i++] = ALC_MONO_SOURCES;
|
||||
data[i++] = device->Context->lNumMonoSources;
|
||||
|
||||
data[i++] = ALC_STEREO_SOURCES;
|
||||
data[i++] = device->Context->lNumStereoSources;
|
||||
|
||||
data[i++] = ALC_MAX_AUXILIARY_SENDS;
|
||||
data[i++] = MAX_SENDS;
|
||||
}
|
||||
ProcessContext(NULL);
|
||||
|
||||
@@ -722,7 +789,7 @@ ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsize
|
||||
else if(!size)
|
||||
SetALCError(ALC_INVALID_VALUE);
|
||||
else
|
||||
*data = device->UpdateFreq;
|
||||
*data = device->Frequency / device->UpdateSize;
|
||||
break;
|
||||
|
||||
case ALC_SYNC:
|
||||
@@ -734,6 +801,24 @@ ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsize
|
||||
*data = ALC_FALSE;
|
||||
break;
|
||||
|
||||
case ALC_MONO_SOURCES:
|
||||
if(!device || !device->Context)
|
||||
SetALCError(ALC_INVALID_DEVICE);
|
||||
else if (size != 1)
|
||||
SetALCError(ALC_INVALID_VALUE);
|
||||
else
|
||||
*data = device->Context->lNumMonoSources;
|
||||
break;
|
||||
|
||||
case ALC_STEREO_SOURCES:
|
||||
if(!device || !device->Context)
|
||||
SetALCError(ALC_INVALID_DEVICE);
|
||||
else if (size != 1)
|
||||
SetALCError(ALC_INVALID_VALUE);
|
||||
else
|
||||
*data = device->Context->lNumStereoSources;
|
||||
break;
|
||||
|
||||
default:
|
||||
SetALCError(ALC_INVALID_ENUM);
|
||||
break;
|
||||
@@ -755,18 +840,31 @@ ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsize
|
||||
ALCAPI ALCboolean ALCAPIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extName)
|
||||
{
|
||||
ALCboolean bResult = ALC_FALSE;
|
||||
ALsizei i = 0;
|
||||
|
||||
(void)device;
|
||||
|
||||
if (extName)
|
||||
{
|
||||
while(alcExtensions[i].extName &&
|
||||
strcasecmp(alcExtensions[i].extName,extName) != 0)
|
||||
i++;
|
||||
const char *ptr;
|
||||
size_t len;
|
||||
|
||||
if (alcExtensions[i].extName)
|
||||
bResult = ALC_TRUE;
|
||||
len = strlen(extName);
|
||||
ptr = alcExtensionList;
|
||||
while(ptr && *ptr)
|
||||
{
|
||||
if(strncasecmp(ptr, extName, len) == 0 &&
|
||||
(ptr[len] == '\0' || isspace(ptr[len])))
|
||||
{
|
||||
bResult = ALC_TRUE;
|
||||
break;
|
||||
}
|
||||
if((ptr=strchr(ptr, ' ')) != NULL)
|
||||
{
|
||||
do {
|
||||
++ptr;
|
||||
} while(isspace(*ptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
SetALCError(ALC_INVALID_VALUE);
|
||||
@@ -906,6 +1004,8 @@ ALCAPI ALCvoid ALCAPIENTRY alcDestroyContext(ALCcontext *context)
|
||||
{
|
||||
ALCcontext **list;
|
||||
|
||||
InitAL();
|
||||
|
||||
// Lock context list
|
||||
SuspendContext(NULL);
|
||||
|
||||
@@ -914,6 +1014,9 @@ ALCAPI ALCvoid ALCAPIENTRY alcDestroyContext(ALCcontext *context)
|
||||
// Lock context
|
||||
SuspendContext(context);
|
||||
|
||||
ReleaseALSources(context);
|
||||
ReleaseALAuxiliaryEffectSlots(context);
|
||||
|
||||
context->Device->Context = NULL;
|
||||
|
||||
list = &g_pContextList;
|
||||
@@ -948,6 +1051,8 @@ ALCAPI ALCcontext * ALCAPIENTRY alcGetCurrentContext(ALCvoid)
|
||||
{
|
||||
ALCcontext *pContext = NULL;
|
||||
|
||||
InitAL();
|
||||
|
||||
SuspendContext(NULL);
|
||||
|
||||
pContext = g_pContextList;
|
||||
@@ -969,6 +1074,8 @@ ALCAPI ALCdevice* ALCAPIENTRY alcGetContextsDevice(ALCcontext *pContext)
|
||||
{
|
||||
ALCdevice *pDevice = NULL;
|
||||
|
||||
InitAL();
|
||||
|
||||
SuspendContext(NULL);
|
||||
if (IsContext(pContext))
|
||||
pDevice = pContext->Device;
|
||||
@@ -990,6 +1097,8 @@ ALCAPI ALCboolean ALCAPIENTRY alcMakeContextCurrent(ALCcontext *context)
|
||||
ALCcontext *ALContext;
|
||||
ALboolean bReturn = AL_TRUE;
|
||||
|
||||
InitAL();
|
||||
|
||||
SuspendContext(NULL);
|
||||
|
||||
// context must be a valid Context or NULL
|
||||
@@ -1034,6 +1143,9 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
|
||||
|
||||
InitAL();
|
||||
|
||||
if(deviceName && !deviceName[0])
|
||||
deviceName = NULL;
|
||||
|
||||
device = malloc(sizeof(ALCdevice));
|
||||
if (device)
|
||||
{
|
||||
@@ -1043,7 +1155,6 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
|
||||
memset(device, 0, sizeof(ALCdevice));
|
||||
|
||||
//Validate device
|
||||
device->InUse = AL_TRUE;
|
||||
device->IsCaptureDevice = AL_FALSE;
|
||||
|
||||
//Set output format
|
||||
@@ -1055,20 +1166,16 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
|
||||
if(fmt[0])
|
||||
device->Format = alGetEnumValue(fmt);
|
||||
|
||||
device->Channels = aluChannelsFromFormat(device->Format);
|
||||
if(!device->Channels)
|
||||
{
|
||||
if(!aluChannelsFromFormat(device->Format))
|
||||
device->Format = AL_FORMAT_STEREO16;
|
||||
device->Channels = 2;
|
||||
device->FrameSize = 4;
|
||||
}
|
||||
else
|
||||
device->FrameSize = aluBytesFromFormat(device->Format) *
|
||||
device->Channels;
|
||||
|
||||
device->UpdateFreq = GetConfigValueInt(NULL, "refresh", 0);
|
||||
if((ALint)device->UpdateFreq <= 0)
|
||||
device->UpdateFreq = 8192 * device->Frequency / 22050;
|
||||
device->UpdateSize = GetConfigValueInt(NULL, "refresh", 8192);
|
||||
if((ALint)device->UpdateSize <= 0)
|
||||
device->UpdateSize = 8192;
|
||||
|
||||
device->MaxNoOfSources = GetConfigValueInt(NULL, "sources", 256);
|
||||
if((ALint)device->MaxNoOfSources <= 0)
|
||||
device->MaxNoOfSources = 256;
|
||||
|
||||
// Find a playback device to open
|
||||
for(i = 0;BackendList[i].Init;i++)
|
||||
@@ -1076,6 +1183,12 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
|
||||
device->Funcs = &BackendList[i].Funcs;
|
||||
if(ALCdevice_OpenPlayback(device, deviceName))
|
||||
{
|
||||
SuspendContext(NULL);
|
||||
device->next = g_pDeviceList;
|
||||
g_pDeviceList = device;
|
||||
g_ulDeviceCount++;
|
||||
ProcessContext(NULL);
|
||||
|
||||
bDeviceFound = AL_TRUE;
|
||||
break;
|
||||
}
|
||||
@@ -1101,9 +1214,23 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
|
||||
ALCAPI ALCboolean ALCAPIENTRY alcCloseDevice(ALCdevice *pDevice)
|
||||
{
|
||||
ALCboolean bReturn = ALC_FALSE;
|
||||
ALCdevice **list;
|
||||
|
||||
if ((pDevice)&&(!pDevice->IsCaptureDevice))
|
||||
{
|
||||
SuspendContext(NULL);
|
||||
|
||||
list = &g_pDeviceList;
|
||||
while(*list != pDevice)
|
||||
list = &(*list)->next;
|
||||
|
||||
*list = (*list)->next;
|
||||
g_ulDeviceCount--;
|
||||
|
||||
ProcessContext(NULL);
|
||||
|
||||
if(pDevice->Context)
|
||||
alcDestroyContext(pDevice->Context);
|
||||
ALCdevice_ClosePlayback(pDevice);
|
||||
|
||||
//Release device structure
|
||||
@@ -1117,4 +1244,22 @@ ALCAPI ALCboolean ALCAPIENTRY alcCloseDevice(ALCdevice *pDevice)
|
||||
|
||||
return bReturn;
|
||||
}
|
||||
|
||||
|
||||
ALCvoid ReleaseALC(ALCvoid)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if(g_ulContextCount > 0)
|
||||
AL_PRINT("exit() %u device(s) and %u context(s) NOT deleted\n", g_ulDeviceCount, g_ulContextCount);
|
||||
#endif
|
||||
|
||||
while(g_pDeviceList)
|
||||
{
|
||||
if(g_pDeviceList->IsCaptureDevice)
|
||||
alcCaptureCloseDevice(g_pDeviceList);
|
||||
else
|
||||
alcCloseDevice(g_pDeviceList);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
|
||||
+19
-2
@@ -18,6 +18,8 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
@@ -200,7 +202,14 @@ void ReadALConfig(void)
|
||||
|
||||
#ifdef _WIN32
|
||||
#else
|
||||
f = fopen("/etc/openal/config", "r");
|
||||
f = fopen("/etc/openal/alsoft.conf", "r");
|
||||
if(!f)
|
||||
{
|
||||
f = fopen("/etc/openal/config", "r");
|
||||
if(f)
|
||||
AL_PRINT("Reading /etc/openal/config; this file is deprecated\n"
|
||||
"\tPlease rename it to /etc/openal/alsoft.conf\n");
|
||||
}
|
||||
if(f)
|
||||
{
|
||||
LoadConfigFromFile(f);
|
||||
@@ -208,8 +217,16 @@ void ReadALConfig(void)
|
||||
}
|
||||
if(getenv("HOME") && *(getenv("HOME")))
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "%s/.openalrc", getenv("HOME"));
|
||||
snprintf(buffer, sizeof(buffer), "%s/.alsoftrc", getenv("HOME"));
|
||||
f = fopen(buffer, "r");
|
||||
if(!f)
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "%s/.openalrc", getenv("HOME"));
|
||||
f = fopen(buffer, "r");
|
||||
if(f)
|
||||
AL_PRINT("Reading ~/.openalrc; this file is deprecated\n"
|
||||
"\tPlease rename it to ~/.alsoftrc\n");
|
||||
}
|
||||
if(f)
|
||||
{
|
||||
LoadConfigFromFile(f);
|
||||
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2007 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "alMain.h"
|
||||
|
||||
|
||||
struct RingBuffer {
|
||||
ALubyte *mem;
|
||||
|
||||
ALsizei frame_size;
|
||||
ALsizei length;
|
||||
ALint read_pos;
|
||||
ALint write_pos;
|
||||
|
||||
CRITICAL_SECTION cs;
|
||||
};
|
||||
|
||||
|
||||
RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length)
|
||||
{
|
||||
RingBuffer *ring = calloc(1, sizeof(*ring));
|
||||
if(ring)
|
||||
{
|
||||
ring->frame_size = frame_size;
|
||||
ring->length = length+1;
|
||||
ring->write_pos = 1;
|
||||
ring->mem = malloc((length+1)*frame_size);
|
||||
if(!ring->mem)
|
||||
{
|
||||
free(ring);
|
||||
ring = NULL;
|
||||
}
|
||||
|
||||
InitializeCriticalSection(&ring->cs);
|
||||
}
|
||||
return ring;
|
||||
}
|
||||
|
||||
void DestroyRingBuffer(RingBuffer *ring)
|
||||
{
|
||||
if(ring)
|
||||
{
|
||||
DeleteCriticalSection(&ring->cs);
|
||||
free(ring->mem);
|
||||
free(ring);
|
||||
}
|
||||
}
|
||||
|
||||
ALsizei RingBufferSize(RingBuffer *ring)
|
||||
{
|
||||
return (ring->write_pos-ring->read_pos-1+ring->length) % ring->length;
|
||||
}
|
||||
|
||||
void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len)
|
||||
{
|
||||
int remain = ring->length - ring->write_pos;
|
||||
|
||||
EnterCriticalSection(&ring->cs);
|
||||
|
||||
if((ring->read_pos-ring->write_pos+ring->length)%ring->length < len)
|
||||
ring->read_pos = (ring->write_pos+len) % ring->length;
|
||||
|
||||
if(remain < len)
|
||||
{
|
||||
memcpy(ring->mem+(ring->write_pos*ring->frame_size), data, remain*ring->frame_size);
|
||||
memcpy(ring->mem, data+(remain*ring->frame_size), (len-remain)*ring->frame_size);
|
||||
}
|
||||
else
|
||||
memcpy(ring->mem+(ring->write_pos*ring->frame_size), data, len*ring->frame_size);
|
||||
|
||||
ring->write_pos += len;
|
||||
ring->write_pos %= ring->length;
|
||||
|
||||
LeaveCriticalSection(&ring->cs);
|
||||
}
|
||||
|
||||
void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len)
|
||||
{
|
||||
int remain = ring->length - ring->read_pos;
|
||||
|
||||
EnterCriticalSection(&ring->cs);
|
||||
|
||||
if(remain < len)
|
||||
{
|
||||
memcpy(data, ring->mem+(ring->read_pos*ring->frame_size), remain*ring->frame_size);
|
||||
memcpy(data+(remain*ring->frame_size), ring->mem, (len-remain)*ring->frame_size);
|
||||
}
|
||||
else
|
||||
memcpy(data, ring->mem+(ring->read_pos*ring->frame_size), len*ring->frame_size);
|
||||
|
||||
ring->read_pos += len;
|
||||
ring->read_pos %= ring->length;
|
||||
|
||||
LeaveCriticalSection(&ring->cs);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "alMain.h"
|
||||
|
||||
+181
-97
@@ -36,6 +36,10 @@
|
||||
typedef struct {
|
||||
snd_pcm_t *pcmHandle;
|
||||
snd_pcm_format_t format;
|
||||
|
||||
ALvoid *buffer;
|
||||
ALsizei size;
|
||||
|
||||
int killNow;
|
||||
ALvoid *thread;
|
||||
} alsa_data;
|
||||
@@ -63,15 +67,19 @@ MAKE_FUNC(snd_pcm_hw_params_set_rate_near);
|
||||
MAKE_FUNC(snd_pcm_hw_params_set_rate);
|
||||
MAKE_FUNC(snd_pcm_hw_params_set_buffer_size_near);
|
||||
MAKE_FUNC(snd_pcm_hw_params_set_buffer_size_min);
|
||||
MAKE_FUNC(snd_pcm_hw_params_get_period_size);
|
||||
MAKE_FUNC(snd_pcm_hw_params_get_access);
|
||||
MAKE_FUNC(snd_pcm_hw_params);
|
||||
MAKE_FUNC(snd_pcm_prepare);
|
||||
MAKE_FUNC(snd_pcm_start);
|
||||
MAKE_FUNC(snd_pcm_resume);
|
||||
MAKE_FUNC(snd_pcm_wait);
|
||||
MAKE_FUNC(snd_pcm_state);
|
||||
MAKE_FUNC(snd_pcm_avail_update);
|
||||
MAKE_FUNC(snd_pcm_areas_silence);
|
||||
MAKE_FUNC(snd_pcm_mmap_begin);
|
||||
MAKE_FUNC(snd_pcm_mmap_commit);
|
||||
MAKE_FUNC(snd_pcm_writei);
|
||||
MAKE_FUNC(snd_pcm_drain);
|
||||
MAKE_FUNC(snd_pcm_info_malloc);
|
||||
MAKE_FUNC(snd_pcm_info_free);
|
||||
@@ -95,27 +103,23 @@ MAKE_FUNC(snd_card_next);
|
||||
|
||||
static DevMap allDevNameMap[MAX_ALL_DEVICES];
|
||||
static ALCchar *alsaDeviceList[MAX_DEVICES];
|
||||
static ALCchar *alsaCaptureDeviceList[MAX_DEVICES];
|
||||
static DevMap allCaptureDevNameMap[MAX_ALL_DEVICES];
|
||||
|
||||
static int xrun_recovery(snd_pcm_t *handle, int err)
|
||||
{
|
||||
if (err == -EPIPE)
|
||||
{ /* under-run */
|
||||
err = psnd_pcm_prepare(handle);
|
||||
if(err >= 0)
|
||||
err = psnd_pcm_start(handle);
|
||||
if (err < 0)
|
||||
AL_PRINT("prepare failed: %s\n", psnd_strerror(err));
|
||||
}
|
||||
else if (err == -ESTRPIPE)
|
||||
{
|
||||
while ((err = psnd_pcm_resume(handle)) == -EAGAIN)
|
||||
usleep(1); /* wait until the suspend flag is released */
|
||||
Sleep(1); /* wait until the suspend flag is released */
|
||||
if (err < 0)
|
||||
{
|
||||
err = psnd_pcm_prepare(handle);
|
||||
if(err >= 0)
|
||||
err = psnd_pcm_start(handle);
|
||||
if (err < 0)
|
||||
AL_PRINT("prepare failed: %s\n", psnd_strerror(err));
|
||||
}
|
||||
@@ -171,7 +175,19 @@ static ALuint ALSAProc(ALvoid *ptr)
|
||||
// make sure there's frames to process
|
||||
if(avail == 0)
|
||||
{
|
||||
usleep(1000);
|
||||
if(state != SND_PCM_STATE_RUNNING)
|
||||
{
|
||||
err = psnd_pcm_start(data->pcmHandle);
|
||||
if(err < 0)
|
||||
err = xrun_recovery(data->pcmHandle, err);
|
||||
if(err < 0)
|
||||
{
|
||||
AL_PRINT("start failed: %s\n", psnd_strerror(err));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(psnd_pcm_wait(data->pcmHandle, 1000) == 0)
|
||||
AL_PRINT("Wait timeout... buffer size too low?\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -210,66 +226,71 @@ static ALuint ALSAProc(ALvoid *ptr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fill_silence(snd_pcm_t *pcmHandle, snd_pcm_format_t alsaFormat, int channels)
|
||||
static ALuint ALSANoMMapProc(ALvoid *ptr)
|
||||
{
|
||||
const snd_pcm_channel_area_t *areas = NULL;
|
||||
snd_pcm_sframes_t avail, commitres;
|
||||
snd_pcm_uframes_t offset, frames;
|
||||
int err;
|
||||
ALCdevice *pDevice = (ALCdevice*)ptr;
|
||||
alsa_data *data = (alsa_data*)pDevice->ExtraData;
|
||||
snd_pcm_sframes_t avail;
|
||||
char *WritePtr;
|
||||
|
||||
avail = psnd_pcm_avail_update(pcmHandle);
|
||||
if(avail < 0)
|
||||
while(!data->killNow)
|
||||
{
|
||||
err = xrun_recovery(pcmHandle, avail);
|
||||
if (err < 0)
|
||||
{
|
||||
AL_PRINT("available update failed: %s\n", psnd_strerror(err));
|
||||
return;
|
||||
}
|
||||
}
|
||||
SuspendContext(NULL);
|
||||
aluMixData(pDevice->Context, data->buffer, data->size, pDevice->Format);
|
||||
ProcessContext(NULL);
|
||||
|
||||
// it is possible that contiguous areas are smaller, thus we use a loop
|
||||
while (avail > 0)
|
||||
{
|
||||
frames = avail;
|
||||
|
||||
err = psnd_pcm_mmap_begin(pcmHandle, &areas, &offset, &frames);
|
||||
if (err < 0)
|
||||
WritePtr = data->buffer;
|
||||
avail = (snd_pcm_uframes_t)data->size / psnd_pcm_frames_to_bytes(data->pcmHandle, 1);
|
||||
while(avail > 0)
|
||||
{
|
||||
err = xrun_recovery(pcmHandle, err);
|
||||
if (err < 0)
|
||||
int ret = psnd_pcm_writei(data->pcmHandle, WritePtr, avail);
|
||||
switch (ret)
|
||||
{
|
||||
AL_PRINT("mmap begin error: %s\n", psnd_strerror(err));
|
||||
case -EAGAIN:
|
||||
continue;
|
||||
case -ESTRPIPE:
|
||||
while((ret=psnd_pcm_resume(data->pcmHandle)) == -EAGAIN)
|
||||
Sleep(1);
|
||||
break;
|
||||
case -EPIPE:
|
||||
break;
|
||||
default:
|
||||
if (ret >= 0)
|
||||
{
|
||||
WritePtr += psnd_pcm_frames_to_bytes(data->pcmHandle, ret);
|
||||
avail -= ret;
|
||||
}
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = psnd_pcm_prepare(data->pcmHandle);
|
||||
if(ret < 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
psnd_pcm_areas_silence(areas, offset, channels, frames, alsaFormat);
|
||||
|
||||
commitres = psnd_pcm_mmap_commit(pcmHandle, offset, frames);
|
||||
if (commitres < 0 || (commitres-frames) != 0)
|
||||
{
|
||||
AL_PRINT("mmap commit error: %s\n",
|
||||
psnd_strerror(commitres >= 0 ? -EPIPE : commitres));
|
||||
break;
|
||||
}
|
||||
|
||||
avail -= frames;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ALCboolean alsa_open_playback(ALCdevice *device, const ALCchar *deviceName)
|
||||
{
|
||||
snd_pcm_uframes_t bufferSizeInFrames;
|
||||
snd_pcm_hw_params_t *p = NULL;
|
||||
snd_pcm_access_t access;
|
||||
unsigned int periods;
|
||||
alsa_data *data;
|
||||
char driver[64];
|
||||
const char *str;
|
||||
int allowmmap;
|
||||
char *err;
|
||||
int i;
|
||||
|
||||
strncpy(driver, GetConfigValue("alsa", "default", "default"), sizeof(driver)-1);
|
||||
if(!alsa_handle)
|
||||
return ALC_FALSE;
|
||||
|
||||
strncpy(driver, GetConfigValue("alsa", "device", "default"), sizeof(driver)-1);
|
||||
driver[sizeof(driver)-1] = 0;
|
||||
if(deviceName)
|
||||
{
|
||||
@@ -308,7 +329,7 @@ open_alsa:
|
||||
i = psnd_pcm_open(&data->pcmHandle, driver, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
|
||||
if(i < 0)
|
||||
{
|
||||
usleep(200000);
|
||||
Sleep(200);
|
||||
i = psnd_pcm_open(&data->pcmHandle, driver, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
|
||||
}
|
||||
if(i >= 0)
|
||||
@@ -324,16 +345,12 @@ open_alsa:
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
switch(device->Format)
|
||||
switch(aluBytesFromFormat(device->Format))
|
||||
{
|
||||
case AL_FORMAT_MONO8:
|
||||
case AL_FORMAT_STEREO8:
|
||||
case AL_FORMAT_QUAD8:
|
||||
case 1:
|
||||
data->format = SND_PCM_FORMAT_U8;
|
||||
break;
|
||||
case AL_FORMAT_MONO16:
|
||||
case AL_FORMAT_STEREO16:
|
||||
case AL_FORMAT_QUAD16:
|
||||
case 2:
|
||||
data->format = SND_PCM_FORMAT_S16;
|
||||
break;
|
||||
default:
|
||||
@@ -341,23 +358,28 @@ open_alsa:
|
||||
AL_PRINT("Unknown format?! %x\n", device->Format);
|
||||
}
|
||||
|
||||
periods = GetConfigValueInt("alsa", "periods", 4);
|
||||
if((int)periods <= 0)
|
||||
periods = 4;
|
||||
bufferSizeInFrames = device->UpdateFreq;
|
||||
periods = GetConfigValueInt("alsa", "periods", 0);
|
||||
bufferSizeInFrames = device->UpdateSize;
|
||||
|
||||
str = GetConfigValue("alsa", "mmap", "true");
|
||||
allowmmap = (strcasecmp(str, "true") == 0 ||
|
||||
strcasecmp(str, "yes") == 0 ||
|
||||
strcasecmp(str, "on") == 0 ||
|
||||
atoi(str) != 0);
|
||||
|
||||
psnd_pcm_hw_params_malloc(&p);
|
||||
#define ok(func, str) (i=(func),((i<0)?(err=(str)),0:1))
|
||||
/* start with the largest configuration space possible */
|
||||
if(!(ok(psnd_pcm_hw_params_any(data->pcmHandle, p), "any") &&
|
||||
/* set interleaved access */
|
||||
ok(psnd_pcm_hw_params_set_access(data->pcmHandle, p, SND_PCM_ACCESS_MMAP_INTERLEAVED), "set access") &&
|
||||
((allowmmap && ok(psnd_pcm_hw_params_set_access(data->pcmHandle, p, SND_PCM_ACCESS_MMAP_INTERLEAVED), "set access")) ||
|
||||
ok(psnd_pcm_hw_params_set_access(data->pcmHandle, p, SND_PCM_ACCESS_RW_INTERLEAVED), "set access")) &&
|
||||
/* set format (implicitly sets sample bits) */
|
||||
ok(psnd_pcm_hw_params_set_format(data->pcmHandle, p, data->format), "set format") &&
|
||||
/* set channels (implicitly sets frame bits) */
|
||||
ok(psnd_pcm_hw_params_set_channels(data->pcmHandle, p, device->Channels), "set channels") &&
|
||||
ok(psnd_pcm_hw_params_set_channels(data->pcmHandle, p, aluChannelsFromFormat(device->Format)), "set channels") &&
|
||||
/* set periods (implicitly constrains period/buffer parameters) */
|
||||
ok(psnd_pcm_hw_params_set_periods_near(data->pcmHandle, p, &periods, NULL), "set periods near") &&
|
||||
(!periods || ok(psnd_pcm_hw_params_set_periods_near(data->pcmHandle, p, &periods, NULL), "set periods near")) &&
|
||||
/* set rate (implicitly constrains period/buffer parameters) */
|
||||
ok(psnd_pcm_hw_params_set_rate_near(data->pcmHandle, p, &device->Frequency, NULL), "set rate near") &&
|
||||
/* set buffer size in frame units (implicitly sets period size/bytes/time and buffer time/bytes) */
|
||||
@@ -372,36 +394,64 @@ open_alsa:
|
||||
return ALC_FALSE;
|
||||
}
|
||||
#undef ok
|
||||
psnd_pcm_hw_params_free(p);
|
||||
|
||||
device->MaxNoOfSources = 256;
|
||||
device->UpdateFreq = bufferSizeInFrames;
|
||||
|
||||
i = psnd_pcm_prepare(data->pcmHandle);
|
||||
if(i < 0)
|
||||
if((i=psnd_pcm_hw_params_get_access(p, &access)) < 0)
|
||||
{
|
||||
AL_PRINT("prepare error: %s\n", psnd_strerror(i));
|
||||
AL_PRINT("get_access failed: %s\n", psnd_strerror(i));
|
||||
psnd_pcm_hw_params_free(p);
|
||||
psnd_pcm_close(data->pcmHandle);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
fill_silence(data->pcmHandle, data->format, device->Channels);
|
||||
i = psnd_pcm_start(data->pcmHandle);
|
||||
if(i < 0)
|
||||
if((i=psnd_pcm_hw_params_get_period_size(p, &bufferSizeInFrames, NULL)) < 0)
|
||||
{
|
||||
AL_PRINT("start error: %s\n", psnd_strerror(i));
|
||||
AL_PRINT("get_period_size failed: %s\n", psnd_strerror(i));
|
||||
psnd_pcm_hw_params_free(p);
|
||||
psnd_pcm_close(data->pcmHandle);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
psnd_pcm_hw_params_free(p);
|
||||
|
||||
device->UpdateSize = bufferSizeInFrames;
|
||||
|
||||
data->size = psnd_pcm_frames_to_bytes(data->pcmHandle, device->UpdateSize);
|
||||
if(access == SND_PCM_ACCESS_RW_INTERLEAVED)
|
||||
{
|
||||
data->buffer = malloc(data->size);
|
||||
if(!data->buffer)
|
||||
{
|
||||
AL_PRINT("buffer malloc failed\n");
|
||||
psnd_pcm_close(data->pcmHandle);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
i = psnd_pcm_prepare(data->pcmHandle);
|
||||
if(i < 0)
|
||||
{
|
||||
AL_PRINT("prepare error: %s\n", psnd_strerror(i));
|
||||
psnd_pcm_close(data->pcmHandle);
|
||||
free(data->buffer);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
device->ExtraData = data;
|
||||
data->thread = StartThread(ALSAProc, device);
|
||||
if(access == SND_PCM_ACCESS_RW_INTERLEAVED)
|
||||
data->thread = StartThread(ALSANoMMapProc, device);
|
||||
else
|
||||
data->thread = StartThread(ALSAProc, device);
|
||||
if(data->thread == NULL)
|
||||
{
|
||||
psnd_pcm_close(data->pcmHandle);
|
||||
device->ExtraData = NULL;
|
||||
free(data->buffer);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
@@ -416,6 +466,7 @@ static void alsa_close_playback(ALCdevice *device)
|
||||
StopThread(data->thread);
|
||||
psnd_pcm_close(data->pcmHandle);
|
||||
|
||||
free(data->buffer);
|
||||
free(data);
|
||||
device->ExtraData = NULL;
|
||||
}
|
||||
@@ -425,34 +476,36 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam
|
||||
{
|
||||
snd_pcm_format_t alsaFormat;
|
||||
snd_pcm_hw_params_t *p;
|
||||
unsigned int periods = 4;
|
||||
snd_pcm_uframes_t bufferSizeInFrames = SampleSize;
|
||||
snd_pcm_uframes_t bufferSizeInFrames;
|
||||
alsa_data *data;
|
||||
char driver[64];
|
||||
char *err;
|
||||
int i;
|
||||
|
||||
if(!alsa_handle)
|
||||
return ALC_FALSE;
|
||||
|
||||
strncpy(driver, GetConfigValue("alsa", "capture", "default"), sizeof(driver)-1);
|
||||
driver[sizeof(driver)-1] = 0;
|
||||
if(deviceName)
|
||||
{
|
||||
size_t idx;
|
||||
|
||||
for(idx = 0;idx < MAX_DEVICES;idx++)
|
||||
for(idx = 0;idx < MAX_ALL_DEVICES;idx++)
|
||||
{
|
||||
if(alsaCaptureDeviceList[idx] &&
|
||||
strcmp(deviceName, alsaCaptureDeviceList[idx]) == 0)
|
||||
if(allCaptureDevNameMap[idx].name &&
|
||||
strcmp(deviceName, allCaptureDevNameMap[idx].name) == 0)
|
||||
{
|
||||
pDevice->szDeviceName = alsaCaptureDeviceList[idx];
|
||||
pDevice->szDeviceName = allCaptureDevNameMap[idx].name;
|
||||
if(idx > 0)
|
||||
sprintf(driver, "hw:%zd,0", idx-1);
|
||||
sprintf(driver, "hw:%d,%d", allCaptureDevNameMap[idx].card, allCaptureDevNameMap[idx].dev);
|
||||
goto open_alsa;
|
||||
}
|
||||
}
|
||||
return ALC_FALSE;
|
||||
}
|
||||
else
|
||||
pDevice->szDeviceName = alsaCaptureDeviceList[0];
|
||||
pDevice->szDeviceName = allCaptureDevNameMap[0].name;
|
||||
|
||||
open_alsa:
|
||||
data = (alsa_data*)calloc(1, sizeof(alsa_data));
|
||||
@@ -460,7 +513,7 @@ open_alsa:
|
||||
i = psnd_pcm_open(&data->pcmHandle, driver, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK);
|
||||
if(i < 0)
|
||||
{
|
||||
usleep(200000);
|
||||
Sleep(200);
|
||||
i = psnd_pcm_open(&data->pcmHandle, driver, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK);
|
||||
}
|
||||
if(i >= 0)
|
||||
@@ -489,6 +542,8 @@ open_alsa:
|
||||
AL_PRINT("Unknown format?! %x\n", format);
|
||||
}
|
||||
|
||||
bufferSizeInFrames = SampleSize;
|
||||
|
||||
psnd_pcm_hw_params_malloc(&p);
|
||||
#define ok(func, str) (i=(func),((i<0)?(err=(str)),0:1))
|
||||
/* start with the largest configuration space possible */
|
||||
@@ -498,9 +553,7 @@ open_alsa:
|
||||
/* set format (implicitly sets sample bits) */
|
||||
ok(psnd_pcm_hw_params_set_format(data->pcmHandle, p, alsaFormat), "set format") &&
|
||||
/* set channels (implicitly sets frame bits) */
|
||||
ok(psnd_pcm_hw_params_set_channels(data->pcmHandle, p, pDevice->Channels), "set channels") &&
|
||||
/* set periods (implicitly constrains period/buffer parameters) */
|
||||
ok(psnd_pcm_hw_params_set_periods_near(data->pcmHandle, p, &periods, NULL), "set periods near") &&
|
||||
ok(psnd_pcm_hw_params_set_channels(data->pcmHandle, p, aluChannelsFromFormat(pDevice->Format)), "set channels") &&
|
||||
/* set rate (implicitly constrains period/buffer parameters) */
|
||||
ok(psnd_pcm_hw_params_set_rate(data->pcmHandle, p, frequency, 0), "set rate") &&
|
||||
/* set buffer size in frame units (implicitly sets period size/bytes/time and buffer time/bytes) */
|
||||
@@ -594,7 +647,7 @@ static void alsa_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint l
|
||||
}
|
||||
|
||||
Pointer = (char*)areas->addr + (offset * areas->step / 8);
|
||||
Count = size * pDevice->FrameSize;
|
||||
Count = psnd_pcm_frames_to_bytes(data->pcmHandle, size);
|
||||
|
||||
memcpy(pBuffer, Pointer, Count);
|
||||
pBuffer = (char*)pBuffer + Count;
|
||||
@@ -670,7 +723,7 @@ void alc_alsa_init(BackendFuncs *func_list)
|
||||
} while(0)
|
||||
#else
|
||||
str = NULL;
|
||||
alsa_handle = NULL;
|
||||
alsa_handle = 0xDEADBEEF;
|
||||
#define LOAD_FUNC(f) p##f = f
|
||||
#endif
|
||||
|
||||
@@ -690,15 +743,19 @@ LOAD_FUNC(snd_pcm_hw_params_set_rate_near);
|
||||
LOAD_FUNC(snd_pcm_hw_params_set_rate);
|
||||
LOAD_FUNC(snd_pcm_hw_params_set_buffer_size_near);
|
||||
LOAD_FUNC(snd_pcm_hw_params_set_buffer_size_min);
|
||||
LOAD_FUNC(snd_pcm_hw_params_get_period_size);
|
||||
LOAD_FUNC(snd_pcm_hw_params_get_access);
|
||||
LOAD_FUNC(snd_pcm_hw_params);
|
||||
LOAD_FUNC(snd_pcm_prepare);
|
||||
LOAD_FUNC(snd_pcm_start);
|
||||
LOAD_FUNC(snd_pcm_resume);
|
||||
LOAD_FUNC(snd_pcm_wait);
|
||||
LOAD_FUNC(snd_pcm_state);
|
||||
LOAD_FUNC(snd_pcm_avail_update);
|
||||
LOAD_FUNC(snd_pcm_areas_silence);
|
||||
LOAD_FUNC(snd_pcm_mmap_begin);
|
||||
LOAD_FUNC(snd_pcm_mmap_commit);
|
||||
LOAD_FUNC(snd_pcm_writei);
|
||||
LOAD_FUNC(snd_pcm_drain);
|
||||
|
||||
LOAD_FUNC(snd_pcm_info_malloc);
|
||||
@@ -732,6 +789,8 @@ LOAD_FUNC(snd_card_next);
|
||||
}
|
||||
|
||||
while (card >= 0) {
|
||||
int firstDev = 1;
|
||||
|
||||
sprintf(name, "hw:%d", card);
|
||||
if ((err = psnd_ctl_open(&handle, name, 0)) < 0) {
|
||||
AL_PRINT("control open (%i): %s\n", card, psnd_strerror(err));
|
||||
@@ -742,11 +801,6 @@ LOAD_FUNC(snd_card_next);
|
||||
psnd_ctl_close(handle);
|
||||
goto next_card;
|
||||
}
|
||||
if(card < MAX_DEVICES-1) {
|
||||
snprintf(name, sizeof(name), "ALSA Software on %s",
|
||||
psnd_ctl_card_info_get_name(info));
|
||||
alsaDeviceList[card+1] = AppendDeviceList(name);
|
||||
}
|
||||
|
||||
dev = -1;
|
||||
while (idx < MAX_ALL_DEVICES) {
|
||||
@@ -756,6 +810,14 @@ LOAD_FUNC(snd_card_next);
|
||||
AL_PRINT("snd_ctl_pcm_next_device failed\n");
|
||||
if (dev < 0)
|
||||
break;
|
||||
|
||||
if(firstDev && card < MAX_DEVICES-1) {
|
||||
firstDev = 0;
|
||||
snprintf(name, sizeof(name), "ALSA Software on %s",
|
||||
psnd_ctl_card_info_get_name(info));
|
||||
alsaDeviceList[card+1] = AppendDeviceList(name);
|
||||
}
|
||||
|
||||
psnd_pcm_info_set_device(pcminfo, dev);
|
||||
psnd_pcm_info_set_subdevice(pcminfo, 0);
|
||||
psnd_pcm_info_set_stream(pcminfo, stream);
|
||||
@@ -793,7 +855,7 @@ next_card:
|
||||
return;
|
||||
}
|
||||
|
||||
alsaCaptureDeviceList[0] = AppendCaptureDeviceList("ALSA Capture on default");
|
||||
allCaptureDevNameMap[0].name = AppendCaptureDeviceList("ALSA Capture on default");
|
||||
|
||||
while (card >= 0) {
|
||||
sprintf(name, "hw:%d", card);
|
||||
@@ -803,13 +865,35 @@ next_card:
|
||||
}
|
||||
if (err >= 0 && (err = psnd_ctl_card_info(handle, info)) < 0) {
|
||||
AL_PRINT("control hardware info (%i): %s\n", card, psnd_strerror(err));
|
||||
psnd_ctl_close(handle);
|
||||
}
|
||||
else if (err >= 0 && card < MAX_DEVICES-1)
|
||||
else if (err >= 0)
|
||||
{
|
||||
snprintf(name, sizeof(name), "ALSA Capture on %s",
|
||||
psnd_ctl_card_info_get_name(info));
|
||||
alsaCaptureDeviceList[card+1] = AppendCaptureDeviceList(name);
|
||||
dev = -1;
|
||||
while (idx < MAX_ALL_DEVICES) {
|
||||
const char *cname, *dname;
|
||||
|
||||
if (psnd_ctl_pcm_next_device(handle, &dev)<0)
|
||||
AL_PRINT("snd_ctl_pcm_next_device failed\n");
|
||||
if (dev < 0)
|
||||
break;
|
||||
psnd_pcm_info_set_device(pcminfo, dev);
|
||||
psnd_pcm_info_set_subdevice(pcminfo, 0);
|
||||
psnd_pcm_info_set_stream(pcminfo, stream);
|
||||
if ((err = psnd_ctl_pcm_info(handle, pcminfo)) < 0) {
|
||||
if (err != -ENOENT)
|
||||
AL_PRINT("control digital audio info (%i): %s\n", card, psnd_strerror(err));
|
||||
continue;
|
||||
}
|
||||
|
||||
cname = psnd_ctl_card_info_get_name(info);
|
||||
dname = psnd_pcm_info_get_name(pcminfo);
|
||||
snprintf(name, sizeof(name), "ALSA Capture on %s [%s]",
|
||||
cname, dname);
|
||||
allDevNameMap[idx].name = AppendCaptureDeviceList(name);
|
||||
allDevNameMap[idx].card = card;
|
||||
allDevNameMap[idx].dev = dev;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
if(handle) psnd_ctl_close(handle);
|
||||
if(psnd_card_next(&card) < 0) {
|
||||
|
||||
+203
@@ -0,0 +1,203 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Boris Mikhaylov
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "bs2b.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
/* Single pole IIR filter.
|
||||
* O[n] = a0*I[n] + a1*I[n-1] + b1*O[n-1]
|
||||
*/
|
||||
|
||||
/* Lowpass filter */
|
||||
#define lo_filter(in, out_1) (bs2b->a0_lo*(in) + bs2b->b1_lo*(out_1))
|
||||
|
||||
/* Highboost filter */
|
||||
#define hi_filter(in, in_1, out_1) (bs2b->a0_hi*(in) + bs2b->a1_hi*(in_1) + bs2b->b1_hi*(out_1))
|
||||
|
||||
/* Set up all data. */
|
||||
static void init(struct bs2b *bs2b)
|
||||
{
|
||||
double Fc_lo, Fc_hi;
|
||||
double G_lo, G_hi;
|
||||
double x;
|
||||
|
||||
if ((bs2b->srate > 192000) || (bs2b->srate < 2000))
|
||||
bs2b->srate = BS2B_DEFAULT_SRATE;
|
||||
|
||||
switch(bs2b->level)
|
||||
{
|
||||
case BS2B_LOW_CLEVEL: /* Low crossfeed level */
|
||||
Fc_lo = 360.0;
|
||||
Fc_hi = 501.0;
|
||||
G_lo = 0.398107170553497;
|
||||
G_hi = 0.205671765275719;
|
||||
break;
|
||||
|
||||
case BS2B_MIDDLE_CLEVEL: /* Middle crossfeed level */
|
||||
Fc_lo = 500.0;
|
||||
Fc_hi = 711.0;
|
||||
G_lo = 0.459726988530872;
|
||||
G_hi = 0.228208484414988;
|
||||
break;
|
||||
|
||||
case BS2B_HIGH_CLEVEL: /* High crossfeed level (virtual speakers are closer to itself) */
|
||||
Fc_lo = 700.0;
|
||||
Fc_hi = 1021.0;
|
||||
G_lo = 0.530884444230988;
|
||||
G_hi = 0.250105790667544;
|
||||
break;
|
||||
|
||||
case BS2B_LOW_ECLEVEL: /* Low easy crossfeed level */
|
||||
Fc_lo = 360.0;
|
||||
Fc_hi = 494.0;
|
||||
G_lo = 0.316227766016838;
|
||||
G_hi = 0.168236228897329;
|
||||
break;
|
||||
|
||||
case BS2B_MIDDLE_ECLEVEL: /* Middle easy crossfeed level */
|
||||
Fc_lo = 500.0;
|
||||
Fc_hi = 689.0;
|
||||
G_lo = 0.354813389233575;
|
||||
G_hi = 0.187169483835901;
|
||||
break;
|
||||
|
||||
default: /* High easy crossfeed level */
|
||||
bs2b->level = BS2B_HIGH_ECLEVEL;
|
||||
|
||||
Fc_lo = 700.0;
|
||||
Fc_hi = 975.0;
|
||||
G_lo = 0.398107170553497;
|
||||
G_hi = 0.205671765275719;
|
||||
break;
|
||||
} /* switch */
|
||||
|
||||
/* $fc = $Fc / $s;
|
||||
* $d = 1 / 2 / pi / $fc;
|
||||
* $x = exp(-1 / $d);
|
||||
*/
|
||||
|
||||
x = exp(-2.0 * M_PI * Fc_lo / bs2b->srate);
|
||||
bs2b->b1_lo = x;
|
||||
bs2b->a0_lo = G_lo * (1.0 - x);
|
||||
|
||||
x = exp(-2.0 * M_PI * Fc_hi / bs2b->srate);
|
||||
bs2b->b1_hi = x;
|
||||
bs2b->a0_hi = 1.0 - G_hi * (1.0 - x);
|
||||
bs2b->a1_hi = -x;
|
||||
|
||||
bs2b->gain = 1.0 / (1.0 - G_hi + G_lo);
|
||||
|
||||
bs2b_clear(bs2b);
|
||||
} /* init */
|
||||
|
||||
/* Exported functions.
|
||||
* See descriptions in "bs2b.h"
|
||||
*/
|
||||
|
||||
void bs2b_set_level(struct bs2b *bs2b, int level)
|
||||
{
|
||||
if(level == bs2b->level)
|
||||
return;
|
||||
bs2b->level = level;
|
||||
init(bs2b);
|
||||
} /* bs2b_set_level */
|
||||
|
||||
int bs2b_get_level(struct bs2b *bs2b)
|
||||
{
|
||||
return bs2b->level;
|
||||
} /* bs2b_get_level */
|
||||
|
||||
void bs2b_set_srate(struct bs2b *bs2b, int srate)
|
||||
{
|
||||
if (srate == bs2b->srate)
|
||||
return;
|
||||
bs2b->srate = srate;
|
||||
init(bs2b);
|
||||
} /* bs2b_set_srate */
|
||||
|
||||
int bs2b_get_srate(struct bs2b *bs2b)
|
||||
{
|
||||
return bs2b->srate;
|
||||
} /* bs2b_get_srate */
|
||||
|
||||
void bs2b_clear(struct bs2b *bs2b)
|
||||
{
|
||||
int loopv = sizeof(bs2b->last_sample);
|
||||
|
||||
while (loopv)
|
||||
{
|
||||
((char *)&bs2b->last_sample)[--loopv] = 0;
|
||||
}
|
||||
} /* bs2b_clear */
|
||||
|
||||
int bs2b_is_clear(struct bs2b *bs2b)
|
||||
{
|
||||
int loopv = sizeof(bs2b->last_sample);
|
||||
|
||||
while (loopv)
|
||||
{
|
||||
if (((char *)&bs2b->last_sample)[--loopv] != 0)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
} /* bs2b_is_clear */
|
||||
|
||||
void bs2b_cross_feed(struct bs2b *bs2b, float *sample)
|
||||
{
|
||||
/* Lowpass filter */
|
||||
bs2b->last_sample.lo[0] = lo_filter(sample[0], bs2b->last_sample.lo[0]);
|
||||
bs2b->last_sample.lo[1] = lo_filter(sample[1], bs2b->last_sample.lo[1]);
|
||||
|
||||
/* Highboost filter */
|
||||
bs2b->last_sample.hi[0] = hi_filter(sample[0], bs2b->last_sample.asis[0], bs2b->last_sample.hi[0]);
|
||||
bs2b->last_sample.hi[1] = hi_filter(sample[1], bs2b->last_sample.asis[1], bs2b->last_sample.hi[1]);
|
||||
bs2b->last_sample.asis[0] = sample[0];
|
||||
bs2b->last_sample.asis[1] = sample[1];
|
||||
|
||||
/* Crossfeed */
|
||||
sample[0] = bs2b->last_sample.hi[0] + bs2b->last_sample.lo[1];
|
||||
sample[1] = bs2b->last_sample.hi[1] + bs2b->last_sample.lo[0];
|
||||
|
||||
/* Bass boost cause allpass attenuation */
|
||||
sample[0] *= bs2b->gain;
|
||||
sample[1] *= bs2b->gain;
|
||||
|
||||
/* Clipping of overloaded samples */
|
||||
#if 0
|
||||
if (sample[0] > 1.0)
|
||||
sample[0] = 1.0;
|
||||
if (sample[0] < -1.0)
|
||||
sample[0] = -1.0;
|
||||
if (sample[1] > 1.0)
|
||||
sample[1] = 1.0;
|
||||
if (sample[1] < -1.0)
|
||||
sample[1] = -1.0;
|
||||
#endif
|
||||
} /* bs2b_cross_feed */
|
||||
+212
-102
@@ -18,122 +18,143 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define INITGUID
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <dsound.h>
|
||||
#include <mmreg.h>
|
||||
|
||||
#include "alMain.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
|
||||
#ifndef DSSPEAKER_7POINT1
|
||||
#define DSSPEAKER_7POINT1 7
|
||||
#endif
|
||||
|
||||
DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
|
||||
|
||||
// Since DSound doesn't report the fragment size, just assume 4 fragments
|
||||
#define DS_FRAGS 4
|
||||
|
||||
typedef struct {
|
||||
// DirectSound Playback Device
|
||||
LPDIRECTSOUND lpDS;
|
||||
LPDIRECTSOUNDBUFFER DSpbuffer;
|
||||
LPDIRECTSOUNDBUFFER DSsbuffer;
|
||||
MMRESULT ulDSTimerID;
|
||||
DWORD OldWriteCursor;
|
||||
|
||||
int killNow;
|
||||
ALvoid *thread;
|
||||
} DSoundData;
|
||||
|
||||
|
||||
static ALCchar *DeviceList[16];
|
||||
typedef struct {
|
||||
ALCchar *name;
|
||||
GUID guid;
|
||||
} DevMap;
|
||||
static DevMap DeviceList[16];
|
||||
|
||||
static void CALLBACK DirectSoundProc(UINT uID,UINT uReserved,DWORD_PTR dwUser,DWORD_PTR dwReserved1,DWORD_PTR dwReserved2)
|
||||
|
||||
static ALuint DSoundProc(ALvoid *ptr)
|
||||
{
|
||||
ALCdevice *pDevice = (ALCdevice *)dwUser;
|
||||
DSoundData *pData = pDevice->ExtraData;
|
||||
DWORD PlayCursor,WriteCursor;
|
||||
BYTE *WritePtr1,*WritePtr2;
|
||||
DWORD WriteCnt1,WriteCnt2;
|
||||
WAVEFORMATEX OutputType;
|
||||
DWORD BytesPlayed;
|
||||
DWORD BufSize;
|
||||
HRESULT DSRes;
|
||||
ALCdevice *pDevice = (ALCdevice*)ptr;
|
||||
DSoundData *pData = (DSoundData*)pDevice->ExtraData;
|
||||
DWORD LastCursor = 0;
|
||||
DWORD PlayCursor;
|
||||
VOID *WritePtr1, *WritePtr2;
|
||||
DWORD WriteCnt1, WriteCnt2;
|
||||
DWORD BufferSize;
|
||||
DWORD avail;
|
||||
HRESULT err;
|
||||
|
||||
(void)uID;
|
||||
(void)uReserved;
|
||||
(void)dwReserved1;
|
||||
(void)dwReserved2;
|
||||
BufferSize = pDevice->UpdateSize * DS_FRAGS *
|
||||
aluBytesFromFormat(pDevice->Format) *
|
||||
aluChannelsFromFormat(pDevice->Format);
|
||||
|
||||
BufSize = pDevice->UpdateFreq * pDevice->FrameSize;
|
||||
|
||||
// Get current play and write cursors
|
||||
IDirectSoundBuffer_GetCurrentPosition(pData->DSsbuffer,&PlayCursor,&WriteCursor);
|
||||
if (!pData->OldWriteCursor) pData->OldWriteCursor=WriteCursor-PlayCursor;
|
||||
|
||||
// Get the output format and figure the number of bytes played (block aligned)
|
||||
IDirectSoundBuffer_GetFormat(pData->DSsbuffer,&OutputType,sizeof(WAVEFORMATEX),NULL);
|
||||
BytesPlayed=((((WriteCursor<pData->OldWriteCursor)?(BufSize+WriteCursor-pData->OldWriteCursor):(WriteCursor-pData->OldWriteCursor))/OutputType.nBlockAlign)*OutputType.nBlockAlign);
|
||||
|
||||
// Lock output buffer started at 40msec in front of the old write cursor (15msec in front of the actual write cursor)
|
||||
DSRes=IDirectSoundBuffer_Lock(pData->DSsbuffer,(pData->OldWriteCursor+(OutputType.nSamplesPerSec/25)*OutputType.nBlockAlign)%BufSize,BytesPlayed,(LPVOID*)&WritePtr1,&WriteCnt1,(LPVOID*)&WritePtr2,&WriteCnt2,0);
|
||||
|
||||
// If the buffer is lost, restore it, play and lock
|
||||
if (DSRes==DSERR_BUFFERLOST)
|
||||
while(!pData->killNow)
|
||||
{
|
||||
IDirectSoundBuffer_Restore(pData->DSsbuffer);
|
||||
IDirectSoundBuffer_Play(pData->DSsbuffer,0,0,DSBPLAY_LOOPING);
|
||||
DSRes=IDirectSoundBuffer_Lock(pData->DSsbuffer,(pData->OldWriteCursor+(OutputType.nSamplesPerSec/25)*OutputType.nBlockAlign)%BufSize,BytesPlayed,(LPVOID*)&WritePtr1,&WriteCnt1,(LPVOID*)&WritePtr2,&WriteCnt2,0);
|
||||
}
|
||||
// Get current play and write cursors
|
||||
IDirectSoundBuffer_GetCurrentPosition(pData->DSsbuffer, &PlayCursor, NULL);
|
||||
avail = (PlayCursor-LastCursor+BufferSize) % BufferSize;
|
||||
|
||||
// Successfully locked the output buffer
|
||||
if (DSRes==DS_OK)
|
||||
{
|
||||
// If we have an active context, mix data directly into output buffer otherwise fill with silence
|
||||
SuspendContext(NULL);
|
||||
if (WritePtr1)
|
||||
if(avail == 0)
|
||||
{
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Lock output buffer
|
||||
WriteCnt1 = 0;
|
||||
WriteCnt2 = 0;
|
||||
err = IDirectSoundBuffer_Lock(pData->DSsbuffer, LastCursor, avail, &WritePtr1, &WriteCnt1, &WritePtr2, &WriteCnt2, 0);
|
||||
|
||||
// If the buffer is lost, restore it, play and lock
|
||||
if(err == DSERR_BUFFERLOST)
|
||||
{
|
||||
err = IDirectSoundBuffer_Restore(pData->DSsbuffer);
|
||||
if(SUCCEEDED(err))
|
||||
err = IDirectSoundBuffer_Play(pData->DSsbuffer, 0, 0, DSBPLAY_LOOPING);
|
||||
if(SUCCEEDED(err))
|
||||
err = IDirectSoundBuffer_Lock(pData->DSsbuffer, LastCursor, avail, &WritePtr1, &WriteCnt1, &WritePtr2, &WriteCnt2, 0);
|
||||
}
|
||||
|
||||
// Successfully locked the output buffer
|
||||
if(SUCCEEDED(err))
|
||||
{
|
||||
// If we have an active context, mix data directly into output buffer otherwise fill with silence
|
||||
SuspendContext(NULL);
|
||||
aluMixData(pDevice->Context, WritePtr1, WriteCnt1, pDevice->Format);
|
||||
if (WritePtr2)
|
||||
aluMixData(pDevice->Context, WritePtr2, WriteCnt2, pDevice->Format);
|
||||
ProcessContext(NULL);
|
||||
ProcessContext(NULL);
|
||||
|
||||
// Unlock output buffer only when successfully locked
|
||||
IDirectSoundBuffer_Unlock(pData->DSsbuffer,WritePtr1,WriteCnt1,WritePtr2,WriteCnt2);
|
||||
// Unlock output buffer only when successfully locked
|
||||
IDirectSoundBuffer_Unlock(pData->DSsbuffer, WritePtr1, WriteCnt1, WritePtr2, WriteCnt2);
|
||||
}
|
||||
else
|
||||
AL_PRINT("Buffer lock error: %#lx\n", err);
|
||||
|
||||
// Update old write cursor location
|
||||
LastCursor += WriteCnt1+WriteCnt2;
|
||||
LastCursor %= BufferSize;
|
||||
}
|
||||
|
||||
// Update old write cursor location
|
||||
pData->OldWriteCursor=((pData->OldWriteCursor+BytesPlayed)%BufSize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName)
|
||||
{
|
||||
DSBUFFERDESC DSBDescription;
|
||||
DSoundData *pData = NULL;
|
||||
WAVEFORMATEX OutputType;
|
||||
WAVEFORMATEXTENSIBLE OutputType;
|
||||
DWORD frameSize = 0;
|
||||
LPGUID guid = NULL;
|
||||
DWORD speakers;
|
||||
HRESULT hr;
|
||||
|
||||
if(deviceName)
|
||||
{
|
||||
int i;
|
||||
for(i = 0;DeviceList[i];i++)
|
||||
for(i = 0;DeviceList[i].name;i++)
|
||||
{
|
||||
if(strcmp(deviceName, DeviceList[i]) == 0)
|
||||
if(strcmp(deviceName, DeviceList[i].name) == 0)
|
||||
{
|
||||
device->szDeviceName = DeviceList[i];
|
||||
device->szDeviceName = DeviceList[i].name;
|
||||
if(i > 0)
|
||||
guid = &DeviceList[i].guid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!DeviceList[i])
|
||||
if(!DeviceList[i].name)
|
||||
return ALC_FALSE;
|
||||
}
|
||||
else
|
||||
device->szDeviceName = DeviceList[0];
|
||||
device->szDeviceName = DeviceList[0].name;
|
||||
|
||||
//Platform specific
|
||||
memset(&OutputType, 0, sizeof(WAVEFORMATEX));
|
||||
OutputType.wFormatTag = WAVE_FORMAT_PCM;
|
||||
OutputType.nChannels = device->Channels;
|
||||
OutputType.wBitsPerSample = (((device->Format==AL_FORMAT_MONO16)||(device->Format==AL_FORMAT_STEREO16)||(device->Format==AL_FORMAT_QUAD16))?16:8);
|
||||
OutputType.nBlockAlign = OutputType.nChannels*OutputType.wBitsPerSample/8;
|
||||
OutputType.nSamplesPerSec = device->Frequency;
|
||||
OutputType.nAvgBytesPerSec = OutputType.nSamplesPerSec*OutputType.nBlockAlign;
|
||||
OutputType.cbSize = 0;
|
||||
memset(&OutputType, 0, sizeof(OutputType));
|
||||
|
||||
//Initialise requested device
|
||||
|
||||
@@ -144,39 +165,121 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
//Init COM
|
||||
CoInitialize(NULL);
|
||||
|
||||
//DirectSound Init code
|
||||
hr = CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSound, (LPVOID*)&pData->lpDS);
|
||||
if(SUCCEEDED(hr))
|
||||
hr = IDirectSound_Initialize(pData->lpDS, NULL);
|
||||
hr = DirectSoundCreate(guid, &pData->lpDS, NULL);
|
||||
if(SUCCEEDED(hr))
|
||||
hr = IDirectSound_SetCooperativeLevel(pData->lpDS, GetForegroundWindow(), DSSCL_PRIORITY);
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
memset(&DSBDescription,0,sizeof(DSBUFFERDESC));
|
||||
DSBDescription.dwSize=sizeof(DSBUFFERDESC);
|
||||
DSBDescription.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
||||
hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSpbuffer, NULL);
|
||||
}
|
||||
hr = IDirectSound_GetSpeakerConfig(pData->lpDS, &speakers);
|
||||
if(SUCCEEDED(hr))
|
||||
hr = IDirectSoundBuffer_SetFormat(pData->DSpbuffer,&OutputType);
|
||||
{
|
||||
speakers = DSSPEAKER_CONFIG(speakers);
|
||||
if(speakers == DSSPEAKER_MONO)
|
||||
{
|
||||
if(aluBytesFromFormat(device->Format) == 1)
|
||||
device->Format = AL_FORMAT_MONO8;
|
||||
else
|
||||
device->Format = AL_FORMAT_MONO16;
|
||||
}
|
||||
else if(speakers == DSSPEAKER_STEREO)
|
||||
{
|
||||
if(aluBytesFromFormat(device->Format) == 1)
|
||||
device->Format = AL_FORMAT_STEREO8;
|
||||
else
|
||||
device->Format = AL_FORMAT_STEREO16;
|
||||
}
|
||||
else if(speakers == DSSPEAKER_QUAD)
|
||||
{
|
||||
if(aluBytesFromFormat(device->Format) == 1)
|
||||
device->Format = AL_FORMAT_QUAD8;
|
||||
else
|
||||
device->Format = AL_FORMAT_QUAD16;
|
||||
OutputType.dwChannelMask = SPEAKER_FRONT_LEFT |
|
||||
SPEAKER_FRONT_RIGHT |
|
||||
SPEAKER_BACK_LEFT |
|
||||
SPEAKER_BACK_RIGHT;
|
||||
}
|
||||
else if(speakers == DSSPEAKER_5POINT1)
|
||||
{
|
||||
if(aluBytesFromFormat(device->Format) == 1)
|
||||
device->Format = AL_FORMAT_51CHN8;
|
||||
else
|
||||
device->Format = AL_FORMAT_51CHN16;
|
||||
OutputType.dwChannelMask = SPEAKER_FRONT_LEFT |
|
||||
SPEAKER_FRONT_RIGHT |
|
||||
SPEAKER_FRONT_CENTER |
|
||||
SPEAKER_LOW_FREQUENCY |
|
||||
SPEAKER_BACK_LEFT |
|
||||
SPEAKER_BACK_RIGHT;
|
||||
}
|
||||
else if(speakers == DSSPEAKER_7POINT1)
|
||||
{
|
||||
if(aluBytesFromFormat(device->Format) == 1)
|
||||
device->Format = AL_FORMAT_71CHN8;
|
||||
else
|
||||
device->Format = AL_FORMAT_71CHN16;
|
||||
OutputType.dwChannelMask = SPEAKER_FRONT_LEFT |
|
||||
SPEAKER_FRONT_RIGHT |
|
||||
SPEAKER_FRONT_CENTER |
|
||||
SPEAKER_LOW_FREQUENCY |
|
||||
SPEAKER_BACK_LEFT |
|
||||
SPEAKER_BACK_RIGHT |
|
||||
SPEAKER_SIDE_LEFT |
|
||||
SPEAKER_SIDE_RIGHT;
|
||||
}
|
||||
frameSize = aluBytesFromFormat(device->Format) *
|
||||
aluChannelsFromFormat(device->Format);
|
||||
|
||||
OutputType.Format.wFormatTag = WAVE_FORMAT_PCM;
|
||||
OutputType.Format.nChannels = aluChannelsFromFormat(device->Format);
|
||||
OutputType.Format.wBitsPerSample = aluBytesFromFormat(device->Format) * 8;
|
||||
OutputType.Format.nBlockAlign = OutputType.Format.nChannels*OutputType.Format.wBitsPerSample/8;
|
||||
OutputType.Format.nSamplesPerSec = device->Frequency;
|
||||
OutputType.Format.nAvgBytesPerSec = OutputType.Format.nSamplesPerSec*OutputType.Format.nBlockAlign;
|
||||
OutputType.Format.cbSize = 0;
|
||||
|
||||
device->UpdateSize /= DS_FRAGS;
|
||||
}
|
||||
|
||||
if(OutputType.Format.nChannels > 2)
|
||||
{
|
||||
OutputType.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
|
||||
OutputType.Samples.wValidBitsPerSample = OutputType.Format.wBitsPerSample;
|
||||
OutputType.Format.cbSize = 22;
|
||||
OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
memset(&DSBDescription,0,sizeof(DSBUFFERDESC));
|
||||
DSBDescription.dwSize=sizeof(DSBUFFERDESC);
|
||||
DSBDescription.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
||||
hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSpbuffer, NULL);
|
||||
}
|
||||
if(SUCCEEDED(hr))
|
||||
hr = IDirectSoundBuffer_SetFormat(pData->DSpbuffer,&OutputType.Format);
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
{
|
||||
memset(&DSBDescription,0,sizeof(DSBUFFERDESC));
|
||||
DSBDescription.dwSize=sizeof(DSBUFFERDESC);
|
||||
DSBDescription.dwFlags=DSBCAPS_GLOBALFOCUS|DSBCAPS_GETCURRENTPOSITION2;
|
||||
DSBDescription.dwBufferBytes=device->UpdateFreq * device->FrameSize;
|
||||
DSBDescription.lpwfxFormat=&OutputType;
|
||||
DSBDescription.dwBufferBytes=device->UpdateSize * DS_FRAGS * frameSize;
|
||||
DSBDescription.lpwfxFormat=&OutputType.Format;
|
||||
hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSsbuffer, NULL);
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hr))
|
||||
hr = IDirectSoundBuffer_Play(pData->DSsbuffer, 0, 0, DSBPLAY_LOOPING);
|
||||
|
||||
device->ExtraData = pData;
|
||||
pData->thread = StartThread(DSoundProc, device);
|
||||
if(!pData->thread)
|
||||
hr = E_FAIL;
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
if (pData->DSsbuffer)
|
||||
@@ -190,10 +293,6 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
pData->ulDSTimerID = timeSetEvent(25, 0, (LPTIMECALLBACK)DirectSoundProc, (DWORD)device, (UINT)TIME_CALLBACK_FUNCTION|TIME_PERIODIC);
|
||||
device->MaxNoOfSources = 256;
|
||||
|
||||
device->ExtraData = pData;
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
@@ -201,26 +300,14 @@ static void DSoundClosePlayback(ALCdevice *device)
|
||||
{
|
||||
DSoundData *pData = device->ExtraData;
|
||||
|
||||
// Stop and release the DS timer
|
||||
if (pData->ulDSTimerID)
|
||||
timeKillEvent(pData->ulDSTimerID);
|
||||
pData->killNow = 1;
|
||||
StopThread(pData->thread);
|
||||
|
||||
// Wait ... just in case any timer events happen
|
||||
Sleep(100);
|
||||
|
||||
SuspendContext(NULL);
|
||||
|
||||
if (pData->DSsbuffer)
|
||||
IDirectSoundBuffer_Release(pData->DSsbuffer);
|
||||
IDirectSoundBuffer_Release(pData->DSsbuffer);
|
||||
if (pData->DSpbuffer)
|
||||
IDirectSoundBuffer_Release(pData->DSpbuffer);
|
||||
IDirectSound_Release(pData->lpDS);
|
||||
|
||||
//Deinit COM
|
||||
CoUninitialize();
|
||||
|
||||
ProcessContext(NULL);
|
||||
|
||||
free(pData);
|
||||
device->ExtraData = NULL;
|
||||
}
|
||||
@@ -276,10 +363,33 @@ BackendFuncs DSoundFuncs = {
|
||||
DSoundAvailableSamples
|
||||
};
|
||||
|
||||
static BOOL CALLBACK DSoundEnumDevices(LPGUID guid, LPCSTR desc, LPCSTR drvname, LPVOID data)
|
||||
{
|
||||
size_t *iter = data;
|
||||
(void)drvname;
|
||||
|
||||
if(guid)
|
||||
{
|
||||
char str[128];
|
||||
snprintf(str, sizeof(str), "DirectSound Software on %s", desc);
|
||||
DeviceList[*iter].name = AppendAllDeviceList(str);
|
||||
DeviceList[*iter].guid = *guid;
|
||||
(*iter)++;
|
||||
}
|
||||
else
|
||||
DeviceList[0].name = AppendDeviceList("DirectSound Software");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void alcDSoundInit(BackendFuncs *FuncList)
|
||||
{
|
||||
size_t iter = 1;
|
||||
HRESULT hr;
|
||||
|
||||
*FuncList = DSoundFuncs;
|
||||
|
||||
DeviceList[0] = AppendDeviceList("DirectSound Software");
|
||||
AppendAllDeviceList(DeviceList[0]);
|
||||
hr = DirectSoundEnumerate(DSoundEnumDevices, &iter);
|
||||
if(FAILED(hr))
|
||||
AL_PRINT("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -46,6 +48,7 @@
|
||||
#endif
|
||||
|
||||
static char *oss_device;
|
||||
static char *oss_device_capture;
|
||||
|
||||
typedef struct {
|
||||
int fd;
|
||||
@@ -54,7 +57,9 @@ typedef struct {
|
||||
|
||||
ALubyte *mix_data;
|
||||
int data_size;
|
||||
int silence;
|
||||
|
||||
RingBuffer *ring;
|
||||
int doCapture;
|
||||
} oss_data;
|
||||
|
||||
|
||||
@@ -74,31 +79,65 @@ static ALuint OSSProc(ALvoid *ptr)
|
||||
{
|
||||
ALCdevice *pDevice = (ALCdevice*)ptr;
|
||||
oss_data *data = (oss_data*)pDevice->ExtraData;
|
||||
int remaining;
|
||||
int remaining = 0;
|
||||
int wrote;
|
||||
|
||||
while(!data->killNow)
|
||||
{
|
||||
SuspendContext(NULL);
|
||||
aluMixData(pDevice->Context,data->mix_data,data->data_size,pDevice->Format);
|
||||
ProcessContext(NULL);
|
||||
int len = data->data_size - remaining;
|
||||
|
||||
remaining = data->data_size;
|
||||
while(remaining > 0)
|
||||
if(len > 0)
|
||||
{
|
||||
wrote = write(data->fd, data->mix_data+data->data_size-remaining, remaining);
|
||||
if(wrote < 0)
|
||||
{
|
||||
AL_PRINT("write failed: %s\n", strerror(errno));
|
||||
break;
|
||||
}
|
||||
if(wrote == 0)
|
||||
{
|
||||
usleep(1000);
|
||||
continue;
|
||||
}
|
||||
remaining -= wrote;
|
||||
SuspendContext(NULL);
|
||||
aluMixData(pDevice->Context, data->mix_data+remaining, len, pDevice->Format);
|
||||
ProcessContext(NULL);
|
||||
}
|
||||
|
||||
remaining += len;
|
||||
wrote = write(data->fd, data->mix_data, remaining);
|
||||
if(wrote < 0)
|
||||
{
|
||||
AL_PRINT("write failed: %s\n", strerror(errno));
|
||||
remaining = 0;
|
||||
}
|
||||
else if(wrote > 0)
|
||||
{
|
||||
remaining -= wrote;
|
||||
if(remaining > 0)
|
||||
memmove(data->mix_data, data->mix_data+wrote, remaining);
|
||||
}
|
||||
else
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ALuint OSSCaptureProc(ALvoid *ptr)
|
||||
{
|
||||
ALCdevice *pDevice = (ALCdevice*)ptr;
|
||||
oss_data *data = (oss_data*)pDevice->ExtraData;
|
||||
int frameSize;
|
||||
int amt;
|
||||
|
||||
frameSize = aluBytesFromFormat(pDevice->Format);
|
||||
frameSize *= aluChannelsFromFormat(pDevice->Format);
|
||||
|
||||
while(!data->killNow)
|
||||
{
|
||||
amt = read(data->fd, data->mix_data, data->data_size);
|
||||
if(amt < 0)
|
||||
{
|
||||
AL_PRINT("read failed: %s\n", strerror(errno));
|
||||
break;
|
||||
}
|
||||
if(amt == 0)
|
||||
{
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
if(data->doCapture)
|
||||
WriteRingBuffer(data->ring, data->mix_data, amt/frameSize);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -110,6 +149,7 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
|
||||
int log2FragmentSize;
|
||||
unsigned int periods;
|
||||
audio_buf_info info;
|
||||
ALuint frameSize;
|
||||
char driver[64];
|
||||
int numChannels;
|
||||
oss_data *data;
|
||||
@@ -140,18 +180,12 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
switch(device->Format)
|
||||
switch(aluBytesFromFormat(device->Format))
|
||||
{
|
||||
case AL_FORMAT_MONO8:
|
||||
case AL_FORMAT_STEREO8:
|
||||
case AL_FORMAT_QUAD8:
|
||||
data->silence = 0x80;
|
||||
case 1:
|
||||
ossFormat = AFMT_U8;
|
||||
break;
|
||||
case AL_FORMAT_MONO16:
|
||||
case AL_FORMAT_STEREO16:
|
||||
case AL_FORMAT_QUAD16:
|
||||
data->silence = 0;
|
||||
case 2:
|
||||
ossFormat = AFMT_S16_NE;
|
||||
break;
|
||||
default:
|
||||
@@ -160,11 +194,13 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
|
||||
}
|
||||
|
||||
periods = GetConfigValueInt("oss", "periods", 4);
|
||||
if((int)periods < 0)
|
||||
if((int)periods <= 0)
|
||||
periods = 4;
|
||||
numChannels = device->Channels;
|
||||
numChannels = aluChannelsFromFormat(device->Format);
|
||||
frameSize = numChannels * aluBytesFromFormat(device->Format);
|
||||
|
||||
ossSpeed = device->Frequency;
|
||||
log2FragmentSize = log2i(device->UpdateFreq * device->FrameSize / periods);
|
||||
log2FragmentSize = log2i(device->UpdateSize * frameSize / periods);
|
||||
|
||||
/* according to the OSS spec, 16 bytes are the minimum */
|
||||
if (log2FragmentSize < 4)
|
||||
@@ -178,68 +214,37 @@ static ALCboolean oss_open_playback(ALCdevice *device, const ALCchar *deviceName
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_SPEED, &ossSpeed), "set speed") &&
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_GETOSPACE, &info), "get space")))
|
||||
{
|
||||
AL_PRINT("%s failed: %s\n", err, strerror(i));
|
||||
AL_PRINT("%s failed: %s\n", err, strerror(errno));
|
||||
close(data->fd);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
#undef ok
|
||||
|
||||
device->Channels = numChannels;
|
||||
device->Frequency = ossSpeed;
|
||||
device->Format = 0;
|
||||
if(ossFormat == AFMT_U8)
|
||||
{
|
||||
if(device->Channels == 1)
|
||||
{
|
||||
device->Format = AL_FORMAT_MONO8;
|
||||
device->FrameSize = 1;
|
||||
}
|
||||
else if(device->Channels == 2)
|
||||
{
|
||||
device->Format = AL_FORMAT_STEREO8;
|
||||
device->FrameSize = 2;
|
||||
}
|
||||
else if(device->Channels == 4)
|
||||
{
|
||||
device->Format = AL_FORMAT_QUAD8;
|
||||
device->FrameSize = 4;
|
||||
}
|
||||
}
|
||||
else if(ossFormat == AFMT_S16_NE)
|
||||
{
|
||||
if(device->Channels == 1)
|
||||
{
|
||||
device->Format = AL_FORMAT_MONO16;
|
||||
device->FrameSize = 2;
|
||||
}
|
||||
else if(device->Channels == 2)
|
||||
{
|
||||
device->Format = AL_FORMAT_STEREO16;
|
||||
device->FrameSize = 4;
|
||||
}
|
||||
else if(device->Channels == 4)
|
||||
{
|
||||
device->Format = AL_FORMAT_QUAD16;
|
||||
device->FrameSize = 8;
|
||||
}
|
||||
}
|
||||
|
||||
if(!device->Format)
|
||||
if((int)aluChannelsFromFormat(device->Format) != numChannels)
|
||||
{
|
||||
AL_PRINT("returned unknown format: %#x %d!\n", ossFormat, numChannels);
|
||||
AL_PRINT("Could not set %d channels, got %d instead\n", aluChannelsFromFormat(device->Format), numChannels);
|
||||
close(data->fd);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
device->UpdateFreq = info.fragsize / device->FrameSize;
|
||||
if(!((ossFormat == AFMT_U8 && aluBytesFromFormat(device->Format) == 1) ||
|
||||
(ossFormat == AFMT_S16_NE && aluBytesFromFormat(device->Format) == 2)))
|
||||
{
|
||||
AL_PRINT("Could not set %d-bit output, got format %#x\n", aluBytesFromFormat(device->Format)*8, ossFormat);
|
||||
close(data->fd);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
data->data_size = device->UpdateFreq * device->FrameSize;
|
||||
device->UpdateSize = info.fragsize / frameSize;
|
||||
|
||||
data->data_size = device->UpdateSize * frameSize;
|
||||
data->mix_data = calloc(1, data->data_size);
|
||||
|
||||
device->MaxNoOfSources = 256;
|
||||
|
||||
device->ExtraData = data;
|
||||
data->thread = StartThread(OSSProc, device);
|
||||
if(data->thread == NULL)
|
||||
@@ -267,42 +272,163 @@ static void oss_close_playback(ALCdevice *device)
|
||||
}
|
||||
|
||||
|
||||
static ALCboolean oss_open_capture(ALCdevice *pDevice, const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei SampleSize)
|
||||
static ALCboolean oss_open_capture(ALCdevice *device, const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei SampleSize)
|
||||
{
|
||||
(void)pDevice;
|
||||
(void)deviceName;
|
||||
(void)frequency;
|
||||
(void)format;
|
||||
(void)SampleSize;
|
||||
return ALC_FALSE;
|
||||
int numFragmentsLogSize;
|
||||
int log2FragmentSize;
|
||||
unsigned int periods;
|
||||
audio_buf_info info;
|
||||
ALuint frameSize;
|
||||
int numChannels;
|
||||
char driver[64];
|
||||
oss_data *data;
|
||||
int ossFormat;
|
||||
int ossSpeed;
|
||||
char *err;
|
||||
int i;
|
||||
|
||||
strncpy(driver, GetConfigValue("oss", "capture", "/dev/dsp"), sizeof(driver)-1);
|
||||
driver[sizeof(driver)-1] = 0;
|
||||
if(deviceName)
|
||||
{
|
||||
if(strcmp(deviceName, oss_device_capture))
|
||||
return ALC_FALSE;
|
||||
device->szDeviceName = oss_device_capture;
|
||||
}
|
||||
else
|
||||
device->szDeviceName = oss_device_capture;
|
||||
|
||||
data = (oss_data*)calloc(1, sizeof(oss_data));
|
||||
data->killNow = 0;
|
||||
|
||||
data->fd = open(driver, O_RDONLY);
|
||||
if(data->fd == -1)
|
||||
{
|
||||
free(data);
|
||||
AL_PRINT("Could not open %s: %s\n", driver, strerror(errno));
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
switch(aluBytesFromFormat(format))
|
||||
{
|
||||
case 1:
|
||||
ossFormat = AFMT_U8;
|
||||
break;
|
||||
case 2:
|
||||
ossFormat = AFMT_S16_NE;
|
||||
break;
|
||||
default:
|
||||
ossFormat = -1;
|
||||
AL_PRINT("Unknown format?! %x\n", device->Format);
|
||||
}
|
||||
|
||||
periods = 4;
|
||||
numChannels = aluChannelsFromFormat(device->Format);
|
||||
frameSize = numChannels * aluBytesFromFormat(device->Format);
|
||||
ossSpeed = frequency;
|
||||
log2FragmentSize = log2i(SampleSize * frameSize / periods);
|
||||
|
||||
/* according to the OSS spec, 16 bytes are the minimum */
|
||||
if (log2FragmentSize < 4)
|
||||
log2FragmentSize = 4;
|
||||
numFragmentsLogSize = (periods << 16) | log2FragmentSize;
|
||||
|
||||
#define ok(func, str) (i=(func),((i<0)?(err=(str)),0:1))
|
||||
if (!(ok(ioctl(data->fd, SNDCTL_DSP_SETFRAGMENT, &numFragmentsLogSize), "set fragment") &&
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_SETFMT, &ossFormat), "set format") &&
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_CHANNELS, &numChannels), "set channels") &&
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_SPEED, &ossSpeed), "set speed") &&
|
||||
ok(ioctl(data->fd, SNDCTL_DSP_GETISPACE, &info), "get space")))
|
||||
{
|
||||
AL_PRINT("%s failed: %s\n", err, strerror(errno));
|
||||
close(data->fd);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
#undef ok
|
||||
|
||||
if((int)aluChannelsFromFormat(device->Format) != numChannels)
|
||||
{
|
||||
AL_PRINT("Could not set %d channels, got %d instead\n", aluChannelsFromFormat(device->Format), numChannels);
|
||||
close(data->fd);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
if(!((ossFormat == AFMT_U8 && aluBytesFromFormat(device->Format) == 1) ||
|
||||
(ossFormat == AFMT_S16_NE && aluBytesFromFormat(device->Format) == 2)))
|
||||
{
|
||||
AL_PRINT("Could not set %d-bit input, got format %#x\n", aluBytesFromFormat(device->Format)*8, ossFormat);
|
||||
close(data->fd);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
data->ring = CreateRingBuffer(frameSize, SampleSize);
|
||||
if(!data->ring)
|
||||
{
|
||||
AL_PRINT("ring buffer create failed\n");
|
||||
close(data->fd);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
data->data_size = info.fragsize;
|
||||
data->mix_data = calloc(1, data->data_size);
|
||||
|
||||
device->ExtraData = data;
|
||||
data->thread = StartThread(OSSCaptureProc, device);
|
||||
if(data->thread == NULL)
|
||||
{
|
||||
device->ExtraData = NULL;
|
||||
free(data->mix_data);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
static void oss_close_capture(ALCdevice *pDevice)
|
||||
static void oss_close_capture(ALCdevice *device)
|
||||
{
|
||||
(void)pDevice;
|
||||
oss_data *data = (oss_data*)device->ExtraData;
|
||||
data->killNow = 1;
|
||||
StopThread(data->thread);
|
||||
|
||||
close(data->fd);
|
||||
|
||||
DestroyRingBuffer(data->ring);
|
||||
|
||||
free(data->mix_data);
|
||||
free(data);
|
||||
device->ExtraData = NULL;
|
||||
}
|
||||
|
||||
static void oss_start_capture(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
oss_data *data = (oss_data*)pDevice->ExtraData;
|
||||
data->doCapture = 1;
|
||||
}
|
||||
|
||||
static void oss_stop_capture(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
oss_data *data = (oss_data*)pDevice->ExtraData;
|
||||
data->doCapture = 0;
|
||||
}
|
||||
|
||||
static void oss_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples)
|
||||
{
|
||||
(void)pDevice;
|
||||
(void)pBuffer;
|
||||
(void)lSamples;
|
||||
oss_data *data = (oss_data*)pDevice->ExtraData;
|
||||
if(lSamples <= (ALCuint)RingBufferSize(data->ring))
|
||||
ReadRingBuffer(data->ring, pBuffer, lSamples);
|
||||
else
|
||||
SetALCError(ALC_INVALID_VALUE);
|
||||
}
|
||||
|
||||
static ALCuint oss_available_samples(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
return 0;
|
||||
oss_data *data = (oss_data*)pDevice->ExtraData;
|
||||
return RingBufferSize(data->ring);
|
||||
}
|
||||
|
||||
|
||||
@@ -323,4 +449,6 @@ void alc_oss_init(BackendFuncs *func_list)
|
||||
|
||||
oss_device = AppendDeviceList("OSS Software");
|
||||
AppendAllDeviceList(oss_device);
|
||||
|
||||
oss_device_capture = AppendCaptureDeviceList("OSS Capture");
|
||||
}
|
||||
|
||||
+334
@@ -0,0 +1,334 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2007 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include "alMain.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
FILE *f;
|
||||
long DataStart;
|
||||
|
||||
ALvoid *buffer;
|
||||
ALuint size;
|
||||
|
||||
int killNow;
|
||||
ALvoid *thread;
|
||||
} wave_data;
|
||||
|
||||
|
||||
static ALCchar *waveDevice;
|
||||
|
||||
|
||||
static ALuint WaveProc(ALvoid *ptr)
|
||||
{
|
||||
ALCdevice *pDevice = (ALCdevice*)ptr;
|
||||
wave_data *data = (wave_data*)pDevice->ExtraData;
|
||||
ALuint frameSize;
|
||||
ALuint now, last;
|
||||
size_t WriteCnt;
|
||||
ALuint avail;
|
||||
union {
|
||||
short s;
|
||||
char b[sizeof(short)];
|
||||
} uSB;
|
||||
|
||||
uSB.s = 1;
|
||||
frameSize = aluBytesFromFormat(pDevice->Format) *
|
||||
aluChannelsFromFormat(pDevice->Format);
|
||||
|
||||
last = timeGetTime();
|
||||
while(!data->killNow)
|
||||
{
|
||||
now = timeGetTime();
|
||||
|
||||
avail = (now-last) * pDevice->Frequency / 1000;
|
||||
if(avail < pDevice->UpdateSize/4)
|
||||
{
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
while(avail > 0)
|
||||
{
|
||||
SuspendContext(NULL);
|
||||
WriteCnt = min(data->size, avail);
|
||||
aluMixData(pDevice->Context, data->buffer, WriteCnt * frameSize,
|
||||
pDevice->Format);
|
||||
ProcessContext(NULL);
|
||||
|
||||
if(uSB.b[0] != 1 && aluBytesFromFormat(pDevice->Format) > 1)
|
||||
{
|
||||
ALubyte *bytes = data->buffer;
|
||||
ALuint i;
|
||||
|
||||
for(i = 0;i < WriteCnt*frameSize;i++)
|
||||
fputc(bytes[i^1], data->f);
|
||||
}
|
||||
else
|
||||
fwrite(data->buffer, frameSize, WriteCnt, data->f);
|
||||
if(ferror(data->f))
|
||||
{
|
||||
AL_PRINT("Error writing to file\n");
|
||||
data->killNow = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
avail -= WriteCnt;
|
||||
}
|
||||
last = now;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ALCboolean wave_open_playback(ALCdevice *device, const ALCchar *deviceName)
|
||||
{
|
||||
wave_data *data;
|
||||
ALuint channels;
|
||||
ALuint bits;
|
||||
const char *fname;
|
||||
int i;
|
||||
|
||||
fname = GetConfigValue("wave", "file", "");
|
||||
if(!fname[0])
|
||||
return ALC_FALSE;
|
||||
|
||||
if(deviceName)
|
||||
{
|
||||
if(strcmp(deviceName, waveDevice) != 0)
|
||||
return ALC_FALSE;
|
||||
device->szDeviceName = waveDevice;
|
||||
}
|
||||
else
|
||||
device->szDeviceName = waveDevice;
|
||||
|
||||
data = (wave_data*)calloc(1, sizeof(wave_data));
|
||||
|
||||
data->f = fopen(fname, "wb");
|
||||
if(!data->f)
|
||||
{
|
||||
free(data);
|
||||
AL_PRINT("Could not open file '%s': %s\n", fname, strerror(errno));
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
bits = aluBytesFromFormat(device->Format) * 8;
|
||||
channels = aluChannelsFromFormat(device->Format);
|
||||
switch(bits)
|
||||
{
|
||||
case 8:
|
||||
case 16:
|
||||
if(channels == 0)
|
||||
{
|
||||
AL_PRINT("Unknown format?! %x\n", device->Format);
|
||||
fclose(data->f);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
AL_PRINT("Unknown format?! %x\n", device->Format);
|
||||
fclose(data->f);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
fprintf(data->f, "RIFF");
|
||||
fputc(0, data->f); // 'RIFF' header len; filled in at close
|
||||
fputc(0, data->f);
|
||||
fputc(0, data->f);
|
||||
fputc(0, data->f);
|
||||
|
||||
fprintf(data->f, "WAVE");
|
||||
|
||||
fprintf(data->f, "fmt ");
|
||||
fputc(16, data->f); // 'fmt ' header len; 16 bytes for PCM
|
||||
fputc(0, data->f);
|
||||
fputc(0, data->f);
|
||||
fputc(0, data->f);
|
||||
// 16-bit val, format type id (PCM: 1)
|
||||
fputc(1, data->f);
|
||||
fputc(0, data->f);
|
||||
// 16-bit val, channel count
|
||||
fputc(channels&0xff, data->f);
|
||||
fputc((channels>>8)&0xff, data->f);
|
||||
// 32-bit val, frequency
|
||||
fputc(device->Frequency&0xff, data->f);
|
||||
fputc((device->Frequency>>8)&0xff, data->f);
|
||||
fputc((device->Frequency>>16)&0xff, data->f);
|
||||
fputc((device->Frequency>>24)&0xff, data->f);
|
||||
// 32-bit val, bytes per second
|
||||
i = device->Frequency * channels * bits / 8;
|
||||
fputc(i&0xff, data->f);
|
||||
fputc((i>>8)&0xff, data->f);
|
||||
fputc((i>>16)&0xff, data->f);
|
||||
fputc((i>>24)&0xff, data->f);
|
||||
// 16-bit val, frame size
|
||||
i = channels * bits / 8;
|
||||
fputc(i&0xff, data->f);
|
||||
fputc((i>>8)&0xff, data->f);
|
||||
// 16-bit val, bits per sample
|
||||
fputc(bits&0xff, data->f);
|
||||
fputc((bits>>8)&0xff, data->f);
|
||||
|
||||
fprintf(data->f, "data");
|
||||
fputc(0, data->f); // 'data' header len; filled in at close
|
||||
fputc(0, data->f);
|
||||
fputc(0, data->f);
|
||||
fputc(0, data->f);
|
||||
|
||||
if(ferror(data->f))
|
||||
{
|
||||
AL_PRINT("Error writing header: %s\n", strerror(errno));
|
||||
fclose(data->f);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
data->DataStart = ftell(data->f);
|
||||
|
||||
device->UpdateSize = max(device->UpdateSize, 2048);
|
||||
|
||||
data->size = device->UpdateSize;
|
||||
data->buffer = malloc(data->size * channels * bits / 8);
|
||||
if(!data->buffer)
|
||||
{
|
||||
AL_PRINT("buffer malloc failed\n");
|
||||
fclose(data->f);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
device->ExtraData = data;
|
||||
data->thread = StartThread(WaveProc, device);
|
||||
if(data->thread == NULL)
|
||||
{
|
||||
device->ExtraData = NULL;
|
||||
fclose(data->f);
|
||||
free(data->buffer);
|
||||
free(data);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
static void wave_close_playback(ALCdevice *device)
|
||||
{
|
||||
wave_data *data = (wave_data*)device->ExtraData;
|
||||
ALuint dataLen;
|
||||
long size;
|
||||
|
||||
data->killNow = 1;
|
||||
StopThread(data->thread);
|
||||
|
||||
size = ftell(data->f);
|
||||
if(size > 0)
|
||||
{
|
||||
dataLen = size - data->DataStart;
|
||||
if(fseek(data->f, data->DataStart-4, SEEK_SET) == 0)
|
||||
{
|
||||
fputc(dataLen&0xff, data->f); // 'data' header len
|
||||
fputc((dataLen>>8)&0xff, data->f);
|
||||
fputc((dataLen>>16)&0xff, data->f);
|
||||
fputc((dataLen>>24)&0xff, data->f);
|
||||
}
|
||||
if(fseek(data->f, 4, SEEK_SET) == 0)
|
||||
{
|
||||
size -= 8;
|
||||
fputc(size&0xff, data->f); // 'WAVE' header len
|
||||
fputc((size>>8)&0xff, data->f);
|
||||
fputc((size>>16)&0xff, data->f);
|
||||
fputc((size>>24)&0xff, data->f);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(data->f);
|
||||
free(data->buffer);
|
||||
free(data);
|
||||
device->ExtraData = NULL;
|
||||
}
|
||||
|
||||
|
||||
static ALCboolean wave_open_capture(ALCdevice *pDevice, const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei SampleSize)
|
||||
{
|
||||
(void)pDevice;
|
||||
(void)deviceName;
|
||||
(void)frequency;
|
||||
(void)format;
|
||||
(void)SampleSize;
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
static void wave_close_capture(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
}
|
||||
|
||||
static void wave_start_capture(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
}
|
||||
|
||||
static void wave_stop_capture(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
}
|
||||
|
||||
static void wave_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples)
|
||||
{
|
||||
(void)pDevice;
|
||||
(void)pBuffer;
|
||||
(void)lSamples;
|
||||
}
|
||||
|
||||
static ALCuint wave_available_samples(ALCdevice *pDevice)
|
||||
{
|
||||
(void)pDevice;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BackendFuncs wave_funcs = {
|
||||
wave_open_playback,
|
||||
wave_close_playback,
|
||||
wave_open_capture,
|
||||
wave_close_capture,
|
||||
wave_start_capture,
|
||||
wave_stop_capture,
|
||||
wave_capture_samples,
|
||||
wave_available_samples
|
||||
};
|
||||
|
||||
void alc_wave_init(BackendFuncs *func_list)
|
||||
{
|
||||
*func_list = wave_funcs;
|
||||
|
||||
waveDevice = AppendDeviceList("Wave File Writer");
|
||||
AppendAllDeviceList(waveDevice);
|
||||
}
|
||||
+37
-16
@@ -18,6 +18,8 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
@@ -63,7 +65,7 @@ static void CALLBACK WaveInProc(HWAVEIN hDevice,UINT uMsg,DWORD_PTR dwInstance,D
|
||||
(void)hDevice;
|
||||
(void)dwParam2;
|
||||
|
||||
if ((uMsg==WIM_DATA) && (pDevice))
|
||||
if ((uMsg==WIM_DATA))
|
||||
{
|
||||
// Decrement number of buffers in use
|
||||
pData->lWaveInBuffersCommitted--;
|
||||
@@ -207,12 +209,13 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
|
||||
|
||||
memset(&wfexCaptureFormat, 0, sizeof(WAVEFORMATEX));
|
||||
wfexCaptureFormat.wFormatTag = WAVE_FORMAT_PCM;
|
||||
wfexCaptureFormat.nChannels = pDevice->Channels;
|
||||
wfexCaptureFormat.wBitsPerSample = pDevice->FrameSize / pDevice->Channels * 8;
|
||||
wfexCaptureFormat.nBlockAlign = pDevice->FrameSize;
|
||||
wfexCaptureFormat.nChannels = aluChannelsFromFormat(pDevice->Format);
|
||||
wfexCaptureFormat.wBitsPerSample = aluBytesFromFormat(pDevice->Format) * 8;
|
||||
wfexCaptureFormat.nBlockAlign = wfexCaptureFormat.wBitsPerSample *
|
||||
wfexCaptureFormat.nChannels / 8;
|
||||
wfexCaptureFormat.nSamplesPerSec = frequency;
|
||||
wfexCaptureFormat.nAvgBytesPerSec = wfexCaptureFormat.nSamplesPerSec *
|
||||
pDevice->FrameSize;
|
||||
wfexCaptureFormat.nBlockAlign;
|
||||
wfexCaptureFormat.cbSize = 0;
|
||||
|
||||
if (waveInOpen(&pData->hWaveInHandle, lDeviceID, &wfexCaptureFormat, (DWORD_PTR)&WaveInProc, (DWORD_PTR)pDevice, CALLBACK_FUNCTION) != MMSYSERR_NOERROR)
|
||||
@@ -226,10 +229,6 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
|
||||
if (pData->hWaveInThreadEvent == NULL)
|
||||
goto failure;
|
||||
|
||||
pData->hWaveInThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CaptureThreadProc, (LPVOID)pDevice, 0, &pData->ulWaveInThreadID);
|
||||
if (pData->hWaveInThread == NULL)
|
||||
goto failure;
|
||||
|
||||
// Allocate circular memory buffer for the captured audio
|
||||
pData->ulCapturedDataSize = SampleSize * wfexCaptureFormat.nBlockAlign;
|
||||
|
||||
@@ -264,15 +263,32 @@ static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName
|
||||
pData->ulWriteCapturedDataPos = 0;
|
||||
|
||||
pDevice->ExtraData = pData;
|
||||
|
||||
pData->hWaveInThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CaptureThreadProc, (LPVOID)pDevice, 0, &pData->ulWaveInThreadID);
|
||||
if (pData->hWaveInThread == NULL)
|
||||
goto failure;
|
||||
|
||||
return ALC_TRUE;
|
||||
|
||||
failure:
|
||||
if (pData->hWaveInThreadEvent)
|
||||
CloseHandle(pData->hWaveInThreadEvent);
|
||||
for (i=0;i<4;i++)
|
||||
{
|
||||
if(pData->WaveInBuffer[i].lpData)
|
||||
{
|
||||
waveInUnprepareHeader(pData->hWaveInHandle, &pData->WaveInBuffer[i], sizeof(WAVEHDR));
|
||||
free(pData->WaveInBuffer[i].lpData);
|
||||
}
|
||||
}
|
||||
|
||||
free(pData->pCapturedSampleData);
|
||||
if(pData->hWaveInHandle)
|
||||
waveInClose(pData->hWaveInHandle);
|
||||
if(pData->hWaveInThread)
|
||||
CloseHandle(pData->hWaveInThread);
|
||||
if (pData->hWaveInHdrEvent)
|
||||
CloseHandle(pData->hWaveInHdrEvent);
|
||||
if (pData->hWaveInHandle)
|
||||
waveInClose(pData->hWaveInHandle);
|
||||
if (pData->hWaveInThreadEvent)
|
||||
CloseHandle(pData->hWaveInThreadEvent);
|
||||
|
||||
free(pData);
|
||||
return ALC_FALSE;
|
||||
@@ -346,16 +362,20 @@ static void WinMMCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lS
|
||||
ALuint ulBytes, ulBytesToCopy;
|
||||
ALuint ulCapturedSamples;
|
||||
ALuint ulReadOffset;
|
||||
ALuint frameSize = aluBytesFromFormat(pDevice->Format) *
|
||||
aluChannelsFromFormat(pDevice->Format);
|
||||
|
||||
// Check that we have the requested numbers of Samples
|
||||
ulCapturedSamples = (pData->ulWriteCapturedDataPos - pData->ulReadCapturedDataPos) / pDevice->FrameSize;
|
||||
ulCapturedSamples = (pData->ulWriteCapturedDataPos -
|
||||
pData->ulReadCapturedDataPos) /
|
||||
frameSize;
|
||||
if(ulSamples > ulCapturedSamples)
|
||||
{
|
||||
SetALCError(ALC_INVALID_VALUE);
|
||||
return;
|
||||
}
|
||||
|
||||
ulBytes = ulSamples * pDevice->FrameSize;
|
||||
ulBytes = ulSamples * frameSize;
|
||||
|
||||
// Get Read Offset
|
||||
ulReadOffset = (pData->ulReadCapturedDataPos % pData->ulCapturedDataSize);
|
||||
@@ -384,7 +404,8 @@ static ALCuint WinMMAvailableSamples(ALCdevice *pDevice)
|
||||
{
|
||||
WinMMData *pData = (WinMMData*)pDevice->ExtraData;
|
||||
ALCuint lCapturedBytes = (pData->ulWriteCapturedDataPos - pData->ulReadCapturedDataPos);
|
||||
return lCapturedBytes / pDevice->FrameSize;
|
||||
return lCapturedBytes / (aluBytesFromFormat(pDevice->Format) *
|
||||
aluChannelsFromFormat(pDevice->Format));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+118
-69
@@ -15,31 +15,22 @@ PROJECT(OpenAL)
|
||||
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
|
||||
|
||||
|
||||
OPTION(ALSA "ALSA backend" ON)
|
||||
OPTION(OSS "OSS backend" ON)
|
||||
OPTION(DSOUND "DirectSound backend" ON)
|
||||
OPTION(WINMM "Windows Multimedia backend" ON)
|
||||
OPTION(ALSA "Check for ALSA backend" ON)
|
||||
OPTION(OSS "Check for OSS backend" ON)
|
||||
OPTION(DSOUND "Check for DirectSound backend" ON)
|
||||
OPTION(WINMM "Check for Windows Multimedia backend" ON)
|
||||
|
||||
OPTION(DLOPEN "Use the dlopen API for loading optional libs" ON)
|
||||
OPTION(DLOPEN "Check for the dlopen API for loading optional libs" ON)
|
||||
|
||||
OPTION(DEBUG "Build lib in debug mode" OFF)
|
||||
OPTION(NODEBUG "Disable all debug info for optimizations" OFF)
|
||||
OPTION(WERROR "Treat compile warnings as errors" OFF)
|
||||
|
||||
|
||||
SET(LIB_MAJOR_VERSION "1")
|
||||
SET(LIB_MINOR_VERSION "0")
|
||||
SET(LIB_BUILD_VERSION "38")
|
||||
SET(LIB_MINOR_VERSION "3")
|
||||
SET(LIB_BUILD_VERSION "253")
|
||||
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_BUILD_VERSION}")
|
||||
|
||||
|
||||
IF("${WIN32}")
|
||||
SET(LIBNAME openal32)
|
||||
ELSE()
|
||||
SET(LIBNAME openal)
|
||||
ENDIF()
|
||||
|
||||
|
||||
CHECK_TYPE_SIZE("long" SIZEOF_LONG)
|
||||
CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
|
||||
CHECK_TYPE_SIZE("unsigned int" SIZEOF_UINT)
|
||||
@@ -48,10 +39,19 @@ CHECK_TYPE_SIZE("void*" SIZEOF_VOIDP)
|
||||
|
||||
# Add definitions, compiler switches, etc.
|
||||
INCLUDE_DIRECTORIES(OpenAL32/Include include "${OpenAL_BINARY_DIR}")
|
||||
SET(EXTRA_LIBS m ${EXTRA_LIBS})
|
||||
|
||||
IF("${MSVC}")
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
|
||||
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
|
||||
FORCE)
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC)
|
||||
# ???
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D_DEBUG")
|
||||
SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
|
||||
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
|
||||
ELSE()
|
||||
ADD_DEFINITIONS(-Wall)
|
||||
CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA)
|
||||
@@ -63,13 +63,18 @@ ELSE()
|
||||
ADD_DEFINITIONS(-Werror)
|
||||
ENDIF()
|
||||
|
||||
IF(DEBUG)
|
||||
ADD_DEFINITIONS(-g3)
|
||||
ELSEIF(NODEBUG)
|
||||
ADD_DEFINITIONS(-O2 -funroll-loops -fomit-frame-pointer)
|
||||
ELSE()
|
||||
ADD_DEFINITIONS(-g -O2 -funroll-loops)
|
||||
ENDIF()
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -funroll-loops -D_DEBUG" CACHE STRING
|
||||
"Flags used by the compiler during Release with Debug Info builds."
|
||||
FORCE)
|
||||
SET(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING
|
||||
"Flags used by the compiler during release minsize builds."
|
||||
FORCE)
|
||||
SET(CMAKE_C_FLAGS_RELEASE "-O2 -funroll-loops -fomit-frame-pointer -DNDEBUG" CACHE STRING
|
||||
"Flags used by the compiler during release builds"
|
||||
FORCE)
|
||||
SET(CMAKE_C_FLAGS_DEBUG "-g3 -D_DEBUG" CACHE STRING
|
||||
"Flags used by the compiler during debug builds."
|
||||
FORCE)
|
||||
|
||||
# The mixer doesn't like GCC's strict aliasing optimizations. Make sure
|
||||
# it's turned off
|
||||
@@ -79,7 +84,7 @@ ELSE()
|
||||
ENDIF()
|
||||
|
||||
# Set visibility options if available
|
||||
IF(NOT "${WIN32}")
|
||||
IF(NOT WIN32)
|
||||
CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor));
|
||||
int main() {return 0;}" HAVE_GCC_DESTRUCTOR)
|
||||
|
||||
@@ -94,31 +99,50 @@ ELSE()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(DEBUG)
|
||||
ADD_DEFINITIONS(-D_DEBUG)
|
||||
ELSEIF(NODEBUG)
|
||||
ADD_DEFINITIONS(-DNDEBUG)
|
||||
ENDIF()
|
||||
|
||||
CHECK_LIBRARY_EXISTS(m sqrtf "" HAVE_SQRTF)
|
||||
CHECK_LIBRARY_EXISTS(m acosf "" HAVE_ACOSF)
|
||||
IF(HAVE_SQRTF OR HAVE_ACOSF)
|
||||
SET(EXTRA_LIBS m ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
|
||||
|
||||
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
|
||||
IF(NOT "${HAVE_STRCASECMP}")
|
||||
IF(NOT HAVE_STRCASECMP)
|
||||
CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
|
||||
IF(NOT "${HAVE__STRICMP}")
|
||||
IF(NOT HAVE__STRICMP)
|
||||
MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!")
|
||||
ENDIF()
|
||||
|
||||
ADD_DEFINITIONS(-Dstrcasecmp=_stricmp)
|
||||
ENDIF()
|
||||
|
||||
CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP)
|
||||
IF(NOT HAVE_STRNCASECMP)
|
||||
CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP)
|
||||
IF(NOT HAVE__STRNICMP)
|
||||
MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!")
|
||||
ENDIF()
|
||||
|
||||
ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp)
|
||||
ENDIF()
|
||||
|
||||
CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
|
||||
IF(NOT HAVE_SNPRINTF)
|
||||
CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF)
|
||||
IF(NOT HAVE__SNPRINTF)
|
||||
MESSAGE(FATAL_ERROR "No snprintf function found, please report!")
|
||||
ENDIF()
|
||||
|
||||
ADD_DEFINITIONS(-Dsnprintf=_snprintf)
|
||||
ENDIF()
|
||||
|
||||
# Check for the dlopen API (for dynamicly loading backend libs)
|
||||
IF(DLOPEN)
|
||||
CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
|
||||
IF("${HAVE_DLFCN_H}")
|
||||
IF(HAVE_DLFCN_H)
|
||||
CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
|
||||
IF("${HAVE_LIBDL}")
|
||||
IF(HAVE_LIBDL)
|
||||
SET(EXTRA_LIBS dl ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
@@ -126,10 +150,20 @@ ENDIF()
|
||||
|
||||
# Check if we have Windows headers
|
||||
CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
|
||||
IF(NOT "${HAVE_WINDOWS_H}")
|
||||
IF(NOT HAVE_WINDOWS_H)
|
||||
CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
|
||||
IF(NOT HAVE_GETTIMEOFDAY)
|
||||
MESSAGE(FATAL_ERROR "No timing function found!")
|
||||
ENDIF()
|
||||
|
||||
CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
|
||||
IF(NOT HAVE_NANOSLEEP)
|
||||
MESSAGE(FATAL_ERROR "No sleep function found!")
|
||||
ENDIF()
|
||||
|
||||
# We need pthreads outside of Windows
|
||||
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
|
||||
IF(NOT "${HAVE_PTHREAD_H}")
|
||||
IF(NOT HAVE_PTHREAD_H)
|
||||
MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
|
||||
ENDIF()
|
||||
|
||||
@@ -137,22 +171,22 @@ IF(NOT "${HAVE_WINDOWS_H}")
|
||||
# _REENTRANT is needed for libc thread-safety
|
||||
ADD_DEFINITIONS(-D_GNU_SOURCE=1 -D_REENTRANT)
|
||||
CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
|
||||
IF("${HAVE_LIBPTHREAD}")
|
||||
IF(HAVE_LIBPTHREAD)
|
||||
SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Check for a 64-bit type
|
||||
CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
|
||||
IF(NOT "${HAVE_STDINT_H}")
|
||||
IF("${HAVE_WINDOWS_H}")
|
||||
IF(NOT HAVE_STDINT_H)
|
||||
IF(HAVE_WINDOWS_H)
|
||||
CHECK_C_SOURCE_COMPILES("\#include <windows.h>
|
||||
__int64 foo;
|
||||
int main() {return 0;}" HAVE___INT64)
|
||||
ENDIF()
|
||||
IF(NOT "${HAVE___INT64}")
|
||||
IF(NOT "${SIZEOF_LONG}" MATCHES "8")
|
||||
IF(NOT "${SIZEOF_LONG_LONG}" MATCHES "8")
|
||||
IF(NOT HAVE___INT64)
|
||||
IF(NOT SIZEOF_LONG MATCHES "8")
|
||||
IF(NOT SIZEOF_LONG_LONG MATCHES "8")
|
||||
MESSAGE(FATAL_ERROR "No 64-bit types found, please report!")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
@@ -160,9 +194,12 @@ IF(NOT "${HAVE_STDINT_H}")
|
||||
ENDIF()
|
||||
|
||||
|
||||
SET(OPENAL_OBJS OpenAL32/alBuffer.c
|
||||
SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c
|
||||
OpenAL32/alBuffer.c
|
||||
OpenAL32/alEffect.c
|
||||
OpenAL32/alError.c
|
||||
OpenAL32/alExtension.c
|
||||
OpenAL32/alFilter.c
|
||||
OpenAL32/alListener.c
|
||||
OpenAL32/alSource.c
|
||||
OpenAL32/alState.c
|
||||
@@ -172,7 +209,10 @@ SET(OPENAL_OBJS OpenAL32/alBuffer.c
|
||||
SET(ALC_OBJS Alc/ALc.c
|
||||
Alc/ALu.c
|
||||
Alc/alcConfig.c
|
||||
Alc/alcRing.c
|
||||
Alc/alcThread.c
|
||||
Alc/bs2b.c
|
||||
Alc/wave.c
|
||||
)
|
||||
|
||||
SET(BACKENDS "")
|
||||
@@ -180,15 +220,15 @@ SET(BACKENDS "")
|
||||
# Check ALSA backend
|
||||
IF(ALSA)
|
||||
CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
|
||||
IF("${HAVE_ALSA_ASOUNDLIB_H}")
|
||||
IF(HAVE_ALSA_ASOUNDLIB_H)
|
||||
CHECK_LIBRARY_EXISTS(asound snd_pcm_open "" HAVE_LIBASOUND)
|
||||
IF("${HAVE_DLFCN_H}" OR "${HAVE_LIBASOUND}")
|
||||
IF(HAVE_DLFCN_H OR HAVE_LIBASOUND)
|
||||
SET(HAVE_ALSA 1)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/alsa.c)
|
||||
IF("${HAVE_DLFCN_H}")
|
||||
SET(BACKENDS ${BACKENDS} ALSA)
|
||||
IF(HAVE_DLFCN_H)
|
||||
SET(BACKENDS "${BACKENDS} ALSA,")
|
||||
ELSE()
|
||||
SET(BACKENDS ${BACKENDS} ALSA\(linked\))
|
||||
SET(BACKENDS "${BACKENDS} ALSA \(linked\),")
|
||||
SET(EXTRA_LIBS asound ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
@@ -198,54 +238,52 @@ ENDIF()
|
||||
# Check OSS backend
|
||||
IF(OSS)
|
||||
CHECK_INCLUDE_FILE(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
|
||||
IF("${HAVE_SYS_SOUNDCARD_H}")
|
||||
IF(HAVE_SYS_SOUNDCARD_H)
|
||||
SET(HAVE_OSS 1)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/oss.c)
|
||||
SET(BACKENDS ${BACKENDS} OSS)
|
||||
SET(BACKENDS "${BACKENDS} OSS,")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Check DSound/MMSystem backend
|
||||
IF("${HAVE_WINDOWS_H}")
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ole32)
|
||||
CHECK_C_SOURCE_COMPILES("int main() {return 0;}" HAVE_LIBOLE32)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES "")
|
||||
# CHECK_LIBRARY_EXISTS(ole32 CoInitialize "" HAVE_LIBOLE32)
|
||||
IF("${HAVE_LIBOLE32}")
|
||||
SET(EXTRA_LIBS ole32 ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
|
||||
IF(HAVE_WINDOWS_H)
|
||||
IF(DSOUND)
|
||||
CHECK_INCLUDE_FILE(dsound.h HAVE_DSOUND_H)
|
||||
IF("${HAVE_DSOUND_H}")
|
||||
IF(HAVE_DSOUND_H)
|
||||
SET(HAVE_DSOUND 1)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/dsound.c)
|
||||
SET(BACKENDS ${BACKENDS} DirectSound)
|
||||
SET(BACKENDS "${BACKENDS} DirectSound,")
|
||||
|
||||
CHECK_LIBRARY_EXISTS(dxguid IID_IDirectSound "" HAVE_LIBDXGUID)
|
||||
IF("${HAVE_LIBDXGUID}")
|
||||
SET(EXTRA_LIBS dxguid ${EXTRA_LIBS})
|
||||
SET(CMAKE_REQUIRED_LIBRARIES dsound)
|
||||
CHECK_C_SOURCE_COMPILES("int main() {return 0;}" HAVE_LIBDSOUND)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES "")
|
||||
# CHECK_LIBRARY_EXISTS(dsound DirectSoundCreate "" HAVE_LIBDSOUND)
|
||||
IF(HAVE_LIBDSOUND)
|
||||
SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
IF(WINMM)
|
||||
CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H)
|
||||
IF("${HAVE_MMSYSTEM_H}")
|
||||
IF(HAVE_MMSYSTEM_H)
|
||||
SET(HAVE_WINMM 1)
|
||||
SET(ALC_OBJS ${ALC_OBJS} Alc/winmm.c)
|
||||
SET(BACKENDS ${BACKENDS} WinMM)
|
||||
SET(BACKENDS "${BACKENDS} WinMM,")
|
||||
|
||||
SET(CMAKE_REQUIRED_LIBRARIES winmm)
|
||||
CHECK_C_SOURCE_COMPILES("int main() {return 0;}" HAVE_LIBWINMM)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES "")
|
||||
# CHECK_LIBRARY_EXISTS(winmm waveInOpen "" HAVE_LIBWINMM)
|
||||
IF("${HAVE_LIBWINMM}")
|
||||
IF(HAVE_LIBWINMM)
|
||||
SET(EXTRA_LIBS winmm ${EXTRA_LIBS})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# This is always available
|
||||
SET(BACKENDS "${BACKENDS} WaveFile")
|
||||
|
||||
# End configuration
|
||||
CONFIGURE_FILE(
|
||||
"${OpenAL_SOURCE_DIR}/config.h.in"
|
||||
@@ -254,8 +292,18 @@ CONFIGURE_FILE(
|
||||
ADD_DEFINITIONS(-DAL_BUILD_LIBRARY)
|
||||
|
||||
# Build a shared library
|
||||
IF(WIN32)
|
||||
SET(LIBNAME openal32)
|
||||
ELSE()
|
||||
SET(LIBNAME openal)
|
||||
ENDIF()
|
||||
|
||||
ADD_LIBRARY(${LIBNAME} SHARED ${OPENAL_OBJS} ${ALC_OBJS})
|
||||
SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION} SOVERSION ${LIB_MAJOR_VERSION})
|
||||
SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
|
||||
SOVERSION ${LIB_MAJOR_VERSION})
|
||||
IF(WIN32)
|
||||
SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
|
||||
ENDIF()
|
||||
|
||||
TARGET_LINK_LIBRARIES(${LIBNAME} ${EXTRA_LIBS})
|
||||
|
||||
@@ -267,6 +315,7 @@ INSTALL(TARGETS ${LIBNAME}
|
||||
)
|
||||
INSTALL(FILES include/AL/al.h
|
||||
include/AL/alc.h
|
||||
include/AL/alext.h
|
||||
DESTINATION include/AL
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef _AL_AUXEFFECTSLOT_H_
|
||||
#define _AL_AUXEFFECTSLOT_H_
|
||||
|
||||
#include "alEffect.h"
|
||||
#include "AL/al.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AL_EFFECTSLOT_EFFECT 0x0001
|
||||
#define AL_EFFECTSLOT_GAIN 0x0002
|
||||
#define AL_EFFECTSLOT_AUXILIARY_SEND_AUTO 0x0003
|
||||
|
||||
#define AL_EFFECTSLOT_NULL 0x0000
|
||||
|
||||
typedef struct ALeffectslot
|
||||
{
|
||||
ALeffect effect;
|
||||
|
||||
ALfloat Gain;
|
||||
ALboolean AuxSendAuto;
|
||||
|
||||
ALfloat *ReverbBuffer;
|
||||
// in frames!
|
||||
ALuint ReverbLength;
|
||||
ALuint ReverbPos;
|
||||
ALuint ReverbReflectPos;
|
||||
ALuint ReverbLatePos;
|
||||
ALfloat ReverbDecayGain;
|
||||
ALfloat LastDecaySample;
|
||||
|
||||
ALuint refcount;
|
||||
|
||||
// Index to itself
|
||||
ALuint effectslot;
|
||||
|
||||
struct ALeffectslot *next;
|
||||
} ALeffectslot;
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots);
|
||||
AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots);
|
||||
AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot);
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue);
|
||||
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues);
|
||||
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue);
|
||||
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues);
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue);
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues);
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue);
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues);
|
||||
|
||||
ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,89 @@
|
||||
#ifndef _AL_EFFECT_H_
|
||||
#define _AL_EFFECT_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AL_EFFECT_TYPE 0x8001
|
||||
|
||||
#define AL_EFFECT_NULL 0x0000
|
||||
#define AL_EFFECT_REVERB 0x0001
|
||||
#define AL_EFFECT_CHORUS 0x0002
|
||||
#define AL_EFFECT_DISTORTION 0x0003
|
||||
#define AL_EFFECT_ECHO 0x0004
|
||||
#define AL_EFFECT_FLANGER 0x0005
|
||||
#define AL_EFFECT_FREQUENCY_SHIFTER 0x0006
|
||||
#define AL_EFFECT_VOCAL_MORPHER 0x0007
|
||||
#define AL_EFFECT_PITCH_SHIFTER 0x0008
|
||||
#define AL_EFFECT_RING_MODULATOR 0x0009
|
||||
#define AL_EFFECT_AUTOWAH 0x000A
|
||||
#define AL_EFFECT_COMPRESSOR 0x000B
|
||||
#define AL_EFFECT_EQUALIZER 0x000C
|
||||
|
||||
#define AL_REVERB_DENSITY 0x0001
|
||||
#define AL_REVERB_DIFFUSION 0x0002
|
||||
#define AL_REVERB_GAIN 0x0003
|
||||
#define AL_REVERB_GAINHF 0x0004
|
||||
#define AL_REVERB_DECAY_TIME 0x0005
|
||||
#define AL_REVERB_DECAY_HFRATIO 0x0006
|
||||
#define AL_REVERB_REFLECTIONS_GAIN 0x0007
|
||||
#define AL_REVERB_REFLECTIONS_DELAY 0x0008
|
||||
#define AL_REVERB_LATE_REVERB_GAIN 0x0009
|
||||
#define AL_REVERB_LATE_REVERB_DELAY 0x000A
|
||||
#define AL_REVERB_AIR_ABSORPTION_GAINHF 0x000B
|
||||
#define AL_REVERB_ROOM_ROLLOFF_FACTOR 0x000C
|
||||
#define AL_REVERB_DECAY_HFLIMIT 0x000D
|
||||
|
||||
|
||||
typedef struct ALeffect_struct
|
||||
{
|
||||
// Effect type (AL_EFFECT_NULL, ...)
|
||||
ALenum type;
|
||||
|
||||
struct {
|
||||
ALfloat Density;
|
||||
ALfloat Diffusion;
|
||||
|
||||
ALfloat Gain;
|
||||
ALfloat GainHF;
|
||||
ALfloat DecayTime;
|
||||
ALfloat DecayHFRatio;
|
||||
ALfloat ReflectionsGain;
|
||||
ALfloat ReflectionsDelay;
|
||||
ALfloat LateReverbGain;
|
||||
ALfloat LateReverbDelay;
|
||||
ALfloat AirAbsorptionGainHF;
|
||||
ALfloat RoomRolloffFactor;
|
||||
ALboolean DecayHFLimit;
|
||||
} Reverb;
|
||||
|
||||
// Index to itself
|
||||
ALuint effect;
|
||||
|
||||
struct ALeffect_struct *next;
|
||||
} ALeffect;
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects);
|
||||
AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects);
|
||||
AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect);
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue);
|
||||
AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValues);
|
||||
AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue);
|
||||
AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, ALfloat *pflValues);
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue);
|
||||
AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues);
|
||||
AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue);
|
||||
AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues);
|
||||
|
||||
ALvoid ReleaseALEffects(ALvoid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef _AL_FILTER_H_
|
||||
#define _AL_FILTER_H_
|
||||
|
||||
#include "AL/al.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AL_FILTER_TYPE 0x8001
|
||||
|
||||
#define AL_FILTER_NULL 0x0000
|
||||
#define AL_FILTER_LOWPASS 0x0001
|
||||
#define AL_FILTER_HIGHPASS 0x0002
|
||||
#define AL_FILTER_BANDPASS 0x0003
|
||||
|
||||
#define AL_LOWPASS_GAIN 0x0001
|
||||
#define AL_LOWPASS_GAINHF 0x0002
|
||||
|
||||
|
||||
typedef struct ALfilter_struct
|
||||
{
|
||||
// Filter type (AL_FILTER_NULL, ...)
|
||||
ALenum type;
|
||||
|
||||
ALfloat Gain;
|
||||
ALfloat GainHF;
|
||||
|
||||
// Index to itself
|
||||
ALuint filter;
|
||||
|
||||
struct ALfilter_struct *next;
|
||||
} ALfilter;
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters);
|
||||
AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters);
|
||||
AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter);
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue);
|
||||
AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, ALint *piValues);
|
||||
AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue);
|
||||
AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, ALfloat *pflValues);
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue);
|
||||
AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues);
|
||||
AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue);
|
||||
AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues);
|
||||
|
||||
ALvoid ReleaseALFilters(ALvoid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -7,6 +7,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AL_METERS_PER_UNIT 0x20004
|
||||
|
||||
typedef struct ALlistener_struct
|
||||
{
|
||||
ALfloat Position[3];
|
||||
@@ -14,6 +16,7 @@ typedef struct ALlistener_struct
|
||||
ALfloat Forward[3];
|
||||
ALfloat Up[3];
|
||||
ALfloat Gain;
|
||||
ALfloat MetersPerUnit;
|
||||
} ALlistener;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+61
-31
@@ -1,21 +1,22 @@
|
||||
#ifndef AL_MAIN_H
|
||||
#define AL_MAIN_H
|
||||
|
||||
#define AL_MAX_CHANNELS 4
|
||||
#define AL_MAX_SOURCES 32
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "alu.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <windows.h>
|
||||
//#define strcasecmp _stricmp
|
||||
|
||||
#else
|
||||
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define IsBadWritePtr(a,b) (0)
|
||||
|
||||
@@ -55,49 +56,64 @@ static inline void DeleteCriticalSection(CRITICAL_SECTION *cs)
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
/* NOTE: This wrapper isn't quite accurate as it returns an ALuint, as opposed
|
||||
* to the expected DWORD. Both are defined as unsigned 32-bit types, however.
|
||||
* Additionally, Win32 is supposed to measure the time since Windows started,
|
||||
* as opposed to the actual time. */
|
||||
static inline ALuint timeGetTime(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
int ret;
|
||||
|
||||
ret = gettimeofday(&tv, NULL);
|
||||
assert(ret == 0);
|
||||
|
||||
return tv.tv_usec/1000 + tv.tv_sec*1000;
|
||||
}
|
||||
|
||||
static inline void Sleep(ALuint t)
|
||||
{
|
||||
struct timespec tv, rem;
|
||||
tv.tv_nsec = (t*1000000)%1000000000;
|
||||
tv.tv_sec = t/1000;
|
||||
|
||||
while(nanosleep(&tv, &rem) == -1 && errno == EINTR)
|
||||
tv = rem;
|
||||
}
|
||||
#define min(x,y) (((x)<(y))?(x):(y))
|
||||
#define max(x,y) (((x)>(y))?(x):(y))
|
||||
#endif
|
||||
|
||||
#include "alBuffer.h"
|
||||
#include "alError.h"
|
||||
#include "alExtension.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "AL/alext.h"
|
||||
#include "alListener.h"
|
||||
#include "alSource.h"
|
||||
#include "alState.h"
|
||||
#include "alThunk.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern CRITICAL_SECTION g_mutex;
|
||||
extern CRITICAL_SECTION _alMutex;
|
||||
|
||||
extern char szDebug[256];
|
||||
extern char _alDebug[256];
|
||||
|
||||
#define AL_PRINT(...) do { \
|
||||
int _al_print_i; \
|
||||
char *_al_print_fn = strrchr(__FILE__, '/'); \
|
||||
if(!_al_print_fn) _al_print_fn = __FILE__; \
|
||||
else _al_print_fn += 1; \
|
||||
_al_print_i = snprintf(szDebug, sizeof(szDebug), "AL lib: %s:%d: ", _al_print_fn, __LINE__); \
|
||||
snprintf(szDebug+_al_print_i, sizeof(szDebug)-_al_print_i, __VA_ARGS__); \
|
||||
fprintf(stderr, "%s", szDebug); \
|
||||
_al_print_i = snprintf(_alDebug, sizeof(_alDebug), "AL lib: %s:%d: ", _al_print_fn, __LINE__); \
|
||||
if(_al_print_i < (int)sizeof(_alDebug) && _al_print_i > 0) \
|
||||
snprintf(_alDebug+_al_print_i, sizeof(_alDebug)-_al_print_i, __VA_ARGS__); \
|
||||
_alDebug[sizeof(_alDebug)-1] = 0; \
|
||||
fprintf(stderr, "%s", _alDebug); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define AL_FORMAT_MONO_IMA4 0x1300
|
||||
#define AL_FORMAT_STEREO_IMA4 0x1301
|
||||
// These are from AL_EXT_MCFORMATS, which we don't support yet but the mixer
|
||||
// can use 4-channel formats
|
||||
#define AL_FORMAT_QUAD8 0x1204
|
||||
#define AL_FORMAT_QUAD16 0x1205
|
||||
|
||||
#define SWMIXER_OUTPUT_RATE 44100
|
||||
//#define OUTPUT_BUFFER_SIZE (32768*SWMIXER_OUTPUT_RATE/22050)
|
||||
|
||||
#define SPEEDOFSOUNDMETRESPERSEC (343.3f)
|
||||
#define AIRABSORBGAINHF (0.994f)
|
||||
|
||||
typedef struct {
|
||||
ALCboolean (*OpenPlayback)(ALCdevice*, const ALCchar*);
|
||||
@@ -115,17 +131,15 @@ void alc_alsa_init(BackendFuncs *func_list);
|
||||
void alc_oss_init(BackendFuncs *func_list);
|
||||
void alcDSoundInit(BackendFuncs *func_list);
|
||||
void alcWinMMInit(BackendFuncs *FuncList);
|
||||
void alc_wave_init(BackendFuncs *func_list);
|
||||
|
||||
|
||||
struct ALCdevice_struct
|
||||
{
|
||||
ALboolean InUse;
|
||||
ALboolean IsCaptureDevice;
|
||||
|
||||
ALuint Frequency;
|
||||
ALuint UpdateFreq;
|
||||
ALuint FrameSize;
|
||||
ALuint Channels;
|
||||
ALuint UpdateSize;
|
||||
ALenum Format;
|
||||
|
||||
ALCchar *szDeviceName;
|
||||
@@ -138,6 +152,8 @@ struct ALCdevice_struct
|
||||
|
||||
BackendFuncs *Funcs;
|
||||
void *ExtraData; // For the backend's use
|
||||
|
||||
ALCdevice *next;
|
||||
};
|
||||
|
||||
#define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b)))
|
||||
@@ -153,8 +169,11 @@ struct ALCcontext_struct
|
||||
{
|
||||
ALlistener Listener;
|
||||
|
||||
ALsource *Source;
|
||||
ALuint SourceCount;
|
||||
struct ALsource *Source;
|
||||
ALuint SourceCount;
|
||||
|
||||
struct ALeffectslot *AuxiliaryEffectSlot;
|
||||
ALuint AuxiliaryEffectSlotCount;
|
||||
|
||||
ALenum LastError;
|
||||
ALboolean InUse;
|
||||
@@ -173,9 +192,13 @@ struct ALCcontext_struct
|
||||
ALCdevice *Device;
|
||||
ALCchar ExtensionList[1024];
|
||||
|
||||
struct bs2b *bs2b;
|
||||
|
||||
ALCcontext *next;
|
||||
};
|
||||
|
||||
ALCvoid ReleaseALC(ALCvoid);
|
||||
|
||||
ALCchar *AppendDeviceList(char *name);
|
||||
ALCchar *AppendAllDeviceList(char *name);
|
||||
ALCchar *AppendCaptureDeviceList(char *name);
|
||||
@@ -188,6 +211,13 @@ ALCvoid ProcessContext(ALCcontext *context);
|
||||
ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr);
|
||||
ALuint StopThread(ALvoid *thread);
|
||||
|
||||
typedef struct RingBuffer RingBuffer;
|
||||
RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length);
|
||||
void DestroyRingBuffer(RingBuffer *ring);
|
||||
ALsizei RingBufferSize(RingBuffer *ring);
|
||||
void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len);
|
||||
void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len);
|
||||
|
||||
void ReadALConfig(void);
|
||||
void FreeALConfig(void);
|
||||
const char *GetConfigValue(const char *blockName, const char *keyName, const char *def);
|
||||
|
||||
@@ -3,8 +3,21 @@
|
||||
|
||||
#define AL_NUM_SOURCE_PARAMS 128
|
||||
|
||||
/* This cannot be changed without working on the code! */
|
||||
#define MAX_SENDS 1
|
||||
|
||||
#include "alFilter.h"
|
||||
#include "AL/al.h"
|
||||
|
||||
#define AL_DIRECT_FILTER 0x20005
|
||||
#define AL_AUXILIARY_SEND_FILTER 0x20006
|
||||
#define AL_AIR_ABSORPTION_FACTOR 0x20007
|
||||
#define AL_ROOM_ROLLOFF_FACTOR 0x20008
|
||||
#define AL_CONE_OUTER_GAINHF 0x20009
|
||||
#define AL_DIRECT_FILTER_GAINHF_AUTO 0x2000A
|
||||
#define AL_AUXILIARY_SEND_FILTER_GAIN_AUTO 0x2000B
|
||||
#define AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO 0x2000C
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -17,7 +30,7 @@ typedef struct ALbufferlistitem
|
||||
struct ALbufferlistitem *next;
|
||||
} ALbufferlistitem;
|
||||
|
||||
typedef struct ALsource_struct
|
||||
typedef struct ALsource
|
||||
{
|
||||
ALfloat flPitch;
|
||||
ALfloat flGain;
|
||||
@@ -50,6 +63,25 @@ typedef struct ALsource_struct
|
||||
ALuint BuffersPlayed; // Number of buffers played on this loop
|
||||
ALuint BufferPosition; // Read position in audio data of current buffer
|
||||
|
||||
ALfilter DirectFilter;
|
||||
|
||||
struct {
|
||||
struct ALeffectslot *Slot;
|
||||
ALfilter WetFilter;
|
||||
} Send[MAX_SENDS];
|
||||
|
||||
ALfloat LastDrySample;
|
||||
ALfloat LastWetSample;
|
||||
|
||||
ALboolean DryGainHFAuto;
|
||||
ALboolean WetGainAuto;
|
||||
ALboolean WetGainHFAuto;
|
||||
ALfloat OuterGainHF;
|
||||
|
||||
ALfloat AirAbsorptionFactor;
|
||||
|
||||
ALfloat RoomRolloffFactor;
|
||||
|
||||
// Index to itself
|
||||
ALuint source;
|
||||
|
||||
@@ -61,9 +93,11 @@ typedef struct ALsource_struct
|
||||
// Source Type (Static, Streaming, or Undetermined)
|
||||
ALint lSourceType;
|
||||
|
||||
struct ALsource_struct *next;
|
||||
struct ALsource *next;
|
||||
} ALsource;
|
||||
|
||||
ALvoid ReleaseALSources(ALCcontext *Context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
#ifndef _ALU_H_
|
||||
#define _ALU_H_
|
||||
|
||||
#define BUFFERSIZE 48000
|
||||
#define FRACTIONBITS 14
|
||||
#define FRACTIONMASK ((1L<<FRACTIONBITS)-1)
|
||||
#define MAX_PITCH 4
|
||||
#define OUTPUTCHANNELS 4
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
|
||||
@@ -14,6 +8,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern ALboolean DuplicateStereo;
|
||||
|
||||
__inline ALuint aluBytesFromFormat(ALenum format);
|
||||
__inline ALuint aluChannelsFromFormat(ALenum format);
|
||||
ALvoid aluMixData(ALCcontext *context,ALvoid *buffer,ALsizei size,ALenum format);
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Boris Mikhaylov
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef BS2B_H
|
||||
#define BS2B_H
|
||||
|
||||
/* Number of crossfeed levels */
|
||||
#define BS2B_CLEVELS 3
|
||||
|
||||
/* Normal crossfeed levels */
|
||||
#define BS2B_HIGH_CLEVEL 3
|
||||
#define BS2B_MIDDLE_CLEVEL 2
|
||||
#define BS2B_LOW_CLEVEL 1
|
||||
|
||||
/* Easy crossfeed levels */
|
||||
#define BS2B_HIGH_ECLEVEL BS2B_HIGH_CLEVEL + BS2B_CLEVELS
|
||||
#define BS2B_MIDDLE_ECLEVEL BS2B_MIDDLE_CLEVEL + BS2B_CLEVELS
|
||||
#define BS2B_LOW_ECLEVEL BS2B_LOW_CLEVEL + BS2B_CLEVELS
|
||||
|
||||
/* Default crossfeed levels */
|
||||
#define BS2B_DEFAULT_CLEVEL BS2B_HIGH_ECLEVEL
|
||||
/* Default sample rate (Hz) */
|
||||
#define BS2B_DEFAULT_SRATE 44100
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct bs2b {
|
||||
int level; /* Crossfeed level */
|
||||
int srate; /* Sample rate (Hz) */
|
||||
|
||||
/* Lowpass IIR filter coefficients */
|
||||
double a0_lo;
|
||||
double b1_lo;
|
||||
|
||||
/* Highboost IIR filter coefficients */
|
||||
double a0_hi;
|
||||
double a1_hi;
|
||||
double b1_hi;
|
||||
|
||||
/* Global gain against overloading */
|
||||
double gain;
|
||||
|
||||
/* Buffer of last filtered sample.
|
||||
* [0] - first channel, [1] - second channel
|
||||
*/
|
||||
struct t_last_sample {
|
||||
double asis[2];
|
||||
double lo[2];
|
||||
double hi[2];
|
||||
} last_sample;
|
||||
};
|
||||
|
||||
/* Clear buffers and set new coefficients with new crossfeed level value.
|
||||
* level - crossfeed level of *LEVEL values.
|
||||
*/
|
||||
void bs2b_set_level(struct bs2b *bs2b, int level);
|
||||
|
||||
/* Return current crossfeed level value */
|
||||
int bs2b_get_level(struct bs2b *bs2b);
|
||||
|
||||
/* Clear buffers and set new coefficients with new sample rate value.
|
||||
* srate - sample rate by Hz.
|
||||
*/
|
||||
void bs2b_set_srate(struct bs2b *bs2b, int srate);
|
||||
|
||||
/* Return current sample rate value */
|
||||
int bs2b_get_srate(struct bs2b *bs2b);
|
||||
|
||||
/* Clear buffer */
|
||||
void bs2b_clear(struct bs2b *bs2b);
|
||||
|
||||
/* Return 1 if buffer is clear */
|
||||
int bs2b_is_clear(struct bs2b *bs2b);
|
||||
|
||||
/* Crossfeeds one stereo sample that are pointed by sample.
|
||||
* [0] - first channel, [1] - second channel.
|
||||
* Returns crossfided samle by sample pointer.
|
||||
*/
|
||||
|
||||
/* sample poits to floats */
|
||||
void bs2b_cross_feed(struct bs2b *bs2b, float *sample);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* BS2B_H */
|
||||
+14
-3
@@ -18,11 +18,16 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "alMain.h"
|
||||
#include "alBuffer.h"
|
||||
#include "alFilter.h"
|
||||
#include "alEffect.h"
|
||||
#include "alAuxEffectSlot.h"
|
||||
#include "alThunk.h"
|
||||
|
||||
CRITICAL_SECTION g_mutex;
|
||||
CRITICAL_SECTION _alMutex;
|
||||
|
||||
#ifdef _WIN32
|
||||
BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
|
||||
@@ -37,10 +42,13 @@ BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
ReleaseALC();
|
||||
ReleaseALBuffers();
|
||||
ReleaseALEffects();
|
||||
ReleaseALFilters();
|
||||
FreeALConfig();
|
||||
ALTHUNK_EXIT();
|
||||
DeleteCriticalSection(&g_mutex);
|
||||
DeleteCriticalSection(&_alMutex);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
@@ -54,10 +62,13 @@ static void my_deinit()
|
||||
if(once) return;
|
||||
once = AL_TRUE;
|
||||
|
||||
ReleaseALC();
|
||||
ReleaseALBuffers();
|
||||
ReleaseALEffects();
|
||||
ReleaseALFilters();
|
||||
FreeALConfig();
|
||||
ALTHUNK_EXIT();
|
||||
DeleteCriticalSection(&g_mutex);
|
||||
DeleteCriticalSection(&_alMutex);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,541 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2007 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alMain.h"
|
||||
#include "alAuxEffectSlot.h"
|
||||
#include "alThunk.h"
|
||||
#include "alError.h"
|
||||
|
||||
|
||||
static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *ALEffectSlot, ALeffect *effect);
|
||||
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALsizei i;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
if(!Context)
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
return;
|
||||
}
|
||||
SuspendContext(Context);
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
/* NOTE: We only support one slot currently */
|
||||
if(n == 1 && Context->AuxiliaryEffectSlotCount == 0)
|
||||
{
|
||||
// Check that enough memory has been allocted in the 'effectslots' array for n Effect Slots
|
||||
if (!IsBadWritePtr((void*)effectslots, n * sizeof(ALuint)))
|
||||
{
|
||||
ALeffectslot **list = &Context->AuxiliaryEffectSlot;
|
||||
while(*list)
|
||||
list = &(*list)->next;
|
||||
|
||||
i = 0;
|
||||
while(i < n)
|
||||
{
|
||||
*list = calloc(1, sizeof(ALeffectslot));
|
||||
if(!(*list))
|
||||
{
|
||||
// We must have run out or memory
|
||||
alDeleteAuxiliaryEffectSlots(i, effectslots);
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
}
|
||||
|
||||
(*list)->Gain = 1.0;
|
||||
(*list)->AuxSendAuto = AL_TRUE;
|
||||
(*list)->refcount = 0;
|
||||
|
||||
effectslots[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
|
||||
(*list)->effectslot = effectslots[i];
|
||||
|
||||
Context->AuxiliaryEffectSlotCount++;
|
||||
i++;
|
||||
|
||||
list = &(*list)->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALeffectslot *ALAuxiliaryEffectSlot;
|
||||
ALsizei i;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
if(!Context)
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
return;
|
||||
}
|
||||
SuspendContext(Context);
|
||||
|
||||
if (n >= 0)
|
||||
{
|
||||
// Check that all effectslots are valid
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
if (!alIsAuxiliaryEffectSlot(effectslots[i]))
|
||||
{
|
||||
alSetError(AL_INVALID_NAME);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ALAuxiliaryEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslots[i]);
|
||||
if(ALAuxiliaryEffectSlot->refcount > 0)
|
||||
{
|
||||
alSetError(AL_INVALID_NAME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i == n)
|
||||
{
|
||||
// All effectslots are valid
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
// Recheck that the effectslot is valid, because there could be duplicated names
|
||||
if (alIsAuxiliaryEffectSlot(effectslots[i]))
|
||||
{
|
||||
ALeffectslot **list;
|
||||
|
||||
ALAuxiliaryEffectSlot = ((ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslots[i]));
|
||||
|
||||
// Remove Source from list of Sources
|
||||
list = &Context->AuxiliaryEffectSlot;
|
||||
while(*list && *list != ALAuxiliaryEffectSlot)
|
||||
list = &(*list)->next;
|
||||
|
||||
if(*list)
|
||||
*list = (*list)->next;
|
||||
ALTHUNK_REMOVEENTRY(ALAuxiliaryEffectSlot->effectslot);
|
||||
|
||||
free(ALAuxiliaryEffectSlot->ReverbBuffer);
|
||||
|
||||
memset(ALAuxiliaryEffectSlot, 0, sizeof(ALeffectslot));
|
||||
free(ALAuxiliaryEffectSlot);
|
||||
|
||||
Context->AuxiliaryEffectSlotCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALeffectslot **list;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
if(!Context)
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
return AL_FALSE;
|
||||
}
|
||||
SuspendContext(Context);
|
||||
|
||||
list = &Context->AuxiliaryEffectSlot;
|
||||
while(*list && (*list)->effectslot != effectslot)
|
||||
list = &(*list)->next;
|
||||
|
||||
ProcessContext(Context);
|
||||
|
||||
return (*list ? AL_TRUE : AL_FALSE);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
if(!Context)
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
return;
|
||||
}
|
||||
SuspendContext(Context);
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot);
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_EFFECT:
|
||||
if(alIsEffect(iValue))
|
||||
{
|
||||
ALeffect *effect = (ALeffect*)ALTHUNK_LOOKUPENTRY(iValue);
|
||||
InitializeEffect(Context, ALEffectSlot, effect);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
|
||||
if(iValue == AL_TRUE || iValue == AL_FALSE)
|
||||
ALEffectSlot->AuxSendAuto = iValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
if(!Context)
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
return;
|
||||
}
|
||||
SuspendContext(Context);
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_EFFECT:
|
||||
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
|
||||
alAuxiliaryEffectSloti(effectslot, param, piValues[0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
if(!Context)
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
return;
|
||||
}
|
||||
SuspendContext(Context);
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot);
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_GAIN:
|
||||
if(flValue >= 0.0f && flValue <= 1.0f)
|
||||
ALEffectSlot->Gain = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
if(!Context)
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
return;
|
||||
}
|
||||
SuspendContext(Context);
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_GAIN:
|
||||
alAuxiliaryEffectSlotf(effectslot, param, pflValues[0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
if(!Context)
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
return;
|
||||
}
|
||||
SuspendContext(Context);
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot);
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_EFFECT:
|
||||
*piValue = ALEffectSlot->effect.effect;
|
||||
break;
|
||||
|
||||
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
|
||||
*piValue = ALEffectSlot->AuxSendAuto;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
if(!Context)
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
return;
|
||||
}
|
||||
SuspendContext(Context);
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_EFFECT:
|
||||
case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO:
|
||||
alGetAuxiliaryEffectSloti(effectslot, param, piValues);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
if(!Context)
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
return;
|
||||
}
|
||||
SuspendContext(Context);
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(effectslot);
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_GAIN:
|
||||
*pflValue = ALEffectSlot->Gain;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
if(!Context)
|
||||
{
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
return;
|
||||
}
|
||||
SuspendContext(Context);
|
||||
|
||||
if (alIsAuxiliaryEffectSlot(effectslot))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_EFFECTSLOT_GAIN:
|
||||
alGetAuxiliaryEffectSlotf(effectslot, param, pflValues);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
|
||||
static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *ALEffectSlot, ALeffect *effect)
|
||||
{
|
||||
ALfloat *ptr = NULL;
|
||||
|
||||
if(!effect)
|
||||
{
|
||||
memset(&ALEffectSlot->effect, 0, sizeof(ALEffectSlot->effect));
|
||||
goto done;
|
||||
}
|
||||
|
||||
if(effect->type == AL_EFFECT_REVERB)
|
||||
{
|
||||
ALuint size;
|
||||
ALfloat reverbwait;
|
||||
|
||||
reverbwait = (1.0f-effect->Reverb.Density)*(0.1f-0.075f) + 0.075f;
|
||||
|
||||
size = (ALuint)((ALfloat)Context->Frequency *
|
||||
(effect->Reverb.ReflectionsDelay +
|
||||
effect->Reverb.LateReverbDelay +
|
||||
reverbwait)) + 1;
|
||||
|
||||
ptr = calloc(size, sizeof(ALfloat));
|
||||
if(!ptr)
|
||||
{
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
if(ALEffectSlot->ReverbBuffer)
|
||||
memcpy(ptr, ALEffectSlot->ReverbBuffer, min(size, ALEffectSlot->ReverbLength)*sizeof(ALfloat));
|
||||
ALEffectSlot->ReverbLength = size;
|
||||
ALEffectSlot->ReverbPos %= size;
|
||||
ALEffectSlot->ReverbReflectPos = (ALuint)(ALEffectSlot->ReverbLength -
|
||||
((ALfloat)Context->Frequency *
|
||||
effect->Reverb.ReflectionsDelay) +
|
||||
ALEffectSlot->ReverbPos) %
|
||||
ALEffectSlot->ReverbLength;
|
||||
ALEffectSlot->ReverbLatePos = (ALuint)(ALEffectSlot->ReverbLength -
|
||||
((ALfloat)Context->Frequency *
|
||||
(effect->Reverb.LateReverbDelay +
|
||||
effect->Reverb.ReflectionsDelay)) +
|
||||
ALEffectSlot->ReverbPos) %
|
||||
ALEffectSlot->ReverbLength;
|
||||
ALEffectSlot->ReverbDecayGain = pow(1.0/32768.0, 1.0/(effect->Reverb.DecayTime/reverbwait));
|
||||
}
|
||||
|
||||
memcpy(&ALEffectSlot->effect, effect, sizeof(*effect));
|
||||
done:
|
||||
free(ALEffectSlot->ReverbBuffer);
|
||||
ALEffectSlot->ReverbBuffer = ptr;
|
||||
}
|
||||
|
||||
|
||||
ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if(Context->AuxiliaryEffectSlotCount > 0)
|
||||
AL_PRINT("alcDestroyContext(): %d AuxiliaryEffectSlot(s) NOT deleted\n", Context->AuxiliaryEffectSlotCount);
|
||||
#endif
|
||||
|
||||
while(Context->AuxiliaryEffectSlot)
|
||||
{
|
||||
ALeffectslot *temp = Context->AuxiliaryEffectSlot;
|
||||
Context->AuxiliaryEffectSlot = Context->AuxiliaryEffectSlot->next;
|
||||
|
||||
// Release effectslot structure
|
||||
free(temp->ReverbBuffer);
|
||||
ALTHUNK_REMOVEENTRY(temp->effectslot);
|
||||
|
||||
memset(temp, 0, sizeof(ALeffectslot));
|
||||
free(temp);
|
||||
}
|
||||
Context->AuxiliaryEffectSlotCount = 0;
|
||||
}
|
||||
+250
-86
@@ -20,15 +20,21 @@
|
||||
|
||||
#define _CRT_SECURE_NO_DEPRECATE // get rid of sprintf security warnings on VS2005
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "alMain.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alError.h"
|
||||
#include "alBuffer.h"
|
||||
#include "alThunk.h"
|
||||
|
||||
|
||||
static void LoadData(ALbuffer *ALBuf, const ALubyte *data, ALsizei size, ALuint freq, ALenum OrigFormat, ALenum NewFormat);
|
||||
|
||||
/*
|
||||
* AL Buffer Functions
|
||||
*
|
||||
@@ -91,20 +97,20 @@ ALAPI ALvoid ALAPIENTRY alGenBuffers(ALsizei n,ALuint *puiBuffers)
|
||||
while(i < n)
|
||||
{
|
||||
*list = calloc(1, sizeof(ALbuffer));
|
||||
if(*list)
|
||||
if(!(*list))
|
||||
{
|
||||
puiBuffers[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
|
||||
(*list)->state = UNUSED;
|
||||
g_uiBufferCount++;
|
||||
i++;
|
||||
|
||||
list = &(*list)->next;
|
||||
alDeleteBuffers(i, puiBuffers);
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If we didn't create all the Buffers, we must have run out of memory
|
||||
if (i != n)
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
puiBuffers[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
|
||||
(*list)->state = UNUSED;
|
||||
g_uiBufferCount++;
|
||||
i++;
|
||||
|
||||
list = &(*list)->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -273,91 +279,152 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d
|
||||
switch(format)
|
||||
{
|
||||
case AL_FORMAT_MONO8:
|
||||
if ((size%1) == 0)
|
||||
{
|
||||
// 8bit Samples are converted to 16 bit here
|
||||
// Allocate 8 extra samples (16 bytes)
|
||||
ALBuf->data=realloc(ALBuf->data,16+(size/sizeof(ALubyte))*(1*sizeof(ALshort)));
|
||||
if (ALBuf->data)
|
||||
{
|
||||
ALBuf->format = AL_FORMAT_MONO16;
|
||||
ALBuf->eOriginalFormat = AL_FORMAT_MONO8;
|
||||
for (i=0;i<(ALsizei)(size/sizeof(ALubyte));i++)
|
||||
ALBuf->data[i]=(ALshort)((((ALubyte *)data)[i]-128)<<8);
|
||||
memset(&(ALBuf->data[size/sizeof(ALubyte)]), 0, 16);
|
||||
ALBuf->size=size/sizeof(ALubyte)*1*sizeof(ALshort);
|
||||
ALBuf->frequency=freq;
|
||||
}
|
||||
else
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_FORMAT_MONO16:
|
||||
if ((size%2) == 0)
|
||||
{
|
||||
// Allocate 8 extra samples (16 bytes)
|
||||
ALBuf->data=realloc(ALBuf->data,16+(size/sizeof(ALshort))*(1*sizeof(ALshort)));
|
||||
if (ALBuf->data)
|
||||
{
|
||||
ALBuf->format = AL_FORMAT_MONO16;
|
||||
ALBuf->eOriginalFormat = AL_FORMAT_MONO16;
|
||||
memcpy(ALBuf->data,data,size/sizeof(ALshort)*1*sizeof(ALshort));
|
||||
memset(&(ALBuf->data[size/sizeof(ALshort)]), 0, 16);
|
||||
ALBuf->size=size/sizeof(ALshort)*1*sizeof(ALshort);
|
||||
ALBuf->frequency=freq;
|
||||
}
|
||||
else
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
case AL_FORMAT_MONO_FLOAT32:
|
||||
LoadData(ALBuf, data, size, freq, format, AL_FORMAT_MONO16);
|
||||
break;
|
||||
|
||||
case AL_FORMAT_STEREO8:
|
||||
if ((size%2) == 0)
|
||||
{
|
||||
// 8bit Samples are converted to 16 bit here
|
||||
// Allocate 8 extra samples (32 bytes)
|
||||
ALBuf->data=realloc(ALBuf->data,32+(size/sizeof(ALubyte))*(1*sizeof(ALshort)));
|
||||
if (ALBuf->data)
|
||||
{
|
||||
ALBuf->format = AL_FORMAT_STEREO16;
|
||||
ALBuf->eOriginalFormat = AL_FORMAT_STEREO8;
|
||||
for (i=0;i<(ALsizei)(size/sizeof(ALubyte));i++)
|
||||
ALBuf->data[i]=(ALshort)((((ALubyte *)data)[i]-128)<<8);
|
||||
memset(&(ALBuf->data[size/sizeof(ALubyte)]), 0, 32);
|
||||
ALBuf->size=size/sizeof(ALubyte)*1*sizeof(ALshort);
|
||||
ALBuf->frequency=freq;
|
||||
}
|
||||
else
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
case AL_FORMAT_STEREO16:
|
||||
case AL_FORMAT_STEREO_FLOAT32:
|
||||
LoadData(ALBuf, data, size, freq, format, AL_FORMAT_STEREO16);
|
||||
break;
|
||||
|
||||
case AL_FORMAT_STEREO16:
|
||||
if ((size%4) == 0)
|
||||
case AL_FORMAT_REAR8:
|
||||
case AL_FORMAT_REAR16:
|
||||
case AL_FORMAT_REAR32: {
|
||||
ALuint NewFormat = AL_FORMAT_QUAD16;
|
||||
ALuint NewChannels = aluChannelsFromFormat(NewFormat);
|
||||
ALuint OrigBytes = ((format==AL_FORMAT_REAR8) ? 1 :
|
||||
((format==AL_FORMAT_REAR16) ? 2 :
|
||||
4));
|
||||
ALsizei i;
|
||||
|
||||
assert(aluBytesFromFormat(NewFormat) == 2);
|
||||
|
||||
if ((size%(OrigBytes*2)) != 0)
|
||||
{
|
||||
// Allocate 8 extra samples (32 bytes)
|
||||
ALBuf->data=realloc(ALBuf->data,32+(size/sizeof(ALshort))*(1*sizeof(ALshort)));
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
}
|
||||
|
||||
switch(OrigBytes)
|
||||
{
|
||||
case 1:
|
||||
size /= sizeof(ALubyte);
|
||||
size *= 2;
|
||||
|
||||
// 8bit Samples are converted to 16 bit here
|
||||
// Allocate 8 extra samples
|
||||
ALBuf->data = realloc(ALBuf->data, (8*NewChannels + size) * (1*sizeof(ALshort)));
|
||||
if (ALBuf->data)
|
||||
{
|
||||
ALBuf->format = AL_FORMAT_STEREO16;
|
||||
ALBuf->eOriginalFormat = AL_FORMAT_STEREO16;
|
||||
memcpy(ALBuf->data,data,size/sizeof(ALshort)*1*sizeof(ALshort));
|
||||
memset(&(ALBuf->data[size/sizeof(ALshort)]), 0, 32);
|
||||
ALBuf->size=size/sizeof(ALshort)*1*sizeof(ALshort);
|
||||
ALBuf->frequency=freq;
|
||||
for (i = 0;i < size;i+=4)
|
||||
{
|
||||
ALBuf->data[i+0] = 0;
|
||||
ALBuf->data[i+1] = 0;
|
||||
ALBuf->data[i+2] = (ALshort)((((ALubyte*)data)[i/2+0]-128) << 8);
|
||||
ALBuf->data[i+3] = (ALshort)((((ALubyte*)data)[i/2+1]-128) << 8);
|
||||
}
|
||||
memset(&(ALBuf->data[size]), 0, 16*NewChannels);
|
||||
|
||||
ALBuf->format = NewFormat;
|
||||
ALBuf->eOriginalFormat = format;
|
||||
ALBuf->size = size*1*sizeof(ALshort);
|
||||
ALBuf->frequency = freq;
|
||||
}
|
||||
else
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
size /= sizeof(ALshort);
|
||||
size *= 2;
|
||||
|
||||
// Allocate 8 extra samples
|
||||
ALBuf->data = realloc(ALBuf->data, (8*NewChannels + size) * (1*sizeof(ALshort)));
|
||||
if (ALBuf->data)
|
||||
{
|
||||
for (i = 0;i < size;i+=4)
|
||||
{
|
||||
ALBuf->data[i+0] = 0;
|
||||
ALBuf->data[i+1] = 0;
|
||||
ALBuf->data[i+2] = ((ALshort*)data)[i/2+0];
|
||||
ALBuf->data[i+3] = ((ALshort*)data)[i/2+1];
|
||||
}
|
||||
memset(&(ALBuf->data[size]), 0, 16*NewChannels);
|
||||
|
||||
ALBuf->format = NewFormat;
|
||||
ALBuf->eOriginalFormat = format;
|
||||
ALBuf->size = size*1*sizeof(ALshort);
|
||||
ALBuf->frequency = freq;
|
||||
}
|
||||
else
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
size /= sizeof(ALfloat);
|
||||
size *= 2;
|
||||
|
||||
// Allocate 8 extra samples
|
||||
ALBuf->data = realloc(ALBuf->data, (8*NewChannels + size) * (1*sizeof(ALshort)));
|
||||
if (ALBuf->data)
|
||||
{
|
||||
ALint smp;
|
||||
for (i = 0;i < size;i+=4)
|
||||
{
|
||||
ALBuf->data[i+0] = 0;
|
||||
ALBuf->data[i+1] = 0;
|
||||
smp = (((ALfloat*)data)[i/2+0] * 32767.5f - 0.5);
|
||||
smp = min(smp, 32767);
|
||||
smp = max(smp, -32768);
|
||||
ALBuf->data[i+2] = (ALshort)smp;
|
||||
smp = (((ALfloat*)data)[i/2+1] * 32767.5f - 0.5);
|
||||
smp = min(smp, 32767);
|
||||
smp = max(smp, -32768);
|
||||
ALBuf->data[i+3] = (ALshort)smp;
|
||||
}
|
||||
memset(&(ALBuf->data[size]), 0, 16*NewChannels);
|
||||
|
||||
ALBuf->format = NewFormat;
|
||||
ALBuf->eOriginalFormat = format;
|
||||
ALBuf->size = size*1*sizeof(ALshort);
|
||||
ALBuf->frequency = freq;
|
||||
}
|
||||
else
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
} break;
|
||||
|
||||
case AL_FORMAT_QUAD8_LOKI:
|
||||
case AL_FORMAT_QUAD16_LOKI:
|
||||
case AL_FORMAT_QUAD8:
|
||||
case AL_FORMAT_QUAD16:
|
||||
case AL_FORMAT_QUAD32:
|
||||
LoadData(ALBuf, data, size, freq, format, AL_FORMAT_QUAD16);
|
||||
break;
|
||||
|
||||
case AL_FORMAT_51CHN8:
|
||||
case AL_FORMAT_51CHN16:
|
||||
case AL_FORMAT_51CHN32:
|
||||
LoadData(ALBuf, data, size, freq, format, AL_FORMAT_51CHN16);
|
||||
break;
|
||||
|
||||
case AL_FORMAT_61CHN8:
|
||||
case AL_FORMAT_61CHN16:
|
||||
case AL_FORMAT_61CHN32:
|
||||
LoadData(ALBuf, data, size, freq, format, AL_FORMAT_61CHN16);
|
||||
break;
|
||||
|
||||
case AL_FORMAT_71CHN8:
|
||||
case AL_FORMAT_71CHN16:
|
||||
case AL_FORMAT_71CHN32:
|
||||
LoadData(ALBuf, data, size, freq, format, AL_FORMAT_71CHN16);
|
||||
break;
|
||||
|
||||
case AL_FORMAT_MONO_IMA4:
|
||||
@@ -489,7 +556,7 @@ ALAPI ALvoid ALAPIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *d
|
||||
else if (LeftIndex>88) LeftIndex=88;
|
||||
ALBuf->data[i*2*65+j+k+2]=(short)LeftSample;
|
||||
LeftIMACode>>=4;
|
||||
|
||||
|
||||
RightSample+=((g_IMAStep_size[RightIndex]*g_IMACodeword_4[RightIMACode&15])/8);
|
||||
RightIndex+=g_IMAIndex_adjust_4[RightIMACode&15];
|
||||
if (RightSample<-32768) RightSample=-32768;
|
||||
@@ -817,11 +884,11 @@ ALAPI ALvoid ALAPIENTRY alGetBufferi(ALuint buffer, ALenum eParam, ALint *plValu
|
||||
break;
|
||||
|
||||
case AL_BITS:
|
||||
*plValue= (((pBuffer->format==AL_FORMAT_MONO8)||(pBuffer->format==AL_FORMAT_STEREO8))?8:16);
|
||||
*plValue = aluBytesFromFormat(pBuffer->format) * 8;
|
||||
break;
|
||||
|
||||
case AL_CHANNELS:
|
||||
*plValue = (((pBuffer->format==AL_FORMAT_MONO8)||(pBuffer->format==AL_FORMAT_MONO16))?1:2);
|
||||
*plValue = aluChannelsFromFormat(pBuffer->format);
|
||||
break;
|
||||
|
||||
case AL_SIZE:
|
||||
@@ -917,6 +984,103 @@ ALAPI void ALAPIENTRY alGetBufferiv(ALuint buffer, ALenum eParam, ALint* plValue
|
||||
ProcessContext(pContext);
|
||||
}
|
||||
|
||||
/*
|
||||
* LoadData
|
||||
*
|
||||
* Loads the specified data into the buffer, using the specified formats.
|
||||
* Currently, the new format must be 16-bit, and must have the same channel
|
||||
* configuration as the original format. This does NOT handle compressed
|
||||
* formats (eg. IMA4).
|
||||
*/
|
||||
static void LoadData(ALbuffer *ALBuf, const ALubyte *data, ALsizei size, ALuint freq, ALenum OrigFormat, ALenum NewFormat)
|
||||
{
|
||||
ALuint NewChannels = aluChannelsFromFormat(NewFormat);
|
||||
ALuint OrigBytes = aluBytesFromFormat(OrigFormat);
|
||||
ALuint OrigChannels = aluChannelsFromFormat(OrigFormat);
|
||||
ALsizei i;
|
||||
|
||||
assert(aluBytesFromFormat(NewFormat) == 2);
|
||||
assert(NewChannels == OrigChannels);
|
||||
|
||||
if ((size%(OrigBytes*OrigChannels)) != 0)
|
||||
{
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
return;
|
||||
}
|
||||
|
||||
switch(OrigBytes)
|
||||
{
|
||||
case 1:
|
||||
size /= sizeof(ALubyte);
|
||||
|
||||
// 8bit Samples are converted to 16 bit here
|
||||
// Allocate 8 extra samples
|
||||
ALBuf->data = realloc(ALBuf->data, (8*NewChannels + size) * (1*sizeof(ALshort)));
|
||||
if (ALBuf->data)
|
||||
{
|
||||
for (i = 0;i < size;i++)
|
||||
ALBuf->data[i] = (ALshort)((data[i]-128) << 8);
|
||||
memset(&(ALBuf->data[size]), 0, 16*NewChannels);
|
||||
|
||||
ALBuf->format = NewFormat;
|
||||
ALBuf->eOriginalFormat = OrigFormat;
|
||||
ALBuf->size = size*1*sizeof(ALshort);
|
||||
ALBuf->frequency = freq;
|
||||
}
|
||||
else
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
size /= sizeof(ALshort);
|
||||
|
||||
// Allocate 8 extra samples
|
||||
ALBuf->data = realloc(ALBuf->data, (8*NewChannels + size) * (1*sizeof(ALshort)));
|
||||
if (ALBuf->data)
|
||||
{
|
||||
memcpy(ALBuf->data, data, size*1*sizeof(ALshort));
|
||||
memset(&(ALBuf->data[size]), 0, 16*NewChannels);
|
||||
|
||||
ALBuf->format = NewFormat;
|
||||
ALBuf->eOriginalFormat = OrigFormat;
|
||||
ALBuf->size = size*1*sizeof(ALshort);
|
||||
ALBuf->frequency = freq;
|
||||
}
|
||||
else
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
size /= sizeof(ALfloat);
|
||||
|
||||
// Allocate 8 extra samples
|
||||
ALBuf->data = realloc(ALBuf->data, (8*NewChannels + size) * (1*sizeof(ALshort)));
|
||||
if (ALBuf->data)
|
||||
{
|
||||
ALint smp;
|
||||
for (i = 0;i < size;i++)
|
||||
{
|
||||
smp = (((ALfloat*)data)[i] * 32767.5f - 0.5f);
|
||||
smp = min(smp, 32767);
|
||||
smp = max(smp, -32768);
|
||||
ALBuf->data[i] = (ALshort)smp;
|
||||
}
|
||||
memset(&(ALBuf->data[size]), 0, 16*NewChannels);
|
||||
|
||||
ALBuf->format = NewFormat;
|
||||
ALBuf->eOriginalFormat = OrigFormat;
|
||||
ALBuf->size = size*1*sizeof(ALshort);
|
||||
ALBuf->frequency = freq;
|
||||
}
|
||||
else
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ReleaseALBuffers()
|
||||
|
||||
@@ -0,0 +1,630 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2007 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alMain.h"
|
||||
#include "alEffect.h"
|
||||
#include "alThunk.h"
|
||||
#include "alError.h"
|
||||
|
||||
static ALeffect *g_EffectList;
|
||||
static ALuint g_EffectCount;
|
||||
|
||||
static void InitEffectParams(ALeffect *effect, ALenum type);
|
||||
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALsizei i;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
// Check that enough memory has been allocted in the 'effects' array for n Effects
|
||||
if (!IsBadWritePtr((void*)effects, n * sizeof(ALuint)))
|
||||
{
|
||||
ALeffect **list = &g_EffectList;
|
||||
while(*list)
|
||||
list = &(*list)->next;
|
||||
|
||||
i = 0;
|
||||
while(i < n)
|
||||
{
|
||||
*list = calloc(1, sizeof(ALeffect));
|
||||
if(!(*list))
|
||||
{
|
||||
// We must have run out or memory
|
||||
alDeleteEffects(i, effects);
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
}
|
||||
|
||||
effects[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
|
||||
(*list)->effect = effects[i];
|
||||
|
||||
InitEffectParams(*list, AL_EFFECT_NULL);
|
||||
g_EffectCount++;
|
||||
i++;
|
||||
|
||||
list = &(*list)->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALeffect *ALEffect;
|
||||
ALsizei i;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (n >= 0)
|
||||
{
|
||||
// Check that all effects are valid
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
if (!alIsEffect(effects[i]))
|
||||
{
|
||||
alSetError(AL_INVALID_NAME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == n)
|
||||
{
|
||||
// All effects are valid
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
// Recheck that the effect is valid, because there could be duplicated names
|
||||
if (effects[i] && alIsEffect(effects[i]))
|
||||
{
|
||||
ALeffect **list;
|
||||
|
||||
ALEffect = ((ALeffect*)ALTHUNK_LOOKUPENTRY(effects[i]));
|
||||
|
||||
// Remove Source from list of Sources
|
||||
list = &g_EffectList;
|
||||
while(*list && *list != ALEffect)
|
||||
list = &(*list)->next;
|
||||
|
||||
if(*list)
|
||||
*list = (*list)->next;
|
||||
ALTHUNK_REMOVEENTRY(ALEffect->effect);
|
||||
|
||||
memset(ALEffect, 0, sizeof(ALeffect));
|
||||
free(ALEffect);
|
||||
|
||||
g_EffectCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALeffect **list;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
list = &g_EffectList;
|
||||
while(*list && (*list)->effect != effect)
|
||||
list = &(*list)->next;
|
||||
|
||||
ProcessContext(Context);
|
||||
|
||||
return ((*list || !effect) ? AL_TRUE : AL_FALSE);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (effect && alIsEffect(effect))
|
||||
{
|
||||
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
|
||||
|
||||
if(param == AL_EFFECT_TYPE)
|
||||
{
|
||||
if(iValue == AL_EFFECT_NULL ||
|
||||
iValue == AL_EFFECT_REVERB)
|
||||
InitEffectParams(ALEffect, iValue);
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
}
|
||||
else if(ALEffect->type == AL_EFFECT_REVERB)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_REVERB_DECAY_HFLIMIT:
|
||||
if(iValue == AL_TRUE || iValue == AL_FALSE)
|
||||
ALEffect->Reverb.DecayHFLimit = iValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (effect && alIsEffect(effect))
|
||||
{
|
||||
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
|
||||
|
||||
if(param == AL_EFFECT_TYPE)
|
||||
{
|
||||
alEffecti(effect, param, piValues[0]);
|
||||
}
|
||||
else if(ALEffect->type == AL_EFFECT_REVERB)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_REVERB_DECAY_HFLIMIT:
|
||||
alEffecti(effect, param, piValues[0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (effect && alIsEffect(effect))
|
||||
{
|
||||
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
|
||||
|
||||
if(ALEffect->type == AL_EFFECT_REVERB)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_REVERB_DENSITY:
|
||||
if(flValue >= 0.0f && flValue <= 1.0f)
|
||||
ALEffect->Reverb.Density = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_REVERB_DIFFUSION:
|
||||
if(flValue >= 0.0f && flValue <= 1.0f)
|
||||
ALEffect->Reverb.Diffusion = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_REVERB_GAIN:
|
||||
if(flValue >= 0.0f && flValue <= 1.0f)
|
||||
ALEffect->Reverb.Gain = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_REVERB_GAINHF:
|
||||
if(flValue >= 0.0f && flValue <= 1.0f)
|
||||
ALEffect->Reverb.GainHF = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_REVERB_DECAY_TIME:
|
||||
if(flValue >= 0.1f && flValue <= 20.0f)
|
||||
ALEffect->Reverb.DecayTime = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_REVERB_DECAY_HFRATIO:
|
||||
if(flValue >= 0.1f && flValue <= 2.0f)
|
||||
ALEffect->Reverb.DecayHFRatio = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_REVERB_REFLECTIONS_GAIN:
|
||||
if(flValue >= 0.0f && flValue <= 3.16f)
|
||||
ALEffect->Reverb.ReflectionsGain = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_REVERB_REFLECTIONS_DELAY:
|
||||
if(flValue >= 0.0f && flValue <= 0.3f)
|
||||
ALEffect->Reverb.ReflectionsDelay = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_REVERB_LATE_REVERB_GAIN:
|
||||
if(flValue >= 0.0f && flValue <= 10.0f)
|
||||
ALEffect->Reverb.LateReverbGain = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_REVERB_LATE_REVERB_DELAY:
|
||||
if(flValue >= 0.0f && flValue <= 0.1f)
|
||||
ALEffect->Reverb.LateReverbDelay = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_REVERB_AIR_ABSORPTION_GAINHF:
|
||||
if(flValue >= 0.892f && flValue <= 1.0f)
|
||||
ALEffect->Reverb.AirAbsorptionGainHF = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_REVERB_ROOM_ROLLOFF_FACTOR:
|
||||
if(flValue >= 0.0f && flValue <= 10.0f)
|
||||
ALEffect->Reverb.RoomRolloffFactor = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, ALfloat *pflValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (effect && alIsEffect(effect))
|
||||
{
|
||||
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
|
||||
|
||||
if(ALEffect->type == AL_EFFECT_REVERB)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_REVERB_DENSITY:
|
||||
case AL_REVERB_DIFFUSION:
|
||||
case AL_REVERB_GAIN:
|
||||
case AL_REVERB_GAINHF:
|
||||
case AL_REVERB_DECAY_TIME:
|
||||
case AL_REVERB_DECAY_HFRATIO:
|
||||
case AL_REVERB_REFLECTIONS_GAIN:
|
||||
case AL_REVERB_REFLECTIONS_DELAY:
|
||||
case AL_REVERB_LATE_REVERB_GAIN:
|
||||
case AL_REVERB_LATE_REVERB_DELAY:
|
||||
case AL_REVERB_AIR_ABSORPTION_GAINHF:
|
||||
case AL_REVERB_ROOM_ROLLOFF_FACTOR:
|
||||
alEffectf(effect, param, pflValues[0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (effect && alIsEffect(effect))
|
||||
{
|
||||
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
|
||||
|
||||
if(param == AL_EFFECT_TYPE)
|
||||
{
|
||||
*piValue = ALEffect->type;
|
||||
}
|
||||
else if(ALEffect->type == AL_EFFECT_REVERB)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_REVERB_DECAY_HFLIMIT:
|
||||
*piValue = ALEffect->Reverb.DecayHFLimit;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (effect && alIsEffect(effect))
|
||||
{
|
||||
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
|
||||
|
||||
if(param == AL_EFFECT_TYPE)
|
||||
{
|
||||
alGetEffecti(effect, param, piValues);
|
||||
}
|
||||
else if(ALEffect->type == AL_EFFECT_REVERB)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_REVERB_DECAY_HFLIMIT:
|
||||
alGetEffecti(effect, param, piValues);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (effect && alIsEffect(effect))
|
||||
{
|
||||
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
|
||||
|
||||
if(ALEffect->type == AL_EFFECT_REVERB)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_REVERB_DENSITY:
|
||||
*pflValue = ALEffect->Reverb.Density;
|
||||
break;
|
||||
|
||||
case AL_REVERB_DIFFUSION:
|
||||
*pflValue = ALEffect->Reverb.Diffusion;
|
||||
break;
|
||||
|
||||
case AL_REVERB_GAIN:
|
||||
*pflValue = ALEffect->Reverb.Gain;
|
||||
break;
|
||||
|
||||
case AL_REVERB_GAINHF:
|
||||
*pflValue = ALEffect->Reverb.GainHF;
|
||||
break;
|
||||
|
||||
case AL_REVERB_DECAY_TIME:
|
||||
*pflValue = ALEffect->Reverb.DecayTime;
|
||||
break;
|
||||
|
||||
case AL_REVERB_DECAY_HFRATIO:
|
||||
*pflValue = ALEffect->Reverb.DecayHFRatio;
|
||||
break;
|
||||
|
||||
case AL_REVERB_REFLECTIONS_GAIN:
|
||||
*pflValue = ALEffect->Reverb.ReflectionsGain;
|
||||
break;
|
||||
|
||||
case AL_REVERB_REFLECTIONS_DELAY:
|
||||
*pflValue = ALEffect->Reverb.ReflectionsDelay;
|
||||
break;
|
||||
|
||||
case AL_REVERB_LATE_REVERB_GAIN:
|
||||
*pflValue = ALEffect->Reverb.LateReverbGain;
|
||||
break;
|
||||
|
||||
case AL_REVERB_LATE_REVERB_DELAY:
|
||||
*pflValue = ALEffect->Reverb.LateReverbDelay;
|
||||
break;
|
||||
|
||||
case AL_REVERB_AIR_ABSORPTION_GAINHF:
|
||||
*pflValue = ALEffect->Reverb.AirAbsorptionGainHF;
|
||||
break;
|
||||
|
||||
case AL_REVERB_ROOM_ROLLOFF_FACTOR:
|
||||
*pflValue = ALEffect->Reverb.RoomRolloffFactor;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (effect && alIsEffect(effect))
|
||||
{
|
||||
ALeffect *ALEffect = (ALeffect*)ALTHUNK_LOOKUPENTRY(effect);
|
||||
|
||||
if(ALEffect->type == AL_EFFECT_REVERB)
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_REVERB_DENSITY:
|
||||
case AL_REVERB_DIFFUSION:
|
||||
case AL_REVERB_GAIN:
|
||||
case AL_REVERB_GAINHF:
|
||||
case AL_REVERB_DECAY_TIME:
|
||||
case AL_REVERB_DECAY_HFRATIO:
|
||||
case AL_REVERB_REFLECTIONS_GAIN:
|
||||
case AL_REVERB_REFLECTIONS_DELAY:
|
||||
case AL_REVERB_LATE_REVERB_GAIN:
|
||||
case AL_REVERB_LATE_REVERB_DELAY:
|
||||
case AL_REVERB_AIR_ABSORPTION_GAINHF:
|
||||
case AL_REVERB_ROOM_ROLLOFF_FACTOR:
|
||||
alGetEffectf(effect, param, pflValues);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
|
||||
ALvoid ReleaseALEffects(ALvoid)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if(g_EffectCount > 0)
|
||||
AL_PRINT("exit() %d Effect(s) NOT deleted\n", g_EffectCount);
|
||||
#endif
|
||||
|
||||
while(g_EffectList)
|
||||
{
|
||||
ALeffect *temp = g_EffectList;
|
||||
g_EffectList = g_EffectList->next;
|
||||
|
||||
// Release effect structure
|
||||
memset(temp, 0, sizeof(ALeffect));
|
||||
free(temp);
|
||||
}
|
||||
g_EffectCount = 0;
|
||||
}
|
||||
|
||||
|
||||
static void InitEffectParams(ALeffect *effect, ALenum type)
|
||||
{
|
||||
effect->type = type;
|
||||
switch(type)
|
||||
{
|
||||
case AL_EFFECT_REVERB:
|
||||
effect->Reverb.Density = 1.0f;
|
||||
effect->Reverb.Diffusion = 1.0f;
|
||||
effect->Reverb.Gain = 0.32f;
|
||||
effect->Reverb.GainHF = 0.89f;
|
||||
effect->Reverb.DecayTime = 1.49f;
|
||||
effect->Reverb.DecayHFRatio = 0.83f;
|
||||
effect->Reverb.ReflectionsGain = 0.05f;
|
||||
effect->Reverb.ReflectionsDelay = 0.007f;
|
||||
effect->Reverb.LateReverbGain = 1.26f;
|
||||
effect->Reverb.LateReverbDelay = 0.011f;
|
||||
effect->Reverb.AirAbsorptionGainHF = 0.994f;
|
||||
effect->Reverb.RoomRolloffFactor = 0.0f;
|
||||
effect->Reverb.DecayHFLimit = AL_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "alMain.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alError.h"
|
||||
|
||||
+131
-18
@@ -18,12 +18,18 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "alExtension.h"
|
||||
#include "alError.h"
|
||||
#include "alMain.h"
|
||||
#include "alFilter.h"
|
||||
#include "alEffect.h"
|
||||
#include "alAuxEffectSlot.h"
|
||||
#include "alSource.h"
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
|
||||
@@ -101,6 +107,43 @@ static ALfunction function[]= {
|
||||
{ "alDopplerVelocity", (ALvoid *) alDopplerVelocity },
|
||||
{ "alSpeedOfSound", (ALvoid *) alSpeedOfSound },
|
||||
{ "alDistanceModel", (ALvoid *) alDistanceModel },
|
||||
|
||||
{ "alGenFilters", (ALvoid *) alGenFilters },
|
||||
{ "alDeleteFilters", (ALvoid *) alDeleteFilters },
|
||||
{ "alIsFilter", (ALvoid *) alIsFilter },
|
||||
{ "alFilteri", (ALvoid *) alFilteri },
|
||||
{ "alFilteriv", (ALvoid *) alFilteriv },
|
||||
{ "alFilterf", (ALvoid *) alFilterf },
|
||||
{ "alFilterfv", (ALvoid *) alFilterfv },
|
||||
{ "alGetFilteri", (ALvoid *) alGetFilteri },
|
||||
{ "alGetFilteriv", (ALvoid *) alGetFilteriv },
|
||||
{ "alGetFilterf", (ALvoid *) alGetFilterf },
|
||||
{ "alGetFilterfv", (ALvoid *) alGetFilterfv },
|
||||
|
||||
{ "alGenEffects", (ALvoid *) alGenEffects },
|
||||
{ "alDeleteEffects", (ALvoid *) alDeleteEffects },
|
||||
{ "alIsEffect", (ALvoid *) alIsEffect },
|
||||
{ "alEffecti", (ALvoid *) alEffecti },
|
||||
{ "alEffectiv", (ALvoid *) alEffectiv },
|
||||
{ "alEffectf", (ALvoid *) alEffectf },
|
||||
{ "alEffectfv", (ALvoid *) alEffectfv },
|
||||
{ "alGetEffecti", (ALvoid *) alGetEffecti },
|
||||
{ "alGetEffectiv", (ALvoid *) alGetEffectiv },
|
||||
{ "alGetEffectf", (ALvoid *) alGetEffectf },
|
||||
{ "alGetEffectfv", (ALvoid *) alGetEffectfv },
|
||||
|
||||
{ "alGenAuxiliaryEffectSlots", (ALvoid *) alGenAuxiliaryEffectSlots },
|
||||
{ "alDeleteAuxiliaryEffectSlots",(ALvoid *) alDeleteAuxiliaryEffectSlots},
|
||||
{ "alIsAuxiliaryEffectSlot", (ALvoid *) alIsAuxiliaryEffectSlot },
|
||||
{ "alAuxiliaryEffectSloti", (ALvoid *) alAuxiliaryEffectSloti },
|
||||
{ "alAuxiliaryEffectSlotiv", (ALvoid *) alAuxiliaryEffectSlotiv },
|
||||
{ "alAuxiliaryEffectSlotf", (ALvoid *) alAuxiliaryEffectSlotf },
|
||||
{ "alAuxiliaryEffectSlotfv", (ALvoid *) alAuxiliaryEffectSlotfv },
|
||||
{ "alGetAuxiliaryEffectSloti", (ALvoid *) alGetAuxiliaryEffectSloti },
|
||||
{ "alGetAuxiliaryEffectSlotiv", (ALvoid *) alGetAuxiliaryEffectSlotiv},
|
||||
{ "alGetAuxiliaryEffectSlotf", (ALvoid *) alGetAuxiliaryEffectSlotf },
|
||||
{ "alGetAuxiliaryEffectSlotfv", (ALvoid *) alGetAuxiliaryEffectSlotfv},
|
||||
|
||||
{ NULL, (ALvoid *) NULL } };
|
||||
|
||||
static ALenums enumeration[]={
|
||||
@@ -135,6 +178,18 @@ static ALenums enumeration[]={
|
||||
{ (ALchar *)"AL_STATIC", AL_STATIC },
|
||||
{ (ALchar *)"AL_STREAMING", AL_STREAMING },
|
||||
{ (ALchar *)"AL_UNDETERMINED", AL_UNDETERMINED },
|
||||
{ (ALchar *)"AL_METERS_PER_UNIT", AL_METERS_PER_UNIT },
|
||||
|
||||
// Source EFX Properties
|
||||
{ (ALchar *)"AL_DIRECT_FILTER", AL_DIRECT_FILTER },
|
||||
{ (ALchar *)"AL_AUXILIARY_SEND_FILTER", AL_AUXILIARY_SEND_FILTER },
|
||||
{ (ALchar *)"AL_AIR_ABSORPTION_FACTOR", AL_AIR_ABSORPTION_FACTOR },
|
||||
{ (ALchar *)"AL_ROOM_ROLLOFF_FACTOR", AL_ROOM_ROLLOFF_FACTOR },
|
||||
{ (ALchar *)"AL_CONE_OUTER_GAINHF", AL_CONE_OUTER_GAINHF },
|
||||
{ (ALchar *)"AL_DIRECT_FILTER_GAINHF_AUTO", AL_DIRECT_FILTER_GAINHF_AUTO },
|
||||
{ (ALchar *)"AL_AUXILIARY_SEND_FILTER_GAIN_AUTO", AL_AUXILIARY_SEND_FILTER_GAIN_AUTO },
|
||||
{ (ALchar *)"AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO", AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO},
|
||||
|
||||
|
||||
// Source State information
|
||||
{ (ALchar *)"AL_SOURCE_STATE", AL_SOURCE_STATE },
|
||||
@@ -150,12 +205,29 @@ static ALenums enumeration[]={
|
||||
// Buffer Formats
|
||||
{ (ALchar *)"AL_FORMAT_MONO8", AL_FORMAT_MONO8 },
|
||||
{ (ALchar *)"AL_FORMAT_MONO16", AL_FORMAT_MONO16 },
|
||||
{ (ALchar *)"AL_FORMAT_MONO_FLOAT32", AL_FORMAT_MONO_FLOAT32 },
|
||||
{ (ALchar *)"AL_FORMAT_STEREO8", AL_FORMAT_STEREO8 },
|
||||
{ (ALchar *)"AL_FORMAT_STEREO16", AL_FORMAT_STEREO16 },
|
||||
{ (ALchar *)"AL_FORMAT_STEREO_FLOAT32", AL_FORMAT_STEREO_FLOAT32 },
|
||||
{ (ALchar *)"AL_FORMAT_MONO_IMA4", AL_FORMAT_MONO_IMA4 },
|
||||
{ (ALchar *)"AL_FORMAT_STEREO_IMA4", AL_FORMAT_STEREO_IMA4 },
|
||||
{ (ALchar *)"AL_FORMAT_QUAD8_LOKI", AL_FORMAT_QUAD8_LOKI },
|
||||
{ (ALchar *)"AL_FORMAT_QUAD16_LOKI", AL_FORMAT_QUAD16_LOKI },
|
||||
{ (ALchar *)"AL_FORMAT_QUAD8", AL_FORMAT_QUAD8 },
|
||||
{ (ALchar *)"AL_FORMAT_QUAD16", AL_FORMAT_QUAD16 },
|
||||
{ (ALchar *)"AL_FORMAT_QUAD32", AL_FORMAT_QUAD32 },
|
||||
{ (ALchar *)"AL_FORMAT_51CHN8", AL_FORMAT_51CHN8 },
|
||||
{ (ALchar *)"AL_FORMAT_51CHN16", AL_FORMAT_51CHN16 },
|
||||
{ (ALchar *)"AL_FORMAT_51CHN32", AL_FORMAT_51CHN32 },
|
||||
{ (ALchar *)"AL_FORMAT_61CHN8", AL_FORMAT_61CHN8 },
|
||||
{ (ALchar *)"AL_FORMAT_61CHN16", AL_FORMAT_61CHN16 },
|
||||
{ (ALchar *)"AL_FORMAT_61CHN32", AL_FORMAT_61CHN32 },
|
||||
{ (ALchar *)"AL_FORMAT_71CHN8", AL_FORMAT_71CHN8 },
|
||||
{ (ALchar *)"AL_FORMAT_71CHN16", AL_FORMAT_71CHN16 },
|
||||
{ (ALchar *)"AL_FORMAT_71CHN32", AL_FORMAT_71CHN32 },
|
||||
{ (ALchar *)"AL_FORMAT_REAR8", AL_FORMAT_REAR8 },
|
||||
{ (ALchar *)"AL_FORMAT_REAR16", AL_FORMAT_REAR16 },
|
||||
{ (ALchar *)"AL_FORMAT_REAR32", AL_FORMAT_REAR32 },
|
||||
|
||||
// Buffer attributes
|
||||
{ (ALchar *)"AL_FREQUENCY", AL_FREQUENCY },
|
||||
@@ -196,8 +268,52 @@ static ALenums enumeration[]={
|
||||
{ (ALchar *)"AL_EXPONENT_DISTANCE", AL_EXPONENT_DISTANCE },
|
||||
{ (ALchar *)"AL_EXPONENT_DISTANCE_CLAMPED", AL_EXPONENT_DISTANCE_CLAMPED },
|
||||
|
||||
// Filter types
|
||||
{ (ALchar *)"AL_FILTER_TYPE", AL_FILTER_TYPE },
|
||||
{ (ALchar *)"AL_FILTER_NULL", AL_FILTER_NULL },
|
||||
{ (ALchar *)"AL_FILTER_LOWPASS", AL_FILTER_LOWPASS },
|
||||
{ (ALchar *)"AL_FILTER_HIGHPASS", AL_FILTER_HIGHPASS },
|
||||
{ (ALchar *)"AL_FILTER_BANDPASS", AL_FILTER_BANDPASS },
|
||||
|
||||
// Filter params
|
||||
{ (ALchar *)"AL_LOWPASS_GAIN", AL_LOWPASS_GAIN },
|
||||
{ (ALchar *)"AL_LOWPASS_GAINHF", AL_LOWPASS_GAINHF },
|
||||
|
||||
// Effect types
|
||||
{ (ALchar *)"AL_EFFECT_TYPE", AL_EFFECT_TYPE },
|
||||
{ (ALchar *)"AL_EFFECT_NULL", AL_EFFECT_NULL },
|
||||
{ (ALchar *)"AL_EFFECT_REVERB", AL_EFFECT_REVERB },
|
||||
{ (ALchar *)"AL_EFFECT_CHORUS", AL_EFFECT_CHORUS },
|
||||
{ (ALchar *)"AL_EFFECT_DISTORTION", AL_EFFECT_DISTORTION },
|
||||
{ (ALchar *)"AL_EFFECT_ECHO", AL_EFFECT_ECHO },
|
||||
{ (ALchar *)"AL_EFFECT_FLANGER", AL_EFFECT_FLANGER },
|
||||
{ (ALchar *)"AL_EFFECT_FREQUENCY_SHIFTER", AL_EFFECT_FREQUENCY_SHIFTER },
|
||||
{ (ALchar *)"AL_EFFECT_VOCAL_MORPHER", AL_EFFECT_VOCAL_MORPHER },
|
||||
{ (ALchar *)"AL_EFFECT_PITCH_SHIFTER", AL_EFFECT_PITCH_SHIFTER },
|
||||
{ (ALchar *)"AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR },
|
||||
{ (ALchar *)"AL_EFFECT_AUTOWAH", AL_EFFECT_AUTOWAH },
|
||||
{ (ALchar *)"AL_EFFECT_COMPRESSOR", AL_EFFECT_COMPRESSOR },
|
||||
{ (ALchar *)"AL_EFFECT_EQUALIZER", AL_EFFECT_EQUALIZER },
|
||||
|
||||
// Reverb params
|
||||
{ (ALchar *)"AL_REVERB_DENSITY", AL_REVERB_DENSITY },
|
||||
{ (ALchar *)"AL_REVERB_DIFFUSION", AL_REVERB_DIFFUSION },
|
||||
{ (ALchar *)"AL_REVERB_GAIN", AL_REVERB_GAIN },
|
||||
{ (ALchar *)"AL_REVERB_GAINHF", AL_REVERB_GAINHF },
|
||||
{ (ALchar *)"AL_REVERB_DECAY_TIME", AL_REVERB_DECAY_TIME },
|
||||
{ (ALchar *)"AL_REVERB_DECAY_HFRATIO", AL_REVERB_DECAY_HFRATIO },
|
||||
{ (ALchar *)"AL_REVERB_REFLECTIONS_GAIN", AL_REVERB_REFLECTIONS_GAIN },
|
||||
{ (ALchar *)"AL_REVERB_REFLECTIONS_DELAY", AL_REVERB_REFLECTIONS_DELAY },
|
||||
{ (ALchar *)"AL_REVERB_LATE_REVERB_GAIN", AL_REVERB_LATE_REVERB_GAIN },
|
||||
{ (ALchar *)"AL_REVERB_LATE_REVERB_DELAY", AL_REVERB_LATE_REVERB_DELAY },
|
||||
{ (ALchar *)"AL_REVERB_AIR_ABSORPTION_GAINHF", AL_REVERB_AIR_ABSORPTION_GAINHF },
|
||||
{ (ALchar *)"AL_REVERB_ROOM_ROLLOFF_FACTOR", AL_REVERB_ROOM_ROLLOFF_FACTOR },
|
||||
{ (ALchar *)"AL_REVERB_DECAY_HFLIMIT", AL_REVERB_DECAY_HFLIMIT },
|
||||
|
||||
|
||||
// Default
|
||||
{ (ALchar *)NULL, (ALenum ) 0 } };
|
||||
{ (ALchar *)NULL, (ALenum)0 }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -205,7 +321,8 @@ ALAPI ALboolean ALAPIENTRY alIsExtensionPresent(const ALchar *extName)
|
||||
{
|
||||
ALboolean bIsSupported = AL_FALSE;
|
||||
ALCcontext *pContext;
|
||||
char *ptr, *ext;
|
||||
const char *ptr;
|
||||
size_t len;
|
||||
|
||||
if (!extName)
|
||||
{
|
||||
@@ -220,32 +337,28 @@ ALAPI ALboolean ALAPIENTRY alIsExtensionPresent(const ALchar *extName)
|
||||
return AL_FALSE;
|
||||
}
|
||||
|
||||
ext = strdup(extName);
|
||||
ptr = ext;
|
||||
do {
|
||||
*ptr = (char)toupper(*ptr);
|
||||
} while(*(ptr++));
|
||||
|
||||
SuspendContext(pContext);
|
||||
|
||||
len = strlen(extName);
|
||||
ptr = pContext->ExtensionList;
|
||||
while((ptr=strstr(ptr, ext)) != NULL)
|
||||
while(ptr && *ptr)
|
||||
{
|
||||
if(ptr == pContext->ExtensionList || ptr[-1] == ' ')
|
||||
if(strncasecmp(ptr, extName, len) == 0 &&
|
||||
(ptr[len] == '\0' || isspace(ptr[len])))
|
||||
{
|
||||
char e = ptr[strlen(ext)];
|
||||
if(e == ' ' || e == 0)
|
||||
{
|
||||
bIsSupported = AL_TRUE;
|
||||
break;
|
||||
}
|
||||
bIsSupported = AL_TRUE;
|
||||
break;
|
||||
}
|
||||
if((ptr=strchr(ptr, ' ')) != NULL)
|
||||
{
|
||||
do {
|
||||
++ptr;
|
||||
} while(isspace(*ptr));
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
|
||||
ProcessContext(pContext);
|
||||
|
||||
free(ext);
|
||||
return bIsSupported;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,424 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 1999-2007 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alMain.h"
|
||||
#include "alFilter.h"
|
||||
#include "alThunk.h"
|
||||
#include "alError.h"
|
||||
|
||||
static ALfilter *g_FilterList;
|
||||
static ALuint g_FilterCount;
|
||||
|
||||
static void InitFilterParams(ALfilter *filter, ALenum type);
|
||||
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALsizei i;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
// Check that enough memory has been allocted in the 'filters' array for n Filters
|
||||
if (!IsBadWritePtr((void*)filters, n * sizeof(ALuint)))
|
||||
{
|
||||
ALfilter **list = &g_FilterList;
|
||||
while(*list)
|
||||
list = &(*list)->next;
|
||||
|
||||
i = 0;
|
||||
while(i < n)
|
||||
{
|
||||
*list = calloc(1, sizeof(ALfilter));
|
||||
if(!(*list))
|
||||
{
|
||||
// We must have run out or memory
|
||||
alDeleteFilters(i, filters);
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
}
|
||||
|
||||
filters[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
|
||||
(*list)->filter = filters[i];
|
||||
|
||||
InitFilterParams(*list, AL_FILTER_NULL);
|
||||
g_FilterCount++;
|
||||
i++;
|
||||
|
||||
list = &(*list)->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALfilter *ALFilter;
|
||||
ALsizei i;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (n >= 0)
|
||||
{
|
||||
// Check that all filters are valid
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
if (!alIsFilter(filters[i]))
|
||||
{
|
||||
alSetError(AL_INVALID_NAME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == n)
|
||||
{
|
||||
// All filters are valid
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
// Recheck that the filter is valid, because there could be duplicated names
|
||||
if (filters[i] && alIsFilter(filters[i]))
|
||||
{
|
||||
ALfilter **list;
|
||||
|
||||
ALFilter = ((ALfilter*)ALTHUNK_LOOKUPENTRY(filters[i]));
|
||||
|
||||
// Remove Source from list of Sources
|
||||
list = &g_FilterList;
|
||||
while(*list && *list != ALFilter)
|
||||
list = &(*list)->next;
|
||||
|
||||
if(*list)
|
||||
*list = (*list)->next;
|
||||
ALTHUNK_REMOVEENTRY(ALFilter->filter);
|
||||
|
||||
memset(ALFilter, 0, sizeof(ALfilter));
|
||||
free(ALFilter);
|
||||
|
||||
g_FilterCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
ALfilter **list;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
list = &g_FilterList;
|
||||
while(*list && (*list)->filter != filter)
|
||||
list = &(*list)->next;
|
||||
|
||||
ProcessContext(Context);
|
||||
|
||||
return ((*list || !filter) ? AL_TRUE : AL_FALSE);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
ALfilter *ALFilter = (ALfilter*)ALTHUNK_LOOKUPENTRY(filter);
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_FILTER_TYPE:
|
||||
if(iValue == AL_FILTER_NULL ||
|
||||
iValue == AL_FILTER_LOWPASS)
|
||||
InitFilterParams(ALFilter, iValue);
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, ALint *piValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_FILTER_TYPE:
|
||||
alFilteri(filter, param, piValues[0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
ALfilter *ALFilter = (ALfilter*)ALTHUNK_LOOKUPENTRY(filter);
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_LOWPASS_GAIN:
|
||||
if(ALFilter->type == AL_FILTER_LOWPASS)
|
||||
{
|
||||
if(flValue >= 0.0f && flValue <= 1.0f)
|
||||
ALFilter->Gain = flValue;
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
|
||||
case AL_LOWPASS_GAINHF:
|
||||
if(ALFilter->type == AL_FILTER_LOWPASS)
|
||||
{
|
||||
if(flValue >= 0.0f && flValue <= 1.0f)
|
||||
ALFilter->GainHF = flValue;
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, ALfloat *pflValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_LOWPASS_GAIN:
|
||||
case AL_LOWPASS_GAINHF:
|
||||
alFilterf(filter, param, pflValues[0]);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
(void)piValue;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
(void)piValues;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
ALfilter *ALFilter = (ALfilter*)ALTHUNK_LOOKUPENTRY(filter);
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case AL_LOWPASS_GAIN:
|
||||
if(ALFilter->type == AL_FILTER_LOWPASS)
|
||||
*pflValue = ALFilter->Gain;
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
|
||||
case AL_LOWPASS_GAINHF:
|
||||
if(ALFilter->type == AL_FILTER_LOWPASS)
|
||||
*pflValue = ALFilter->GainHF;
|
||||
else
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues)
|
||||
{
|
||||
ALCcontext *Context;
|
||||
|
||||
Context = alcGetCurrentContext();
|
||||
SuspendContext(Context);
|
||||
|
||||
if (filter && alIsFilter(filter))
|
||||
{
|
||||
switch(param)
|
||||
{
|
||||
case AL_LOWPASS_GAIN:
|
||||
case AL_LOWPASS_GAINHF:
|
||||
alGetFilterf(filter, param, pflValues);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_NAME);
|
||||
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
||||
|
||||
ALvoid ReleaseALFilters(ALvoid)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if(g_FilterCount > 0)
|
||||
AL_PRINT("exit() %d Filter(s) NOT deleted\n", g_FilterCount);
|
||||
#endif
|
||||
|
||||
while(g_FilterList)
|
||||
{
|
||||
ALfilter *temp = g_FilterList;
|
||||
g_FilterList = g_FilterList->next;
|
||||
|
||||
// Release filter structure
|
||||
memset(temp, 0, sizeof(ALfilter));
|
||||
free(temp);
|
||||
}
|
||||
g_FilterCount = 0;
|
||||
}
|
||||
|
||||
|
||||
static void InitFilterParams(ALfilter *filter, ALenum type)
|
||||
{
|
||||
filter->type = type;
|
||||
|
||||
filter->Gain = 1.0;
|
||||
filter->GainHF = 1.0;
|
||||
}
|
||||
@@ -18,6 +18,8 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "alMain.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alError.h"
|
||||
@@ -41,6 +43,13 @@ ALAPI ALvoid ALAPIENTRY alListenerf(ALenum eParam, ALfloat flValue)
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_METERS_PER_UNIT:
|
||||
if (flValue > 0.0f)
|
||||
pContext->Listener.MetersPerUnit = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
@@ -112,6 +121,13 @@ ALAPI ALvoid ALAPIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues)
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_METERS_PER_UNIT:
|
||||
if (pflValues[0] > 0.0f)
|
||||
pContext->Listener.MetersPerUnit = pflValues[0];
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_POSITION:
|
||||
pContext->Listener.Position[0] = pflValues[0];
|
||||
pContext->Listener.Position[1] = pflValues[1];
|
||||
@@ -274,6 +290,10 @@ ALAPI ALvoid ALAPIENTRY alGetListenerf(ALenum eParam, ALfloat *pflValue)
|
||||
*pflValue = pContext->Listener.Gain;
|
||||
break;
|
||||
|
||||
case AL_METERS_PER_UNIT:
|
||||
*pflValue = pContext->Listener.MetersPerUnit;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
@@ -350,6 +370,10 @@ ALAPI ALvoid ALAPIENTRY alGetListenerfv(ALenum eParam, ALfloat *pflValues)
|
||||
pflValues[0] = pContext->Listener.Gain;
|
||||
break;
|
||||
|
||||
case AL_METERS_PER_UNIT:
|
||||
pflValues[0] = pContext->Listener.MetersPerUnit;
|
||||
break;
|
||||
|
||||
case AL_POSITION:
|
||||
pflValues[0] = pContext->Listener.Position[0];
|
||||
pflValues[1] = pContext->Listener.Position[1];
|
||||
|
||||
+238
-31
@@ -18,6 +18,8 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
@@ -26,6 +28,9 @@
|
||||
#include "AL/alc.h"
|
||||
#include "alError.h"
|
||||
#include "alSource.h"
|
||||
#include "alBuffer.h"
|
||||
#include "alThunk.h"
|
||||
#include "alAuxEffectSlot.h"
|
||||
|
||||
static ALvoid InitSourceParams(ALsource *pSource);
|
||||
static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOffset);
|
||||
@@ -63,22 +68,22 @@ ALAPI ALvoid ALAPIENTRY alGenSources(ALsizei n,ALuint *sources)
|
||||
while(i < n)
|
||||
{
|
||||
*list = calloc(1, sizeof(ALsource));
|
||||
if(*list)
|
||||
if(!(*list))
|
||||
{
|
||||
sources[i]=(ALuint)ALTHUNK_ADDENTRY(*list);
|
||||
(*list)->source = sources[i];
|
||||
|
||||
InitSourceParams(*list);
|
||||
Context->SourceCount++;
|
||||
i++;
|
||||
|
||||
list = &(*list)->next;
|
||||
alDeleteSources(i, sources);
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If we didn't create all the Sources, we must have run out or memory
|
||||
if(i != n)
|
||||
alSetError(AL_OUT_OF_MEMORY);
|
||||
sources[i] = (ALuint)ALTHUNK_ADDENTRY(*list);
|
||||
(*list)->source = sources[i];
|
||||
|
||||
InitSourceParams(*list);
|
||||
Context->SourceCount++;
|
||||
i++;
|
||||
|
||||
list = &(*list)->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -117,7 +122,7 @@ ALAPI ALvoid ALAPIENTRY alDeleteSources(ALsizei n, const ALuint *sources)
|
||||
ALCdevice *Device;
|
||||
ALsource *ALSource;
|
||||
ALsource **list;
|
||||
ALsizei i;
|
||||
ALsizei i, j;
|
||||
ALbufferlistitem *ALBufferList;
|
||||
ALboolean bSourcesValid = AL_TRUE;
|
||||
|
||||
@@ -169,6 +174,13 @@ ALAPI ALvoid ALAPIENTRY alDeleteSources(ALsizei n, const ALuint *sources)
|
||||
free(ALBufferList);
|
||||
}
|
||||
|
||||
for(j = 0;j < MAX_SENDS;++j)
|
||||
{
|
||||
if(ALSource->Send[j].Slot)
|
||||
ALSource->Send[j].Slot->refcount--;
|
||||
ALSource->Send[j].Slot = NULL;
|
||||
}
|
||||
|
||||
// Decrement Source count
|
||||
Context->SourceCount--;
|
||||
|
||||
@@ -341,6 +353,27 @@ ALAPI ALvoid ALAPIENTRY alSourcef(ALuint source, ALenum eParam, ALfloat flValue)
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_CONE_OUTER_GAINHF:
|
||||
if ((flValue >= 0.0f) && (flValue <= 1.0f))
|
||||
pSource->OuterGainHF = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_AIR_ABSORPTION_FACTOR:
|
||||
if (flValue >= 0.0f && flValue <= 10.0f)
|
||||
pSource->AirAbsorptionFactor = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_ROOM_ROLLOFF_FACTOR:
|
||||
if (flValue >= 0.0f && flValue <= 1.0f)
|
||||
pSource->RoomRolloffFactor = flValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_SEC_OFFSET:
|
||||
case AL_SAMPLE_OFFSET:
|
||||
case AL_BYTE_OFFSET:
|
||||
@@ -461,9 +494,12 @@ ALAPI ALvoid ALAPIENTRY alSourcefv(ALuint source, ALenum eParam, const ALfloat *
|
||||
case AL_MIN_GAIN:
|
||||
case AL_MAX_GAIN:
|
||||
case AL_CONE_OUTER_GAIN:
|
||||
case AL_CONE_OUTER_GAINHF:
|
||||
case AL_SEC_OFFSET:
|
||||
case AL_SAMPLE_OFFSET:
|
||||
case AL_BYTE_OFFSET:
|
||||
case AL_AIR_ABSORPTION_FACTOR:
|
||||
case AL_ROOM_ROLLOFF_FACTOR:
|
||||
alSourcef(source, eParam, pflValues[0]);
|
||||
break;
|
||||
|
||||
@@ -636,6 +672,43 @@ ALAPI ALvoid ALAPIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_DIRECT_FILTER:
|
||||
if(alIsFilter(lValue))
|
||||
{
|
||||
ALfilter *filter = (ALfilter*)ALTHUNK_LOOKUPENTRY(lValue);
|
||||
if(!filter)
|
||||
{
|
||||
pSource->DirectFilter.type = AL_FILTER_NULL;
|
||||
pSource->DirectFilter.filter = 0;
|
||||
}
|
||||
else
|
||||
memcpy(&pSource->DirectFilter, filter, sizeof(*filter));
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_DIRECT_FILTER_GAINHF_AUTO:
|
||||
if(lValue == AL_TRUE || lValue == AL_FALSE)
|
||||
pSource->DryGainHFAuto = lValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO:
|
||||
if(lValue == AL_TRUE || lValue == AL_FALSE)
|
||||
pSource->WetGainAuto = lValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO:
|
||||
if(lValue == AL_TRUE || lValue == AL_FALSE)
|
||||
pSource->WetGainHFAuto = lValue;
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
@@ -664,6 +737,8 @@ ALAPI void ALAPIENTRY alSource3i(ALuint source, ALenum eParam, ALint lValue1, AL
|
||||
|
||||
if (alIsSource(source))
|
||||
{
|
||||
ALsource *pSource = ((ALsource *)ALTHUNK_LOOKUPENTRY(source));
|
||||
|
||||
switch (eParam)
|
||||
{
|
||||
case AL_POSITION:
|
||||
@@ -672,6 +747,35 @@ ALAPI void ALAPIENTRY alSource3i(ALuint source, ALenum eParam, ALint lValue1, AL
|
||||
alSource3f(source, eParam, (ALfloat)lValue1, (ALfloat)lValue2, (ALfloat)lValue3);
|
||||
break;
|
||||
|
||||
case AL_AUXILIARY_SEND_FILTER:
|
||||
if(lValue2 >= 0 && lValue2 < MAX_SENDS &&
|
||||
(alIsAuxiliaryEffectSlot(lValue1) || lValue1 == 0) &&
|
||||
alIsFilter(lValue3))
|
||||
{
|
||||
ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(lValue1);
|
||||
ALfilter *ALFilter = (ALfilter*)ALTHUNK_LOOKUPENTRY(lValue3);
|
||||
|
||||
/* Release refcount on the previous slot, and add one for
|
||||
* the new slot */
|
||||
if(pSource->Send[lValue2].Slot)
|
||||
pSource->Send[lValue2].Slot->refcount--;
|
||||
pSource->Send[lValue2].Slot = ALEffectSlot;
|
||||
if(pSource->Send[lValue2].Slot)
|
||||
pSource->Send[lValue2].Slot->refcount++;
|
||||
|
||||
if(!ALFilter)
|
||||
{
|
||||
/* Disable filter */
|
||||
pSource->Send[lValue2].WetFilter.type = 0;
|
||||
pSource->Send[lValue2].WetFilter.filter = 0;
|
||||
}
|
||||
else
|
||||
memcpy(&pSource->Send[lValue2].WetFilter, ALFilter, sizeof(*ALFilter));
|
||||
}
|
||||
else
|
||||
alSetError(AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
@@ -716,12 +820,17 @@ ALAPI void ALAPIENTRY alSourceiv(ALuint source, ALenum eParam, const ALint* plVa
|
||||
case AL_MAX_DISTANCE:
|
||||
case AL_ROLLOFF_FACTOR:
|
||||
case AL_REFERENCE_DISTANCE:
|
||||
case AL_DIRECT_FILTER:
|
||||
case AL_DIRECT_FILTER_GAINHF_AUTO:
|
||||
case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO:
|
||||
case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO:
|
||||
alSourcei(source, eParam, plValues[0]);
|
||||
break;
|
||||
|
||||
case AL_POSITION:
|
||||
case AL_VELOCITY:
|
||||
case AL_DIRECTION:
|
||||
case AL_AUXILIARY_SEND_FILTER:
|
||||
alSource3i(source, eParam, plValues[0], plValues[1], plValues[2]);
|
||||
break;
|
||||
|
||||
@@ -792,6 +901,10 @@ ALAPI ALvoid ALAPIENTRY alGetSourcef(ALuint source, ALenum eParam, ALfloat *pflV
|
||||
*pflValue = pSource->flOuterGain;
|
||||
break;
|
||||
|
||||
case AL_CONE_OUTER_GAINHF:
|
||||
*pflValue = pSource->OuterGainHF;
|
||||
break;
|
||||
|
||||
case AL_SEC_OFFSET:
|
||||
case AL_SAMPLE_OFFSET:
|
||||
case AL_BYTE_OFFSET:
|
||||
@@ -813,6 +926,14 @@ ALAPI ALvoid ALAPIENTRY alGetSourcef(ALuint source, ALenum eParam, ALfloat *pflV
|
||||
*pflValue = pSource->flRefDistance;
|
||||
break;
|
||||
|
||||
case AL_AIR_ABSORPTION_FACTOR:
|
||||
*pflValue = pSource->AirAbsorptionFactor;
|
||||
break;
|
||||
|
||||
case AL_ROOM_ROLLOFF_FACTOR:
|
||||
*pflValue = pSource->RoomRolloffFactor;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
@@ -920,6 +1041,9 @@ ALAPI ALvoid ALAPIENTRY alGetSourcefv(ALuint source, ALenum eParam, ALfloat *pfl
|
||||
case AL_CONE_INNER_ANGLE:
|
||||
case AL_CONE_OUTER_ANGLE:
|
||||
case AL_REFERENCE_DISTANCE:
|
||||
case AL_CONE_OUTER_GAINHF:
|
||||
case AL_AIR_ABSORPTION_FACTOR:
|
||||
case AL_ROOM_ROLLOFF_FACTOR:
|
||||
alGetSourcef(source, eParam, pflValues);
|
||||
break;
|
||||
|
||||
@@ -1044,6 +1168,22 @@ ALAPI ALvoid ALAPIENTRY alGetSourcei(ALuint source, ALenum eParam, ALint *plValu
|
||||
alSetError(AL_INVALID_OPERATION);
|
||||
break;
|
||||
|
||||
case AL_DIRECT_FILTER:
|
||||
*plValue = pSource->DirectFilter.filter;
|
||||
break;
|
||||
|
||||
case AL_DIRECT_FILTER_GAINHF_AUTO:
|
||||
*plValue = pSource->DryGainHFAuto;
|
||||
break;
|
||||
|
||||
case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO:
|
||||
*plValue = pSource->WetGainAuto;
|
||||
break;
|
||||
|
||||
case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO:
|
||||
*plValue = pSource->WetGainHFAuto;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(AL_INVALID_ENUM);
|
||||
break;
|
||||
@@ -1153,6 +1293,10 @@ ALAPI void ALAPIENTRY alGetSourceiv(ALuint source, ALenum eParam, ALint* plValue
|
||||
case AL_ROLLOFF_FACTOR:
|
||||
case AL_REFERENCE_DISTANCE:
|
||||
case AL_SOURCE_TYPE:
|
||||
case AL_DIRECT_FILTER:
|
||||
case AL_DIRECT_FILTER_GAINHF_AUTO:
|
||||
case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO:
|
||||
case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO:
|
||||
alGetSourcei(source, eParam, plValues);
|
||||
break;
|
||||
|
||||
@@ -1829,6 +1973,13 @@ static ALvoid InitSourceParams(ALsource *pSource)
|
||||
pSource->flMinGain = 0.0f;
|
||||
pSource->flMaxGain = 1.0f;
|
||||
pSource->flOuterGain = 0.0f;
|
||||
pSource->OuterGainHF = 1.0f;
|
||||
|
||||
pSource->DryGainHFAuto = AL_TRUE;
|
||||
pSource->WetGainAuto = AL_TRUE;
|
||||
pSource->WetGainHFAuto = AL_TRUE;
|
||||
pSource->AirAbsorptionFactor = 0.0f;
|
||||
pSource->RoomRolloffFactor = 0.0f;
|
||||
|
||||
pSource->state = AL_INITIAL;
|
||||
pSource->lSourceType = AL_UNDETERMINED;
|
||||
@@ -1846,6 +1997,7 @@ static ALvoid InitSourceParams(ALsource *pSource)
|
||||
static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOffset)
|
||||
{
|
||||
ALbufferlistitem *pBufferList;
|
||||
ALbuffer *pBuffer;
|
||||
ALfloat flBufferFreq;
|
||||
ALint lBytesPlayed, lChannels;
|
||||
ALenum eOriginalFormat;
|
||||
@@ -1854,10 +2006,11 @@ static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOf
|
||||
|
||||
if (((pSource->state == AL_PLAYING) || (pSource->state == AL_PAUSED)) && (pSource->ulBufferID))
|
||||
{
|
||||
pBuffer = ALTHUNK_LOOKUPENTRY(pSource->ulBufferID);
|
||||
// Get Current Buffer Size and frequency (in milliseconds)
|
||||
flBufferFreq = (ALfloat)(((ALbuffer*)ALTHUNK_LOOKUPENTRY(pSource->ulBufferID))->frequency);
|
||||
eOriginalFormat = ((ALbuffer*)ALTHUNK_LOOKUPENTRY(pSource->ulBufferID))->eOriginalFormat;
|
||||
lChannels = ((((ALbuffer*)ALTHUNK_LOOKUPENTRY(pSource->ulBufferID))->format == AL_FORMAT_MONO16)?1:2);
|
||||
flBufferFreq = (ALfloat)pBuffer->frequency;
|
||||
eOriginalFormat = pBuffer->eOriginalFormat;
|
||||
lChannels = aluChannelsFromFormat(pBuffer->format);
|
||||
|
||||
// Get Current BytesPlayed
|
||||
lBytesPlayed = pSource->position * lChannels * 2; // NOTE : This is the byte offset into the *current* buffer
|
||||
@@ -1904,17 +2057,30 @@ static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOf
|
||||
break;
|
||||
case AL_BYTE_OFFSET:
|
||||
// Take into account the original format of the Buffer
|
||||
if ((eOriginalFormat == AL_FORMAT_MONO8) || (eOriginalFormat == AL_FORMAT_STEREO8))
|
||||
{
|
||||
*pflOffset = (ALfloat)(lBytesPlayed >> 1);
|
||||
}
|
||||
else if ((eOriginalFormat == AL_FORMAT_MONO_IMA4) || (eOriginalFormat == AL_FORMAT_STEREO_IMA4))
|
||||
if ((eOriginalFormat == AL_FORMAT_MONO_IMA4) ||
|
||||
(eOriginalFormat == AL_FORMAT_STEREO_IMA4))
|
||||
{
|
||||
// Compression rate of the ADPCM supported is 3.6111 to 1
|
||||
lBytesPlayed = (ALint)((ALfloat)lBytesPlayed / 3.6111f);
|
||||
// Round down to nearest ADPCM block
|
||||
*pflOffset = (ALfloat)((lBytesPlayed / (36 * lChannels)) * 36 * lChannels);
|
||||
}
|
||||
else if (eOriginalFormat == AL_FORMAT_REAR8)
|
||||
{
|
||||
*pflOffset = (ALfloat)(lBytesPlayed >> 2);
|
||||
}
|
||||
else if (eOriginalFormat == AL_FORMAT_REAR16)
|
||||
{
|
||||
*pflOffset = (ALfloat)(lBytesPlayed >> 1);
|
||||
}
|
||||
else if (aluBytesFromFormat(eOriginalFormat) == 1)
|
||||
{
|
||||
*pflOffset = (ALfloat)(lBytesPlayed >> 1);
|
||||
}
|
||||
else if (aluBytesFromFormat(eOriginalFormat) == 4)
|
||||
{
|
||||
*pflOffset = (ALfloat)(lBytesPlayed << 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
*pflOffset = (ALfloat)lBytesPlayed;
|
||||
@@ -1940,6 +2106,7 @@ static ALboolean GetSourceOffset(ALsource *pSource, ALenum eName, ALfloat *pflOf
|
||||
static void ApplyOffset(ALsource *pSource, ALboolean bUpdateContext)
|
||||
{
|
||||
ALbufferlistitem *pBufferList;
|
||||
ALbuffer *pBuffer;
|
||||
ALint lBufferSize, lTotalBufferSize;
|
||||
ALint lByteOffset;
|
||||
|
||||
@@ -1956,7 +2123,8 @@ static void ApplyOffset(ALsource *pSource, ALboolean bUpdateContext)
|
||||
pSource->BuffersProcessed = 0;
|
||||
while (pBufferList)
|
||||
{
|
||||
lBufferSize = pBufferList->buffer ? ((ALbuffer*)ALTHUNK_LOOKUPENTRY(pBufferList->buffer))->size : 0;
|
||||
pBuffer = ALTHUNK_LOOKUPENTRY(pBufferList->buffer);
|
||||
lBufferSize = pBuffer ? pBuffer->size : 0;
|
||||
|
||||
if ((lTotalBufferSize + lBufferSize) <= lByteOffset)
|
||||
{
|
||||
@@ -1985,7 +2153,9 @@ static void ApplyOffset(ALsource *pSource, ALboolean bUpdateContext)
|
||||
pSource->lBytesPlayed = lByteOffset;
|
||||
|
||||
// SW Mixer Positions are in Samples
|
||||
pSource->position = pSource->BufferPosition / ((((ALbuffer*)ALTHUNK_LOOKUPENTRY(pBufferList->buffer))->format == AL_FORMAT_MONO16)?2:4);
|
||||
pSource->position = pSource->BufferPosition /
|
||||
aluBytesFromFormat(pBuffer->format) /
|
||||
aluChannelsFromFormat(pBuffer->format);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2042,19 +2212,15 @@ static ALint GetByteOffset(ALsource *pSource)
|
||||
if (pBuffer)
|
||||
{
|
||||
flBufferFreq = ((ALfloat)pBuffer->frequency);
|
||||
lChannels = (pBuffer->format == AL_FORMAT_MONO16)?1:2;
|
||||
lChannels = aluChannelsFromFormat(pBuffer->format);
|
||||
|
||||
// Determine the ByteOffset (and ensure it is block aligned)
|
||||
switch (pSource->lOffsetType)
|
||||
{
|
||||
case AL_BYTE_OFFSET:
|
||||
// Take into consideration the original format
|
||||
if ((pBuffer->eOriginalFormat == AL_FORMAT_MONO8) || (pBuffer->eOriginalFormat == AL_FORMAT_STEREO8))
|
||||
{
|
||||
lByteOffset = pSource->lOffset * 2;
|
||||
lByteOffset -= (lByteOffset % (lChannels * 2));
|
||||
}
|
||||
else if ((pBuffer->eOriginalFormat == AL_FORMAT_MONO_IMA4) || (pBuffer->eOriginalFormat == AL_FORMAT_STEREO_IMA4))
|
||||
if ((pBuffer->eOriginalFormat == AL_FORMAT_MONO_IMA4) ||
|
||||
(pBuffer->eOriginalFormat == AL_FORMAT_STEREO_IMA4))
|
||||
{
|
||||
// Round down to nearest ADPCM block
|
||||
lByteOffset = (pSource->lOffset / (36 * lChannels)) * 36 * lChannels;
|
||||
@@ -2062,6 +2228,26 @@ static ALint GetByteOffset(ALsource *pSource)
|
||||
lByteOffset = (ALint)(3.6111f * (ALfloat)lByteOffset);
|
||||
lByteOffset -= (lByteOffset % (lChannels * 2));
|
||||
}
|
||||
else if (pBuffer->eOriginalFormat == AL_FORMAT_REAR8)
|
||||
{
|
||||
lByteOffset = pSource->lOffset * 4;
|
||||
lByteOffset -= (lByteOffset % (lChannels * 2));
|
||||
}
|
||||
else if (pBuffer->eOriginalFormat == AL_FORMAT_REAR16)
|
||||
{
|
||||
lByteOffset = pSource->lOffset * 2;
|
||||
lByteOffset -= (lByteOffset % (lChannels * 2));
|
||||
}
|
||||
else if (aluBytesFromFormat(pBuffer->eOriginalFormat) == 1)
|
||||
{
|
||||
lByteOffset = pSource->lOffset * 2;
|
||||
lByteOffset -= (lByteOffset % (lChannels * 2));
|
||||
}
|
||||
else if (aluBytesFromFormat(pBuffer->eOriginalFormat) == 4)
|
||||
{
|
||||
lByteOffset = pSource->lOffset / 2;
|
||||
lByteOffset -= (lByteOffset % (lChannels * 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
lByteOffset = pSource->lOffset;
|
||||
@@ -2096,3 +2282,24 @@ static ALint GetByteOffset(ALsource *pSource)
|
||||
|
||||
return lByteOffset;
|
||||
}
|
||||
|
||||
|
||||
ALvoid ReleaseALSources(ALCcontext *Context)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if(Context->SourceCount > 0)
|
||||
AL_PRINT("alcDestroyContext(): %d Source(s) NOT deleted\n", Context->SourceCount);
|
||||
#endif
|
||||
|
||||
while(Context->Source)
|
||||
{
|
||||
ALsource *temp = Context->Source;
|
||||
Context->Source = Context->Source->next;
|
||||
|
||||
// Release source structure
|
||||
ALTHUNK_REMOVEENTRY(temp->source);
|
||||
memset(temp, 0, sizeof(ALsource));
|
||||
free(temp);
|
||||
}
|
||||
Context->SourceCount = 0;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "alMain.h"
|
||||
#include "AL/alc.h"
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "alMain.h"
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
# OpenAL config file. Options that are not under a block or are under the
|
||||
# [general] block are for general, non-backend-specific options. Blocks may
|
||||
# appear multiple times, and duplicated options will take the last value
|
||||
# specified.
|
||||
# The system-wide settings can be put in /etc/openal/alsoft.conf and user-
|
||||
# specific override settings in ~/.alsoftrc.
|
||||
|
||||
# Option and block names are case-insenstive. The supplied values are only
|
||||
# hints and may not be honored (though generally it'll try to get as close as
|
||||
# possible). These are the current available settings:
|
||||
|
||||
format = AL_FORMAT_STEREO16 # Sets the output format. Can be one of:
|
||||
# AL_FORMAT_MONO8 (8-bit mono)
|
||||
# AL_FORMAT_STEREO8 (8-bit stereo)
|
||||
# AL_FORMAT_QUAD8 (8-bit 4-channel)
|
||||
# AL_FORMAT_51CHN8 (8-bit 5.1 output)
|
||||
# AL_FORMAT_61CHN8 (8-bit 6.1 output)
|
||||
# AL_FORMAT_71CHN8 (8-bit 7.1 output)
|
||||
# AL_FORMAT_MONO16 (16-bit mono)
|
||||
# AL_FORMAT_STEREO16 (16-bit stereo)
|
||||
# AL_FORMAT_QUAD16 (16-bit 4-channel)
|
||||
# AL_FORMAT_51CHN16 (16-bit 5.1 output)
|
||||
# AL_FORMAT_61CHN16 (16-bit 6.1 output)
|
||||
# AL_FORMAT_71CHN16 (16-bit 7.1 output)
|
||||
# Default is AL_FORMAT_STEREO16
|
||||
|
||||
cf_level = 0 # Sets the crossfeed level for stereo output. Valid values are:
|
||||
# 0 - No crossfeed
|
||||
# 1 - Low crossfeed
|
||||
# 2 - Middle crossfeed
|
||||
# 3 - High crossfeed (virtual speakers are closer to itself)
|
||||
# 4 - Low easy crossfeed
|
||||
# 5 - Middle easy crossfeed
|
||||
# 6 - High easy crossfeed
|
||||
# Default is 0. Users of headphones may want to try various
|
||||
# settings. Has no effect on non-stereo modes.
|
||||
|
||||
frequency = 44100 # Sets the output frequency. Default is 44100
|
||||
|
||||
refresh = 8192 # Sets the buffer size, in frames. Default is 8192. Note that
|
||||
# the actual granularity may or may not be less than this.
|
||||
|
||||
sources = 256 # Sets the maximum number of allocatable sources. Lower values
|
||||
# may help for systems with apps that try to play more sounds
|
||||
# than the CPU can handle. Default is 256
|
||||
|
||||
stereodup = # Sets whether to duplicate stereo sounds on the rear speakers for
|
||||
# 4+ channel output. This can make stereo sources substantially
|
||||
# louder than mono or even 4+ channel sources, but provides a
|
||||
# "fuller" playback quality. True, yes, on, and non-0 values will
|
||||
# duplicate stereo sources. 0 and anything else will cause stereo
|
||||
# sounds to only play out the front speakers.
|
||||
# Default is false
|
||||
|
||||
drivers = # Sets the backend driver list order, comma-seperated. Unknown
|
||||
# backends and duplicated names are ignored, and unlisted backends
|
||||
# won't be considered for use. An empty list means the default.
|
||||
# Default is:
|
||||
# alsa,oss,dsound,winmm,wave
|
||||
|
||||
[alsa] # ALSA backend stuff
|
||||
device = default # Sets the device name for the default playback device.
|
||||
# Default is default
|
||||
|
||||
periods = 0 # Sets the number of update buffers for playback. A value of 0
|
||||
# means auto-select. Default is 0
|
||||
|
||||
capture = default # Sets the device name for the default capture device.
|
||||
# Default is default
|
||||
|
||||
mmap = true # Sets whether to try using mmap mode (helps reduce latencies and
|
||||
# CPU consumption). If mmap isn't available, it will automatically
|
||||
# fall back to non-mmap mode. True, yes, on, and non-0 values will
|
||||
# attempt to use mmap. 0 and anything else will force mmap off.
|
||||
# Default is true.
|
||||
|
||||
[oss] # OSS backend stuff
|
||||
device = /dev/dsp # Sets the device name for OSS output. Default is /dev/dsp
|
||||
|
||||
periods = 4 # Sets the number of update buffers. Default is 4
|
||||
|
||||
capture = /dev/dsp # Sets the device name for OSS capture. Default is /dev/dsp
|
||||
|
||||
[dsound] # DirectSound backend stuff
|
||||
# Nothing yet...
|
||||
|
||||
[winmm] # Windows Multimedia backend stuff
|
||||
# Nothing yet...
|
||||
|
||||
[wave] # Wave File Writer stuff
|
||||
file = # Sets the filename of the wave file to write to. An empty name
|
||||
# prevents the backend from opening, even when explicitly requested.
|
||||
# THIS WILL OVERWRITE EXISTING FILES WITHOUT QUESTION!
|
||||
# Default is empty
|
||||
@@ -19,6 +19,9 @@
|
||||
/* Define if we have the sqrtf function */
|
||||
#cmakedefine HAVE_SQRTF
|
||||
|
||||
/* Define if we have the acosf function */
|
||||
#cmakedefine HAVE_ACOSF
|
||||
|
||||
/* Define if we have the strtof function */
|
||||
#cmakedefine HAVE_STRTOF
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* OpenAL cross platform audio library
|
||||
* Copyright (C) 2008 by authors.
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
#ifndef AL_ALEXT_H
|
||||
#define AL_ALEXT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef AL_EXT_float32
|
||||
#define AL_EXT_float32 1
|
||||
#define AL_FORMAT_MONO_FLOAT32 0x10010
|
||||
#define AL_FORMAT_STEREO_FLOAT32 0x10011
|
||||
#endif
|
||||
|
||||
#ifndef AL_LOKI_quadriphonic
|
||||
#define AL_LOKI_quadriphonic 1
|
||||
#define AL_FORMAT_QUAD8_LOKI 0x10004
|
||||
#define AL_FORMAT_QUAD16_LOKI 0x10005
|
||||
#endif
|
||||
|
||||
#ifndef AL_EXT_MCFORMATS
|
||||
#define AL_EXT_MCFORMATS 1
|
||||
#define AL_FORMAT_QUAD8 0x1204
|
||||
#define AL_FORMAT_QUAD16 0x1205
|
||||
#define AL_FORMAT_QUAD32 0x1206
|
||||
#define AL_FORMAT_REAR8 0x1207
|
||||
#define AL_FORMAT_REAR16 0x1208
|
||||
#define AL_FORMAT_REAR32 0x1209
|
||||
#define AL_FORMAT_51CHN8 0x120A
|
||||
#define AL_FORMAT_51CHN16 0x120B
|
||||
#define AL_FORMAT_51CHN32 0x120C
|
||||
#define AL_FORMAT_61CHN8 0x120D
|
||||
#define AL_FORMAT_61CHN16 0x120E
|
||||
#define AL_FORMAT_61CHN32 0x120F
|
||||
#define AL_FORMAT_71CHN8 0x1210
|
||||
#define AL_FORMAT_71CHN16 0x1211
|
||||
#define AL_FORMAT_71CHN32 0x1212
|
||||
#endif
|
||||
|
||||
#ifndef AL_EXT_IMA4
|
||||
#define AL_EXT_IMA4 1
|
||||
#define AL_FORMAT_MONO_IMA4 0x1300
|
||||
#define AL_FORMAT_STEREO_IMA4 0x1301
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,50 +0,0 @@
|
||||
# OpenAL config file. Options that are not under a block or are under the
|
||||
# [general] block are for general, non-backend-specific options. Blocks may
|
||||
# appear multiple times, and duplicated options will take the last value
|
||||
# specified. The system-wide settings can be put in /etc/openal/config and
|
||||
# user-specific override settings in ~/.openalrc
|
||||
|
||||
# Option and block names are case-insenstive. The supplied values are only
|
||||
# hints and may not be honored (though generally it'll try to get as close as
|
||||
# possible). These are the current available settings:
|
||||
|
||||
format = AL_FORMAT_STEREO16 # Sets the output format. Can be one of:
|
||||
# AL_FORMAT_MONO8 (8-bit mono)
|
||||
# AL_FORMAT_STEREO8 (8-bit stereo)
|
||||
# AL_FORMAT_QUAD8 (8-bit 4-channel)
|
||||
# AL_FORMAT_MONO16 (16-bit mono)
|
||||
# AL_FORMAT_STEREO16 (16-bit stereo)
|
||||
# AL_FORMAT_QUAD16 (16-bit 4-channel)
|
||||
# Default is AL_FORMAT_STEREO16
|
||||
|
||||
frequency = 44100 # Sets the output frequency. Default is 44100
|
||||
|
||||
refresh = 0 # Sets the number of frames-per-update. Default is calculated as
|
||||
# 8192*frequency/22050. Note that the actual granularity may or
|
||||
# may not be less than this.
|
||||
|
||||
drivers = # Sets the backend driver list order, comma-seperated. Unknown
|
||||
# backends and duplicated names are ignored, and unlisted backends
|
||||
# won't be considered for use. An empty list means the default.
|
||||
# Default is:
|
||||
# alsa,oss,dsound,winmm
|
||||
|
||||
[alsa] # ALSA backend stuff
|
||||
device = default # Sets the device name for the default playback device.
|
||||
# Default is default
|
||||
|
||||
periods = 4 # Sets the number of update buffers. Default is 4
|
||||
|
||||
capture = default # Sets the device name for the default capture device.
|
||||
# Default is default
|
||||
|
||||
[oss] # OSS backend stuff
|
||||
device = /dev/dsp # Sets the device name for OSS output. Default is /dev/dsp
|
||||
|
||||
periods = 4 # Sets the number of update buffers. Default is 4
|
||||
|
||||
[dsound] # DirectSound backend stuff
|
||||
# Nothing yet...
|
||||
|
||||
[winmm] # Windows Multimedia backend stuff
|
||||
# Nothing yet...
|
||||
Reference in New Issue
Block a user