From 752dfb3d95482c562e5d24c6ea839c4815de9a6d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 14 Feb 2010 17:04:39 +0100 Subject: replay_gain: reimplement as a filter plugin Apply the replay gain in the output thread. This means a new setting will be active instantly, without going through the whole music pipe. And we might have different replay gain settings for each audio output device. --- src/decoder_api.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/decoder_api.c') diff --git a/src/decoder_api.c b/src/decoder_api.c index 7dfe84062..285e21a6b 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -27,8 +27,6 @@ #include "buffer.h" #include "pipe.h" #include "chunk.h" -#include "replay_gain_state.h" -#include "replay_gain_config.h" #include @@ -343,13 +341,6 @@ decoder_data(struct decoder *decoder, memcpy(dest, data, nbytes); - /* apply replay gain or normalization */ - - replay_gain_state_set_mode(decoder->replay_gain, - replay_gain_mode); - replay_gain_state_apply(decoder->replay_gain, - dest, nbytes, &dc->out_audio_format); - /* expand the music pipe chunk */ full = music_chunk_expand(chunk, &dc->out_audio_format, nbytes); @@ -418,5 +409,21 @@ decoder_replay_gain(struct decoder *decoder, { assert(decoder != NULL); - replay_gain_state_set_info(decoder->replay_gain, replay_gain_info); + if (replay_gain_info != NULL) { + static unsigned serial; + if (++serial == 0) + serial = 1; + + decoder->replay_gain_info = *replay_gain_info; + decoder->replay_gain_serial = serial; + + if (decoder->chunk != NULL) { + /* flush the current chunk because the new + replay gain values affect the following + samples */ + decoder_flush_chunk(decoder); + player_lock_signal(); + } + } else + decoder->replay_gain_serial = 0; } -- cgit v1.2.3