aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/decoder/_flac_common.c6
-rw-r--r--src/decoder/mad_decoder_plugin.c7
-rw-r--r--src/decoder_api.c16
-rw-r--r--src/decoder_api.h6
-rw-r--r--src/decoder_control.c2
-rw-r--r--src/decoder_control.h2
-rw-r--r--src/decoder_thread.c2
7 files changed, 33 insertions, 8 deletions
diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c
index 6f6d33f05..8dd22a253 100644
--- a/src/decoder/_flac_common.c
+++ b/src/decoder/_flac_common.c
@@ -114,6 +114,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
struct replay_gain_info rgi;
char *mixramp_start;
char *mixramp_end;
+ float replay_gain_db = 0;
switch (block->type) {
case FLAC__METADATA_TYPE_STREAMINFO:
@@ -122,10 +123,11 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
if (flac_parse_replay_gain(&rgi, block))
- decoder_replay_gain(data->decoder, &rgi);
+ replay_gain_db = decoder_replay_gain(data->decoder, &rgi);
if (flac_parse_mixramp(&mixramp_start, &mixramp_end, block)) {
g_debug("setting mixramp_tags");
- decoder_mixramp(data->decoder, mixramp_start, mixramp_end);
+ decoder_mixramp(data->decoder, replay_gain_db,
+ mixramp_start, mixramp_end);
}
if (data->tag != NULL)
diff --git a/src/decoder/mad_decoder_plugin.c b/src/decoder/mad_decoder_plugin.c
index 57221d878..573afc975 100644
--- a/src/decoder/mad_decoder_plugin.c
+++ b/src/decoder/mad_decoder_plugin.c
@@ -446,13 +446,16 @@ static void mp3_parse_id3(struct mp3_data *data, size_t tagsize,
struct replay_gain_info rgi;
char *mixramp_start;
char *mixramp_end;
+ float replay_gain_db = 0;
+
if (parse_id3_replay_gain_info(&rgi, id3_tag)) {
- decoder_replay_gain(data->decoder, &rgi);
+ replay_gain_db = decoder_replay_gain(data->decoder, &rgi);
data->found_replay_gain = true;
}
if (parse_id3_mixramp(&mixramp_start, &mixramp_end, id3_tag)) {
g_debug("setting mixramp_tags");
- decoder_mixramp(data->decoder, mixramp_start, mixramp_end);
+ decoder_mixramp(data->decoder, replay_gain_db,
+ mixramp_start, mixramp_end);
}
}
diff --git a/src/decoder_api.c b/src/decoder_api.c
index 948ccb567..a951b07cf 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_config.h"
#include <glib.h>
@@ -403,10 +404,11 @@ decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is,
return cmd;
}
-void
+float
decoder_replay_gain(struct decoder *decoder,
const struct replay_gain_info *replay_gain_info)
{
+ float return_db = 0;
assert(decoder != NULL);
if (replay_gain_info != NULL) {
@@ -414,6 +416,13 @@ decoder_replay_gain(struct decoder *decoder,
if (++serial == 0)
serial = 1;
+ if (REPLAY_GAIN_OFF != replay_gain_mode) {
+ return_db = 20.0 * log10f(
+ replay_gain_tuple_scale(
+ &replay_gain_info->tuples[replay_gain_mode],
+ replay_gain_preamp));
+ }
+
decoder->replay_gain_info = *replay_gain_info;
decoder->replay_gain_serial = serial;
@@ -426,16 +435,19 @@ decoder_replay_gain(struct decoder *decoder,
}
} else
decoder->replay_gain_serial = 0;
+
+ return return_db;
}
void
-decoder_mixramp(struct decoder *decoder,
+decoder_mixramp(struct decoder *decoder, float replay_gain_db,
char *mixramp_start, char *mixramp_end)
{
assert(decoder != NULL);
struct decoder_control *dc = decoder->dc;
assert(dc != NULL);
+ dc->replay_gain_db = replay_gain_db;
dc_mixramp_start(dc, mixramp_start);
dc_mixramp_end(dc, mixramp_end);
}
diff --git a/src/decoder_api.h b/src/decoder_api.h
index e2b645f6d..8b5f3d82b 100644
--- a/src/decoder_api.h
+++ b/src/decoder_api.h
@@ -152,8 +152,9 @@ decoder_tag(struct decoder *decoder, struct input_stream *is,
* @param decoder the decoder object
* @param rgi the replay_gain_info object; may be NULL to invalidate
* the previous replay gain values
+ * @return the replay gain adjustment used
*/
-void
+float
decoder_replay_gain(struct decoder *decoder,
const struct replay_gain_info *replay_gain_info);
@@ -161,11 +162,12 @@ decoder_replay_gain(struct decoder *decoder,
* Store MixRamp tags.
*
* @param decoder the decoder object
+ * @param replay_gain_db the ReplayGain adjustment used for this song
* @param mixramp_start the mixramp_start tag; may be NULL to invalidate
* @param mixramp_end the mixramp_end tag; may be NULL to invalidate
*/
void
-decoder_mixramp(struct decoder *decoder,
+decoder_mixramp(struct decoder *decoder, float replay_gain_db,
char *mixramp_start, char *mixramp_end);
#endif
diff --git a/src/decoder_control.c b/src/decoder_control.c
index 7388d307f..9a1d9abfb 100644
--- a/src/decoder_control.c
+++ b/src/decoder_control.c
@@ -38,6 +38,8 @@ dc_init(struct decoder_control *dc)
dc->state = DECODE_STATE_STOP;
dc->command = DECODE_COMMAND_NONE;
+ dc->replay_gain_db = 0;
+ dc->replay_gain_prev_db = 0;
dc->mixramp_start = NULL;
dc->mixramp_end = NULL;
dc->mixramp_prev_end = NULL;
diff --git a/src/decoder_control.h b/src/decoder_control.h
index 7794258c9..449e974b7 100644
--- a/src/decoder_control.h
+++ b/src/decoder_control.h
@@ -90,6 +90,8 @@ struct decoder_control {
*/
struct music_pipe *pipe;
+ float replay_gain_db;
+ float replay_gain_prev_db;
char *mixramp_start;
char *mixramp_end;
char *mixramp_prev_end;
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index 3eab61295..a75f09d37 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -438,6 +438,8 @@ decoder_task(gpointer arg)
dc_mixramp_start(dc, NULL);
dc_mixramp_prev_end(dc, dc->mixramp_end);
dc->mixramp_end = NULL; /* Don't free, it's copied above. */
+ dc->replay_gain_prev_db = dc->replay_gain_db;
+ dc->replay_gain_db = 0;
/* fall through */