Commit 5fb6de10 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Rewrite atomic float helpers, fix 64-bits big endian support

parent 17d2ca87
...@@ -362,21 +362,22 @@ static inline uintptr_t vlc_atomic_compare_swap(vlc_atomic_t *atom, ...@@ -362,21 +362,22 @@ static inline uintptr_t vlc_atomic_compare_swap(vlc_atomic_t *atom,
return u; return u;
} }
typedef atomic_uint_least32_t vlc_atomic_float;
/** Helper to retrieve a single precision from an atom. */ /** 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; union { float f; uint32_t i; } u;
u.i = vlc_atomic_get(atom); u.i = atomic_load(atom);
return u.f; return u.f;
} }
/** Helper to store a single precision into an atom. */ /** 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; u.f = f;
vlc_atomic_set(atom, u.i); atomic_store(atom, u.i);
return f;
} }
#endif #endif
...@@ -37,7 +37,7 @@ struct aout_volume ...@@ -37,7 +37,7 @@ struct aout_volume
{ {
audio_volume_t object; audio_volume_t object;
audio_replay_gain_t replay_gain; audio_replay_gain_t replay_gain;
vlc_atomic_t gain_factor; vlc_atomic_float gain_factor;
float output_factor; float output_factor;
module_t *module; module_t *module;
}; };
...@@ -135,7 +135,7 @@ int aout_volume_Amplify(aout_volume_t *vol, block_t *block) ...@@ -135,7 +135,7 @@ int aout_volume_Amplify(aout_volume_t *vol, block_t *block)
return -1; return -1;
float amp = vol->output_factor float amp = vol->output_factor
* vlc_atomic_getf (&vol->gain_factor); * vlc_atomic_loadf (&vol->gain_factor);
vol->object.amplify(&vol->object, block, amp); vol->object.amplify(&vol->object, block, amp);
return 0; return 0;
...@@ -197,7 +197,7 @@ static int ReplayGainCallback (vlc_object_t *obj, char const *var, ...@@ -197,7 +197,7 @@ static int ReplayGainCallback (vlc_object_t *obj, char const *var,
aout_volume_t *vol = data; aout_volume_t *vol = data;
float multiplier = aout_ReplayGainSelect(obj, val.psz_string, float multiplier = aout_ReplayGainSelect(obj, val.psz_string,
&vol->replay_gain); &vol->replay_gain);
vlc_atomic_setf (&vol->gain_factor, multiplier); vlc_atomic_storef (&vol->gain_factor, multiplier);
VLC_UNUSED(var); VLC_UNUSED(oldval); VLC_UNUSED(var); VLC_UNUSED(oldval);
return VLC_SUCCESS; return VLC_SUCCESS;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment