diff options
author | Chris Robinson <[email protected]> | 2017-02-20 16:57:25 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-02-20 16:57:25 -0800 |
commit | bb4726d52038befc53ab219da8b75193a2605c5d (patch) | |
tree | 743e8a8f4adcf6605c867d62f4ba6d20e3822299 | |
parent | f5e8a8c75e98e7a720a42a840701808b3f869a8a (diff) |
Avoid duplicating device buffer layout logic
-rw-r--r-- | Alc/ALc.c | 49 | ||||
-rw-r--r-- | Alc/bformatdec.c | 1 | ||||
-rw-r--r-- | Alc/panning.c | 26 |
3 files changed, 38 insertions, 38 deletions
@@ -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) diff --git a/Alc/bformatdec.c b/Alc/bformatdec.c index 5b848ee0..955b9e4a 100644 --- a/Alc/bformatdec.c +++ b/Alc/bformatdec.c @@ -401,6 +401,7 @@ void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BU { ALsizei chan, i; + OutBuffer = ASSUME_ALIGNED(OutBuffer, 16); if(dec->DualBand) { for(i = 0;i < dec->NumChannels;i++) diff --git a/Alc/panning.c b/Alc/panning.c index 52618a5e..70355b41 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -569,6 +569,7 @@ static void InitPanning(ALCdevice *device) { device->FOAOut.Ambi = device->Dry.Ambi; device->FOAOut.CoeffCount = device->Dry.CoeffCount; + device->FOAOut.NumChannels = 0; } else { @@ -582,6 +583,7 @@ static void InitPanning(ALCdevice *device) device->FOAOut.Ambi.Map[i].Index = i; } device->FOAOut.CoeffCount = 0; + device->FOAOut.NumChannels = 4; ambiup_reset(device->AmbiUp, device); } @@ -607,7 +609,9 @@ static void InitPanning(ALCdevice *device) device->FOAOut.Ambi.Coeffs[i][j] = device->Dry.Ambi.Coeffs[i][j] * xyz_scale; } device->FOAOut.CoeffCount = 4; + device->FOAOut.NumChannels = 0; } + device->RealOut.NumChannels = 0; } static void InitDistanceComp(ALCdevice *device, const AmbDecConf *conf, const ALsizei speakermap[MAX_OUTPUT_CHANNELS]) @@ -729,6 +733,9 @@ static void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const A device->FOAOut.Ambi.Coeffs[i][j] = device->Dry.Ambi.Coeffs[i][j] * xyz_scale; } device->FOAOut.CoeffCount = 4; + device->FOAOut.NumChannels = 0; + + device->RealOut.NumChannels = 0; InitDistanceComp(device, conf, speakermap); } @@ -774,28 +781,36 @@ static void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALsiz { device->FOAOut.Ambi = device->Dry.Ambi; device->FOAOut.CoeffCount = device->Dry.CoeffCount; + device->FOAOut.NumChannels = 0; } else { memset(&device->FOAOut.Ambi, 0, sizeof(device->FOAOut.Ambi)); if((conf->ChanMask&AMBI_PERIPHONIC_MASK)) - for(i = 0;i < 4;i++) + { + count = 4; + for(i = 0;i < count;i++) { device->FOAOut.Ambi.Map[i].Scale = 1.0f; device->FOAOut.Ambi.Map[i].Index = i; } + } else { static const int map[3] = { 0, 1, 3 }; - for(i = 0;i < 3;i++) + count = 3; + for(i = 0;i < count;i++) { device->FOAOut.Ambi.Map[i].Scale = 1.0f; device->FOAOut.Ambi.Map[i].Index = map[i]; } } device->FOAOut.CoeffCount = 0; + device->FOAOut.NumChannels = count; } + device->RealOut.NumChannels = ChannelsFromDevFmt(device->FmtChans); + InitDistanceComp(device, conf, speakermap); } @@ -868,6 +883,7 @@ static void InitHrtfPanning(ALCdevice *device, bool hoa_mode) { device->FOAOut.Ambi = device->Dry.Ambi; device->FOAOut.CoeffCount = device->Dry.CoeffCount; + device->FOAOut.NumChannels = 0; } else { @@ -878,10 +894,13 @@ static void InitHrtfPanning(ALCdevice *device, bool hoa_mode) device->FOAOut.Ambi.Map[i].Index = i; } device->FOAOut.CoeffCount = 0; + device->FOAOut.NumChannels = 4; ambiup_reset(device->AmbiUp, device); } + device->RealOut.NumChannels = ChannelsFromDevFmt(device->FmtChans); + memset(device->Hrtf.Coeffs, 0, sizeof(device->Hrtf.Coeffs)); device->Hrtf.IrSize = BuildBFormatHrtf(device->Hrtf.Handle, device->Hrtf.Coeffs, device->Dry.NumChannels, @@ -908,6 +927,9 @@ static void InitUhjPanning(ALCdevice *device) device->FOAOut.Ambi = device->Dry.Ambi; device->FOAOut.CoeffCount = device->Dry.CoeffCount; + device->FOAOut.NumChannels = 0; + + device->RealOut.NumChannels = ChannelsFromDevFmt(device->FmtChans); } void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf_appreq, enum HrtfRequestMode hrtf_userreq) |