aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/_flac_common.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-07-22 13:31:48 +0200
committerMax Kellermann <max@duempel.org>2009-07-22 13:31:48 +0200
commit47ed89bd4c6499d475d5f16cb89d7be95763670c (patch)
treeccb40679c95b12e75057a3061cc5915d5f2112ed /src/decoder/_flac_common.c
parentcf1fd2b0da4be4675ddb16c5421d949a0e923b20 (diff)
downloadmpd-47ed89bd4c6499d475d5f16cb89d7be95763670c.tar.gz
mpd-47ed89bd4c6499d475d5f16cb89d7be95763670c.tar.xz
mpd-47ed89bd4c6499d475d5f16cb89d7be95763670c.zip
decoder/flac: parse all replaygain tags
The FLAC replaygain parser used the "||" operator. This made the code stop after the first value which was found.
Diffstat (limited to 'src/decoder/_flac_common.c')
-rw-r--r--src/decoder/_flac_common.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c
index a450b6886..9e2d9f437 100644
--- a/src/decoder/_flac_common.c
+++ b/src/decoder/_flac_common.c
@@ -40,9 +40,9 @@ flac_data_init(struct flac_data *data, struct decoder * decoder,
data->tag = NULL;
}
-static bool
+static void
flac_find_float_comment(const FLAC__StreamMetadata *block,
- const char *cmnt, float *fl)
+ const char *cmnt, float *fl, bool *found_r)
{
int offset;
size_t pos;
@@ -52,12 +52,12 @@ flac_find_float_comment(const FLAC__StreamMetadata *block,
offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0,
cmnt);
if (offset < 0)
- return false;
+ return;
pos = strlen(cmnt) + 1; /* 1 is for '=' */
len = block->data.vorbis_comment.comments[offset].length - pos;
if (len <= 0)
- return false;
+ return;
p = &block->data.vorbis_comment.comments[offset].entry[pos];
tmp = p[len];
@@ -65,28 +65,32 @@ flac_find_float_comment(const FLAC__StreamMetadata *block,
*fl = (float)atof((char *)p);
p[len] = tmp;
- return true;
+ *found_r = true;
}
static void
flac_parse_replay_gain(const FLAC__StreamMetadata *block,
struct flac_data *data)
{
- bool found;
+ bool found = false;
if (data->replay_gain_info)
replay_gain_info_free(data->replay_gain_info);
data->replay_gain_info = replay_gain_info_new();
- found = flac_find_float_comment(block, "replaygain_album_gain",
- &data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain) ||
- flac_find_float_comment(block, "replaygain_album_peak",
- &data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].peak) ||
- flac_find_float_comment(block, "replaygain_track_gain",
- &data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain) ||
- flac_find_float_comment(block, "replaygain_track_peak",
- &data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].peak);
+ flac_find_float_comment(block, "replaygain_album_gain",
+ &data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain,
+ &found);
+ flac_find_float_comment(block, "replaygain_album_peak",
+ &data->replay_gain_info->tuples[REPLAY_GAIN_ALBUM].peak,
+ &found);
+ flac_find_float_comment(block, "replaygain_track_gain",
+ &data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain,
+ &found);
+ flac_find_float_comment(block, "replaygain_track_peak",
+ &data->replay_gain_info->tuples[REPLAY_GAIN_TRACK].peak,
+ &found);
if (!found) {
replay_gain_info_free(data->replay_gain_info);