summaryrefslogtreecommitdiff
path: root/plugins/alac
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-08-21 21:21:59 +0200
committerGravatar waker <wakeroid@gmail.com>2012-08-21 21:21:59 +0200
commitd664351dc42900dce940477b9e5e325ceee930aa (patch)
tree42d6eae935b87b3aaa8c44b44d4268c8f502effe /plugins/alac
parent6955b64286f7b96cf8a9f99c62607ec81bd323c9 (diff)
updated metadata reader in alac plugin to support custom fields
Diffstat (limited to 'plugins/alac')
-rw-r--r--plugins/alac/alac_plugin.c62
1 files changed, 38 insertions, 24 deletions
diff --git a/plugins/alac/alac_plugin.c b/plugins/alac/alac_plugin.c
index ebaf1467..c62292e9 100644
--- a/plugins/alac/alac_plugin.c
+++ b/plugins/alac/alac_plugin.c
@@ -370,33 +370,47 @@ void
alacplug_load_tags (DB_playItem_t *it, mp4ff_t *mp4) {
char *s = NULL;
int got_itunes_tags = 0;
- for (int i = 0; metainfo[i]; i += 2) {
- if (mp4ff_meta_find_by_name(mp4, metainfo[i], &s)) {
- deadbeef->pl_add_meta (it, metainfo[i+1], s);
+
+ int n = mp4ff_meta_get_num_items (mp4);
+ for (int t = 0; t < n; t++) {
+ char *key = NULL;
+ char *value = NULL;
+ int res = mp4ff_meta_get_by_index(mp4, t, &key, &value);
+ if (key && value) {
got_itunes_tags = 1;
- free (s);
+ if (!strcasecmp (key, "replaygain_track_gain")) {
+ deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKGAIN, atof (value));
+ }
+ else if (!strcasecmp (key, "replaygain_album_gain")) {
+ deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMGAIN, atof (value));
+ }
+ else if (!strcasecmp (key, "replaygain_track_peak")) {
+ deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKPEAK, atof (value));
+ }
+ else if (!strcasecmp (key, "replaygain_album_peak")) {
+ deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMPEAK, atof (value));
+ }
+ else {
+ int i;
+ for (i = 0; metainfo[i]; i += 2) {
+ if (!strcasecmp (metainfo[i], key)) {
+ deadbeef->pl_add_meta (it, metainfo[i+1], value);
+ break;
+ }
+ }
+ if (!metainfo[i]) {
+ deadbeef->pl_add_meta (it, key, value);
+ }
+ }
+ }
+ if (key) {
+ free (key);
+ }
+ if (value) {
+ free (value);
}
}
- if (mp4ff_meta_find_by_name(mp4, "replaygain_track_gain", &s)) {
- deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKGAIN, atof (s));
- got_itunes_tags = 1;
- free (s);
- }
- if (mp4ff_meta_find_by_name(mp4, "replaygain_track_peak", &s)) {
- deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_TRACKPEAK, atof (s));
- got_itunes_tags = 1;
- free (s);
- }
- if (mp4ff_meta_find_by_name(mp4, "replaygain_album_gain", &s)) {
- deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMGAIN, atof (s));
- got_itunes_tags = 1;
- free (s);
- }
- if (mp4ff_meta_find_by_name(mp4, "replaygain_album_peak", &s)) {
- deadbeef->pl_set_item_replaygain (it, DDB_REPLAYGAIN_ALBUMPEAK, atof (s));
- got_itunes_tags = 1;
- free (s);
- }
+
if (got_itunes_tags) {
uint32_t f = deadbeef->pl_get_item_flags (it);
f |= DDB_TAG_ITUNES;