aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/_flac_common.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-01-03 22:44:23 +0100
committerMax Kellermann <max@duempel.org>2010-01-04 20:42:49 +0100
commitcd8f92c9285e9b3b460ff47d2f251bfabce544da (patch)
tree594de0f646b0fc69405132c3a9e2f05060399abf /src/decoder/_flac_common.c
parente58b4f773f28ad7b8e26c14c9c853fc2798408a1 (diff)
downloadmpd-cd8f92c9285e9b3b460ff47d2f251bfabce544da.tar.gz
mpd-cd8f92c9285e9b3b460ff47d2f251bfabce544da.tar.xz
mpd-cd8f92c9285e9b3b460ff47d2f251bfabce544da.zip
decoder_api: added function decoder_replay_gain()
This function replaces the replay_gain_info parameter for decoder_data(). This allows the decoder to announce replay gain changes, instead of having to pass the same object over and over.
Diffstat (limited to '')
-rw-r--r--src/decoder/_flac_common.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c
index b970567c4..471e52522 100644
--- a/src/decoder/_flac_common.c
+++ b/src/decoder/_flac_common.c
@@ -44,7 +44,6 @@ flac_data_init(struct flac_data *data, struct decoder * decoder,
data->position = 0;
data->decoder = decoder;
data->input_stream = input_stream;
- data->replay_gain_info = NULL;
data->tag = NULL;
}
@@ -53,9 +52,6 @@ flac_data_deinit(struct flac_data *data)
{
pcm_buffer_deinit(&data->buffer);
- if (data->replay_gain_info != NULL)
- replay_gain_info_free(data->replay_gain_info);
-
if (data->tag != NULL)
tag_free(data->tag);
}
@@ -111,6 +107,8 @@ flac_data_get_audio_format(struct flac_data *data,
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
struct flac_data *data)
{
+ struct replay_gain_info *rgi;
+
switch (block->type) {
case FLAC__METADATA_TYPE_STREAMINFO:
data->stream_info = block->data.stream_info;
@@ -118,9 +116,11 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
break;
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
- if (data->replay_gain_info)
- replay_gain_info_free(data->replay_gain_info);
- data->replay_gain_info = flac_parse_replay_gain(block);
+ rgi = flac_parse_replay_gain(block);
+ if (rgi != NULL) {
+ decoder_replay_gain(data->decoder, rgi);
+ replay_gain_info_free(rgi);
+ }
if (data->tag != NULL)
flac_vorbis_comments_to_tag(data->tag, NULL,
@@ -177,8 +177,7 @@ flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
cmd = decoder_data(data->decoder, data->input_stream,
buffer, buffer_size,
- bit_rate,
- data->replay_gain_info);
+ bit_rate);
data->next_frame += frame->header.blocksize;
switch (cmd) {
case DECODE_COMMAND_NONE: