aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALc.c112
1 files changed, 70 insertions, 42 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index c0ac5b95..7a5e3c54 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1049,14 +1049,8 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
int oldMode;
ALuint i;
- if(device->Type == Loopback && !(attrList && attrList[0]))
- {
- WARN("Missing attributes for loopback device\n");
- return ALC_INVALID_VALUE;
- }
-
// Check for attributes
- if(attrList && attrList[0])
+ if(device->Type == Loopback)
{
enum {
GotFreq = 1<<0,
@@ -1070,23 +1064,19 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
ALCuint attrIdx = 0;
ALCint gotFmt = 0;
- // If a context is already running on the device, stop playback so the
- // device attributes can be updated
- if((device->Flags&DEVICE_RUNNING))
- ALCdevice_StopPlayback(device);
- device->Flags &= ~DEVICE_RUNNING;
+ if(!attrList)
+ {
+ WARN("Missing attributes for loopback device\n");
+ return ALC_INVALID_VALUE;
+ }
- freq = device->Frequency;
- schans = device->FmtChans;
- stype = device->FmtType;
numMono = device->NumMonoSources;
numStereo = device->NumStereoSources;
numSends = device->NumAuxSends;
while(attrList[attrIdx])
{
- if(attrList[attrIdx] == ALC_FORMAT_CHANNELS_SOFT &&
- device->Type == Loopback)
+ if(attrList[attrIdx] == ALC_FORMAT_CHANNELS_SOFT)
{
ALCint val = attrList[attrIdx + 1];
if(!IsValidALCChannels(val) || !ChannelsFromDevFmt(val))
@@ -1095,8 +1085,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
gotFmt |= GotChans;
}
- if(attrList[attrIdx] == ALC_FORMAT_TYPE_SOFT &&
- device->Type == Loopback)
+ if(attrList[attrIdx] == ALC_FORMAT_TYPE_SOFT)
{
ALCint val = attrList[attrIdx + 1];
if(!IsValidALCType(val) || !BytesFromDevFmt(val))
@@ -1107,18 +1096,10 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
if(attrList[attrIdx] == ALC_FREQUENCY)
{
- if(device->Type == Loopback)
- {
- freq = attrList[attrIdx + 1];
- if(freq < MIN_OUTPUT_RATE)
- return ALC_INVALID_VALUE;
- gotFmt |= GotFreq;
- }
- else
- {
- freq = attrList[attrIdx + 1];
- device->Flags |= DEVICE_FREQUENCY_REQUEST;
- }
+ freq = attrList[attrIdx + 1];
+ if(freq < MIN_OUTPUT_RATE)
+ return ALC_INVALID_VALUE;
+ gotFmt |= GotFreq;
}
if(attrList[attrIdx] == ALC_STEREO_SOURCES)
@@ -1136,19 +1117,68 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
attrIdx += 2;
}
- if(device->Type == Loopback)
+ if(gotFmt != GotAll)
{
- if(gotFmt != GotAll)
- {
- WARN("Missing format for loopback device\n");
- return ALC_INVALID_VALUE;
- }
+ WARN("Missing format for loopback device\n");
+ return ALC_INVALID_VALUE;
}
- else
+
+ ConfigValueUInt(NULL, "sends", &numSends);
+ numSends = minu(MAX_SENDS, numSends);
+
+ if((device->Flags&DEVICE_RUNNING))
+ ALCdevice_StopPlayback(device);
+ device->Flags &= ~DEVICE_RUNNING;
+
+ device->Frequency = freq;
+ device->FmtChans = schans;
+ device->FmtType = stype;
+ device->NumMonoSources = numMono;
+ device->NumStereoSources = numStereo;
+ device->NumAuxSends = numSends;
+ }
+ else if(attrList && attrList[0])
+ {
+ ALCuint freq, numMono, numStereo, numSends;
+ ALCuint attrIdx = 0;
+
+ /* If a context is already running on the device, stop playback so the
+ * device attributes can be updated. */
+ if((device->Flags&DEVICE_RUNNING))
+ ALCdevice_StopPlayback(device);
+ device->Flags &= ~DEVICE_RUNNING;
+
+ freq = device->Frequency;
+ numMono = device->NumMonoSources;
+ numStereo = device->NumStereoSources;
+ numSends = device->NumAuxSends;
+
+ while(attrList[attrIdx])
{
- ConfigValueUInt(NULL, "frequency", &freq);
- freq = maxu(freq, MIN_OUTPUT_RATE);
+ if(attrList[attrIdx] == ALC_FREQUENCY)
+ {
+ freq = attrList[attrIdx + 1];
+ device->Flags |= DEVICE_FREQUENCY_REQUEST;
+ }
+
+ if(attrList[attrIdx] == ALC_STEREO_SOURCES)
+ {
+ numStereo = attrList[attrIdx + 1];
+ if(numStereo > device->MaxNoOfSources)
+ numStereo = device->MaxNoOfSources;
+
+ numMono = device->MaxNoOfSources - numStereo;
+ }
+
+ if(attrList[attrIdx] == ALC_MAX_AUXILIARY_SENDS)
+ numSends = attrList[attrIdx + 1];
+
+ attrIdx += 2;
}
+
+ ConfigValueUInt(NULL, "frequency", &freq);
+ freq = maxu(freq, MIN_OUTPUT_RATE);
+
ConfigValueUInt(NULL, "sends", &numSends);
numSends = minu(MAX_SENDS, numSends);
@@ -1156,8 +1186,6 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
device->Frequency;
device->Frequency = freq;
- device->FmtChans = schans;
- device->FmtType = stype;
device->NumMonoSources = numMono;
device->NumStereoSources = numStereo;
device->NumAuxSends = numSends;