diff options
author | Chris Robinson <[email protected]> | 2012-01-25 19:54:55 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2012-01-25 19:54:55 -0800 |
commit | f87b607a53de19bb4cc6021034760a071ddc33ed (patch) | |
tree | 5d97b4c885fbd7d358ff225f26c208332ca9f2ca /Alc/ALc.c | |
parent | b4ba83ec34f1467b9e37c9e735f4a3a5ddc100e9 (diff) |
Make sure the attributes list specifies a format for loopback devices
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r-- | Alc/ALc.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -1053,10 +1053,15 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) // Check for attributes if(attrList && attrList[0]) { + static const ALCint GotFreq = 1<<0; + static const ALCint GotChans = 1<<1; + static const ALCint GotType = 1<<2; + static const ALCint GotAll = GotFreq|GotChans|GotType; ALCuint freq, numMono, numStereo, numSends; enum DevFmtChannels schans; enum DevFmtType stype; - ALuint attrIdx; + ALCuint attrIdx = 0; + ALCint gotFmt = 0; // If a context is already running on the device, stop playback so the // device attributes can be updated @@ -1071,7 +1076,6 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) numStereo = device->NumStereoSources; numSends = device->NumAuxSends; - attrIdx = 0; while(attrList[attrIdx]) { if(attrList[attrIdx] == ALC_FORMAT_CHANNELS_SOFT && @@ -1084,6 +1088,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) return ALC_FALSE; } schans = val; + gotFmt |= GotChans; } if(attrList[attrIdx] == ALC_FORMAT_TYPE_SOFT && @@ -1096,6 +1101,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) return ALC_FALSE; } stype = val; + gotFmt |= GotType; } if(attrList[attrIdx] == ALC_FREQUENCY) @@ -1108,6 +1114,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) alcSetError(device, ALC_INVALID_VALUE); return ALC_FALSE; } + gotFmt |= GotFreq; } else { @@ -1131,7 +1138,16 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) attrIdx += 2; } - if(!device->IsLoopbackDevice) + if(device->IsLoopbackDevice) + { + if(gotFmt != GotAll) + { + WARN("Missing format for loopback device\n"); + alcSetError(device, ALC_INVALID_VALUE); + return ALC_FALSE; + } + } + else { ConfigValueUInt(NULL, "frequency", &freq); freq = maxu(freq, 8000); |