diff options
author | Chris Robinson <[email protected]> | 2016-07-06 13:33:40 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-07-06 13:33:40 -0700 |
commit | b495d80f5624328569bd0d8b9478927c0fc32100 (patch) | |
tree | 8e8d167cf5fa90b9adf22f5bf855430be819f17d | |
parent | d096e183a8d1e20ed2a71d502897394a14bf8404 (diff) |
Avoid using memcpy to copy a single struct
-rw-r--r-- | Alc/panning.c | 8 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 26 | ||||
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 6 |
3 files changed, 19 insertions, 21 deletions
diff --git a/Alc/panning.c b/Alc/panning.c index 6949c565..c7bc82f8 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -581,7 +581,7 @@ static void InitPanning(ALCdevice *device) device->Dry.CoeffCount = 0; device->Dry.NumChannels = count; - memcpy(&device->FOAOut.Ambi, &device->Dry.Ambi, sizeof(device->FOAOut.Ambi)); + device->FOAOut.Ambi = device->Dry.Ambi; device->FOAOut.CoeffCount = device->Dry.CoeffCount; } else @@ -708,7 +708,7 @@ static void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALuin if(bformatdec_getOrder(device->AmbiDecoder) < 2) { - memcpy(&device->FOAOut.Ambi, &device->Dry.Ambi, sizeof(device->FOAOut.Ambi)); + device->FOAOut.Ambi = device->Dry.Ambi; device->FOAOut.CoeffCount = device->Dry.CoeffCount; } else @@ -763,7 +763,7 @@ static void InitHrtfPanning(ALCdevice *device) &device->Dry.NumChannels, AL_TRUE); device->Dry.CoeffCount = 4; - memcpy(&device->FOAOut.Ambi, &device->Dry.Ambi, sizeof(device->FOAOut.Ambi)); + device->FOAOut.Ambi = device->Dry.Ambi; device->FOAOut.CoeffCount = device->Dry.CoeffCount; for(i = 0;i < device->Dry.NumChannels;i++) @@ -788,7 +788,7 @@ static void InitUhjPanning(ALCdevice *device) device->Dry.CoeffCount = 0; device->Dry.NumChannels = count; - memcpy(&device->FOAOut.Ambi, &device->Dry.Ambi, sizeof(device->FOAOut.Ambi)); + device->FOAOut.Ambi = device->Dry.Ambi; device->FOAOut.CoeffCount = device->Dry.CoeffCount; } diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index e1411b83..13aadef5 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -504,6 +504,13 @@ typedef struct BFChannelConfig { ALuint Index; } BFChannelConfig; +typedef union AmbiConfig { + /* Ambisonic coefficients for mixing to the dry buffer. */ + ChannelConfig Coeffs[MAX_OUTPUT_CHANNELS]; + /* Coefficient channel mapping for mixing to the dry buffer. */ + BFChannelConfig Map[MAX_OUTPUT_CHANNELS]; +} AmbiConfig; + #define HRTF_HISTORY_BITS (6) #define HRTF_HISTORY_LENGTH (1<<HRTF_HISTORY_BITS) @@ -599,16 +606,10 @@ struct ALCdevice_struct /* The "dry" path corresponds to the main output. */ struct { - union { - /* Ambisonic coefficients for mixing to the dry buffer. */ - ChannelConfig Coeffs[MAX_OUTPUT_CHANNELS]; - /* Coefficient channel mapping for mixing to the dry buffer. */ - BFChannelConfig Map[MAX_OUTPUT_CHANNELS]; - } Ambi; - /* Number of coefficients in each ChannelConfig to mix together (4 for - * first-order, 9 for second-order, etc). If the count is 0, the - * BFChannelConfig is used instead to map each output to a coefficient - * index. + AmbiConfig Ambi; + /* Number of coefficients in each Ambi.Coeffs to mix together (4 for + * first-order, 9 for second-order, etc). If the count is 0, Ambi.Map + * is used instead to map each output to a coefficient index. */ ALuint CoeffCount; @@ -618,10 +619,7 @@ struct ALCdevice_struct /* First-order ambisonics output, to be upsampled to the dry buffer if different. */ struct { - union { - ChannelConfig Coeffs[MAX_OUTPUT_CHANNELS]; - BFChannelConfig Map[MAX_OUTPUT_CHANNELS]; - } Ambi; + AmbiConfig Ambi; /* Will only be 4 or 0. */ ALuint CoeffCount; diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index bbaf0668..14066cf9 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -511,7 +511,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e else { EffectSlot->Effect.Type = effect->type; - memcpy(&EffectSlot->Effect.Props, &effect->Props, sizeof(EffectSlot->Effect.Props)); + EffectSlot->Effect.Props = effect->Props; } EffectSlot->Effect.State = State; @@ -519,7 +519,7 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e } else if(effect) { - memcpy(&EffectSlot->Effect.Props, &effect->Props, sizeof(EffectSlot->Effect.Props)); + EffectSlot->Effect.Props = effect->Props; UpdateEffectSlotProps(EffectSlot); } @@ -630,7 +630,7 @@ void UpdateEffectSlotProps(ALeffectslot *slot) ATOMIC_STORE(&props->AuxSendAuto, slot->AuxSendAuto, almemory_order_relaxed); ATOMIC_STORE(&props->Type, slot->Effect.Type, almemory_order_relaxed); - memcpy(&props->Props, &slot->Effect.Props, sizeof(props->Props)); + props->Props = slot->Effect.Props; /* Swap out any stale effect state object there may be in the container, to * delete it. */ |