[vlc-commits] Rewrite atomic float helpers, fix 64-bits big endian support
Rémi Denis-Courmont
git at videolan.org
Thu Dec 13 17:57:38 CET 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Dec 13 18:53:52 2012 +0200| [5fb6de10c74f87f6a1509e558f943cd83c4f1918] | committer: Rémi Denis-Courmont
Rewrite atomic float helpers, fix 64-bits big endian support
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5fb6de10c74f87f6a1509e558f943cd83c4f1918
---
include/vlc_atomic.h | 15 ++++++++-------
src/audio_output/volume.c | 6 +++---
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/include/vlc_atomic.h b/include/vlc_atomic.h
index 8364e98..5905a73 100644
--- a/include/vlc_atomic.h
+++ b/include/vlc_atomic.h
@@ -362,21 +362,22 @@ static inline uintptr_t vlc_atomic_compare_swap(vlc_atomic_t *atom,
return u;
}
+typedef atomic_uint_least32_t vlc_atomic_float;
+
/** Helper to retrieve a single precision from an atom. */
-static inline float vlc_atomic_getf(vlc_atomic_t *atom)
+static inline float vlc_atomic_loadf(vlc_atomic_float *atom)
{
- union { float f; uintptr_t i; } u;
- u.i = vlc_atomic_get(atom);
+ union { float f; uint32_t i; } u;
+ u.i = atomic_load(atom);
return u.f;
}
/** Helper to store a single precision into an atom. */
-static inline float vlc_atomic_setf(vlc_atomic_t *atom, float f)
+static inline void vlc_atomic_storef(vlc_atomic_float *atom, float f)
{
- union { float f; uintptr_t i; } u;
+ union { float f; uint32_t i; } u;
u.f = f;
- vlc_atomic_set(atom, u.i);
- return f;
+ atomic_store(atom, u.i);
}
#endif
diff --git a/src/audio_output/volume.c b/src/audio_output/volume.c
index 0991a8b..7eb977d 100644
--- a/src/audio_output/volume.c
+++ b/src/audio_output/volume.c
@@ -37,7 +37,7 @@ struct aout_volume
{
audio_volume_t object;
audio_replay_gain_t replay_gain;
- vlc_atomic_t gain_factor;
+ vlc_atomic_float gain_factor;
float output_factor;
module_t *module;
};
@@ -135,7 +135,7 @@ int aout_volume_Amplify(aout_volume_t *vol, block_t *block)
return -1;
float amp = vol->output_factor
- * vlc_atomic_getf (&vol->gain_factor);
+ * vlc_atomic_loadf (&vol->gain_factor);
vol->object.amplify(&vol->object, block, amp);
return 0;
@@ -197,7 +197,7 @@ static int ReplayGainCallback (vlc_object_t *obj, char const *var,
aout_volume_t *vol = data;
float multiplier = aout_ReplayGainSelect(obj, val.psz_string,
&vol->replay_gain);
- vlc_atomic_setf (&vol->gain_factor, multiplier);
+ vlc_atomic_storef (&vol->gain_factor, multiplier);
VLC_UNUSED(var); VLC_UNUSED(oldval);
return VLC_SUCCESS;
}
More information about the vlc-commits
mailing list