+ AoutInputsMarkToRestart( p_aout );
+ return VLC_SUCCESS;
+}
+
+static int ReplayGainCallback( vlc_object_t *p_this, char const *psz_cmd,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+ VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
+ VLC_UNUSED(newval); VLC_UNUSED(p_data);
+ aout_instance_t *p_aout = (aout_instance_t *)p_this;
+ int i;
+
+ aout_lock_mixer( p_aout );
+ for( i = 0; i < p_aout->i_nb_inputs; i++ )
+ ReplayGainSelect( p_aout, p_aout->pp_inputs[i] );
+
+ /* Restart the mixer (a trivial mixer may be in use) */
+ if( p_aout->p_mixer )
+ aout_MixerMultiplierSet( p_aout, p_aout->mixer_multiplier );
+ aout_unlock_mixer( p_aout );
+
+ return VLC_SUCCESS;
+}
+
+static void ReplayGainSelect( aout_instance_t *p_aout, aout_input_t *p_input )
+{
+ char *psz_replay_gain = var_GetNonEmptyString( p_aout,
+ "audio-replay-gain-mode" );
+ int i_mode;
+ int i_use;
+ float f_gain;
+
+ p_input->mixer.multiplier = 1.0;
+
+ if( !psz_replay_gain )
+ return;
+
+ /* Find select mode */
+ if( !strcmp( psz_replay_gain, "track" ) )
+ i_mode = AUDIO_REPLAY_GAIN_TRACK;
+ else if( !strcmp( psz_replay_gain, "album" ) )
+ i_mode = AUDIO_REPLAY_GAIN_ALBUM;
+ else
+ i_mode = AUDIO_REPLAY_GAIN_MAX;
+
+ /* If the select mode is not available, prefer the other one */
+ i_use = i_mode;
+ if( i_use != AUDIO_REPLAY_GAIN_MAX && !p_input->replay_gain.pb_gain[i_use] )