diff options
Diffstat (limited to '')
-rw-r--r-- | src/output_init.c | 11 | ||||
-rw-r--r-- | src/output_internal.h | 12 | ||||
-rw-r--r-- | src/output_thread.c | 11 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/output_init.c b/src/output_init.c index 2ce6b30f9..387915ddc 100644 --- a/src/output_init.c +++ b/src/output_init.c @@ -194,6 +194,17 @@ audio_output_init(struct audio_output *ao, const struct config_param *param, ao->filter = filter_chain_new(); assert(ao->filter != NULL); + /* create the replay_gain filter */ + + ao->replay_gain_filter = filter_new(&replay_gain_filter_plugin, + param, NULL); + assert(ao->replay_gain_filter != NULL); + + filter_chain_append(ao->filter, ao->replay_gain_filter); + ao->replay_gain_serial = 0; + + /* create the normalization filter (if configured) */ + if (config_get_bool(CONF_VOLUME_NORMALIZATION, false)) { struct filter *normalize_filter = filter_new(&normalize_filter_plugin, NULL, NULL); diff --git a/src/output_internal.h b/src/output_internal.h index 804fd8cdc..2a438c62f 100644 --- a/src/output_internal.h +++ b/src/output_internal.h @@ -135,6 +135,18 @@ struct audio_output { struct filter *filter; /** + * The replay_gain_filter_plugin instance of this audio + * output. + */ + struct filter *replay_gain_filter; + + /** + * The serial number of the last replay gain info. 0 means no + * replay gain info was available. + */ + unsigned replay_gain_serial; + + /** * The convert_filter_plugin instance of this audio output. * It is the last item in the filter chain, and is responsible * for converting the input data into the appropriate format diff --git a/src/output_thread.c b/src/output_thread.c index eb44d4c87..0e34c64b7 100644 --- a/src/output_thread.c +++ b/src/output_thread.c @@ -26,6 +26,7 @@ #include "player_control.h" #include "filter_plugin.h" #include "filter/convert_filter_plugin.h" +#include "filter/replay_gain_filter_plugin.h" #include <glib.h> @@ -261,6 +262,16 @@ ao_play_chunk(struct audio_output *ao, const struct music_chunk *chunk) g_mutex_lock(ao->mutex); } + /* update replay gain */ + + if (chunk->replay_gain_serial != ao->replay_gain_serial) { + replay_gain_filter_set_info(ao->replay_gain_filter, + chunk->replay_gain_serial != 0 + ? &chunk->replay_gain_info + : NULL); + ao->replay_gain_serial = chunk->replay_gain_serial; + } + if (size == 0) return true; |