aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-01-04 13:31:20 +0100
committerMax Kellermann <max@duempel.org>2010-01-04 20:54:01 +0100
commit0e183d3fa1f216729725127d868d66268e1a35d4 (patch)
tree63f14bdadec2e24104fa0fe957d2a30900e25385 /src/decoder
parentcd8f92c9285e9b3b460ff47d2f251bfabce544da (diff)
downloadmpd-0e183d3fa1f216729725127d868d66268e1a35d4.tar.gz
mpd-0e183d3fa1f216729725127d868d66268e1a35d4.tar.xz
mpd-0e183d3fa1f216729725127d868d66268e1a35d4.zip
replay_gain: refactor API, move code to replay_gain_state.c
The replay_gain_state struct holds the precalculated scale factor, which is removed from struct replay_gain_info.
Diffstat (limited to '')
-rw-r--r--src/decoder_api.c16
-rw-r--r--src/decoder_internal.h2
-rw-r--r--src/decoder_thread.c7
3 files changed, 11 insertions, 14 deletions
diff --git a/src/decoder_api.c b/src/decoder_api.c
index 5106b564f..8e1e22f9d 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -27,6 +27,7 @@
#include "buffer.h"
#include "pipe.h"
#include "chunk.h"
+#include "replay_gain_state.h"
#include <glib.h>
@@ -352,10 +353,10 @@ decoder_data(struct decoder *decoder,
/* apply replay gain or normalization */
- if (replay_gain_mode != REPLAY_GAIN_OFF)
- replay_gain_apply(decoder->replay_gain,
- dest, nbytes,
- &dc->out_audio_format);
+ 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 */
@@ -425,10 +426,5 @@ decoder_replay_gain(struct decoder *decoder,
{
assert(decoder != NULL);
- if (decoder->replay_gain != NULL)
- replay_gain_info_free(decoder->replay_gain);
-
- decoder->replay_gain = replay_gain_info != NULL
- ? replay_gain_info_dup(replay_gain_info)
- : NULL;
+ replay_gain_state_set_info(decoder->replay_gain, replay_gain_info);
}
diff --git a/src/decoder_internal.h b/src/decoder_internal.h
index b15b06888..159b40b92 100644
--- a/src/decoder_internal.h
+++ b/src/decoder_internal.h
@@ -53,7 +53,7 @@ struct decoder {
/** the chunk currently being written to */
struct music_chunk *chunk;
- struct replay_gain_info *replay_gain;
+ struct replay_gain_state *replay_gain;
};
/**
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index f793fd032..625ec46cc 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -31,7 +31,7 @@
#include "mapper.h"
#include "path.h"
#include "uri.h"
-#include "replay_gain.h"
+#include "replay_gain_state.h"
#include <glib.h>
@@ -303,7 +303,8 @@ decoder_run_song(struct decoder_control *dc,
{
struct decoder decoder = {
.dc = dc,
- .replay_gain = NULL,
+ .replay_gain = replay_gain_state_new(replay_gain_preamp,
+ replay_gain_missing_preamp),
};
int ret;
@@ -332,7 +333,7 @@ decoder_run_song(struct decoder_control *dc,
/* flush the last chunk */
if (decoder.replay_gain != NULL)
- replay_gain_info_free(decoder.replay_gain);
+ replay_gain_state_free(decoder.replay_gain);
if (decoder.chunk != NULL)
decoder_flush_chunk(&decoder);