aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-02-20 16:57:25 -0800
committerChris Robinson <[email protected]>2017-02-20 16:57:25 -0800
commitbb4726d52038befc53ab219da8b75193a2605c5d (patch)
tree743e8a8f4adcf6605c867d62f4ba6d20e3822299 /Alc/ALc.c
parentf5e8a8c75e98e7a720a42a840701808b3f869a8a (diff)
Avoid duplicating device buffer layout logic
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c49
1 files changed, 13 insertions, 36 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index d200733b..c831ca9d 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2116,22 +2116,12 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
);
aluInitRenderer(device, hrtf_id, hrtf_appreq, hrtf_userreq);
+ TRACE("Channel config, Dry: %d, FOA: %d, Real: %d\n", device->Dry.NumChannels,
+ device->FOAOut.NumChannels, device->RealOut.NumChannels);
/* Allocate extra channels for any post-filter output. */
- size = device->Dry.NumChannels;
- if(device->AmbiDecoder && bformatdec_getOrder(device->AmbiDecoder) >= 2)
- {
- size += ChannelsFromDevFmt(device->FmtChans);
- size += bformatdec_isPeriphonic(device->AmbiDecoder) ? 4 : 3;
- }
- else
- {
- if(device->Hrtf.Handle || device->Uhj_Encoder || device->AmbiDecoder)
- size += ChannelsFromDevFmt(device->FmtChans);
- if(device->AmbiUp)
- size += 4;
- }
- size *= sizeof(device->Dry.Buffer[0]);
+ size = (device->Dry.NumChannels + device->FOAOut.NumChannels +
+ device->RealOut.NumChannels)*sizeof(device->Dry.Buffer[0]);
TRACE("Allocating "SZFMT" channels, "SZFMT" bytes\n", size/sizeof(device->Dry.Buffer[0]), size);
device->Dry.Buffer = al_calloc(16, size);
@@ -2141,35 +2131,22 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
return ALC_INVALID_DEVICE;
}
- if((device->AmbiDecoder && bformatdec_getOrder(device->AmbiDecoder) >= 2) || device->AmbiUp)
- {
- /* Higher-order rendering requires upsampling first-order content, so
- * make sure to mix it separately.
- */
- device->FOAOut.Buffer = device->Dry.Buffer + device->Dry.NumChannels;
- if((device->AmbiDecoder && bformatdec_isPeriphonic(device->AmbiDecoder)) || device->AmbiUp)
- device->FOAOut.NumChannels = 4;
- else
- device->FOAOut.NumChannels = 3;
- }
+ if(device->RealOut.NumChannels != 0)
+ device->RealOut.Buffer = device->Dry.Buffer + device->Dry.NumChannels +
+ device->FOAOut.NumChannels;
else
{
- device->FOAOut.Buffer = device->Dry.Buffer;
- device->FOAOut.NumChannels = device->Dry.NumChannels;
+ device->RealOut.Buffer = device->Dry.Buffer;
+ device->RealOut.NumChannels = device->Dry.NumChannels;
}
- if(device->Hrtf.Handle || device->Uhj_Encoder || device->AmbiDecoder)
- {
- device->RealOut.Buffer = device->FOAOut.Buffer + device->FOAOut.NumChannels;
- device->RealOut.NumChannels = ChannelsFromDevFmt(device->FmtChans);
- }
+ if(device->FOAOut.NumChannels != 0)
+ device->FOAOut.Buffer = device->Dry.Buffer + device->Dry.NumChannels;
else
{
- device->RealOut.Buffer = device->Dry.Buffer;
- device->RealOut.NumChannels = device->Dry.NumChannels;
+ device->FOAOut.Buffer = device->Dry.Buffer;
+ device->FOAOut.NumChannels = device->Dry.NumChannels;
}
- TRACE("Channel config, Dry: %d, FOA: %d, Real: %d\n", device->Dry.NumChannels,
- device->FOAOut.NumChannels, device->RealOut.NumChannels);
SetMixerFPUMode(&oldMode);
if(device->DefaultSlot)