diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/metadata/ape.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/apps/metadata/ape.c b/apps/metadata/ape.c index 44fc69a45a..eb534a498f 100644 --- a/apps/metadata/ape.c +++ b/apps/metadata/ape.c | |||
@@ -35,6 +35,13 @@ | |||
35 | #define APETAG_ITEM_HEADER_FORMAT "ll" | 35 | #define APETAG_ITEM_HEADER_FORMAT "ll" |
36 | #define APETAG_ITEM_TYPE_MASK 3 | 36 | #define APETAG_ITEM_TYPE_MASK 3 |
37 | 37 | ||
38 | #ifdef HAVE_ALBUMART | ||
39 | /* The AA header consists of the pseudo filename "Album Cover (Front).ext" | ||
40 | * whereas ".ext" is the file extension. For now ".jpg" and ".png" are | ||
41 | * supported by this APE metadata parser. Therefore the length is 22. */ | ||
42 | #define APETAG_AA_HEADER_LENGTH 22 | ||
43 | #endif | ||
44 | |||
38 | struct apetag_header | 45 | struct apetag_header |
39 | { | 46 | { |
40 | char id[8]; | 47 | char id[8]; |
@@ -125,6 +132,43 @@ bool read_ape_tags(int fd, struct mp3entry* id3) | |||
125 | } | 132 | } |
126 | else | 133 | else |
127 | { | 134 | { |
135 | #ifdef HAVE_ALBUMART | ||
136 | if (strcasecmp(name, "cover art (front)") == 0) | ||
137 | { | ||
138 | /* Allow to read at least APETAG_AA_HEADER_LENGTH bytes. */ | ||
139 | r = read_string(fd, name, sizeof(name), 0, APETAG_AA_HEADER_LENGTH); | ||
140 | if (r == -1) | ||
141 | { | ||
142 | return false; | ||
143 | } | ||
144 | |||
145 | /* Gather the album art format from the pseudo file name. */ | ||
146 | id3->albumart.type = AA_TYPE_UNKNOWN; | ||
147 | if (strcasecmp(name, "cover art (front).jpg") == 0) | ||
148 | { | ||
149 | id3->albumart.type = AA_TYPE_JPG; | ||
150 | } | ||
151 | else if (strcasecmp(name, "cover art (front).png") == 0) | ||
152 | { | ||
153 | id3->albumart.type = AA_TYPE_PNG; | ||
154 | } | ||
155 | |||
156 | /* Set the album art size and position. */ | ||
157 | if (id3->albumart.type != AA_TYPE_UNKNOWN) | ||
158 | { | ||
159 | id3->albumart.pos = lseek(fd, 0, SEEK_CUR); | ||
160 | id3->albumart.size = item.length - r; | ||
161 | id3->embed_albumart = true; | ||
162 | } | ||
163 | |||
164 | /* Seek back to this APE items begin. */ | ||
165 | if (lseek(fd, -r, SEEK_CUR) < 0) | ||
166 | { | ||
167 | return false; | ||
168 | } | ||
169 | } | ||
170 | #endif | ||
171 | /* Seek to the next APE item. */ | ||
128 | if (lseek(fd, item.length, SEEK_CUR) < 0) | 172 | if (lseek(fd, item.length, SEEK_CUR) < 0) |
129 | { | 173 | { |
130 | return false; | 174 | return false; |