From bb4726d52038befc53ab219da8b75193a2605c5d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 20 Feb 2017 16:57:25 -0800 Subject: Avoid duplicating device buffer layout logic --- Alc/ALc.c | 49 +++++++++++++------------------------------------ 1 file changed, 13 insertions(+), 36 deletions(-) (limited to 'Alc/ALc.c') 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) -- cgit v1.2.3