aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-09-15 19:06:47 -0700
committerChris Robinson <[email protected]>2009-09-15 19:06:47 -0700
commit12f81bcbb91f95df8bafdafa29f30adf55701203 (patch)
tree9628a3c6b312dfe6d1a609a5a729135f2b516e12 /Alc/ALc.c
parent6636131d3bb52687229881d4d2343b5c464b5c81 (diff)
Move the stereo-to-binaural filter to the device
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 229af2e9..049a62d7 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -534,8 +534,6 @@ ALCcontext *GetContextSuspended(void)
*/
static ALvoid InitContext(ALCcontext *pContext)
{
- int level;
-
//Initialise listener
pContext->Listener.Gain = 1.0f;
pContext->Listener.MetersPerUnit = 1.0f;
@@ -567,14 +565,6 @@ static ALvoid InitContext(ALCcontext *pContext)
pContext->ExtensionList = "AL_EXTX_buffer_sub_data AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_OFFSET AL_EXTX_sample_buffer_object AL_EXTX_source_distance_model 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);
- }
-
aluInitPanning(pContext);
}
@@ -589,9 +579,6 @@ static ALCvoid ExitContext(ALCcontext *pContext)
//Invalidate context
pContext->LastError = AL_NO_ERROR;
pContext->InUse = AL_FALSE;
-
- free(pContext->bs2b);
- pContext->bs2b = NULL;
}
///////////////////////////////////////////////////////
@@ -1174,6 +1161,7 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
// Check for attributes
if (attrList)
{
+ ALCint level = device->Bs2bLevel;
ALCuint freq = device->Frequency;
ALCint numMono = device->lNumMonoSources;
ALCint numStereo = device->lNumStereoSources;
@@ -1213,12 +1201,22 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
ulAttributeIndex += 2;
}
+ device->Bs2bLevel = GetConfigValueInt(NULL, "cf_level", level);
device->Frequency = GetConfigValueInt(NULL, "frequency", freq);
device->lNumMonoSources = numMono;
device->lNumStereoSources = numStereo;
device->NumAuxSends = numSends;
}
+ free(device->Bs2b);
+ device->Bs2b = NULL;
+ if(device->Bs2bLevel > 0 && device->Bs2bLevel <= 6)
+ {
+ device->Bs2b = calloc(1, sizeof(*device->Bs2b));
+ bs2b_set_srate(device->Bs2b, device->Frequency);
+ bs2b_set_level(device->Bs2b, device->Bs2bLevel);
+ }
+
if(ALCdevice_StartContext(device, ALContext) == ALC_FALSE)
{
alcDestroyContext(ALContext);
@@ -1476,6 +1474,7 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
device->Connected = ALC_TRUE;
device->IsCaptureDevice = AL_FALSE;
+ device->Bs2b = NULL;
device->szDeviceName = NULL;
//Set output format
@@ -1505,6 +1504,8 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
if(device->NumAuxSends > MAX_SENDS)
device->NumAuxSends = MAX_SENDS;
+ device->Bs2bLevel = GetConfigValueInt(NULL, "cf_level", 0);
+
// Find a playback device to open
SuspendContext(NULL);
for(i = 0;BackendList[i].Init;i++)
@@ -1598,6 +1599,9 @@ ALCAPI ALCboolean ALCAPIENTRY alcCloseDevice(ALCdevice *pDevice)
ReleaseALDatabuffers(pDevice);
}
+ free(pDevice->Bs2b);
+ pDevice->Bs2b = NULL;
+
free(pDevice->szDeviceName);
//Release device structure