aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALc.c30
-rw-r--r--Alc/ALu.c4
-rw-r--r--OpenAL32/Include/alMain.h6
3 files changed, 23 insertions, 17 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
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 509929b7..171758ba 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1258,14 +1258,14 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
} \
break; \
case AL_FORMAT_STEREO##bits: \
- if(ALContext && ALContext->bs2b) \
+ if(ALContext && ALContext->Device->Bs2b) \
{ \
for(i = 0;i < SamplesToDo;i++) \
{ \
float samples[2]; \
samples[0] = DryBuffer[i][FRONT_LEFT]; \
samples[1] = DryBuffer[i][FRONT_RIGHT]; \
- bs2b_cross_feed(ALContext->bs2b, samples); \
+ bs2b_cross_feed(ALContext->Device->Bs2b, samples); \
((type*)buffer)[0] = (func)(samples[0]); \
((type*)buffer)[1] = (func)(samples[1]); \
buffer = ((type*)buffer) + 2; \
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 55b59b97..cc48aee4 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -240,6 +240,10 @@ struct ALCdevice_struct
struct ALdatabuffer *Databuffers;
ALuint DatabufferCount;
+ // Stereo-to-binaural filter
+ struct bs2b *Bs2b;
+ ALCint Bs2bLevel;
+
// Context created on this device
ALCcontext *Context;
@@ -292,8 +296,6 @@ struct ALCcontext_struct
ALCdevice *Device;
const ALCchar *ExtensionList;
- struct bs2b *bs2b;
-
ALCcontext *next;
};