aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder_api.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-02-14 17:04:39 +0100
committerMax Kellermann <max@duempel.org>2010-02-17 07:23:13 +0100
commit752dfb3d95482c562e5d24c6ea839c4815de9a6d (patch)
tree46b62f26c4c68ebe81b72b9ca30366ffa14af1a5 /src/decoder_api.c
parent5e0117b4441f257fcb1aab48b42a787567ebcbe6 (diff)
downloadmpd-752dfb3d95482c562e5d24c6ea839c4815de9a6d.tar.gz
mpd-752dfb3d95482c562e5d24c6ea839c4815de9a6d.tar.xz
mpd-752dfb3d95482c562e5d24c6ea839c4815de9a6d.zip
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.
Diffstat (limited to '')
-rw-r--r--src/decoder_api.c27
1 files changed, 17 insertions, 10 deletions
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 <glib.h>
@@ -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;
}