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

aout: use atomic variable for replay gain

parent 1252a5eb
......@@ -51,7 +51,7 @@ block_t *aout_FilterBufferNew( filter_t *, int );
/** an input stream for the audio output */
struct aout_input_t
{
float multiplier; /**< Replay gain multiplier */
vlc_atomic_t multiplier; /**< Replay gain multiplier */
unsigned samplerate; /**< Input sample rate */
/* pre-filters */
......@@ -134,6 +134,7 @@ int aout_InputNew(audio_output_t *, const audio_sample_format_t *,
int aout_InputDelete( audio_output_t * p_aout, aout_input_t * p_input );
block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
block_t *p_buffer, int i_input_rate, date_t * );
float aout_InputGetMultiplier(const aout_input_t *);
/* From filters.c : */
int aout_FiltersCreatePipeline( vlc_object_t *, filter_t **, int *,
......
......@@ -273,7 +273,8 @@ int aout_DecPlay (audio_output_t *p_aout, block_t *p_buffer, int i_input_rate)
date_Increment (&owner->sync.date, p_buffer->i_nb_samples);
/* Mixer */
float amp = owner->volume.multiplier * p_input->multiplier;
float amp = owner->volume.multiplier
* aout_InputGetMultiplier (p_input);
aout_MixerRun (owner->volume.mixer, p_buffer, amp);
/* Output */
......
......@@ -41,9 +41,9 @@
#include <vlc_input.h>
#include <vlc_vout.h> /* for vout_Request */
#include <vlc_modules.h>
#include <vlc_aout.h>
#include <vlc_filter.h>
#include <vlc_atomic.h>
#include <libvlc.h>
#include "aout_internal.h"
......@@ -210,8 +210,9 @@ int aout_InputNew( audio_output_t * p_aout,
}
char *gain = var_InheritString (p_aout, "audio-replay-gain-mode");
p_input->multiplier = ReplayGainSelect (VLC_OBJECT(p_aout), gain,
&p_input->replay_gain);
vlc_atomic_setf (&p_input->multiplier,
ReplayGainSelect (VLC_OBJECT(p_aout), gain,
&p_input->replay_gain));
free (gain);
if( var_Type( p_aout, "audio-replay-gain-preamp" ) == 0 )
......@@ -824,17 +825,19 @@ static int EqualizerCallback (vlc_object_t *obj, char const *cmd,
return VLC_SUCCESS;
}
float aout_InputGetMultiplier (const aout_input_t *input)
{
return vlc_atomic_getf (&input->multiplier);
}
static int ReplayGainCallback (vlc_object_t *obj, char const *var,
vlc_value_t oldval, vlc_value_t val, void *data)
{
audio_output_t *aout = (audio_output_t *)obj;
aout_input_t *input = data;
float multiplier = ReplayGainSelect (obj, val.psz_string,
&input->replay_gain);
aout_lock (aout);
input->multiplier = multiplier;
aout_unlock (aout);
vlc_atomic_setf (&input->multiplier, multiplier);
VLC_UNUSED(var); VLC_UNUSED(oldval);
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