From 928572d384518858c9f7fa0e6c1ae445a943567d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 12 Aug 2010 17:24:55 -0700 Subject: Start the device when creating a context without specified attributes --- Alc/ALc.c | 94 +++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/Alc/ALc.c b/Alc/ALc.c index 3bc7be78..72106824 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -827,66 +827,70 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) ALuint attrIdx; ALuint i; - // Check for attributes - if(!attrList || !attrList[0]) - return ALC_TRUE; - running = ((device->NumContexts > 0) ? AL_TRUE : AL_FALSE); oldRate = device->Frequency; - // If a context is already running on the device, stop playback so the - // device attributes can be updated - if(running) - { - ProcessContext(NULL); - ALCdevice_StopPlayback(device); - SuspendContext(NULL); - running = AL_FALSE; - } - - freq = device->Frequency; - numMono = device->NumMonoSources; - numStereo = device->NumStereoSources; - numSends = device->NumAuxSends; - - attrIdx = 0; - while(attrList[attrIdx]) + // Check for attributes + if(attrList && attrList[0]) { - if(attrList[attrIdx] == ALC_FREQUENCY && - !ConfigValueExists(NULL, "frequency")) + // If a context is already running on the device, stop playback so the + // device attributes can be updated + if(running) { - freq = attrList[attrIdx + 1]; - if(freq < 8000) - freq = 8000; + ProcessContext(NULL); + ALCdevice_StopPlayback(device); + SuspendContext(NULL); + running = AL_FALSE; } - if(attrList[attrIdx] == ALC_STEREO_SOURCES) + freq = device->Frequency; + numMono = device->NumMonoSources; + numStereo = device->NumStereoSources; + numSends = device->NumAuxSends; + + attrIdx = 0; + while(attrList[attrIdx]) { - numStereo = attrList[attrIdx + 1]; - if(numStereo > device->MaxNoOfSources) - numStereo = device->MaxNoOfSources; + if(attrList[attrIdx] == ALC_FREQUENCY && + !ConfigValueExists(NULL, "frequency")) + { + freq = attrList[attrIdx + 1]; + if(freq < 8000) + freq = 8000; + } - numMono = device->MaxNoOfSources - numStereo; - } + if(attrList[attrIdx] == ALC_STEREO_SOURCES) + { + numStereo = attrList[attrIdx + 1]; + if(numStereo > device->MaxNoOfSources) + numStereo = device->MaxNoOfSources; - if(attrList[attrIdx] == ALC_MAX_AUXILIARY_SENDS && - !ConfigValueExists(NULL, "sends")) - { - numSends = attrList[attrIdx + 1]; - if(numSends > MAX_SENDS) - numSends = MAX_SENDS; + numMono = device->MaxNoOfSources - numStereo; + } + + if(attrList[attrIdx] == ALC_MAX_AUXILIARY_SENDS && + !ConfigValueExists(NULL, "sends")) + { + numSends = attrList[attrIdx + 1]; + if(numSends > MAX_SENDS) + numSends = MAX_SENDS; + } + + attrIdx += 2; } - attrIdx += 2; + device->UpdateSize = (ALuint64)device->UpdateSize * freq / + device->Frequency; + + device->Frequency = freq; + device->NumMonoSources = numMono; + device->NumStereoSources = numStereo; + device->NumAuxSends = numSends; } - device->UpdateSize = (ALuint64)device->UpdateSize * freq / - device->Frequency; + if(running) + return ALC_TRUE; - device->Frequency = freq; - device->NumMonoSources = numMono; - device->NumStereoSources = numStereo; - device->NumAuxSends = numSends; if(ALCdevice_ResetPlayback(device) == ALC_FALSE) return ALC_FALSE; -- cgit v1.2.3