diff options
author | Chris Robinson <[email protected]> | 2015-02-04 19:19:43 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2015-02-04 23:39:51 -0800 |
commit | 61743a3a0017c567ee62ab50c3da28a5ed2fed8d (patch) | |
tree | 8f928cd0b98695c43921a89efd38e2ca141be9a6 | |
parent | efb7b11d7f60d7fe6b1c10c21b4790f5a1dcd728 (diff) |
Avoid unnecessary uses of ExchangeInt/Ptr
-rw-r--r-- | Alc/ALc.c | 12 | ||||
-rw-r--r-- | Alc/midi/base.h | 2 | ||||
-rw-r--r-- | Alc/midi/fluidsynth.c | 6 | ||||
-rw-r--r-- | OpenAL32/alSoundfont.c | 18 |
4 files changed, 23 insertions, 15 deletions
@@ -1599,11 +1599,14 @@ void ALCcontext_DeferUpdates(ALCcontext *context) SetMixerFPUMode(&oldMode); V0(device->Backend,lock)(); - if(!ExchangeInt(&context->DeferUpdates, AL_TRUE)) + if(!context->DeferUpdates) { ALboolean UpdateSources; ALvoice *voice, *voice_end; ALeffectslot **slot, **slot_end; + + context->DeferUpdates = AL_TRUE; + /* Make sure all pending updates are performed */ UpdateSources = ATOMIC_EXCHANGE(ALenum, &context->UpdateSources, AL_FALSE); @@ -1649,10 +1652,12 @@ void ALCcontext_ProcessUpdates(ALCcontext *context) ALCdevice *device = context->Device; V0(device->Backend,lock)(); - if(ExchangeInt(&context->DeferUpdates, AL_FALSE)) + if(context->DeferUpdates) { ALsizei pos; + context->DeferUpdates = AL_FALSE; + LockUIntMapRead(&context->SourceMap); for(pos = 0;pos < context->SourceMap.size;pos++) { @@ -1667,7 +1672,8 @@ void ALCcontext_ProcessUpdates(ALCcontext *context) ReadUnlock(&Source->queue_lock); } - new_state = ExchangeInt(&Source->new_state, AL_NONE); + new_state = Source->new_state; + Source->new_state = AL_NONE; if(new_state) SetSourceState(Source, context, new_state); } diff --git a/Alc/midi/base.h b/Alc/midi/base.h index 157f2399..309e1a55 100644 --- a/Alc/midi/base.h +++ b/Alc/midi/base.h @@ -60,7 +60,7 @@ void MidiSynth_Destruct(MidiSynth *self); ALenum MidiSynth_selectSoundfonts(MidiSynth *self, ALCcontext *context, ALsizei count, const ALuint *ids); inline void MidiSynth_setGain(MidiSynth *self, ALfloat gain) { self->Gain = gain; } inline ALfloat MidiSynth_getGain(const MidiSynth *self) { return self->Gain; } -inline void MidiSynth_setState(MidiSynth *self, ALenum state) { ExchangeInt(&self->State, state); } +inline void MidiSynth_setState(MidiSynth *self, ALenum state) { self->State = state; } inline ALenum MidiSynth_getState(const MidiSynth *self) { return self->State; } void MidiSynth_stop(MidiSynth *self); inline void MidiSynth_reset(MidiSynth *self) { MidiSynth_stop(self); } diff --git a/Alc/midi/fluidsynth.c b/Alc/midi/fluidsynth.c index d08d4fb5..fbcd4353 100644 --- a/Alc/midi/fluidsynth.c +++ b/Alc/midi/fluidsynth.c @@ -716,8 +716,10 @@ static ALenum FSynth_selectSoundfonts(FSynth *self, ALCcontext *context, ALsizei else { ERR("Failed to allocate space for %d font IDs!\n", count); - fontid = ExchangePtr((XchgPtr*)&self->FontIDs, NULL); - count = ExchangeInt(&self->NumFontIDs, 0); + fontid = self->FontIDs; + count = self->NumFontIDs; + self->FontIDs = NULL; + self->NumFontIDs = 0; } for(i = 0;i < count;i++) diff --git a/OpenAL32/alSoundfont.c b/OpenAL32/alSoundfont.c index 44f5c35c..8ea4c750 100644 --- a/OpenAL32/alSoundfont.c +++ b/OpenAL32/alSoundfont.c @@ -360,26 +360,26 @@ ALsoundfont *ALsoundfont_getDefSoundfont(ALCcontext *context) void ALsoundfont_deleteSoundfont(ALsoundfont *self, ALCdevice *device) { - ALsfpreset **presets; - ALsizei num_presets; + ALsfpreset **presets = self->Presets; + ALsizei num_presets = self->NumPresets; VECTOR(ALbuffer*) buffers; ALsizei i; VECTOR_INIT(buffers); - presets = ExchangePtr((XchgPtr*)&self->Presets, NULL); - num_presets = ExchangeInt(&self->NumPresets, 0); + + self->Presets = NULL; + self->NumPresets = 0; for(i = 0;i < num_presets;i++) { ALsfpreset *preset = presets[i]; - ALfontsound **sounds; - ALsizei num_sounds; + ALfontsound **sounds = preset->Sounds; + ALsizei num_sounds = preset->NumSounds; ALboolean deleting; ALsizei j; - sounds = ExchangePtr((XchgPtr*)&preset->Sounds, NULL); - num_sounds = ExchangeInt(&preset->NumSounds, 0); - + preset->Sounds = NULL; + preset->NumSounds = 0; DeletePreset(device, preset); preset = NULL; |