Support the ALC_FREQUENCY context attribute

This commit is contained in:
Chris Robinson 2009-08-13 13:28:35 -07:00
parent 87fee8c504
commit d46655fbb2

View File

@ -1049,6 +1049,7 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
// Check for attributes // Check for attributes
if (attrList) if (attrList)
{ {
ALCuint freq = device->Frequency;
ALCint numMono = device->lNumMonoSources; ALCint numMono = device->lNumMonoSources;
ALCint numStereo = device->lNumStereoSources; ALCint numStereo = device->lNumStereoSources;
ALCuint numSends = device->NumAuxSends; ALCuint numSends = device->NumAuxSends;
@ -1056,6 +1057,13 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
ulAttributeIndex = 0; ulAttributeIndex = 0;
while ((ulAttributeIndex < 10) && (attrList[ulAttributeIndex])) while ((ulAttributeIndex < 10) && (attrList[ulAttributeIndex]))
{ {
if(attrList[ulAttributeIndex] == ALC_FREQUENCY)
{
freq = attrList[ulAttributeIndex + 1];
if(freq == 0)
freq = device->Frequency;
}
if(attrList[ulAttributeIndex] == ALC_STEREO_SOURCES) if(attrList[ulAttributeIndex] == ALC_STEREO_SOURCES)
{ {
ulRequestedStereoSources = attrList[ulAttributeIndex + 1]; ulRequestedStereoSources = attrList[ulAttributeIndex + 1];
@ -1080,6 +1088,7 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
ulAttributeIndex += 2; ulAttributeIndex += 2;
} }
device->Frequency = GetConfigValueInt(NULL, "frequency", freq);
device->lNumMonoSources = numMono; device->lNumMonoSources = numMono;
device->lNumStereoSources = numStereo; device->lNumStereoSources = numStereo;
device->NumAuxSends = numSends; device->NumAuxSends = numSends;
@ -1091,6 +1100,7 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint
ALContext = NULL; ALContext = NULL;
SetALCError(ALC_INVALID_VALUE); SetALCError(ALC_INVALID_VALUE);
} }
ALContext->Frequency = device->Frequency;
} }
else else
{ {
@ -1266,7 +1276,7 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
//Set output format //Set output format
device->Frequency = GetConfigValueInt(NULL, "frequency", SWMIXER_OUTPUT_RATE); device->Frequency = GetConfigValueInt(NULL, "frequency", SWMIXER_OUTPUT_RATE);
if((ALint)device->Frequency <= 0) if(device->Frequency == 0)
device->Frequency = SWMIXER_OUTPUT_RATE; device->Frequency = SWMIXER_OUTPUT_RATE;
fmt = GetConfigValue(NULL, "format", "AL_FORMAT_STEREO16"); fmt = GetConfigValue(NULL, "format", "AL_FORMAT_STEREO16");