diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-16 08:20:47 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-05-16 08:20:47 +0000 |
commit | f7ec9c0fad79521fca3f03e09af1b858ae5ceead (patch) | |
tree | b216f8a954a718add80095628f5c55e6c801d5b1 /apps/recorder | |
parent | cfc022bbfc55df4f1fca6d42a95949a36c430f37 (diff) | |
download | rockbox-f7ec9c0fad79521fca3f03e09af1b858ae5ceead.tar.gz rockbox-f7ec9c0fad79521fca3f03e09af1b858ae5ceead.zip |
Clean up albumart.c a bit, reducing use of USE_JPEG_COVER inside search_albumart_files to only around the folder.jpg test and a strlen call. 0 delta vs previous code for #undef HAVE_JPEG.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20958 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder')
-rw-r--r-- | apps/recorder/albumart.c | 59 |
1 files changed, 11 insertions, 48 deletions
diff --git a/apps/recorder/albumart.c b/apps/recorder/albumart.c index ffc69b43d4..e052906037 100644 --- a/apps/recorder/albumart.c +++ b/apps/recorder/albumart.c | |||
@@ -113,6 +113,10 @@ static bool try_exts(char *path, int len) | |||
113 | } | 113 | } |
114 | return false; | 114 | return false; |
115 | } | 115 | } |
116 | #define EXT | ||
117 | #else | ||
118 | #define EXT "bmp" | ||
119 | #define try_exts(path, len) file_exists(path) | ||
116 | #endif | 120 | #endif |
117 | 121 | ||
118 | /* Look for the first matching album art bitmap in the following list: | 122 | /* Look for the first matching album art bitmap in the following list: |
@@ -137,9 +141,7 @@ bool search_albumart_files(const struct mp3entry *id3, const char *size_string, | |||
137 | const char *artist; | 141 | const char *artist; |
138 | int dirlen; | 142 | int dirlen; |
139 | int albumlen; | 143 | int albumlen; |
140 | #ifdef USE_JPEG_COVER | ||
141 | int pathlen; | 144 | int pathlen; |
142 | #endif | ||
143 | 145 | ||
144 | if (!id3 || !buf) | 146 | if (!id3 || !buf) |
145 | return false; | 147 | return false; |
@@ -156,43 +158,27 @@ bool search_albumart_files(const struct mp3entry *id3, const char *size_string, | |||
156 | /* the first file we look for is one specific to the track playing */ | 158 | /* the first file we look for is one specific to the track playing */ |
157 | strip_extension(path, sizeof(path) - strlen(size_string) - 4, trackname); | 159 | strip_extension(path, sizeof(path) - strlen(size_string) - 4, trackname); |
158 | strcat(path, size_string); | 160 | strcat(path, size_string); |
161 | strcat(path, "." EXT); | ||
159 | #ifdef USE_JPEG_COVER | 162 | #ifdef USE_JPEG_COVER |
160 | strcat(path, "."); | ||
161 | pathlen = strlen(path); | 163 | pathlen = strlen(path); |
162 | found = try_exts(path, pathlen); | ||
163 | #else | ||
164 | strcat(path, ".bmp"); | ||
165 | found = file_exists(path); | ||
166 | #endif | 164 | #endif |
165 | found = try_exts(path, pathlen); | ||
167 | if (!found && albumlen > 0) | 166 | if (!found && albumlen > 0) |
168 | { | 167 | { |
169 | /* if it doesn't exist, | 168 | /* if it doesn't exist, |
170 | * we look for a file specific to the track's album name */ | 169 | * we look for a file specific to the track's album name */ |
171 | #ifdef USE_JPEG_COVER | ||
172 | pathlen = snprintf(path, sizeof(path), | 170 | pathlen = snprintf(path, sizeof(path), |
173 | "%s%s%s.", dir, id3->album, size_string); | 171 | "%s%s%s." EXT, dir, id3->album, size_string); |
174 | fix_path_part(path, dirlen, albumlen); | 172 | fix_path_part(path, dirlen, albumlen); |
175 | found = try_exts(path, pathlen); | 173 | found = try_exts(path, pathlen); |
176 | #else | ||
177 | snprintf(path, sizeof(path), | ||
178 | "%s%s%s.bmp", dir, id3->album, size_string); | ||
179 | fix_path_part(path, dirlen, albumlen); | ||
180 | found = file_exists(path); | ||
181 | #endif | ||
182 | } | 174 | } |
183 | 175 | ||
184 | if (!found) | 176 | if (!found) |
185 | { | 177 | { |
186 | /* if it still doesn't exist, we look for a generic file */ | 178 | /* if it still doesn't exist, we look for a generic file */ |
187 | #ifdef USE_JPEG_COVER | ||
188 | pathlen = snprintf(path, sizeof(path), | 179 | pathlen = snprintf(path, sizeof(path), |
189 | "%scover%s.", dir, size_string); | 180 | "%scover%s." EXT, dir, size_string); |
190 | found = try_exts(path, pathlen); | 181 | found = try_exts(path, pathlen); |
191 | #else | ||
192 | snprintf(path, sizeof(path), | ||
193 | "%scover%s.bmp", dir, size_string); | ||
194 | found = file_exists(path); | ||
195 | #endif | ||
196 | } | 182 | } |
197 | 183 | ||
198 | #ifdef USE_JPEG_COVER | 184 | #ifdef USE_JPEG_COVER |
@@ -208,23 +194,13 @@ bool search_albumart_files(const struct mp3entry *id3, const char *size_string, | |||
208 | if (!found && artist && id3->album) | 194 | if (!found && artist && id3->album) |
209 | { | 195 | { |
210 | /* look in the albumart subdir of .rockbox */ | 196 | /* look in the albumart subdir of .rockbox */ |
211 | #ifdef USE_JPEG_COVER | ||
212 | pathlen = snprintf(path, sizeof(path), | 197 | pathlen = snprintf(path, sizeof(path), |
213 | ROCKBOX_DIR "/albumart/%s-%s%s.", | 198 | ROCKBOX_DIR "/albumart/%s-%s%s." EXT, |
214 | artist, | 199 | artist, |
215 | id3->album, | 200 | id3->album, |
216 | size_string); | 201 | size_string); |
217 | fix_path_part(path, strlen(ROCKBOX_DIR "/albumart/"), MAX_PATH); | 202 | fix_path_part(path, strlen(ROCKBOX_DIR "/albumart/"), MAX_PATH); |
218 | found = try_exts(path, pathlen); | 203 | found = try_exts(path, pathlen); |
219 | #else | ||
220 | snprintf(path, sizeof(path), | ||
221 | ROCKBOX_DIR "/albumart/%s-%s%s.bmp", | ||
222 | artist, | ||
223 | id3->album, | ||
224 | size_string); | ||
225 | fix_path_part(path, strlen(ROCKBOX_DIR "/albumart/"), MAX_PATH); | ||
226 | found = file_exists(path); | ||
227 | #endif | ||
228 | } | 204 | } |
229 | 205 | ||
230 | if (!found) | 206 | if (!found) |
@@ -244,32 +220,19 @@ bool search_albumart_files(const struct mp3entry *id3, const char *size_string, | |||
244 | { | 220 | { |
245 | /* we look in the parent directory | 221 | /* we look in the parent directory |
246 | * for a file specific to the track's album name */ | 222 | * for a file specific to the track's album name */ |
247 | #ifdef USE_JPEG_COVER | ||
248 | pathlen = snprintf(path, sizeof(path), | 223 | pathlen = snprintf(path, sizeof(path), |
249 | "%s%s%s.", dir, id3->album, size_string); | 224 | "%s%s%s." EXT, dir, id3->album, size_string); |
250 | fix_path_part(path, dirlen, albumlen); | 225 | fix_path_part(path, dirlen, albumlen); |
251 | found = try_exts(path, pathlen); | 226 | found = try_exts(path, pathlen); |
252 | #else | ||
253 | snprintf(path, sizeof(path), | ||
254 | "%s%s%s.bmp", dir, id3->album, size_string); | ||
255 | fix_path_part(path, dirlen, albumlen); | ||
256 | found = file_exists(path); | ||
257 | #endif | ||
258 | } | 227 | } |
259 | 228 | ||
260 | if (!found) | 229 | if (!found) |
261 | { | 230 | { |
262 | /* if it still doesn't exist, we look in the parent directory | 231 | /* if it still doesn't exist, we look in the parent directory |
263 | * for a generic file */ | 232 | * for a generic file */ |
264 | #ifdef USE_JPEG_COVER | ||
265 | pathlen = snprintf(path, sizeof(path), | 233 | pathlen = snprintf(path, sizeof(path), |
266 | "%scover%s.", dir, size_string); | 234 | "%scover%s." EXT, dir, size_string); |
267 | found = try_exts(path, pathlen); | 235 | found = try_exts(path, pathlen); |
268 | #else | ||
269 | snprintf(path, sizeof(path), | ||
270 | "%scover%s.bmp", dir, size_string); | ||
271 | found = file_exists(path); | ||
272 | #endif | ||
273 | } | 236 | } |
274 | } | 237 | } |
275 | 238 | ||