diff options
Diffstat (limited to 'apps/recorder')
-rw-r--r-- | apps/recorder/albumart.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/apps/recorder/albumart.c b/apps/recorder/albumart.c index 327f4dfe5c..cf4a3e8e11 100644 --- a/apps/recorder/albumart.c +++ b/apps/recorder/albumart.c | |||
@@ -91,6 +91,27 @@ static void fix_path_part(char* path, int offset, int count) | |||
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | #if LCD_DEPTH > 1 | ||
95 | const char * extensions[] = { "jpeg", "jpg", "bmp" }; | ||
96 | int extension_lens[] = { 4, 3, 3 }; | ||
97 | /* Try checking for several file extensions, return true if a file is found and | ||
98 | * leaving the path modified to include the matching extension. | ||
99 | */ | ||
100 | static bool try_exts(char *path, int len) | ||
101 | { | ||
102 | int i; | ||
103 | for (i = 0; i < 3; i++) | ||
104 | { | ||
105 | if (extension_lens[i] + len > MAX_PATH) | ||
106 | continue; | ||
107 | strcpy(path + len, extensions[i]); | ||
108 | if (file_exists(path)) | ||
109 | return true; | ||
110 | } | ||
111 | return false; | ||
112 | } | ||
113 | #endif | ||
114 | |||
94 | /* Look for the first matching album art bitmap in the following list: | 115 | /* Look for the first matching album art bitmap in the following list: |
95 | * ./<trackname><size>.bmp | 116 | * ./<trackname><size>.bmp |
96 | * ./<albumname><size>.bmp | 117 | * ./<albumname><size>.bmp |
@@ -113,6 +134,9 @@ bool search_albumart_files(const struct mp3entry *id3, const char *size_string, | |||
113 | const char *artist; | 134 | const char *artist; |
114 | int dirlen; | 135 | int dirlen; |
115 | int albumlen; | 136 | int albumlen; |
137 | #if LCD_DEPTH > 1 | ||
138 | int pathlen; | ||
139 | #endif | ||
116 | 140 | ||
117 | if (!id3 || !buf) | 141 | if (!id3 || !buf) |
118 | return false; | 142 | return false; |
@@ -135,25 +159,55 @@ bool search_albumart_files(const struct mp3entry *id3, const char *size_string, | |||
135 | { | 159 | { |
136 | /* if it doesn't exist, | 160 | /* if it doesn't exist, |
137 | * we look for a file specific to the track's album name */ | 161 | * we look for a file specific to the track's album name */ |
162 | #if LCD_DEPTH > 1 | ||
163 | pathlen = snprintf(path, sizeof(path), | ||
164 | "%s%s%s.", dir, id3->album, size_string); | ||
165 | fix_path_part(path, dirlen, albumlen); | ||
166 | found = try_exts(path, pathlen); | ||
167 | #else | ||
138 | snprintf(path, sizeof(path), | 168 | snprintf(path, sizeof(path), |
139 | "%s%s%s.bmp", dir, id3->album, size_string); | 169 | "%s%s%s.bmp", dir, id3->album, size_string); |
140 | fix_path_part(path, dirlen, albumlen); | 170 | fix_path_part(path, dirlen, albumlen); |
141 | found = file_exists(path); | 171 | found = file_exists(path); |
172 | #endif | ||
142 | } | 173 | } |
143 | 174 | ||
144 | if (!found) | 175 | if (!found) |
145 | { | 176 | { |
146 | /* if it still doesn't exist, we look for a generic file */ | 177 | /* if it still doesn't exist, we look for a generic file */ |
178 | #if LCD_DEPTH > 1 | ||
179 | pathlen = snprintf(path, sizeof(path), | ||
180 | "%scover%s.", dir, size_string); | ||
181 | found = try_exts(path, pathlen); | ||
182 | #else | ||
147 | snprintf(path, sizeof(path), | 183 | snprintf(path, sizeof(path), |
148 | "%scover%s.bmp", dir, size_string); | 184 | "%scover%s.bmp", dir, size_string); |
149 | found = file_exists(path); | 185 | found = file_exists(path); |
186 | #endif | ||
150 | } | 187 | } |
151 | 188 | ||
189 | #if LCD_DEPTH > 1 | ||
190 | if (!found) | ||
191 | { | ||
192 | snprintf (path, sizeof(path), "%sfolder.jpg", dir); | ||
193 | found = file_exists(path); | ||
194 | } | ||
195 | #endif | ||
196 | |||
152 | artist = id3->albumartist != NULL ? id3->albumartist : id3->artist; | 197 | artist = id3->albumartist != NULL ? id3->albumartist : id3->artist; |
153 | 198 | ||
154 | if (!found && artist && id3->album) | 199 | if (!found && artist && id3->album) |
155 | { | 200 | { |
156 | /* look in the albumart subdir of .rockbox */ | 201 | /* look in the albumart subdir of .rockbox */ |
202 | #if LCD_DEPTH > 1 | ||
203 | pathlen = snprintf(path, sizeof(path), | ||
204 | ROCKBOX_DIR "/albumart/%s-%s%s.", | ||
205 | artist, | ||
206 | id3->album, | ||
207 | size_string); | ||
208 | fix_path_part(path, strlen(ROCKBOX_DIR "/albumart/"), MAX_PATH); | ||
209 | found = try_exts(path, pathlen); | ||
210 | #else | ||
157 | snprintf(path, sizeof(path), | 211 | snprintf(path, sizeof(path), |
158 | ROCKBOX_DIR "/albumart/%s-%s%s.bmp", | 212 | ROCKBOX_DIR "/albumart/%s-%s%s.bmp", |
159 | artist, | 213 | artist, |
@@ -161,6 +215,7 @@ bool search_albumart_files(const struct mp3entry *id3, const char *size_string, | |||
161 | size_string); | 215 | size_string); |
162 | fix_path_part(path, strlen(ROCKBOX_DIR "/albumart/"), MAX_PATH); | 216 | fix_path_part(path, strlen(ROCKBOX_DIR "/albumart/"), MAX_PATH); |
163 | found = file_exists(path); | 217 | found = file_exists(path); |
218 | #endif | ||
164 | } | 219 | } |
165 | 220 | ||
166 | if (!found) | 221 | if (!found) |
@@ -180,19 +235,32 @@ bool search_albumart_files(const struct mp3entry *id3, const char *size_string, | |||
180 | { | 235 | { |
181 | /* we look in the parent directory | 236 | /* we look in the parent directory |
182 | * for a file specific to the track's album name */ | 237 | * for a file specific to the track's album name */ |
238 | #if LCD_DEPTH > 1 | ||
239 | pathlen = snprintf(path, sizeof(path), | ||
240 | "%s%s%s.", dir, id3->album, size_string); | ||
241 | fix_path_part(path, dirlen, albumlen); | ||
242 | found = try_exts(path, pathlen); | ||
243 | #else | ||
183 | snprintf(path, sizeof(path), | 244 | snprintf(path, sizeof(path), |
184 | "%s%s%s.bmp", dir, id3->album, size_string); | 245 | "%s%s%s.bmp", dir, id3->album, size_string); |
185 | fix_path_part(path, dirlen, albumlen); | 246 | fix_path_part(path, dirlen, albumlen); |
186 | found = file_exists(path); | 247 | found = file_exists(path); |
248 | #endif | ||
187 | } | 249 | } |
188 | 250 | ||
189 | if (!found) | 251 | if (!found) |
190 | { | 252 | { |
191 | /* if it still doesn't exist, we look in the parent directory | 253 | /* if it still doesn't exist, we look in the parent directory |
192 | * for a generic file */ | 254 | * for a generic file */ |
255 | #if LCD_DEPTH > 1 | ||
256 | pathlen = snprintf(path, sizeof(path), | ||
257 | "%scover%s.", dir, size_string); | ||
258 | found = try_exts(path, pathlen); | ||
259 | #else | ||
193 | snprintf(path, sizeof(path), | 260 | snprintf(path, sizeof(path), |
194 | "%scover%s.bmp", dir, size_string); | 261 | "%scover%s.bmp", dir, size_string); |
195 | found = file_exists(path); | 262 | found = file_exists(path); |
263 | #endif | ||
196 | } | 264 | } |
197 | } | 265 | } |
198 | 266 | ||