aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/decoder_api.c27
-rw-r--r--src/decoder_internal.c9
-rw-r--r--src/decoder_internal.h9
-rw-r--r--src/decoder_thread.c6
4 files changed, 33 insertions, 18 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;
}
diff --git a/src/decoder_internal.c b/src/decoder_internal.c
index 7829b4d76..990d728e9 100644
--- a/src/decoder_internal.c
+++ b/src/decoder_internal.c
@@ -86,8 +86,15 @@ decoder_get_chunk(struct decoder *decoder, struct input_stream *is)
do {
decoder->chunk = music_buffer_allocate(dc->buffer);
- if (decoder->chunk != NULL)
+ if (decoder->chunk != NULL) {
+ decoder->chunk->replay_gain_serial =
+ decoder->replay_gain_serial;
+ if (decoder->replay_gain_serial != 0)
+ decoder->chunk->replay_gain_info =
+ decoder->replay_gain_info;
+
return decoder->chunk;
+ }
decoder_lock(dc);
cmd = need_chunks(dc, is, true);
diff --git a/src/decoder_internal.h b/src/decoder_internal.h
index 159b40b92..9e7e2037a 100644
--- a/src/decoder_internal.h
+++ b/src/decoder_internal.h
@@ -22,6 +22,7 @@
#include "decoder_command.h"
#include "pcm_convert.h"
+#include "replay_gain_info.h"
struct input_stream;
@@ -53,7 +54,13 @@ struct decoder {
/** the chunk currently being written to */
struct music_chunk *chunk;
- struct replay_gain_state *replay_gain;
+ struct replay_gain_info replay_gain_info;
+
+ /**
+ * A positive serial number for checking if replay gain info
+ * has changed since the last check.
+ */
+ unsigned replay_gain_serial;
};
/**
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index 42a537ffe..99fa2c7e2 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -31,8 +31,6 @@
#include "mapper.h"
#include "path.h"
#include "uri.h"
-#include "replay_gain_state.h"
-#include "replay_gain_config.h"
#include <glib.h>
@@ -351,8 +349,6 @@ decoder_run_song(struct decoder_control *dc,
{
struct decoder decoder = {
.dc = dc,
- .replay_gain = replay_gain_state_new(replay_gain_preamp,
- replay_gain_missing_preamp),
};
int ret;
@@ -380,8 +376,6 @@ decoder_run_song(struct decoder_control *dc,
pcm_convert_deinit(&decoder.conv_state);
/* flush the last chunk */
- if (decoder.replay_gain != NULL)
- replay_gain_state_free(decoder.replay_gain);
if (decoder.chunk != NULL)
decoder_flush_chunk(&decoder);