aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/flac_metadata.c
diff options
context:
space:
mode:
authorTim Phipps <mpd@phipps-hutton.freeserve.co.uk>2010-03-21 18:21:47 +0100
committerMax Kellermann <max@duempel.org>2010-03-21 18:21:47 +0100
commite7a515c8b11c643332406d60a13ab1fe06d2b226 (patch)
treeaa7179b453b6fe7b163d1b4b807157359cb436cf /src/decoder/flac_metadata.c
parente9b75d462c4d0ffee3b3b26582800ec4f657a333 (diff)
downloadmpd-e7a515c8b11c643332406d60a13ab1fe06d2b226.tar.gz
mpd-e7a515c8b11c643332406d60a13ab1fe06d2b226.tar.xz
mpd-e7a515c8b11c643332406d60a13ab1fe06d2b226.zip
Add support for MixRamp tags
Adds mixrampdb and mixrampdelay commands. Reads MIXRAP_START and MIXRAMP_END tags from FLAC files and overlaps instead of crossfading.
Diffstat (limited to 'src/decoder/flac_metadata.c')
-rw-r--r--src/decoder/flac_metadata.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/decoder/flac_metadata.c b/src/decoder/flac_metadata.c
index 926cd3af7..68d15f6d4 100644
--- a/src/decoder/flac_metadata.c
+++ b/src/decoder/flac_metadata.c
@@ -80,6 +80,49 @@ flac_parse_replay_gain(struct replay_gain_info *rgi,
return found;
}
+static bool
+flac_find_string_comment(const FLAC__StreamMetadata *block,
+ const char *cmnt, char **str)
+{
+ int offset;
+ size_t pos;
+ int len;
+ unsigned char tmp, *p;
+
+ *str = NULL;
+ offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0,
+ cmnt);
+ if (offset < 0)
+ return false;
+
+ pos = strlen(cmnt) + 1; /* 1 is for '=' */
+ len = block->data.vorbis_comment.comments[offset].length - pos;
+ if (len <= 0)
+ return false;
+
+ p = &block->data.vorbis_comment.comments[offset].entry[pos];
+ tmp = p[len];
+ p[len] = '\0';
+ *str = strdup((char *)p);
+ p[len] = tmp;
+
+ return true;
+}
+
+bool
+flac_parse_mixramp(char **mixramp_start, char **mixramp_end,
+ const FLAC__StreamMetadata *block)
+{
+ bool found = false;
+
+ if (flac_find_string_comment(block, "mixramp_start", mixramp_start))
+ found = true;
+ if (flac_find_string_comment(block, "mixramp_end", mixramp_end))
+ found = true;
+
+ return found;
+}
+
/**
* Checks if the specified name matches the entry's name, and if yes,
* returns the comment value (not null-temrinated).